]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9.1-3.10.10-201309011630.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9.1-3.10.10-201309011630.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 2fe6e76..889ee23 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 @@ -1928,6 +1932,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 @@ -2195,6 +2203,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 b119684..13ac256 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) KERNELRELASE 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 @@ -1223,6 +1289,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 @@ -1359,17 +1427,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 @@ -1379,11 +1451,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 c2cbe4f..f7264b4 100644
501 --- a/arch/alpha/include/asm/atomic.h
502 +++ b/arch/alpha/include/asm/atomic.h
503 @@ -250,6 +250,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
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 81a4342..348b927 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 b9e37ad..44c24e7 100644
618 --- a/arch/alpha/kernel/osf_sys.c
619 +++ b/arch/alpha/kernel/osf_sys.c
620 @@ -1297,10 +1297,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 @@ -1308,6 +1309,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 @@ -1340,20 +1342,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 18a9f5e..ca910b7 100644
833 --- a/arch/arm/Kconfig
834 +++ b/arch/arm/Kconfig
835 @@ -1766,7 +1766,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 cbdc7a2..32f44fe 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 18f5cef..25b8f43 100644
1932 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h
1933 +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
1934 @@ -41,6 +41,7 @@
1935 */
1936 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1937 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1938 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 1) << 7)
1939 #define PMD_SECT_S (_AT(pmdval_t, 3) << 8)
1940 #define PMD_SECT_AF (_AT(pmdval_t, 1) << 10)
1941 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 11)
1942 @@ -71,6 +72,7 @@
1943 #define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1944 #define PTE_EXT_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
1945 #define PTE_EXT_NG (_AT(pteval_t, 1) << 11) /* nG */
1946 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1947 #define PTE_EXT_XN (_AT(pteval_t, 1) << 54) /* XN */
1948
1949 /*
1950 diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
1951 index 86b8fe3..e25f975 100644
1952 --- a/arch/arm/include/asm/pgtable-3level.h
1953 +++ b/arch/arm/include/asm/pgtable-3level.h
1954 @@ -74,6 +74,7 @@
1955 #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */
1956 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1957 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
1958 +#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1959 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
1960 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55) /* unused */
1961 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */
1962 @@ -82,6 +83,7 @@
1963 /*
1964 * To be used in assembly code with the upper page attributes.
1965 */
1966 +#define L_PTE_PXN_HIGH (1 << (53 - 32))
1967 #define L_PTE_XN_HIGH (1 << (54 - 32))
1968 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
1969
1970 diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
1971 index 9bcd262..1ff999b 100644
1972 --- a/arch/arm/include/asm/pgtable.h
1973 +++ b/arch/arm/include/asm/pgtable.h
1974 @@ -30,6 +30,9 @@
1975 #include <asm/pgtable-2level.h>
1976 #endif
1977
1978 +#define ktla_ktva(addr) (addr)
1979 +#define ktva_ktla(addr) (addr)
1980 +
1981 /*
1982 * Just any arbitrary offset to the start of the vmalloc VM area: the
1983 * current 8MB value just means that there will be a 8MB "hole" after the
1984 @@ -45,6 +48,9 @@
1985 #define LIBRARY_TEXT_START 0x0c000000
1986
1987 #ifndef __ASSEMBLY__
1988 +extern pteval_t __supported_pte_mask;
1989 +extern pmdval_t __supported_pmd_mask;
1990 +
1991 extern void __pte_error(const char *file, int line, pte_t);
1992 extern void __pmd_error(const char *file, int line, pmd_t);
1993 extern void __pgd_error(const char *file, int line, pgd_t);
1994 @@ -53,6 +59,48 @@ extern void __pgd_error(const char *file, int line, pgd_t);
1995 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
1996 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
1997
1998 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
1999 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
2000 +
2001 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2002 +#include <asm/domain.h>
2003 +#include <linux/thread_info.h>
2004 +#include <linux/preempt.h>
2005 +
2006 +static inline int test_domain(int domain, int domaintype)
2007 +{
2008 + return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
2009 +}
2010 +#endif
2011 +
2012 +#ifdef CONFIG_PAX_KERNEXEC
2013 +static inline unsigned long pax_open_kernel(void) {
2014 +#ifdef CONFIG_ARM_LPAE
2015 + /* TODO */
2016 +#else
2017 + preempt_disable();
2018 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
2019 + modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
2020 +#endif
2021 + return 0;
2022 +}
2023 +
2024 +static inline unsigned long pax_close_kernel(void) {
2025 +#ifdef CONFIG_ARM_LPAE
2026 + /* TODO */
2027 +#else
2028 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
2029 + /* DOMAIN_MANAGER = "client" under KERNEXEC */
2030 + modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
2031 + preempt_enable_no_resched();
2032 +#endif
2033 + return 0;
2034 +}
2035 +#else
2036 +static inline unsigned long pax_open_kernel(void) { return 0; }
2037 +static inline unsigned long pax_close_kernel(void) { return 0; }
2038 +#endif
2039 +
2040 /*
2041 * This is the lowest virtual address we can permit any user space
2042 * mapping to be mapped at. This is particularly important for
2043 @@ -72,8 +120,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2044 /*
2045 * The pgprot_* and protection_map entries will be fixed up in runtime
2046 * to include the cachable and bufferable bits based on memory policy,
2047 - * as well as any architecture dependent bits like global/ASID and SMP
2048 - * shared mapping bits.
2049 + * as well as any architecture dependent bits like global/ASID, PXN,
2050 + * and SMP shared mapping bits.
2051 */
2052 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
2053
2054 @@ -257,7 +305,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
2055 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
2056 {
2057 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
2058 - L_PTE_NONE | L_PTE_VALID;
2059 + L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
2060 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2061 return pte;
2062 }
2063 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h
2064 index f3628fb..a0672dd 100644
2065 --- a/arch/arm/include/asm/proc-fns.h
2066 +++ b/arch/arm/include/asm/proc-fns.h
2067 @@ -75,7 +75,7 @@ extern struct processor {
2068 unsigned int suspend_size;
2069 void (*do_suspend)(void *);
2070 void (*do_resume)(void *);
2071 -} processor;
2072 +} __do_const processor;
2073
2074 #ifndef MULTI_CPU
2075 extern void cpu_proc_init(void);
2076 diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
2077 index ce0dbe7..c085b6f 100644
2078 --- a/arch/arm/include/asm/psci.h
2079 +++ b/arch/arm/include/asm/psci.h
2080 @@ -29,7 +29,7 @@ struct psci_operations {
2081 int (*cpu_off)(struct psci_power_state state);
2082 int (*cpu_on)(unsigned long cpuid, unsigned long entry_point);
2083 int (*migrate)(unsigned long cpuid);
2084 -};
2085 +} __no_const;
2086
2087 extern struct psci_operations psci_ops;
2088
2089 diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2090 index d3a22be..3a69ad5 100644
2091 --- a/arch/arm/include/asm/smp.h
2092 +++ b/arch/arm/include/asm/smp.h
2093 @@ -107,7 +107,7 @@ struct smp_operations {
2094 int (*cpu_disable)(unsigned int cpu);
2095 #endif
2096 #endif
2097 -};
2098 +} __no_const;
2099
2100 /*
2101 * set platform specific SMP operations
2102 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2103 index f00b569..aa5bb41 100644
2104 --- a/arch/arm/include/asm/thread_info.h
2105 +++ b/arch/arm/include/asm/thread_info.h
2106 @@ -77,9 +77,9 @@ struct thread_info {
2107 .flags = 0, \
2108 .preempt_count = INIT_PREEMPT_COUNT, \
2109 .addr_limit = KERNEL_DS, \
2110 - .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2111 - domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2112 - domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2113 + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2114 + domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2115 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2116 .restart_block = { \
2117 .fn = do_no_restart_syscall, \
2118 }, \
2119 @@ -152,7 +152,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2120 #define TIF_SYSCALL_AUDIT 9
2121 #define TIF_SYSCALL_TRACEPOINT 10
2122 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2123 -#define TIF_NOHZ 12 /* in adaptive nohz mode */
2124 +/* within 8 bits of TIF_SYSCALL_TRACE
2125 + * to meet flexible second operand requirements
2126 + */
2127 +#define TIF_GRSEC_SETXID 12
2128 +#define TIF_NOHZ 13 /* in adaptive nohz mode */
2129 #define TIF_USING_IWMMXT 17
2130 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2131 #define TIF_RESTORE_SIGMASK 20
2132 @@ -165,10 +169,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2133 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2134 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2135 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2136 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2137
2138 /* Checks for any syscall work in entry-common.S */
2139 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2140 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2141 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2142
2143 /*
2144 * Change these and you break ASM code in entry-common.S
2145 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2146 index 7e1f760..de33b13 100644
2147 --- a/arch/arm/include/asm/uaccess.h
2148 +++ b/arch/arm/include/asm/uaccess.h
2149 @@ -18,6 +18,7 @@
2150 #include <asm/domain.h>
2151 #include <asm/unified.h>
2152 #include <asm/compiler.h>
2153 +#include <asm/pgtable.h>
2154
2155 #define VERIFY_READ 0
2156 #define VERIFY_WRITE 1
2157 @@ -63,11 +64,38 @@ extern int __put_user_bad(void);
2158 static inline void set_fs(mm_segment_t fs)
2159 {
2160 current_thread_info()->addr_limit = fs;
2161 - modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2162 + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2163 }
2164
2165 #define segment_eq(a,b) ((a) == (b))
2166
2167 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
2168 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
2169 +
2170 +static inline void pax_open_userland(void)
2171 +{
2172 +
2173 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2174 + if (segment_eq(get_fs(), USER_DS)) {
2175 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2176 + modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2177 + }
2178 +#endif
2179 +
2180 +}
2181 +
2182 +static inline void pax_close_userland(void)
2183 +{
2184 +
2185 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2186 + if (segment_eq(get_fs(), USER_DS)) {
2187 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2188 + modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2189 + }
2190 +#endif
2191 +
2192 +}
2193 +
2194 #define __addr_ok(addr) ({ \
2195 unsigned long flag; \
2196 __asm__("cmp %2, %0; movlo %0, #0" \
2197 @@ -143,8 +171,12 @@ extern int __get_user_4(void *);
2198
2199 #define get_user(x,p) \
2200 ({ \
2201 + int __e; \
2202 might_fault(); \
2203 - __get_user_check(x,p); \
2204 + pax_open_userland(); \
2205 + __e = __get_user_check(x,p); \
2206 + pax_close_userland(); \
2207 + __e; \
2208 })
2209
2210 extern int __put_user_1(void *, unsigned int);
2211 @@ -188,8 +220,12 @@ extern int __put_user_8(void *, unsigned long long);
2212
2213 #define put_user(x,p) \
2214 ({ \
2215 + int __e; \
2216 might_fault(); \
2217 - __put_user_check(x,p); \
2218 + pax_open_userland(); \
2219 + __e = __put_user_check(x,p); \
2220 + pax_close_userland(); \
2221 + __e; \
2222 })
2223
2224 #else /* CONFIG_MMU */
2225 @@ -230,13 +266,17 @@ static inline void set_fs(mm_segment_t fs)
2226 #define __get_user(x,ptr) \
2227 ({ \
2228 long __gu_err = 0; \
2229 + pax_open_userland(); \
2230 __get_user_err((x),(ptr),__gu_err); \
2231 + pax_close_userland(); \
2232 __gu_err; \
2233 })
2234
2235 #define __get_user_error(x,ptr,err) \
2236 ({ \
2237 + pax_open_userland(); \
2238 __get_user_err((x),(ptr),err); \
2239 + pax_close_userland(); \
2240 (void) 0; \
2241 })
2242
2243 @@ -312,13 +352,17 @@ do { \
2244 #define __put_user(x,ptr) \
2245 ({ \
2246 long __pu_err = 0; \
2247 + pax_open_userland(); \
2248 __put_user_err((x),(ptr),__pu_err); \
2249 + pax_close_userland(); \
2250 __pu_err; \
2251 })
2252
2253 #define __put_user_error(x,ptr,err) \
2254 ({ \
2255 + pax_open_userland(); \
2256 __put_user_err((x),(ptr),err); \
2257 + pax_close_userland(); \
2258 (void) 0; \
2259 })
2260
2261 @@ -418,11 +462,44 @@ do { \
2262
2263
2264 #ifdef CONFIG_MMU
2265 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2266 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2267 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2268 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2269 +
2270 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2271 +{
2272 + unsigned long ret;
2273 +
2274 + check_object_size(to, n, false);
2275 + pax_open_userland();
2276 + ret = ___copy_from_user(to, from, n);
2277 + pax_close_userland();
2278 + return ret;
2279 +}
2280 +
2281 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2282 +{
2283 + unsigned long ret;
2284 +
2285 + check_object_size(from, n, true);
2286 + pax_open_userland();
2287 + ret = ___copy_to_user(to, from, n);
2288 + pax_close_userland();
2289 + return ret;
2290 +}
2291 +
2292 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2293 -extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2294 +extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2295 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2296 +
2297 +static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2298 +{
2299 + unsigned long ret;
2300 + pax_open_userland();
2301 + ret = ___clear_user(addr, n);
2302 + pax_close_userland();
2303 + return ret;
2304 +}
2305 +
2306 #else
2307 #define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
2308 #define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
2309 @@ -431,6 +508,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2310
2311 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2312 {
2313 + if ((long)n < 0)
2314 + return n;
2315 +
2316 if (access_ok(VERIFY_READ, from, n))
2317 n = __copy_from_user(to, from, n);
2318 else /* security hole - plug it */
2319 @@ -440,6 +520,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2320
2321 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2322 {
2323 + if ((long)n < 0)
2324 + return n;
2325 +
2326 if (access_ok(VERIFY_WRITE, to, n))
2327 n = __copy_to_user(to, from, n);
2328 return n;
2329 diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2330 index 96ee092..37f1844 100644
2331 --- a/arch/arm/include/uapi/asm/ptrace.h
2332 +++ b/arch/arm/include/uapi/asm/ptrace.h
2333 @@ -73,7 +73,7 @@
2334 * ARMv7 groups of PSR bits
2335 */
2336 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2337 -#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2338 +#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2339 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2340 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2341
2342 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2343 index 60d3b73..e5a0f22 100644
2344 --- a/arch/arm/kernel/armksyms.c
2345 +++ b/arch/arm/kernel/armksyms.c
2346 @@ -53,7 +53,7 @@ EXPORT_SYMBOL(arm_delay_ops);
2347
2348 /* networking */
2349 EXPORT_SYMBOL(csum_partial);
2350 -EXPORT_SYMBOL(csum_partial_copy_from_user);
2351 +EXPORT_SYMBOL(__csum_partial_copy_from_user);
2352 EXPORT_SYMBOL(csum_partial_copy_nocheck);
2353 EXPORT_SYMBOL(__csum_ipv6_magic);
2354
2355 @@ -89,9 +89,9 @@ EXPORT_SYMBOL(__memzero);
2356 #ifdef CONFIG_MMU
2357 EXPORT_SYMBOL(copy_page);
2358
2359 -EXPORT_SYMBOL(__copy_from_user);
2360 -EXPORT_SYMBOL(__copy_to_user);
2361 -EXPORT_SYMBOL(__clear_user);
2362 +EXPORT_SYMBOL(___copy_from_user);
2363 +EXPORT_SYMBOL(___copy_to_user);
2364 +EXPORT_SYMBOL(___clear_user);
2365
2366 EXPORT_SYMBOL(__get_user_1);
2367 EXPORT_SYMBOL(__get_user_2);
2368 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2369 index d43c7e5..257c050 100644
2370 --- a/arch/arm/kernel/entry-armv.S
2371 +++ b/arch/arm/kernel/entry-armv.S
2372 @@ -47,6 +47,87 @@
2373 9997:
2374 .endm
2375
2376 + .macro pax_enter_kernel
2377 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2378 + @ make aligned space for saved DACR
2379 + sub sp, sp, #8
2380 + @ save regs
2381 + stmdb sp!, {r1, r2}
2382 + @ read DACR from cpu_domain into r1
2383 + mov r2, sp
2384 + @ assume 8K pages, since we have to split the immediate in two
2385 + bic r2, r2, #(0x1fc0)
2386 + bic r2, r2, #(0x3f)
2387 + ldr r1, [r2, #TI_CPU_DOMAIN]
2388 + @ store old DACR on stack
2389 + str r1, [sp, #8]
2390 +#ifdef CONFIG_PAX_KERNEXEC
2391 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2392 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2393 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2394 +#endif
2395 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2396 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2397 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2398 +#endif
2399 + @ write r1 to current_thread_info()->cpu_domain
2400 + str r1, [r2, #TI_CPU_DOMAIN]
2401 + @ write r1 to DACR
2402 + mcr p15, 0, r1, c3, c0, 0
2403 + @ instruction sync
2404 + instr_sync
2405 + @ restore regs
2406 + ldmia sp!, {r1, r2}
2407 +#endif
2408 + .endm
2409 +
2410 + .macro pax_open_userland
2411 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2412 + @ save regs
2413 + stmdb sp!, {r0, r1}
2414 + @ read DACR from cpu_domain into r1
2415 + mov r0, sp
2416 + @ assume 8K pages, since we have to split the immediate in two
2417 + bic r0, r0, #(0x1fc0)
2418 + bic r0, r0, #(0x3f)
2419 + ldr r1, [r0, #TI_CPU_DOMAIN]
2420 + @ set current DOMAIN_USER to DOMAIN_CLIENT
2421 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2422 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2423 + @ write r1 to current_thread_info()->cpu_domain
2424 + str r1, [r0, #TI_CPU_DOMAIN]
2425 + @ write r1 to DACR
2426 + mcr p15, 0, r1, c3, c0, 0
2427 + @ instruction sync
2428 + instr_sync
2429 + @ restore regs
2430 + ldmia sp!, {r0, r1}
2431 +#endif
2432 + .endm
2433 +
2434 + .macro pax_close_userland
2435 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2436 + @ save regs
2437 + stmdb sp!, {r0, r1}
2438 + @ read DACR from cpu_domain into r1
2439 + mov r0, sp
2440 + @ assume 8K pages, since we have to split the immediate in two
2441 + bic r0, r0, #(0x1fc0)
2442 + bic r0, r0, #(0x3f)
2443 + ldr r1, [r0, #TI_CPU_DOMAIN]
2444 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2445 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2446 + @ write r1 to current_thread_info()->cpu_domain
2447 + str r1, [r0, #TI_CPU_DOMAIN]
2448 + @ write r1 to DACR
2449 + mcr p15, 0, r1, c3, c0, 0
2450 + @ instruction sync
2451 + instr_sync
2452 + @ restore regs
2453 + ldmia sp!, {r0, r1}
2454 +#endif
2455 + .endm
2456 +
2457 .macro pabt_helper
2458 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2459 #ifdef MULTI_PABORT
2460 @@ -89,11 +170,15 @@
2461 * Invalid mode handlers
2462 */
2463 .macro inv_entry, reason
2464 +
2465 + pax_enter_kernel
2466 +
2467 sub sp, sp, #S_FRAME_SIZE
2468 ARM( stmib sp, {r1 - lr} )
2469 THUMB( stmia sp, {r0 - r12} )
2470 THUMB( str sp, [sp, #S_SP] )
2471 THUMB( str lr, [sp, #S_LR] )
2472 +
2473 mov r1, #\reason
2474 .endm
2475
2476 @@ -149,7 +234,11 @@ ENDPROC(__und_invalid)
2477 .macro svc_entry, stack_hole=0
2478 UNWIND(.fnstart )
2479 UNWIND(.save {r0 - pc} )
2480 +
2481 + pax_enter_kernel
2482 +
2483 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2484 +
2485 #ifdef CONFIG_THUMB2_KERNEL
2486 SPFIX( str r0, [sp] ) @ temporarily saved
2487 SPFIX( mov r0, sp )
2488 @@ -164,7 +253,12 @@ ENDPROC(__und_invalid)
2489 ldmia r0, {r3 - r5}
2490 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2491 mov r6, #-1 @ "" "" "" ""
2492 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2493 + @ offset sp by 8 as done in pax_enter_kernel
2494 + add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2495 +#else
2496 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2497 +#endif
2498 SPFIX( addeq r2, r2, #4 )
2499 str r3, [sp, #-4]! @ save the "real" r0 copied
2500 @ from the exception stack
2501 @@ -316,6 +410,9 @@ ENDPROC(__pabt_svc)
2502 .macro usr_entry
2503 UNWIND(.fnstart )
2504 UNWIND(.cantunwind ) @ don't unwind the user space
2505 +
2506 + pax_enter_kernel_user
2507 +
2508 sub sp, sp, #S_FRAME_SIZE
2509 ARM( stmib sp, {r1 - r12} )
2510 THUMB( stmia sp, {r0 - r12} )
2511 @@ -357,7 +454,8 @@ ENDPROC(__pabt_svc)
2512 .endm
2513
2514 .macro kuser_cmpxchg_check
2515 -#if !defined(CONFIG_CPU_32v6K) && !defined(CONFIG_NEEDS_SYSCALL_FOR_CMPXCHG)
2516 +#if !defined(CONFIG_CPU_32v6K) && defined(CONFIG_KUSER_HELPERS) && \
2517 + !defined(CONFIG_NEEDS_SYSCALL_FOR_CMPXCHG)
2518 #ifndef CONFIG_MMU
2519 #warning "NPTL on non MMU needs fixing"
2520 #else
2521 @@ -414,7 +512,9 @@ __und_usr:
2522 tst r3, #PSR_T_BIT @ Thumb mode?
2523 bne __und_usr_thumb
2524 sub r4, r2, #4 @ ARM instr at LR - 4
2525 + pax_open_userland
2526 1: ldrt r0, [r4]
2527 + pax_close_userland
2528 #ifdef CONFIG_CPU_ENDIAN_BE8
2529 rev r0, r0 @ little endian instruction
2530 #endif
2531 @@ -449,10 +549,14 @@ __und_usr_thumb:
2532 */
2533 .arch armv6t2
2534 #endif
2535 + pax_open_userland
2536 2: ldrht r5, [r4]
2537 + pax_close_userland
2538 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2539 blo __und_usr_fault_16 @ 16bit undefined instruction
2540 + pax_open_userland
2541 3: ldrht r0, [r2]
2542 + pax_close_userland
2543 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2544 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2545 orr r0, r0, r5, lsl #16
2546 @@ -481,7 +585,8 @@ ENDPROC(__und_usr)
2547 */
2548 .pushsection .fixup, "ax"
2549 .align 2
2550 -4: mov pc, r9
2551 +4: pax_close_userland
2552 + mov pc, r9
2553 .popsection
2554 .pushsection __ex_table,"a"
2555 .long 1b, 4b
2556 @@ -690,7 +795,7 @@ ENTRY(__switch_to)
2557 THUMB( stmia ip!, {r4 - sl, fp} ) @ Store most regs on stack
2558 THUMB( str sp, [ip], #4 )
2559 THUMB( str lr, [ip], #4 )
2560 -#ifdef CONFIG_CPU_USE_DOMAINS
2561 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2562 ldr r6, [r2, #TI_CPU_DOMAIN]
2563 #endif
2564 set_tls r3, r4, r5
2565 @@ -699,7 +804,7 @@ ENTRY(__switch_to)
2566 ldr r8, =__stack_chk_guard
2567 ldr r7, [r7, #TSK_STACK_CANARY]
2568 #endif
2569 -#ifdef CONFIG_CPU_USE_DOMAINS
2570 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2571 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2572 #endif
2573 mov r5, r0
2574 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2575 index bc5bc0a..d0998ca 100644
2576 --- a/arch/arm/kernel/entry-common.S
2577 +++ b/arch/arm/kernel/entry-common.S
2578 @@ -10,18 +10,46 @@
2579
2580 #include <asm/unistd.h>
2581 #include <asm/ftrace.h>
2582 +#include <asm/domain.h>
2583 #include <asm/unwind.h>
2584
2585 +#include "entry-header.S"
2586 +
2587 #ifdef CONFIG_NEED_RET_TO_USER
2588 #include <mach/entry-macro.S>
2589 #else
2590 .macro arch_ret_to_user, tmp1, tmp2
2591 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2592 + @ save regs
2593 + stmdb sp!, {r1, r2}
2594 + @ read DACR from cpu_domain into r1
2595 + mov r2, sp
2596 + @ assume 8K pages, since we have to split the immediate in two
2597 + bic r2, r2, #(0x1fc0)
2598 + bic r2, r2, #(0x3f)
2599 + ldr r1, [r2, #TI_CPU_DOMAIN]
2600 +#ifdef CONFIG_PAX_KERNEXEC
2601 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2602 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2603 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2604 +#endif
2605 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2606 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2607 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2608 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2609 +#endif
2610 + @ write r1 to current_thread_info()->cpu_domain
2611 + str r1, [r2, #TI_CPU_DOMAIN]
2612 + @ write r1 to DACR
2613 + mcr p15, 0, r1, c3, c0, 0
2614 + @ instruction sync
2615 + instr_sync
2616 + @ restore regs
2617 + ldmia sp!, {r1, r2}
2618 +#endif
2619 .endm
2620 #endif
2621
2622 -#include "entry-header.S"
2623 -
2624 -
2625 .align 5
2626 /*
2627 * This is the fast syscall return path. We do as little as
2628 @@ -350,6 +378,7 @@ ENDPROC(ftrace_stub)
2629
2630 .align 5
2631 ENTRY(vector_swi)
2632 +
2633 sub sp, sp, #S_FRAME_SIZE
2634 stmia sp, {r0 - r12} @ Calling r0 - r12
2635 ARM( add r8, sp, #S_PC )
2636 @@ -399,6 +428,12 @@ ENTRY(vector_swi)
2637 ldr scno, [lr, #-4] @ get SWI instruction
2638 #endif
2639
2640 + /*
2641 + * do this here to avoid a performance hit of wrapping the code above
2642 + * that directly dereferences userland to parse the SWI instruction
2643 + */
2644 + pax_enter_kernel_user
2645 +
2646 #ifdef CONFIG_ALIGNMENT_TRAP
2647 ldr ip, __cr_alignment
2648 ldr ip, [ip]
2649 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2650 index 160f337..db67ee4 100644
2651 --- a/arch/arm/kernel/entry-header.S
2652 +++ b/arch/arm/kernel/entry-header.S
2653 @@ -73,6 +73,60 @@
2654 msr cpsr_c, \rtemp @ switch back to the SVC mode
2655 .endm
2656
2657 + .macro pax_enter_kernel_user
2658 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2659 + @ save regs
2660 + stmdb sp!, {r0, r1}
2661 + @ read DACR from cpu_domain into r1
2662 + mov r0, sp
2663 + @ assume 8K pages, since we have to split the immediate in two
2664 + bic r0, r0, #(0x1fc0)
2665 + bic r0, r0, #(0x3f)
2666 + ldr r1, [r0, #TI_CPU_DOMAIN]
2667 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2668 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2669 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2670 +#endif
2671 +#ifdef CONFIG_PAX_KERNEXEC
2672 + @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2673 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2674 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2675 +#endif
2676 + @ write r1 to current_thread_info()->cpu_domain
2677 + str r1, [r0, #TI_CPU_DOMAIN]
2678 + @ write r1 to DACR
2679 + mcr p15, 0, r1, c3, c0, 0
2680 + @ instruction sync
2681 + instr_sync
2682 + @ restore regs
2683 + ldmia sp!, {r0, r1}
2684 +#endif
2685 + .endm
2686 +
2687 + .macro pax_exit_kernel
2688 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2689 + @ save regs
2690 + stmdb sp!, {r0, r1}
2691 + @ read old DACR from stack into r1
2692 + ldr r1, [sp, #(8 + S_SP)]
2693 + sub r1, r1, #8
2694 + ldr r1, [r1]
2695 +
2696 + @ write r1 to current_thread_info()->cpu_domain
2697 + mov r0, sp
2698 + @ assume 8K pages, since we have to split the immediate in two
2699 + bic r0, r0, #(0x1fc0)
2700 + bic r0, r0, #(0x3f)
2701 + str r1, [r0, #TI_CPU_DOMAIN]
2702 + @ write r1 to DACR
2703 + mcr p15, 0, r1, c3, c0, 0
2704 + @ instruction sync
2705 + instr_sync
2706 + @ restore regs
2707 + ldmia sp!, {r0, r1}
2708 +#endif
2709 + .endm
2710 +
2711 #ifndef CONFIG_THUMB2_KERNEL
2712 .macro svc_exit, rpsr, irq = 0
2713 .if \irq != 0
2714 @@ -92,6 +146,9 @@
2715 blne trace_hardirqs_off
2716 #endif
2717 .endif
2718 +
2719 + pax_exit_kernel
2720 +
2721 msr spsr_cxsf, \rpsr
2722 #if defined(CONFIG_CPU_V6)
2723 ldr r0, [sp]
2724 @@ -155,6 +212,9 @@
2725 blne trace_hardirqs_off
2726 #endif
2727 .endif
2728 +
2729 + pax_exit_kernel
2730 +
2731 ldr lr, [sp, #S_SP] @ top of the stack
2732 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2733 clrex @ clear the exclusive monitor
2734 diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2735 index 25442f4..d4948fc 100644
2736 --- a/arch/arm/kernel/fiq.c
2737 +++ b/arch/arm/kernel/fiq.c
2738 @@ -84,17 +84,16 @@ int show_fiq_list(struct seq_file *p, int prec)
2739
2740 void set_fiq_handler(void *start, unsigned int length)
2741 {
2742 -#if defined(CONFIG_CPU_USE_DOMAINS)
2743 - void *base = (void *)0xffff0000;
2744 -#else
2745 void *base = vectors_page;
2746 -#endif
2747 unsigned offset = FIQ_OFFSET;
2748
2749 + pax_open_kernel();
2750 memcpy(base + offset, start, length);
2751 + pax_close_kernel();
2752 +
2753 + if (!cache_is_vipt_nonaliasing())
2754 + flush_icache_range(base + offset, offset + length);
2755 flush_icache_range(0xffff0000 + offset, 0xffff0000 + offset + length);
2756 - if (!vectors_high())
2757 - flush_icache_range(offset, offset + length);
2758 }
2759
2760 int claim_fiq(struct fiq_handler *f)
2761 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2762 index 8bac553..caee108 100644
2763 --- a/arch/arm/kernel/head.S
2764 +++ b/arch/arm/kernel/head.S
2765 @@ -52,7 +52,9 @@
2766 .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
2767
2768 .macro pgtbl, rd, phys
2769 - add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
2770 + mov \rd, #TEXT_OFFSET
2771 + sub \rd, #PG_DIR_SIZE
2772 + add \rd, \rd, \phys
2773 .endm
2774
2775 /*
2776 @@ -434,7 +436,7 @@ __enable_mmu:
2777 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2778 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2779 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2780 - domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2781 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2782 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2783 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2784 #endif
2785 diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c
2786 index 1fd749e..47adb08 100644
2787 --- a/arch/arm/kernel/hw_breakpoint.c
2788 +++ b/arch/arm/kernel/hw_breakpoint.c
2789 @@ -1029,7 +1029,7 @@ static int __cpuinit dbg_reset_notify(struct notifier_block *self,
2790 return NOTIFY_OK;
2791 }
2792
2793 -static struct notifier_block __cpuinitdata dbg_reset_nb = {
2794 +static struct notifier_block dbg_reset_nb = {
2795 .notifier_call = dbg_reset_notify,
2796 };
2797
2798 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2799 index 1e9be5d..03edbc2 100644
2800 --- a/arch/arm/kernel/module.c
2801 +++ b/arch/arm/kernel/module.c
2802 @@ -37,12 +37,37 @@
2803 #endif
2804
2805 #ifdef CONFIG_MMU
2806 -void *module_alloc(unsigned long size)
2807 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2808 {
2809 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2810 + return NULL;
2811 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2812 - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
2813 + GFP_KERNEL, prot, -1,
2814 __builtin_return_address(0));
2815 }
2816 +
2817 +void *module_alloc(unsigned long size)
2818 +{
2819 +
2820 +#ifdef CONFIG_PAX_KERNEXEC
2821 + return __module_alloc(size, PAGE_KERNEL);
2822 +#else
2823 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2824 +#endif
2825 +
2826 +}
2827 +
2828 +#ifdef CONFIG_PAX_KERNEXEC
2829 +void module_free_exec(struct module *mod, void *module_region)
2830 +{
2831 + module_free(mod, module_region);
2832 +}
2833 +
2834 +void *module_alloc_exec(unsigned long size)
2835 +{
2836 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2837 +}
2838 +#endif
2839 #endif
2840
2841 int
2842 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2843 index 07314af..c46655c 100644
2844 --- a/arch/arm/kernel/patch.c
2845 +++ b/arch/arm/kernel/patch.c
2846 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2847 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2848 int size;
2849
2850 + pax_open_kernel();
2851 if (thumb2 && __opcode_is_thumb16(insn)) {
2852 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2853 size = sizeof(u16);
2854 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2855 *(u32 *)addr = insn;
2856 size = sizeof(u32);
2857 }
2858 + pax_close_kernel();
2859
2860 flush_icache_range((uintptr_t)(addr),
2861 (uintptr_t)(addr) + size);
2862 diff --git a/arch/arm/kernel/perf_event.c b/arch/arm/kernel/perf_event.c
2863 index e19edc6..e186ee1 100644
2864 --- a/arch/arm/kernel/perf_event.c
2865 +++ b/arch/arm/kernel/perf_event.c
2866 @@ -56,7 +56,7 @@ armpmu_map_hw_event(const unsigned (*event_map)[PERF_COUNT_HW_MAX], u64 config)
2867 int mapping;
2868
2869 if (config >= PERF_COUNT_HW_MAX)
2870 - return -ENOENT;
2871 + return -EINVAL;
2872
2873 mapping = (*event_map)[config];
2874 return mapping == HW_OP_UNSUPPORTED ? -ENOENT : mapping;
2875 diff --git a/arch/arm/kernel/perf_event_cpu.c b/arch/arm/kernel/perf_event_cpu.c
2876 index 1f2740e..b36e225 100644
2877 --- a/arch/arm/kernel/perf_event_cpu.c
2878 +++ b/arch/arm/kernel/perf_event_cpu.c
2879 @@ -171,7 +171,7 @@ static int __cpuinit cpu_pmu_notify(struct notifier_block *b,
2880 return NOTIFY_OK;
2881 }
2882
2883 -static struct notifier_block __cpuinitdata cpu_pmu_hotplug_notifier = {
2884 +static struct notifier_block cpu_pmu_hotplug_notifier = {
2885 .notifier_call = cpu_pmu_notify,
2886 };
2887
2888 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2889 index 5bc2615..dcd439f 100644
2890 --- a/arch/arm/kernel/process.c
2891 +++ b/arch/arm/kernel/process.c
2892 @@ -223,6 +223,7 @@ void machine_power_off(void)
2893
2894 if (pm_power_off)
2895 pm_power_off();
2896 + BUG();
2897 }
2898
2899 /*
2900 @@ -236,7 +237,7 @@ void machine_power_off(void)
2901 * executing pre-reset code, and using RAM that the primary CPU's code wishes
2902 * to use. Implementing such co-ordination would be essentially impossible.
2903 */
2904 -void machine_restart(char *cmd)
2905 +__noreturn void machine_restart(char *cmd)
2906 {
2907 smp_send_stop();
2908
2909 @@ -258,8 +259,8 @@ void __show_regs(struct pt_regs *regs)
2910
2911 show_regs_print_info(KERN_DEFAULT);
2912
2913 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2914 - print_symbol("LR is at %s\n", regs->ARM_lr);
2915 + printk("PC is at %pA\n", (void *)instruction_pointer(regs));
2916 + printk("LR is at %pA\n", (void *)regs->ARM_lr);
2917 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2918 "sp : %08lx ip : %08lx fp : %08lx\n",
2919 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2920 @@ -426,12 +427,6 @@ unsigned long get_wchan(struct task_struct *p)
2921 return 0;
2922 }
2923
2924 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2925 -{
2926 - unsigned long range_end = mm->brk + 0x02000000;
2927 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2928 -}
2929 -
2930 #ifdef CONFIG_MMU
2931 #ifdef CONFIG_KUSER_HELPERS
2932 /*
2933 @@ -447,7 +442,7 @@ static struct vm_area_struct gate_vma = {
2934
2935 static int __init gate_vma_init(void)
2936 {
2937 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2938 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2939 return 0;
2940 }
2941 arch_initcall(gate_vma_init);
2942 @@ -466,48 +461,23 @@ int in_gate_area_no_mm(unsigned long addr)
2943 {
2944 return in_gate_area(NULL, addr);
2945 }
2946 -#define is_gate_vma(vma) ((vma) = &gate_vma)
2947 +#define is_gate_vma(vma) ((vma) == &gate_vma)
2948 #else
2949 #define is_gate_vma(vma) 0
2950 #endif
2951
2952 const char *arch_vma_name(struct vm_area_struct *vma)
2953 {
2954 - return is_gate_vma(vma) ? "[vectors]" :
2955 - (vma->vm_mm && vma->vm_start == vma->vm_mm->context.sigpage) ?
2956 - "[sigpage]" : NULL;
2957 + return is_gate_vma(vma) ? "[vectors]" : NULL;
2958 }
2959
2960 -static struct page *signal_page;
2961 -extern struct page *get_signal_page(void);
2962 -
2963 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
2964 {
2965 struct mm_struct *mm = current->mm;
2966 - unsigned long addr;
2967 - int ret;
2968 -
2969 - if (!signal_page)
2970 - signal_page = get_signal_page();
2971 - if (!signal_page)
2972 - return -ENOMEM;
2973
2974 down_write(&mm->mmap_sem);
2975 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
2976 - if (IS_ERR_VALUE(addr)) {
2977 - ret = addr;
2978 - goto up_fail;
2979 - }
2980 -
2981 - ret = install_special_mapping(mm, addr, PAGE_SIZE,
2982 - VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC,
2983 - &signal_page);
2984 -
2985 - if (ret == 0)
2986 - mm->context.sigpage = addr;
2987 -
2988 - up_fail:
2989 + mm->context.sigpage = (PAGE_OFFSET + (get_random_int() % 0x3FFEFFE0)) & 0xFFFFFFFC;
2990 up_write(&mm->mmap_sem);
2991 - return ret;
2992 + return 0;
2993 }
2994 #endif
2995 diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
2996 index 3653164..d83e55d 100644
2997 --- a/arch/arm/kernel/psci.c
2998 +++ b/arch/arm/kernel/psci.c
2999 @@ -24,7 +24,7 @@
3000 #include <asm/opcodes-virt.h>
3001 #include <asm/psci.h>
3002
3003 -struct psci_operations psci_ops;
3004 +struct psci_operations psci_ops __read_only;
3005
3006 static int (*invoke_psci_fn)(u32, u32, u32, u32);
3007
3008 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
3009 index 03deeff..741ce88 100644
3010 --- a/arch/arm/kernel/ptrace.c
3011 +++ b/arch/arm/kernel/ptrace.c
3012 @@ -937,10 +937,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
3013 return current_thread_info()->syscall;
3014 }
3015
3016 +#ifdef CONFIG_GRKERNSEC_SETXID
3017 +extern void gr_delayed_cred_worker(void);
3018 +#endif
3019 +
3020 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
3021 {
3022 current_thread_info()->syscall = scno;
3023
3024 +#ifdef CONFIG_GRKERNSEC_SETXID
3025 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
3026 + gr_delayed_cred_worker();
3027 +#endif
3028 +
3029 /* Do the secure computing check first; failures should be fast. */
3030 if (secure_computing(scno) == -1)
3031 return -1;
3032 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
3033 index b4b1d39..efdc9be 100644
3034 --- a/arch/arm/kernel/setup.c
3035 +++ b/arch/arm/kernel/setup.c
3036 @@ -97,21 +97,23 @@ EXPORT_SYMBOL(system_serial_high);
3037 unsigned int elf_hwcap __read_mostly;
3038 EXPORT_SYMBOL(elf_hwcap);
3039
3040 +pteval_t __supported_pte_mask __read_only;
3041 +pmdval_t __supported_pmd_mask __read_only;
3042
3043 #ifdef MULTI_CPU
3044 -struct processor processor __read_mostly;
3045 +struct processor processor;
3046 #endif
3047 #ifdef MULTI_TLB
3048 -struct cpu_tlb_fns cpu_tlb __read_mostly;
3049 +struct cpu_tlb_fns cpu_tlb __read_only;
3050 #endif
3051 #ifdef MULTI_USER
3052 -struct cpu_user_fns cpu_user __read_mostly;
3053 +struct cpu_user_fns cpu_user __read_only;
3054 #endif
3055 #ifdef MULTI_CACHE
3056 -struct cpu_cache_fns cpu_cache __read_mostly;
3057 +struct cpu_cache_fns cpu_cache __read_only;
3058 #endif
3059 #ifdef CONFIG_OUTER_CACHE
3060 -struct outer_cache_fns outer_cache __read_mostly;
3061 +struct outer_cache_fns outer_cache __read_only;
3062 EXPORT_SYMBOL(outer_cache);
3063 #endif
3064
3065 @@ -236,9 +238,13 @@ static int __get_cpu_architecture(void)
3066 asm("mrc p15, 0, %0, c0, c1, 4"
3067 : "=r" (mmfr0));
3068 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
3069 - (mmfr0 & 0x000000f0) >= 0x00000030)
3070 + (mmfr0 & 0x000000f0) >= 0x00000030) {
3071 cpu_arch = CPU_ARCH_ARMv7;
3072 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3073 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
3074 + __supported_pte_mask |= L_PTE_PXN;
3075 + __supported_pmd_mask |= PMD_PXNTABLE;
3076 + }
3077 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3078 (mmfr0 & 0x000000f0) == 0x00000020)
3079 cpu_arch = CPU_ARCH_ARMv6;
3080 else
3081 @@ -479,7 +485,7 @@ static void __init setup_processor(void)
3082 __cpu_architecture = __get_cpu_architecture();
3083
3084 #ifdef MULTI_CPU
3085 - processor = *list->proc;
3086 + memcpy((void *)&processor, list->proc, sizeof processor);
3087 #endif
3088 #ifdef MULTI_TLB
3089 cpu_tlb = *list->tlb;
3090 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
3091 index 5a42c12..a2bb7c6 100644
3092 --- a/arch/arm/kernel/signal.c
3093 +++ b/arch/arm/kernel/signal.c
3094 @@ -45,8 +45,6 @@ static const unsigned long sigreturn_codes[7] = {
3095 MOV_R7_NR_RT_SIGRETURN, SWI_SYS_RT_SIGRETURN, SWI_THUMB_RT_SIGRETURN,
3096 };
3097
3098 -static unsigned long signal_return_offset;
3099 -
3100 #ifdef CONFIG_CRUNCH
3101 static int preserve_crunch_context(struct crunch_sigframe __user *frame)
3102 {
3103 @@ -406,8 +404,7 @@ setup_return(struct pt_regs *regs, struct ksignal *ksig,
3104 * except when the MPU has protected the vectors
3105 * page from PL0
3106 */
3107 - retcode = mm->context.sigpage + signal_return_offset +
3108 - (idx << 2) + thumb;
3109 + retcode = mm->context.sigpage + (idx << 2) + thumb;
3110 } else
3111 #endif
3112 {
3113 @@ -611,33 +608,3 @@ do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall)
3114 } while (thread_flags & _TIF_WORK_MASK);
3115 return 0;
3116 }
3117 -
3118 -struct page *get_signal_page(void)
3119 -{
3120 - unsigned long ptr;
3121 - unsigned offset;
3122 - struct page *page;
3123 - void *addr;
3124 -
3125 - page = alloc_pages(GFP_KERNEL, 0);
3126 -
3127 - if (!page)
3128 - return NULL;
3129 -
3130 - addr = page_address(page);
3131 -
3132 - /* Give the signal return code some randomness */
3133 - offset = 0x200 + (get_random_int() & 0x7fc);
3134 - signal_return_offset = offset;
3135 -
3136 - /*
3137 - * Copy signal return handlers into the vector page, and
3138 - * set sigreturn to be a pointer to these.
3139 - */
3140 - memcpy(addr + offset, sigreturn_codes, sizeof(sigreturn_codes));
3141 -
3142 - ptr = (unsigned long)addr + offset;
3143 - flush_icache_range(ptr, ptr + sizeof(sigreturn_codes));
3144 -
3145 - return page;
3146 -}
3147 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
3148 index 5919eb4..b5d6dfe 100644
3149 --- a/arch/arm/kernel/smp.c
3150 +++ b/arch/arm/kernel/smp.c
3151 @@ -70,7 +70,7 @@ enum ipi_msg_type {
3152
3153 static DECLARE_COMPLETION(cpu_running);
3154
3155 -static struct smp_operations smp_ops;
3156 +static struct smp_operations smp_ops __read_only;
3157
3158 void __init smp_set_ops(struct smp_operations *ops)
3159 {
3160 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
3161 index 6b9567e..b8af2d6 100644
3162 --- a/arch/arm/kernel/traps.c
3163 +++ b/arch/arm/kernel/traps.c
3164 @@ -55,7 +55,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
3165 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
3166 {
3167 #ifdef CONFIG_KALLSYMS
3168 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
3169 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
3170 #else
3171 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
3172 #endif
3173 @@ -257,6 +257,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3174 static int die_owner = -1;
3175 static unsigned int die_nest_count;
3176
3177 +extern void gr_handle_kernel_exploit(void);
3178 +
3179 static unsigned long oops_begin(void)
3180 {
3181 int cpu;
3182 @@ -299,6 +301,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3183 panic("Fatal exception in interrupt");
3184 if (panic_on_oops)
3185 panic("Fatal exception");
3186 +
3187 + gr_handle_kernel_exploit();
3188 +
3189 if (signr)
3190 do_exit(signr);
3191 }
3192 @@ -592,7 +597,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3193 * The user helper at 0xffff0fe0 must be used instead.
3194 * (see entry-armv.S for details)
3195 */
3196 + pax_open_kernel();
3197 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3198 + pax_close_kernel();
3199 }
3200 return 0;
3201
3202 @@ -848,5 +855,9 @@ void __init early_trap_init(void *vectors_base)
3203 kuser_init(vectors_base);
3204
3205 flush_icache_range(vectors, vectors + PAGE_SIZE * 2);
3206 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3207 +
3208 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3209 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3210 +#endif
3211 +
3212 }
3213 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3214 index 33f2ea3..0b91824 100644
3215 --- a/arch/arm/kernel/vmlinux.lds.S
3216 +++ b/arch/arm/kernel/vmlinux.lds.S
3217 @@ -8,7 +8,11 @@
3218 #include <asm/thread_info.h>
3219 #include <asm/memory.h>
3220 #include <asm/page.h>
3221 -
3222 +
3223 +#ifdef CONFIG_PAX_KERNEXEC
3224 +#include <asm/pgtable.h>
3225 +#endif
3226 +
3227 #define PROC_INFO \
3228 . = ALIGN(4); \
3229 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3230 @@ -94,6 +98,11 @@ SECTIONS
3231 _text = .;
3232 HEAD_TEXT
3233 }
3234 +
3235 +#ifdef CONFIG_PAX_KERNEXEC
3236 + . = ALIGN(1<<SECTION_SHIFT);
3237 +#endif
3238 +
3239 .text : { /* Real text segment */
3240 _stext = .; /* Text and read-only data */
3241 __exception_text_start = .;
3242 @@ -116,6 +125,8 @@ SECTIONS
3243 ARM_CPU_KEEP(PROC_INFO)
3244 }
3245
3246 + _etext = .; /* End of text section */
3247 +
3248 RO_DATA(PAGE_SIZE)
3249
3250 . = ALIGN(4);
3251 @@ -146,7 +157,9 @@ SECTIONS
3252
3253 NOTES
3254
3255 - _etext = .; /* End of text and rodata section */
3256 +#ifdef CONFIG_PAX_KERNEXEC
3257 + . = ALIGN(1<<SECTION_SHIFT);
3258 +#endif
3259
3260 #ifndef CONFIG_XIP_KERNEL
3261 . = ALIGN(PAGE_SIZE);
3262 @@ -224,6 +237,11 @@ SECTIONS
3263 . = PAGE_OFFSET + TEXT_OFFSET;
3264 #else
3265 __init_end = .;
3266 +
3267 +#ifdef CONFIG_PAX_KERNEXEC
3268 + . = ALIGN(1<<SECTION_SHIFT);
3269 +#endif
3270 +
3271 . = ALIGN(THREAD_SIZE);
3272 __data_loc = .;
3273 #endif
3274 diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
3275 index ef1703b..46b77f3 100644
3276 --- a/arch/arm/kvm/arm.c
3277 +++ b/arch/arm/kvm/arm.c
3278 @@ -56,7 +56,7 @@ static unsigned long hyp_default_vectors;
3279 static DEFINE_PER_CPU(struct kvm_vcpu *, kvm_arm_running_vcpu);
3280
3281 /* The VMID used in the VTTBR */
3282 -static atomic64_t kvm_vmid_gen = ATOMIC64_INIT(1);
3283 +static atomic64_unchecked_t kvm_vmid_gen = ATOMIC64_INIT(1);
3284 static u8 kvm_next_vmid;
3285 static DEFINE_SPINLOCK(kvm_vmid_lock);
3286
3287 @@ -392,7 +392,7 @@ void force_vm_exit(const cpumask_t *mask)
3288 */
3289 static bool need_new_vmid_gen(struct kvm *kvm)
3290 {
3291 - return unlikely(kvm->arch.vmid_gen != atomic64_read(&kvm_vmid_gen));
3292 + return unlikely(kvm->arch.vmid_gen != atomic64_read_unchecked(&kvm_vmid_gen));
3293 }
3294
3295 /**
3296 @@ -425,7 +425,7 @@ static void update_vttbr(struct kvm *kvm)
3297
3298 /* First user of a new VMID generation? */
3299 if (unlikely(kvm_next_vmid == 0)) {
3300 - atomic64_inc(&kvm_vmid_gen);
3301 + atomic64_inc_unchecked(&kvm_vmid_gen);
3302 kvm_next_vmid = 1;
3303
3304 /*
3305 @@ -442,7 +442,7 @@ static void update_vttbr(struct kvm *kvm)
3306 kvm_call_hyp(__kvm_flush_vm_context);
3307 }
3308
3309 - kvm->arch.vmid_gen = atomic64_read(&kvm_vmid_gen);
3310 + kvm->arch.vmid_gen = atomic64_read_unchecked(&kvm_vmid_gen);
3311 kvm->arch.vmid = kvm_next_vmid;
3312 kvm_next_vmid++;
3313
3314 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3315 index 14a0d98..7771a7d 100644
3316 --- a/arch/arm/lib/clear_user.S
3317 +++ b/arch/arm/lib/clear_user.S
3318 @@ -12,14 +12,14 @@
3319
3320 .text
3321
3322 -/* Prototype: int __clear_user(void *addr, size_t sz)
3323 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3324 * Purpose : clear some user memory
3325 * Params : addr - user memory address to clear
3326 * : sz - number of bytes to clear
3327 * Returns : number of bytes NOT cleared
3328 */
3329 ENTRY(__clear_user_std)
3330 -WEAK(__clear_user)
3331 +WEAK(___clear_user)
3332 stmfd sp!, {r1, lr}
3333 mov r2, #0
3334 cmp r1, #4
3335 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3336 USER( strnebt r2, [r0])
3337 mov r0, #0
3338 ldmfd sp!, {r1, pc}
3339 -ENDPROC(__clear_user)
3340 +ENDPROC(___clear_user)
3341 ENDPROC(__clear_user_std)
3342
3343 .pushsection .fixup,"ax"
3344 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3345 index 66a477a..bee61d3 100644
3346 --- a/arch/arm/lib/copy_from_user.S
3347 +++ b/arch/arm/lib/copy_from_user.S
3348 @@ -16,7 +16,7 @@
3349 /*
3350 * Prototype:
3351 *
3352 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3353 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3354 *
3355 * Purpose:
3356 *
3357 @@ -84,11 +84,11 @@
3358
3359 .text
3360
3361 -ENTRY(__copy_from_user)
3362 +ENTRY(___copy_from_user)
3363
3364 #include "copy_template.S"
3365
3366 -ENDPROC(__copy_from_user)
3367 +ENDPROC(___copy_from_user)
3368
3369 .pushsection .fixup,"ax"
3370 .align 0
3371 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3372 index 6ee2f67..d1cce76 100644
3373 --- a/arch/arm/lib/copy_page.S
3374 +++ b/arch/arm/lib/copy_page.S
3375 @@ -10,6 +10,7 @@
3376 * ASM optimised string functions
3377 */
3378 #include <linux/linkage.h>
3379 +#include <linux/const.h>
3380 #include <asm/assembler.h>
3381 #include <asm/asm-offsets.h>
3382 #include <asm/cache.h>
3383 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3384 index d066df6..df28194 100644
3385 --- a/arch/arm/lib/copy_to_user.S
3386 +++ b/arch/arm/lib/copy_to_user.S
3387 @@ -16,7 +16,7 @@
3388 /*
3389 * Prototype:
3390 *
3391 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3392 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3393 *
3394 * Purpose:
3395 *
3396 @@ -88,11 +88,11 @@
3397 .text
3398
3399 ENTRY(__copy_to_user_std)
3400 -WEAK(__copy_to_user)
3401 +WEAK(___copy_to_user)
3402
3403 #include "copy_template.S"
3404
3405 -ENDPROC(__copy_to_user)
3406 +ENDPROC(___copy_to_user)
3407 ENDPROC(__copy_to_user_std)
3408
3409 .pushsection .fixup,"ax"
3410 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3411 index 7d08b43..f7ca7ea 100644
3412 --- a/arch/arm/lib/csumpartialcopyuser.S
3413 +++ b/arch/arm/lib/csumpartialcopyuser.S
3414 @@ -57,8 +57,8 @@
3415 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3416 */
3417
3418 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3419 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3420 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3421 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3422
3423 #include "csumpartialcopygeneric.S"
3424
3425 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3426 index 64dbfa5..84a3fd9 100644
3427 --- a/arch/arm/lib/delay.c
3428 +++ b/arch/arm/lib/delay.c
3429 @@ -28,7 +28,7 @@
3430 /*
3431 * Default to the loop-based delay implementation.
3432 */
3433 -struct arm_delay_ops arm_delay_ops = {
3434 +struct arm_delay_ops arm_delay_ops __read_only = {
3435 .delay = __loop_delay,
3436 .const_udelay = __loop_const_udelay,
3437 .udelay = __loop_udelay,
3438 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3439 index 025f742..8432b08 100644
3440 --- a/arch/arm/lib/uaccess_with_memcpy.c
3441 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3442 @@ -104,7 +104,7 @@ out:
3443 }
3444
3445 unsigned long
3446 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3447 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3448 {
3449 /*
3450 * This test is stubbed out of the main function above to keep
3451 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3452 index f389228..592ef66 100644
3453 --- a/arch/arm/mach-kirkwood/common.c
3454 +++ b/arch/arm/mach-kirkwood/common.c
3455 @@ -149,7 +149,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3456 clk_gate_ops.disable(hw);
3457 }
3458
3459 -static struct clk_ops clk_gate_fn_ops;
3460 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3461 +{
3462 + return clk_gate_ops.is_enabled(hw);
3463 +}
3464 +
3465 +static struct clk_ops clk_gate_fn_ops = {
3466 + .enable = clk_gate_fn_enable,
3467 + .disable = clk_gate_fn_disable,
3468 + .is_enabled = clk_gate_fn_is_enabled,
3469 +};
3470
3471 static struct clk __init *clk_register_gate_fn(struct device *dev,
3472 const char *name,
3473 @@ -183,14 +192,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3474 gate_fn->fn_en = fn_en;
3475 gate_fn->fn_dis = fn_dis;
3476
3477 - /* ops is the gate ops, but with our enable/disable functions */
3478 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3479 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3480 - clk_gate_fn_ops = clk_gate_ops;
3481 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3482 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3483 - }
3484 -
3485 clk = clk_register(dev, &gate_fn->gate.hw);
3486
3487 if (IS_ERR(clk))
3488 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3489 index f6eeb87..cc90868 100644
3490 --- a/arch/arm/mach-omap2/board-n8x0.c
3491 +++ b/arch/arm/mach-omap2/board-n8x0.c
3492 @@ -631,7 +631,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3493 }
3494 #endif
3495
3496 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3497 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3498 .late_init = n8x0_menelaus_late_init,
3499 };
3500
3501 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3502 index 6c4da12..d9ca72d 100644
3503 --- a/arch/arm/mach-omap2/gpmc.c
3504 +++ b/arch/arm/mach-omap2/gpmc.c
3505 @@ -147,7 +147,6 @@ struct omap3_gpmc_regs {
3506 };
3507
3508 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3509 -static struct irq_chip gpmc_irq_chip;
3510 static unsigned gpmc_irq_start;
3511
3512 static struct resource gpmc_mem_root;
3513 @@ -711,6 +710,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3514
3515 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3516
3517 +static struct irq_chip gpmc_irq_chip = {
3518 + .name = "gpmc",
3519 + .irq_startup = gpmc_irq_noop_ret,
3520 + .irq_enable = gpmc_irq_enable,
3521 + .irq_disable = gpmc_irq_disable,
3522 + .irq_shutdown = gpmc_irq_noop,
3523 + .irq_ack = gpmc_irq_noop,
3524 + .irq_mask = gpmc_irq_noop,
3525 + .irq_unmask = gpmc_irq_noop,
3526 +
3527 +};
3528 +
3529 static int gpmc_setup_irq(void)
3530 {
3531 int i;
3532 @@ -725,15 +736,6 @@ static int gpmc_setup_irq(void)
3533 return gpmc_irq_start;
3534 }
3535
3536 - gpmc_irq_chip.name = "gpmc";
3537 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3538 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3539 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3540 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3541 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3542 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3543 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3544 -
3545 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3546 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3547
3548 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3549 index f8bb3b9..831e7b8 100644
3550 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3551 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3552 @@ -339,7 +339,7 @@ static int __cpuinit irq_cpu_hotplug_notify(struct notifier_block *self,
3553 return NOTIFY_OK;
3554 }
3555
3556 -static struct notifier_block __refdata irq_hotplug_notifier = {
3557 +static struct notifier_block irq_hotplug_notifier = {
3558 .notifier_call = irq_cpu_hotplug_notify,
3559 };
3560
3561 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3562 index e6d2307..d057195 100644
3563 --- a/arch/arm/mach-omap2/omap_device.c
3564 +++ b/arch/arm/mach-omap2/omap_device.c
3565 @@ -499,7 +499,7 @@ void omap_device_delete(struct omap_device *od)
3566 struct platform_device __init *omap_device_build(const char *pdev_name,
3567 int pdev_id,
3568 struct omap_hwmod *oh,
3569 - void *pdata, int pdata_len)
3570 + const void *pdata, int pdata_len)
3571 {
3572 struct omap_hwmod *ohs[] = { oh };
3573
3574 @@ -527,7 +527,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name,
3575 struct platform_device __init *omap_device_build_ss(const char *pdev_name,
3576 int pdev_id,
3577 struct omap_hwmod **ohs,
3578 - int oh_cnt, void *pdata,
3579 + int oh_cnt, const void *pdata,
3580 int pdata_len)
3581 {
3582 int ret = -ENOMEM;
3583 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3584 index 044c31d..2ee0861 100644
3585 --- a/arch/arm/mach-omap2/omap_device.h
3586 +++ b/arch/arm/mach-omap2/omap_device.h
3587 @@ -72,12 +72,12 @@ int omap_device_idle(struct platform_device *pdev);
3588 /* Core code interface */
3589
3590 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3591 - struct omap_hwmod *oh, void *pdata,
3592 + struct omap_hwmod *oh, const void *pdata,
3593 int pdata_len);
3594
3595 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3596 struct omap_hwmod **oh, int oh_cnt,
3597 - void *pdata, int pdata_len);
3598 + const void *pdata, int pdata_len);
3599
3600 struct omap_device *omap_device_alloc(struct platform_device *pdev,
3601 struct omap_hwmod **ohs, int oh_cnt);
3602 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3603 index 7341eff..fd75e34 100644
3604 --- a/arch/arm/mach-omap2/omap_hwmod.c
3605 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3606 @@ -194,10 +194,10 @@ struct omap_hwmod_soc_ops {
3607 int (*init_clkdm)(struct omap_hwmod *oh);
3608 void (*update_context_lost)(struct omap_hwmod *oh);
3609 int (*get_context_lost)(struct omap_hwmod *oh);
3610 -};
3611 +} __no_const;
3612
3613 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3614 -static struct omap_hwmod_soc_ops soc_ops;
3615 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3616
3617 /* omap_hwmod_list contains all registered struct omap_hwmods */
3618 static LIST_HEAD(omap_hwmod_list);
3619 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3620 index d15c7bb..b2d1f0c 100644
3621 --- a/arch/arm/mach-omap2/wd_timer.c
3622 +++ b/arch/arm/mach-omap2/wd_timer.c
3623 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3624 struct omap_hwmod *oh;
3625 char *oh_name = "wd_timer2";
3626 char *dev_name = "omap_wdt";
3627 - struct omap_wd_timer_platform_data pdata;
3628 + static struct omap_wd_timer_platform_data pdata = {
3629 + .read_reset_sources = prm_read_reset_sources
3630 + };
3631
3632 if (!cpu_class_is_omap2() || of_have_populated_dt())
3633 return 0;
3634 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3635 return -EINVAL;
3636 }
3637
3638 - pdata.read_reset_sources = prm_read_reset_sources;
3639 -
3640 pdev = omap_device_build(dev_name, id, oh, &pdata,
3641 sizeof(struct omap_wd_timer_platform_data));
3642 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
3643 diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c
3644 index 0cdba8d..297993e 100644
3645 --- a/arch/arm/mach-tegra/cpuidle-tegra20.c
3646 +++ b/arch/arm/mach-tegra/cpuidle-tegra20.c
3647 @@ -181,7 +181,7 @@ static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev,
3648 bool entered_lp2 = false;
3649
3650 if (tegra_pending_sgi())
3651 - ACCESS_ONCE(abort_flag) = true;
3652 + ACCESS_ONCE_RW(abort_flag) = true;
3653
3654 cpuidle_coupled_parallel_barrier(dev, &abort_barrier);
3655
3656 diff --git a/arch/arm/mach-ux500/setup.h b/arch/arm/mach-ux500/setup.h
3657 index cad3ca86..1d79e0f 100644
3658 --- a/arch/arm/mach-ux500/setup.h
3659 +++ b/arch/arm/mach-ux500/setup.h
3660 @@ -37,13 +37,6 @@ extern void ux500_timer_init(void);
3661 .type = MT_DEVICE, \
3662 }
3663
3664 -#define __MEM_DEV_DESC(x, sz) { \
3665 - .virtual = IO_ADDRESS(x), \
3666 - .pfn = __phys_to_pfn(x), \
3667 - .length = sz, \
3668 - .type = MT_MEMORY, \
3669 -}
3670 -
3671 extern struct smp_operations ux500_smp_ops;
3672 extern void ux500_cpu_die(unsigned int cpu);
3673
3674 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3675 index 08c9fe9..191320c 100644
3676 --- a/arch/arm/mm/Kconfig
3677 +++ b/arch/arm/mm/Kconfig
3678 @@ -436,7 +436,7 @@ config CPU_32v5
3679
3680 config CPU_32v6
3681 bool
3682 - select CPU_USE_DOMAINS if CPU_V6 && MMU
3683 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3684 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3685
3686 config CPU_32v6K
3687 @@ -585,6 +585,7 @@ config CPU_CP15_MPU
3688
3689 config CPU_USE_DOMAINS
3690 bool
3691 + depends on !ARM_LPAE && !PAX_KERNEXEC
3692 help
3693 This option enables or disables the use of domain switching
3694 via the set_fs() function.
3695 @@ -780,6 +781,7 @@ config NEED_KUSER_HELPERS
3696 config KUSER_HELPERS
3697 bool "Enable kuser helpers in vector page" if !NEED_KUSER_HELPERS
3698 default y
3699 + depends on !(CPU_V6 || CPU_V6K || CPU_V7)
3700 help
3701 Warning: disabling this option may break user programs.
3702
3703 @@ -792,7 +794,7 @@ config KUSER_HELPERS
3704 See Documentation/arm/kernel_user_helpers.txt for details.
3705
3706 However, the fixed address nature of these helpers can be used
3707 - by ROP (return orientated programming) authors when creating
3708 + by ROP (Return Oriented Programming) authors when creating
3709 exploits.
3710
3711 If all of the binaries and libraries which run on your platform
3712 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3713 index 6f4585b..7b6f52b 100644
3714 --- a/arch/arm/mm/alignment.c
3715 +++ b/arch/arm/mm/alignment.c
3716 @@ -211,10 +211,12 @@ union offset_union {
3717 #define __get16_unaligned_check(ins,val,addr) \
3718 do { \
3719 unsigned int err = 0, v, a = addr; \
3720 + pax_open_userland(); \
3721 __get8_unaligned_check(ins,v,a,err); \
3722 val = v << ((BE) ? 8 : 0); \
3723 __get8_unaligned_check(ins,v,a,err); \
3724 val |= v << ((BE) ? 0 : 8); \
3725 + pax_close_userland(); \
3726 if (err) \
3727 goto fault; \
3728 } while (0)
3729 @@ -228,6 +230,7 @@ union offset_union {
3730 #define __get32_unaligned_check(ins,val,addr) \
3731 do { \
3732 unsigned int err = 0, v, a = addr; \
3733 + pax_open_userland(); \
3734 __get8_unaligned_check(ins,v,a,err); \
3735 val = v << ((BE) ? 24 : 0); \
3736 __get8_unaligned_check(ins,v,a,err); \
3737 @@ -236,6 +239,7 @@ union offset_union {
3738 val |= v << ((BE) ? 8 : 16); \
3739 __get8_unaligned_check(ins,v,a,err); \
3740 val |= v << ((BE) ? 0 : 24); \
3741 + pax_close_userland(); \
3742 if (err) \
3743 goto fault; \
3744 } while (0)
3745 @@ -249,6 +253,7 @@ union offset_union {
3746 #define __put16_unaligned_check(ins,val,addr) \
3747 do { \
3748 unsigned int err = 0, v = val, a = addr; \
3749 + pax_open_userland(); \
3750 __asm__( FIRST_BYTE_16 \
3751 ARM( "1: "ins" %1, [%2], #1\n" ) \
3752 THUMB( "1: "ins" %1, [%2]\n" ) \
3753 @@ -268,6 +273,7 @@ union offset_union {
3754 " .popsection\n" \
3755 : "=r" (err), "=&r" (v), "=&r" (a) \
3756 : "0" (err), "1" (v), "2" (a)); \
3757 + pax_close_userland(); \
3758 if (err) \
3759 goto fault; \
3760 } while (0)
3761 @@ -281,6 +287,7 @@ union offset_union {
3762 #define __put32_unaligned_check(ins,val,addr) \
3763 do { \
3764 unsigned int err = 0, v = val, a = addr; \
3765 + pax_open_userland(); \
3766 __asm__( FIRST_BYTE_32 \
3767 ARM( "1: "ins" %1, [%2], #1\n" ) \
3768 THUMB( "1: "ins" %1, [%2]\n" ) \
3769 @@ -310,6 +317,7 @@ union offset_union {
3770 " .popsection\n" \
3771 : "=r" (err), "=&r" (v), "=&r" (a) \
3772 : "0" (err), "1" (v), "2" (a)); \
3773 + pax_close_userland(); \
3774 if (err) \
3775 goto fault; \
3776 } while (0)
3777 diff --git a/arch/arm/mm/context.c b/arch/arm/mm/context.c
3778 index eeab06e..2638dc2 100644
3779 --- a/arch/arm/mm/context.c
3780 +++ b/arch/arm/mm/context.c
3781 @@ -42,7 +42,7 @@
3782 #define NUM_USER_ASIDS ASID_FIRST_VERSION
3783
3784 static DEFINE_RAW_SPINLOCK(cpu_asid_lock);
3785 -static atomic64_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3786 +static atomic64_unchecked_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3787 static DECLARE_BITMAP(asid_map, NUM_USER_ASIDS);
3788
3789 static DEFINE_PER_CPU(atomic64_t, active_asids);
3790 @@ -188,7 +188,7 @@ static int is_reserved_asid(u64 asid)
3791 static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3792 {
3793 u64 asid = atomic64_read(&mm->context.id);
3794 - u64 generation = atomic64_read(&asid_generation);
3795 + u64 generation = atomic64_read_unchecked(&asid_generation);
3796
3797 if (asid != 0 && is_reserved_asid(asid)) {
3798 /*
3799 @@ -206,7 +206,7 @@ static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3800 */
3801 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
3802 if (asid == NUM_USER_ASIDS) {
3803 - generation = atomic64_add_return(ASID_FIRST_VERSION,
3804 + generation = atomic64_add_return_unchecked(ASID_FIRST_VERSION,
3805 &asid_generation);
3806 flush_context(cpu);
3807 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
3808 @@ -235,14 +235,14 @@ void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk)
3809 cpu_set_reserved_ttbr0();
3810
3811 asid = atomic64_read(&mm->context.id);
3812 - if (!((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS)
3813 + if (!((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS)
3814 && atomic64_xchg(&per_cpu(active_asids, cpu), asid))
3815 goto switch_mm_fastpath;
3816
3817 raw_spin_lock_irqsave(&cpu_asid_lock, flags);
3818 /* Check that our ASID belongs to the current generation. */
3819 asid = atomic64_read(&mm->context.id);
3820 - if ((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS) {
3821 + if ((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS) {
3822 asid = new_context(mm, cpu);
3823 atomic64_set(&mm->context.id, asid);
3824 }
3825 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3826 index 5dbf13f..a2d1876 100644
3827 --- a/arch/arm/mm/fault.c
3828 +++ b/arch/arm/mm/fault.c
3829 @@ -25,6 +25,7 @@
3830 #include <asm/system_misc.h>
3831 #include <asm/system_info.h>
3832 #include <asm/tlbflush.h>
3833 +#include <asm/sections.h>
3834
3835 #include "fault.h"
3836
3837 @@ -138,6 +139,20 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3838 if (fixup_exception(regs))
3839 return;
3840
3841 +#ifdef CONFIG_PAX_KERNEXEC
3842 + if ((fsr & FSR_WRITE) &&
3843 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3844 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3845 + {
3846 + if (current->signal->curr_ip)
3847 + 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),
3848 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3849 + else
3850 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3851 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3852 + }
3853 +#endif
3854 +
3855 /*
3856 * No handler, we'll have to terminate things with extreme prejudice.
3857 */
3858 @@ -174,6 +189,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3859 }
3860 #endif
3861
3862 +#ifdef CONFIG_PAX_PAGEEXEC
3863 + if (fsr & FSR_LNX_PF) {
3864 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3865 + do_group_exit(SIGKILL);
3866 + }
3867 +#endif
3868 +
3869 tsk->thread.address = addr;
3870 tsk->thread.error_code = fsr;
3871 tsk->thread.trap_no = 14;
3872 @@ -398,6 +420,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3873 }
3874 #endif /* CONFIG_MMU */
3875
3876 +#ifdef CONFIG_PAX_PAGEEXEC
3877 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3878 +{
3879 + long i;
3880 +
3881 + printk(KERN_ERR "PAX: bytes at PC: ");
3882 + for (i = 0; i < 20; i++) {
3883 + unsigned char c;
3884 + if (get_user(c, (__force unsigned char __user *)pc+i))
3885 + printk(KERN_CONT "?? ");
3886 + else
3887 + printk(KERN_CONT "%02x ", c);
3888 + }
3889 + printk("\n");
3890 +
3891 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3892 + for (i = -1; i < 20; i++) {
3893 + unsigned long c;
3894 + if (get_user(c, (__force unsigned long __user *)sp+i))
3895 + printk(KERN_CONT "???????? ");
3896 + else
3897 + printk(KERN_CONT "%08lx ", c);
3898 + }
3899 + printk("\n");
3900 +}
3901 +#endif
3902 +
3903 /*
3904 * First Level Translation Fault Handler
3905 *
3906 @@ -543,9 +592,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3907 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
3908 struct siginfo info;
3909
3910 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3911 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
3912 + if (current->signal->curr_ip)
3913 + 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),
3914 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3915 + else
3916 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3917 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3918 + goto die;
3919 + }
3920 +#endif
3921 +
3922 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
3923 return;
3924
3925 +die:
3926 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
3927 inf->name, fsr, addr);
3928
3929 @@ -569,15 +631,68 @@ hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int, struct pt_regs *
3930 ifsr_info[nr].name = name;
3931 }
3932
3933 +asmlinkage int sys_sigreturn(struct pt_regs *regs);
3934 +asmlinkage int sys_rt_sigreturn(struct pt_regs *regs);
3935 +
3936 asmlinkage void __exception
3937 do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
3938 {
3939 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
3940 struct siginfo info;
3941 + unsigned long pc = instruction_pointer(regs);
3942 +
3943 + if (user_mode(regs)) {
3944 + unsigned long sigpage = current->mm->context.sigpage;
3945 +
3946 + if (sigpage <= pc && pc < sigpage + 7*4) {
3947 + if (pc < sigpage + 3*4)
3948 + sys_sigreturn(regs);
3949 + else
3950 + sys_rt_sigreturn(regs);
3951 + return;
3952 + }
3953 + if (pc == 0xffff0fe0UL) {
3954 + /*
3955 + * PaX: __kuser_get_tls emulation
3956 + */
3957 + regs->ARM_r0 = current_thread_info()->tp_value;
3958 + regs->ARM_pc = regs->ARM_lr;
3959 + return;
3960 + }
3961 + }
3962 +
3963 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3964 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3965 + if (current->signal->curr_ip)
3966 + 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),
3967 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3968 + pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
3969 + else
3970 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
3971 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3972 + pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
3973 + goto die;
3974 + }
3975 +#endif
3976 +
3977 +#ifdef CONFIG_PAX_REFCOUNT
3978 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
3979 + unsigned int bkpt;
3980 +
3981 + if (!probe_kernel_address((unsigned int *)pc, bkpt) && cpu_to_le32(bkpt) == 0xe12f1073) {
3982 + current->thread.error_code = ifsr;
3983 + current->thread.trap_no = 0;
3984 + pax_report_refcount_overflow(regs);
3985 + fixup_exception(regs);
3986 + return;
3987 + }
3988 + }
3989 +#endif
3990
3991 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
3992 return;
3993
3994 +die:
3995 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
3996 inf->name, ifsr, addr);
3997
3998 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
3999 index cf08bdf..772656c 100644
4000 --- a/arch/arm/mm/fault.h
4001 +++ b/arch/arm/mm/fault.h
4002 @@ -3,6 +3,7 @@
4003
4004 /*
4005 * Fault status register encodings. We steal bit 31 for our own purposes.
4006 + * Set when the FSR value is from an instruction fault.
4007 */
4008 #define FSR_LNX_PF (1 << 31)
4009 #define FSR_WRITE (1 << 11)
4010 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
4011 }
4012 #endif
4013
4014 +/* valid for LPAE and !LPAE */
4015 +static inline int is_xn_fault(unsigned int fsr)
4016 +{
4017 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
4018 +}
4019 +
4020 +static inline int is_domain_fault(unsigned int fsr)
4021 +{
4022 + return ((fsr_fs(fsr) & 0xD) == 0x9);
4023 +}
4024 +
4025 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
4026 unsigned long search_exception_table(unsigned long addr);
4027
4028 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
4029 index 0ecc43f..190b956 100644
4030 --- a/arch/arm/mm/init.c
4031 +++ b/arch/arm/mm/init.c
4032 @@ -30,6 +30,8 @@
4033 #include <asm/setup.h>
4034 #include <asm/tlb.h>
4035 #include <asm/fixmap.h>
4036 +#include <asm/system_info.h>
4037 +#include <asm/cp15.h>
4038
4039 #include <asm/mach/arch.h>
4040 #include <asm/mach/map.h>
4041 @@ -726,7 +728,46 @@ void free_initmem(void)
4042 {
4043 #ifdef CONFIG_HAVE_TCM
4044 extern char __tcm_start, __tcm_end;
4045 +#endif
4046
4047 +#ifdef CONFIG_PAX_KERNEXEC
4048 + unsigned long addr;
4049 + pgd_t *pgd;
4050 + pud_t *pud;
4051 + pmd_t *pmd;
4052 + int cpu_arch = cpu_architecture();
4053 + unsigned int cr = get_cr();
4054 +
4055 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
4056 + /* make pages tables, etc before .text NX */
4057 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
4058 + pgd = pgd_offset_k(addr);
4059 + pud = pud_offset(pgd, addr);
4060 + pmd = pmd_offset(pud, addr);
4061 + __section_update(pmd, addr, PMD_SECT_XN);
4062 + }
4063 + /* make init NX */
4064 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
4065 + pgd = pgd_offset_k(addr);
4066 + pud = pud_offset(pgd, addr);
4067 + pmd = pmd_offset(pud, addr);
4068 + __section_update(pmd, addr, PMD_SECT_XN);
4069 + }
4070 + /* make kernel code/rodata RX */
4071 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
4072 + pgd = pgd_offset_k(addr);
4073 + pud = pud_offset(pgd, addr);
4074 + pmd = pmd_offset(pud, addr);
4075 +#ifdef CONFIG_ARM_LPAE
4076 + __section_update(pmd, addr, PMD_SECT_RDONLY);
4077 +#else
4078 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
4079 +#endif
4080 + }
4081 + }
4082 +#endif
4083 +
4084 +#ifdef CONFIG_HAVE_TCM
4085 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
4086 free_reserved_area(&__tcm_start, &__tcm_end, 0, "TCM link");
4087 #endif
4088 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
4089 index 04d9006..c547d85 100644
4090 --- a/arch/arm/mm/ioremap.c
4091 +++ b/arch/arm/mm/ioremap.c
4092 @@ -392,9 +392,9 @@ __arm_ioremap_exec(unsigned long phys_addr, size_t size, bool cached)
4093 unsigned int mtype;
4094
4095 if (cached)
4096 - mtype = MT_MEMORY;
4097 + mtype = MT_MEMORY_RX;
4098 else
4099 - mtype = MT_MEMORY_NONCACHED;
4100 + mtype = MT_MEMORY_NONCACHED_RX;
4101
4102 return __arm_ioremap_caller(phys_addr, size, mtype,
4103 __builtin_return_address(0));
4104 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
4105 index 10062ce..8695745 100644
4106 --- a/arch/arm/mm/mmap.c
4107 +++ b/arch/arm/mm/mmap.c
4108 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4109 struct vm_area_struct *vma;
4110 int do_align = 0;
4111 int aliasing = cache_is_vipt_aliasing();
4112 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4113 struct vm_unmapped_area_info info;
4114
4115 /*
4116 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4117 if (len > TASK_SIZE)
4118 return -ENOMEM;
4119
4120 +#ifdef CONFIG_PAX_RANDMMAP
4121 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4122 +#endif
4123 +
4124 if (addr) {
4125 if (do_align)
4126 addr = COLOUR_ALIGN(addr, pgoff);
4127 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4128 addr = PAGE_ALIGN(addr);
4129
4130 vma = find_vma(mm, addr);
4131 - if (TASK_SIZE - len >= addr &&
4132 - (!vma || addr + len <= vma->vm_start))
4133 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4134 return addr;
4135 }
4136
4137 @@ -99,6 +103,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4138 info.high_limit = TASK_SIZE;
4139 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4140 info.align_offset = pgoff << PAGE_SHIFT;
4141 + info.threadstack_offset = offset;
4142 return vm_unmapped_area(&info);
4143 }
4144
4145 @@ -112,6 +117,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4146 unsigned long addr = addr0;
4147 int do_align = 0;
4148 int aliasing = cache_is_vipt_aliasing();
4149 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4150 struct vm_unmapped_area_info info;
4151
4152 /*
4153 @@ -132,6 +138,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4154 return addr;
4155 }
4156
4157 +#ifdef CONFIG_PAX_RANDMMAP
4158 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4159 +#endif
4160 +
4161 /* requesting a specific address */
4162 if (addr) {
4163 if (do_align)
4164 @@ -139,8 +149,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4165 else
4166 addr = PAGE_ALIGN(addr);
4167 vma = find_vma(mm, addr);
4168 - if (TASK_SIZE - len >= addr &&
4169 - (!vma || addr + len <= vma->vm_start))
4170 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4171 return addr;
4172 }
4173
4174 @@ -150,6 +159,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4175 info.high_limit = mm->mmap_base;
4176 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4177 info.align_offset = pgoff << PAGE_SHIFT;
4178 + info.threadstack_offset = offset;
4179 addr = vm_unmapped_area(&info);
4180
4181 /*
4182 @@ -173,6 +183,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4183 {
4184 unsigned long random_factor = 0UL;
4185
4186 +#ifdef CONFIG_PAX_RANDMMAP
4187 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4188 +#endif
4189 +
4190 /* 8 bits of randomness in 20 address space bits */
4191 if ((current->flags & PF_RANDOMIZE) &&
4192 !(current->personality & ADDR_NO_RANDOMIZE))
4193 @@ -180,10 +194,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4194
4195 if (mmap_is_legacy()) {
4196 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
4197 +
4198 +#ifdef CONFIG_PAX_RANDMMAP
4199 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4200 + mm->mmap_base += mm->delta_mmap;
4201 +#endif
4202 +
4203 mm->get_unmapped_area = arch_get_unmapped_area;
4204 mm->unmap_area = arch_unmap_area;
4205 } else {
4206 mm->mmap_base = mmap_base(random_factor);
4207 +
4208 +#ifdef CONFIG_PAX_RANDMMAP
4209 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4210 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
4211 +#endif
4212 +
4213 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
4214 mm->unmap_area = arch_unmap_area_topdown;
4215 }
4216 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
4217 index daf336f..4e6392c 100644
4218 --- a/arch/arm/mm/mmu.c
4219 +++ b/arch/arm/mm/mmu.c
4220 @@ -36,6 +36,22 @@
4221 #include "mm.h"
4222 #include "tcm.h"
4223
4224 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
4225 +void modify_domain(unsigned int dom, unsigned int type)
4226 +{
4227 + struct thread_info *thread = current_thread_info();
4228 + unsigned int domain = thread->cpu_domain;
4229 + /*
4230 + * DOMAIN_MANAGER might be defined to some other value,
4231 + * use the arch-defined constant
4232 + */
4233 + domain &= ~domain_val(dom, 3);
4234 + thread->cpu_domain = domain | domain_val(dom, type);
4235 + set_domain(thread->cpu_domain);
4236 +}
4237 +EXPORT_SYMBOL(modify_domain);
4238 +#endif
4239 +
4240 /*
4241 * empty_zero_page is a special page that is used for
4242 * zero-initialized data and COW.
4243 @@ -228,10 +244,18 @@ __setup("noalign", noalign_setup);
4244
4245 #endif /* ifdef CONFIG_CPU_CP15 / else */
4246
4247 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
4248 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
4249 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4250
4251 -static struct mem_type mem_types[] = {
4252 +#ifdef CONFIG_PAX_KERNEXEC
4253 +#define L_PTE_KERNEXEC L_PTE_RDONLY
4254 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4255 +#else
4256 +#define L_PTE_KERNEXEC L_PTE_DIRTY
4257 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4258 +#endif
4259 +
4260 +static struct mem_type mem_types[] __read_only = {
4261 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4262 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4263 L_PTE_SHARED,
4264 @@ -260,16 +284,16 @@ static struct mem_type mem_types[] = {
4265 [MT_UNCACHED] = {
4266 .prot_pte = PROT_PTE_DEVICE,
4267 .prot_l1 = PMD_TYPE_TABLE,
4268 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4269 + .prot_sect = PROT_SECT_DEVICE,
4270 .domain = DOMAIN_IO,
4271 },
4272 [MT_CACHECLEAN] = {
4273 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4274 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4275 .domain = DOMAIN_KERNEL,
4276 },
4277 #ifndef CONFIG_ARM_LPAE
4278 [MT_MINICLEAN] = {
4279 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4280 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
4281 .domain = DOMAIN_KERNEL,
4282 },
4283 #endif
4284 @@ -277,36 +301,54 @@ static struct mem_type mem_types[] = {
4285 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4286 L_PTE_RDONLY,
4287 .prot_l1 = PMD_TYPE_TABLE,
4288 - .domain = DOMAIN_USER,
4289 + .domain = DOMAIN_VECTORS,
4290 },
4291 [MT_HIGH_VECTORS] = {
4292 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4293 L_PTE_USER | L_PTE_RDONLY,
4294 .prot_l1 = PMD_TYPE_TABLE,
4295 - .domain = DOMAIN_USER,
4296 + .domain = DOMAIN_VECTORS,
4297 },
4298 - [MT_MEMORY] = {
4299 + [MT_MEMORY_RWX] = {
4300 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4301 .prot_l1 = PMD_TYPE_TABLE,
4302 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4303 .domain = DOMAIN_KERNEL,
4304 },
4305 + [MT_MEMORY_RW] = {
4306 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4307 + .prot_l1 = PMD_TYPE_TABLE,
4308 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4309 + .domain = DOMAIN_KERNEL,
4310 + },
4311 + [MT_MEMORY_RX] = {
4312 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4313 + .prot_l1 = PMD_TYPE_TABLE,
4314 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4315 + .domain = DOMAIN_KERNEL,
4316 + },
4317 [MT_ROM] = {
4318 - .prot_sect = PMD_TYPE_SECT,
4319 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4320 .domain = DOMAIN_KERNEL,
4321 },
4322 - [MT_MEMORY_NONCACHED] = {
4323 + [MT_MEMORY_NONCACHED_RW] = {
4324 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4325 L_PTE_MT_BUFFERABLE,
4326 .prot_l1 = PMD_TYPE_TABLE,
4327 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4328 .domain = DOMAIN_KERNEL,
4329 },
4330 + [MT_MEMORY_NONCACHED_RX] = {
4331 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4332 + L_PTE_MT_BUFFERABLE,
4333 + .prot_l1 = PMD_TYPE_TABLE,
4334 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4335 + .domain = DOMAIN_KERNEL,
4336 + },
4337 [MT_MEMORY_DTCM] = {
4338 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4339 - L_PTE_XN,
4340 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4341 .prot_l1 = PMD_TYPE_TABLE,
4342 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4343 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4344 .domain = DOMAIN_KERNEL,
4345 },
4346 [MT_MEMORY_ITCM] = {
4347 @@ -316,10 +358,10 @@ static struct mem_type mem_types[] = {
4348 },
4349 [MT_MEMORY_SO] = {
4350 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4351 - L_PTE_MT_UNCACHED | L_PTE_XN,
4352 + L_PTE_MT_UNCACHED,
4353 .prot_l1 = PMD_TYPE_TABLE,
4354 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4355 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4356 + PMD_SECT_UNCACHED,
4357 .domain = DOMAIN_KERNEL,
4358 },
4359 [MT_MEMORY_DMA_READY] = {
4360 @@ -405,9 +447,35 @@ static void __init build_mem_type_table(void)
4361 * to prevent speculative instruction fetches.
4362 */
4363 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4364 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4365 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4366 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4367 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4368 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4369 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4370 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4371 +
4372 + /* Mark other regions on ARMv6+ as execute-never */
4373 +
4374 +#ifdef CONFIG_PAX_KERNEXEC
4375 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4376 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4377 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4378 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4379 +#ifndef CONFIG_ARM_LPAE
4380 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4381 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4382 +#endif
4383 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4384 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4385 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4386 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4387 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4388 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4389 +#endif
4390 +
4391 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4392 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4393 }
4394 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4395 /*
4396 @@ -468,6 +536,9 @@ static void __init build_mem_type_table(void)
4397 * from SVC mode and no access from userspace.
4398 */
4399 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4400 +#ifdef CONFIG_PAX_KERNEXEC
4401 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4402 +#endif
4403 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4404 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4405 #endif
4406 @@ -485,11 +556,17 @@ static void __init build_mem_type_table(void)
4407 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4408 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4409 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4410 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4411 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4412 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4413 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4414 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4415 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4416 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4417 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4418 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4419 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4420 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4421 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4422 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4423 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4424 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4425 }
4426 }
4427
4428 @@ -500,15 +577,20 @@ static void __init build_mem_type_table(void)
4429 if (cpu_arch >= CPU_ARCH_ARMv6) {
4430 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4431 /* Non-cacheable Normal is XCB = 001 */
4432 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4433 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4434 + PMD_SECT_BUFFERED;
4435 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4436 PMD_SECT_BUFFERED;
4437 } else {
4438 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4439 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4440 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4441 + PMD_SECT_TEX(1);
4442 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4443 PMD_SECT_TEX(1);
4444 }
4445 } else {
4446 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4447 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4448 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4449 }
4450
4451 #ifdef CONFIG_ARM_LPAE
4452 @@ -524,6 +606,8 @@ static void __init build_mem_type_table(void)
4453 vecs_pgprot |= PTE_EXT_AF;
4454 #endif
4455
4456 + user_pgprot |= __supported_pte_mask;
4457 +
4458 for (i = 0; i < 16; i++) {
4459 pteval_t v = pgprot_val(protection_map[i]);
4460 protection_map[i] = __pgprot(v | user_pgprot);
4461 @@ -541,10 +625,15 @@ static void __init build_mem_type_table(void)
4462
4463 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4464 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4465 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4466 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4467 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4468 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4469 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4470 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4471 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4472 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4473 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4474 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4475 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4476 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4477 mem_types[MT_ROM].prot_sect |= cp->pmd;
4478
4479 switch (cp->pmd) {
4480 @@ -1166,18 +1255,15 @@ void __init arm_mm_memblock_reserve(void)
4481 * called function. This means you can't use any function or debugging
4482 * method which may touch any device, otherwise the kernel _will_ crash.
4483 */
4484 +
4485 +static char vectors[PAGE_SIZE * 2] __read_only __aligned(PAGE_SIZE);
4486 +
4487 static void __init devicemaps_init(struct machine_desc *mdesc)
4488 {
4489 struct map_desc map;
4490 unsigned long addr;
4491 - void *vectors;
4492
4493 - /*
4494 - * Allocate the vector page early.
4495 - */
4496 - vectors = early_alloc(PAGE_SIZE * 2);
4497 -
4498 - early_trap_init(vectors);
4499 + early_trap_init(&vectors);
4500
4501 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4502 pmd_clear(pmd_off_k(addr));
4503 @@ -1217,7 +1303,7 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
4504 * location (0xffff0000). If we aren't using high-vectors, also
4505 * create a mapping at the low-vectors virtual address.
4506 */
4507 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4508 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4509 map.virtual = 0xffff0000;
4510 map.length = PAGE_SIZE;
4511 #ifdef CONFIG_KUSER_HELPERS
4512 @@ -1287,8 +1373,39 @@ static void __init map_lowmem(void)
4513 map.pfn = __phys_to_pfn(start);
4514 map.virtual = __phys_to_virt(start);
4515 map.length = end - start;
4516 - map.type = MT_MEMORY;
4517
4518 +#ifdef CONFIG_PAX_KERNEXEC
4519 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4520 + struct map_desc kernel;
4521 + struct map_desc initmap;
4522 +
4523 + /* when freeing initmem we will make this RW */
4524 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4525 + initmap.virtual = (unsigned long)__init_begin;
4526 + initmap.length = _sdata - __init_begin;
4527 + initmap.type = MT_MEMORY_RWX;
4528 + create_mapping(&initmap);
4529 +
4530 + /* when freeing initmem we will make this RX */
4531 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4532 + kernel.virtual = (unsigned long)_stext;
4533 + kernel.length = __init_begin - _stext;
4534 + kernel.type = MT_MEMORY_RWX;
4535 + create_mapping(&kernel);
4536 +
4537 + if (map.virtual < (unsigned long)_stext) {
4538 + map.length = (unsigned long)_stext - map.virtual;
4539 + map.type = MT_MEMORY_RWX;
4540 + create_mapping(&map);
4541 + }
4542 +
4543 + map.pfn = __phys_to_pfn(__pa(_sdata));
4544 + map.virtual = (unsigned long)_sdata;
4545 + map.length = end - __pa(_sdata);
4546 + }
4547 +#endif
4548 +
4549 + map.type = MT_MEMORY_RW;
4550 create_mapping(&map);
4551 }
4552 }
4553 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4554 index a5bc92d..0bb4730 100644
4555 --- a/arch/arm/plat-omap/sram.c
4556 +++ b/arch/arm/plat-omap/sram.c
4557 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4558 * Looks like we need to preserve some bootloader code at the
4559 * beginning of SRAM for jumping to flash for reboot to work...
4560 */
4561 + pax_open_kernel();
4562 memset_io(omap_sram_base + omap_sram_skip, 0,
4563 omap_sram_size - omap_sram_skip);
4564 + pax_close_kernel();
4565 }
4566 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4567 index ce6d763..cfea917 100644
4568 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4569 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4570 @@ -47,7 +47,7 @@ struct samsung_dma_ops {
4571 int (*started)(unsigned ch);
4572 int (*flush)(unsigned ch);
4573 int (*stop)(unsigned ch);
4574 -};
4575 +} __no_const;
4576
4577 extern void *samsung_dmadev_get_ops(void);
4578 extern void *s3c_dma_get_ops(void);
4579 diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
4580 index f4726dc..39ed646 100644
4581 --- a/arch/arm64/kernel/debug-monitors.c
4582 +++ b/arch/arm64/kernel/debug-monitors.c
4583 @@ -149,7 +149,7 @@ static int __cpuinit os_lock_notify(struct notifier_block *self,
4584 return NOTIFY_OK;
4585 }
4586
4587 -static struct notifier_block __cpuinitdata os_lock_nb = {
4588 +static struct notifier_block os_lock_nb = {
4589 .notifier_call = os_lock_notify,
4590 };
4591
4592 diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c
4593 index 5ab825c..96aaec8 100644
4594 --- a/arch/arm64/kernel/hw_breakpoint.c
4595 +++ b/arch/arm64/kernel/hw_breakpoint.c
4596 @@ -831,7 +831,7 @@ static int __cpuinit hw_breakpoint_reset_notify(struct notifier_block *self,
4597 return NOTIFY_OK;
4598 }
4599
4600 -static struct notifier_block __cpuinitdata hw_breakpoint_reset_nb = {
4601 +static struct notifier_block hw_breakpoint_reset_nb = {
4602 .notifier_call = hw_breakpoint_reset_notify,
4603 };
4604
4605 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4606 index c3a58a1..78fbf54 100644
4607 --- a/arch/avr32/include/asm/cache.h
4608 +++ b/arch/avr32/include/asm/cache.h
4609 @@ -1,8 +1,10 @@
4610 #ifndef __ASM_AVR32_CACHE_H
4611 #define __ASM_AVR32_CACHE_H
4612
4613 +#include <linux/const.h>
4614 +
4615 #define L1_CACHE_SHIFT 5
4616 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4617 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4618
4619 /*
4620 * Memory returned by kmalloc() may be used for DMA, so we must make
4621 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4622 index d232888..87c8df1 100644
4623 --- a/arch/avr32/include/asm/elf.h
4624 +++ b/arch/avr32/include/asm/elf.h
4625 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4626 the loader. We need to make sure that it is out of the way of the program
4627 that it will "exec", and that there is sufficient room for the brk. */
4628
4629 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4630 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4631
4632 +#ifdef CONFIG_PAX_ASLR
4633 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4634 +
4635 +#define PAX_DELTA_MMAP_LEN 15
4636 +#define PAX_DELTA_STACK_LEN 15
4637 +#endif
4638
4639 /* This yields a mask that user programs can use to figure out what
4640 instruction set this CPU supports. This could be done in user space,
4641 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4642 index 479330b..53717a8 100644
4643 --- a/arch/avr32/include/asm/kmap_types.h
4644 +++ b/arch/avr32/include/asm/kmap_types.h
4645 @@ -2,9 +2,9 @@
4646 #define __ASM_AVR32_KMAP_TYPES_H
4647
4648 #ifdef CONFIG_DEBUG_HIGHMEM
4649 -# define KM_TYPE_NR 29
4650 +# define KM_TYPE_NR 30
4651 #else
4652 -# define KM_TYPE_NR 14
4653 +# define KM_TYPE_NR 15
4654 #endif
4655
4656 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4657 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4658 index b2f2d2d..d1c85cb 100644
4659 --- a/arch/avr32/mm/fault.c
4660 +++ b/arch/avr32/mm/fault.c
4661 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4662
4663 int exception_trace = 1;
4664
4665 +#ifdef CONFIG_PAX_PAGEEXEC
4666 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4667 +{
4668 + unsigned long i;
4669 +
4670 + printk(KERN_ERR "PAX: bytes at PC: ");
4671 + for (i = 0; i < 20; i++) {
4672 + unsigned char c;
4673 + if (get_user(c, (unsigned char *)pc+i))
4674 + printk(KERN_CONT "???????? ");
4675 + else
4676 + printk(KERN_CONT "%02x ", c);
4677 + }
4678 + printk("\n");
4679 +}
4680 +#endif
4681 +
4682 /*
4683 * This routine handles page faults. It determines the address and the
4684 * problem, and then passes it off to one of the appropriate routines.
4685 @@ -174,6 +191,16 @@ bad_area:
4686 up_read(&mm->mmap_sem);
4687
4688 if (user_mode(regs)) {
4689 +
4690 +#ifdef CONFIG_PAX_PAGEEXEC
4691 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4692 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4693 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4694 + do_group_exit(SIGKILL);
4695 + }
4696 + }
4697 +#endif
4698 +
4699 if (exception_trace && printk_ratelimit())
4700 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4701 "sp %08lx ecr %lu\n",
4702 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4703 index 568885a..f8008df 100644
4704 --- a/arch/blackfin/include/asm/cache.h
4705 +++ b/arch/blackfin/include/asm/cache.h
4706 @@ -7,6 +7,7 @@
4707 #ifndef __ARCH_BLACKFIN_CACHE_H
4708 #define __ARCH_BLACKFIN_CACHE_H
4709
4710 +#include <linux/const.h>
4711 #include <linux/linkage.h> /* for asmlinkage */
4712
4713 /*
4714 @@ -14,7 +15,7 @@
4715 * Blackfin loads 32 bytes for cache
4716 */
4717 #define L1_CACHE_SHIFT 5
4718 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4719 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4720 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4721
4722 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4723 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4724 index aea2718..3639a60 100644
4725 --- a/arch/cris/include/arch-v10/arch/cache.h
4726 +++ b/arch/cris/include/arch-v10/arch/cache.h
4727 @@ -1,8 +1,9 @@
4728 #ifndef _ASM_ARCH_CACHE_H
4729 #define _ASM_ARCH_CACHE_H
4730
4731 +#include <linux/const.h>
4732 /* Etrax 100LX have 32-byte cache-lines. */
4733 -#define L1_CACHE_BYTES 32
4734 #define L1_CACHE_SHIFT 5
4735 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4736
4737 #endif /* _ASM_ARCH_CACHE_H */
4738 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4739 index 7caf25d..ee65ac5 100644
4740 --- a/arch/cris/include/arch-v32/arch/cache.h
4741 +++ b/arch/cris/include/arch-v32/arch/cache.h
4742 @@ -1,11 +1,12 @@
4743 #ifndef _ASM_CRIS_ARCH_CACHE_H
4744 #define _ASM_CRIS_ARCH_CACHE_H
4745
4746 +#include <linux/const.h>
4747 #include <arch/hwregs/dma.h>
4748
4749 /* A cache-line is 32 bytes. */
4750 -#define L1_CACHE_BYTES 32
4751 #define L1_CACHE_SHIFT 5
4752 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4753
4754 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4755
4756 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4757 index b86329d..6709906 100644
4758 --- a/arch/frv/include/asm/atomic.h
4759 +++ b/arch/frv/include/asm/atomic.h
4760 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4761 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4762 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4763
4764 +#define atomic64_read_unchecked(v) atomic64_read(v)
4765 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4766 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4767 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4768 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4769 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4770 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4771 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4772 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4773 +
4774 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4775 {
4776 int c, old;
4777 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4778 index 2797163..c2a401d 100644
4779 --- a/arch/frv/include/asm/cache.h
4780 +++ b/arch/frv/include/asm/cache.h
4781 @@ -12,10 +12,11 @@
4782 #ifndef __ASM_CACHE_H
4783 #define __ASM_CACHE_H
4784
4785 +#include <linux/const.h>
4786
4787 /* bytes per L1 cache line */
4788 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4789 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4790 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4791
4792 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4793 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4794 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4795 index 43901f2..0d8b865 100644
4796 --- a/arch/frv/include/asm/kmap_types.h
4797 +++ b/arch/frv/include/asm/kmap_types.h
4798 @@ -2,6 +2,6 @@
4799 #ifndef _ASM_KMAP_TYPES_H
4800 #define _ASM_KMAP_TYPES_H
4801
4802 -#define KM_TYPE_NR 17
4803 +#define KM_TYPE_NR 18
4804
4805 #endif
4806 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4807 index 836f147..4cf23f5 100644
4808 --- a/arch/frv/mm/elf-fdpic.c
4809 +++ b/arch/frv/mm/elf-fdpic.c
4810 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4811 {
4812 struct vm_area_struct *vma;
4813 struct vm_unmapped_area_info info;
4814 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4815
4816 if (len > TASK_SIZE)
4817 return -ENOMEM;
4818 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4819 if (addr) {
4820 addr = PAGE_ALIGN(addr);
4821 vma = find_vma(current->mm, addr);
4822 - if (TASK_SIZE - len >= addr &&
4823 - (!vma || addr + len <= vma->vm_start))
4824 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4825 goto success;
4826 }
4827
4828 @@ -85,6 +85,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4829 info.high_limit = (current->mm->start_stack - 0x00200000);
4830 info.align_mask = 0;
4831 info.align_offset = 0;
4832 + info.threadstack_offset = offset;
4833 addr = vm_unmapped_area(&info);
4834 if (!(addr & ~PAGE_MASK))
4835 goto success;
4836 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4837 index f4ca594..adc72fd6 100644
4838 --- a/arch/hexagon/include/asm/cache.h
4839 +++ b/arch/hexagon/include/asm/cache.h
4840 @@ -21,9 +21,11 @@
4841 #ifndef __ASM_CACHE_H
4842 #define __ASM_CACHE_H
4843
4844 +#include <linux/const.h>
4845 +
4846 /* Bytes per L1 cache line */
4847 -#define L1_CACHE_SHIFT (5)
4848 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4849 +#define L1_CACHE_SHIFT 5
4850 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4851
4852 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4853 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4854 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4855 index 6e6fe18..a6ae668 100644
4856 --- a/arch/ia64/include/asm/atomic.h
4857 +++ b/arch/ia64/include/asm/atomic.h
4858 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4859 #define atomic64_inc(v) atomic64_add(1, (v))
4860 #define atomic64_dec(v) atomic64_sub(1, (v))
4861
4862 +#define atomic64_read_unchecked(v) atomic64_read(v)
4863 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4864 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4865 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4866 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4867 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4868 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4869 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4870 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4871 +
4872 /* Atomic operations are already serializing */
4873 #define smp_mb__before_atomic_dec() barrier()
4874 #define smp_mb__after_atomic_dec() barrier()
4875 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4876 index 988254a..e1ee885 100644
4877 --- a/arch/ia64/include/asm/cache.h
4878 +++ b/arch/ia64/include/asm/cache.h
4879 @@ -1,6 +1,7 @@
4880 #ifndef _ASM_IA64_CACHE_H
4881 #define _ASM_IA64_CACHE_H
4882
4883 +#include <linux/const.h>
4884
4885 /*
4886 * Copyright (C) 1998-2000 Hewlett-Packard Co
4887 @@ -9,7 +10,7 @@
4888
4889 /* Bytes per L1 (data) cache line. */
4890 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4891 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4892 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4893
4894 #ifdef CONFIG_SMP
4895 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4896 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4897 index 5a83c5c..4d7f553 100644
4898 --- a/arch/ia64/include/asm/elf.h
4899 +++ b/arch/ia64/include/asm/elf.h
4900 @@ -42,6 +42,13 @@
4901 */
4902 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4903
4904 +#ifdef CONFIG_PAX_ASLR
4905 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4906 +
4907 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4908 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4909 +#endif
4910 +
4911 #define PT_IA_64_UNWIND 0x70000001
4912
4913 /* IA-64 relocations: */
4914 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4915 index 96a8d92..617a1cf 100644
4916 --- a/arch/ia64/include/asm/pgalloc.h
4917 +++ b/arch/ia64/include/asm/pgalloc.h
4918 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4919 pgd_val(*pgd_entry) = __pa(pud);
4920 }
4921
4922 +static inline void
4923 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4924 +{
4925 + pgd_populate(mm, pgd_entry, pud);
4926 +}
4927 +
4928 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4929 {
4930 return quicklist_alloc(0, GFP_KERNEL, NULL);
4931 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4932 pud_val(*pud_entry) = __pa(pmd);
4933 }
4934
4935 +static inline void
4936 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4937 +{
4938 + pud_populate(mm, pud_entry, pmd);
4939 +}
4940 +
4941 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4942 {
4943 return quicklist_alloc(0, GFP_KERNEL, NULL);
4944 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4945 index 815810c..d60bd4c 100644
4946 --- a/arch/ia64/include/asm/pgtable.h
4947 +++ b/arch/ia64/include/asm/pgtable.h
4948 @@ -12,7 +12,7 @@
4949 * David Mosberger-Tang <davidm@hpl.hp.com>
4950 */
4951
4952 -
4953 +#include <linux/const.h>
4954 #include <asm/mman.h>
4955 #include <asm/page.h>
4956 #include <asm/processor.h>
4957 @@ -142,6 +142,17 @@
4958 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4959 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4960 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4961 +
4962 +#ifdef CONFIG_PAX_PAGEEXEC
4963 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4964 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4965 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4966 +#else
4967 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
4968 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
4969 +# define PAGE_COPY_NOEXEC PAGE_COPY
4970 +#endif
4971 +
4972 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
4973 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
4974 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
4975 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
4976 index 54ff557..70c88b7 100644
4977 --- a/arch/ia64/include/asm/spinlock.h
4978 +++ b/arch/ia64/include/asm/spinlock.h
4979 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
4980 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
4981
4982 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
4983 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
4984 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
4985 }
4986
4987 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
4988 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
4989 index 449c8c0..18965fb 100644
4990 --- a/arch/ia64/include/asm/uaccess.h
4991 +++ b/arch/ia64/include/asm/uaccess.h
4992 @@ -240,12 +240,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
4993 static inline unsigned long
4994 __copy_to_user (void __user *to, const void *from, unsigned long count)
4995 {
4996 + if (count > INT_MAX)
4997 + return count;
4998 +
4999 + if (!__builtin_constant_p(count))
5000 + check_object_size(from, count, true);
5001 +
5002 return __copy_user(to, (__force void __user *) from, count);
5003 }
5004
5005 static inline unsigned long
5006 __copy_from_user (void *to, const void __user *from, unsigned long count)
5007 {
5008 + if (count > INT_MAX)
5009 + return count;
5010 +
5011 + if (!__builtin_constant_p(count))
5012 + check_object_size(to, count, false);
5013 +
5014 return __copy_user((__force void __user *) to, from, count);
5015 }
5016
5017 @@ -255,10 +267,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5018 ({ \
5019 void __user *__cu_to = (to); \
5020 const void *__cu_from = (from); \
5021 - long __cu_len = (n); \
5022 + unsigned long __cu_len = (n); \
5023 \
5024 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
5025 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
5026 + if (!__builtin_constant_p(n)) \
5027 + check_object_size(__cu_from, __cu_len, true); \
5028 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
5029 + } \
5030 __cu_len; \
5031 })
5032
5033 @@ -266,11 +281,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5034 ({ \
5035 void *__cu_to = (to); \
5036 const void __user *__cu_from = (from); \
5037 - long __cu_len = (n); \
5038 + unsigned long __cu_len = (n); \
5039 \
5040 __chk_user_ptr(__cu_from); \
5041 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
5042 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
5043 + if (!__builtin_constant_p(n)) \
5044 + check_object_size(__cu_to, __cu_len, false); \
5045 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
5046 + } \
5047 __cu_len; \
5048 })
5049
5050 diff --git a/arch/ia64/kernel/err_inject.c b/arch/ia64/kernel/err_inject.c
5051 index 2d67317..07d8bfa 100644
5052 --- a/arch/ia64/kernel/err_inject.c
5053 +++ b/arch/ia64/kernel/err_inject.c
5054 @@ -256,7 +256,7 @@ static int __cpuinit err_inject_cpu_callback(struct notifier_block *nfb,
5055 return NOTIFY_OK;
5056 }
5057
5058 -static struct notifier_block __cpuinitdata err_inject_cpu_notifier =
5059 +static struct notifier_block err_inject_cpu_notifier =
5060 {
5061 .notifier_call = err_inject_cpu_callback,
5062 };
5063 diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
5064 index d7396db..b33e873 100644
5065 --- a/arch/ia64/kernel/mca.c
5066 +++ b/arch/ia64/kernel/mca.c
5067 @@ -1922,7 +1922,7 @@ static int __cpuinit mca_cpu_callback(struct notifier_block *nfb,
5068 return NOTIFY_OK;
5069 }
5070
5071 -static struct notifier_block mca_cpu_notifier __cpuinitdata = {
5072 +static struct notifier_block mca_cpu_notifier = {
5073 .notifier_call = mca_cpu_callback
5074 };
5075
5076 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
5077 index 24603be..948052d 100644
5078 --- a/arch/ia64/kernel/module.c
5079 +++ b/arch/ia64/kernel/module.c
5080 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
5081 void
5082 module_free (struct module *mod, void *module_region)
5083 {
5084 - if (mod && mod->arch.init_unw_table &&
5085 - module_region == mod->module_init) {
5086 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
5087 unw_remove_unwind_table(mod->arch.init_unw_table);
5088 mod->arch.init_unw_table = NULL;
5089 }
5090 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
5091 }
5092
5093 static inline int
5094 +in_init_rx (const struct module *mod, uint64_t addr)
5095 +{
5096 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
5097 +}
5098 +
5099 +static inline int
5100 +in_init_rw (const struct module *mod, uint64_t addr)
5101 +{
5102 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
5103 +}
5104 +
5105 +static inline int
5106 in_init (const struct module *mod, uint64_t addr)
5107 {
5108 - return addr - (uint64_t) mod->module_init < mod->init_size;
5109 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
5110 +}
5111 +
5112 +static inline int
5113 +in_core_rx (const struct module *mod, uint64_t addr)
5114 +{
5115 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
5116 +}
5117 +
5118 +static inline int
5119 +in_core_rw (const struct module *mod, uint64_t addr)
5120 +{
5121 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
5122 }
5123
5124 static inline int
5125 in_core (const struct module *mod, uint64_t addr)
5126 {
5127 - return addr - (uint64_t) mod->module_core < mod->core_size;
5128 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
5129 }
5130
5131 static inline int
5132 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
5133 break;
5134
5135 case RV_BDREL:
5136 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
5137 + if (in_init_rx(mod, val))
5138 + val -= (uint64_t) mod->module_init_rx;
5139 + else if (in_init_rw(mod, val))
5140 + val -= (uint64_t) mod->module_init_rw;
5141 + else if (in_core_rx(mod, val))
5142 + val -= (uint64_t) mod->module_core_rx;
5143 + else if (in_core_rw(mod, val))
5144 + val -= (uint64_t) mod->module_core_rw;
5145 break;
5146
5147 case RV_LTV:
5148 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
5149 * addresses have been selected...
5150 */
5151 uint64_t gp;
5152 - if (mod->core_size > MAX_LTOFF)
5153 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
5154 /*
5155 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
5156 * at the end of the module.
5157 */
5158 - gp = mod->core_size - MAX_LTOFF / 2;
5159 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
5160 else
5161 - gp = mod->core_size / 2;
5162 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
5163 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
5164 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
5165 mod->arch.gp = gp;
5166 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
5167 }
5168 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
5169 index 2b3c2d7..a318d84 100644
5170 --- a/arch/ia64/kernel/palinfo.c
5171 +++ b/arch/ia64/kernel/palinfo.c
5172 @@ -980,7 +980,7 @@ static int __cpuinit palinfo_cpu_callback(struct notifier_block *nfb,
5173 return NOTIFY_OK;
5174 }
5175
5176 -static struct notifier_block __refdata palinfo_cpu_notifier =
5177 +static struct notifier_block palinfo_cpu_notifier =
5178 {
5179 .notifier_call = palinfo_cpu_callback,
5180 .priority = 0,
5181 diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
5182 index 4bc580a..7767f24 100644
5183 --- a/arch/ia64/kernel/salinfo.c
5184 +++ b/arch/ia64/kernel/salinfo.c
5185 @@ -609,7 +609,7 @@ salinfo_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu
5186 return NOTIFY_OK;
5187 }
5188
5189 -static struct notifier_block salinfo_cpu_notifier __cpuinitdata =
5190 +static struct notifier_block salinfo_cpu_notifier =
5191 {
5192 .notifier_call = salinfo_cpu_callback,
5193 .priority = 0,
5194 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
5195 index 41e33f8..65180b2 100644
5196 --- a/arch/ia64/kernel/sys_ia64.c
5197 +++ b/arch/ia64/kernel/sys_ia64.c
5198 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5199 unsigned long align_mask = 0;
5200 struct mm_struct *mm = current->mm;
5201 struct vm_unmapped_area_info info;
5202 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5203
5204 if (len > RGN_MAP_LIMIT)
5205 return -ENOMEM;
5206 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5207 if (REGION_NUMBER(addr) == RGN_HPAGE)
5208 addr = 0;
5209 #endif
5210 +
5211 +#ifdef CONFIG_PAX_RANDMMAP
5212 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5213 + addr = mm->free_area_cache;
5214 + else
5215 +#endif
5216 +
5217 if (!addr)
5218 addr = TASK_UNMAPPED_BASE;
5219
5220 @@ -61,6 +69,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5221 info.high_limit = TASK_SIZE;
5222 info.align_mask = align_mask;
5223 info.align_offset = 0;
5224 + info.threadstack_offset = offset;
5225 return vm_unmapped_area(&info);
5226 }
5227
5228 diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
5229 index dc00b2c..cce53c2 100644
5230 --- a/arch/ia64/kernel/topology.c
5231 +++ b/arch/ia64/kernel/topology.c
5232 @@ -445,7 +445,7 @@ static int __cpuinit cache_cpu_callback(struct notifier_block *nfb,
5233 return NOTIFY_OK;
5234 }
5235
5236 -static struct notifier_block __cpuinitdata cache_cpu_notifier =
5237 +static struct notifier_block cache_cpu_notifier =
5238 {
5239 .notifier_call = cache_cpu_callback
5240 };
5241 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5242 index 0ccb28f..8992469 100644
5243 --- a/arch/ia64/kernel/vmlinux.lds.S
5244 +++ b/arch/ia64/kernel/vmlinux.lds.S
5245 @@ -198,7 +198,7 @@ SECTIONS {
5246 /* Per-cpu data: */
5247 . = ALIGN(PERCPU_PAGE_SIZE);
5248 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5249 - __phys_per_cpu_start = __per_cpu_load;
5250 + __phys_per_cpu_start = per_cpu_load;
5251 /*
5252 * ensure percpu data fits
5253 * into percpu page size
5254 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5255 index 6cf0341..d352594 100644
5256 --- a/arch/ia64/mm/fault.c
5257 +++ b/arch/ia64/mm/fault.c
5258 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5259 return pte_present(pte);
5260 }
5261
5262 +#ifdef CONFIG_PAX_PAGEEXEC
5263 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5264 +{
5265 + unsigned long i;
5266 +
5267 + printk(KERN_ERR "PAX: bytes at PC: ");
5268 + for (i = 0; i < 8; i++) {
5269 + unsigned int c;
5270 + if (get_user(c, (unsigned int *)pc+i))
5271 + printk(KERN_CONT "???????? ");
5272 + else
5273 + printk(KERN_CONT "%08x ", c);
5274 + }
5275 + printk("\n");
5276 +}
5277 +#endif
5278 +
5279 # define VM_READ_BIT 0
5280 # define VM_WRITE_BIT 1
5281 # define VM_EXEC_BIT 2
5282 @@ -149,8 +166,21 @@ retry:
5283 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5284 goto bad_area;
5285
5286 - if ((vma->vm_flags & mask) != mask)
5287 + if ((vma->vm_flags & mask) != mask) {
5288 +
5289 +#ifdef CONFIG_PAX_PAGEEXEC
5290 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5291 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5292 + goto bad_area;
5293 +
5294 + up_read(&mm->mmap_sem);
5295 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5296 + do_group_exit(SIGKILL);
5297 + }
5298 +#endif
5299 +
5300 goto bad_area;
5301 + }
5302
5303 /*
5304 * If for any reason at all we couldn't handle the fault, make
5305 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5306 index 76069c1..c2aa816 100644
5307 --- a/arch/ia64/mm/hugetlbpage.c
5308 +++ b/arch/ia64/mm/hugetlbpage.c
5309 @@ -149,6 +149,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5310 unsigned long pgoff, unsigned long flags)
5311 {
5312 struct vm_unmapped_area_info info;
5313 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5314
5315 if (len > RGN_MAP_LIMIT)
5316 return -ENOMEM;
5317 @@ -172,6 +173,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5318 info.high_limit = HPAGE_REGION_BASE + RGN_MAP_LIMIT;
5319 info.align_mask = PAGE_MASK & (HPAGE_SIZE - 1);
5320 info.align_offset = 0;
5321 + info.threadstack_offset = offset;
5322 return vm_unmapped_area(&info);
5323 }
5324
5325 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5326 index d1fe4b4..2628f37 100644
5327 --- a/arch/ia64/mm/init.c
5328 +++ b/arch/ia64/mm/init.c
5329 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5330 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5331 vma->vm_end = vma->vm_start + PAGE_SIZE;
5332 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5333 +
5334 +#ifdef CONFIG_PAX_PAGEEXEC
5335 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5336 + vma->vm_flags &= ~VM_EXEC;
5337 +
5338 +#ifdef CONFIG_PAX_MPROTECT
5339 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5340 + vma->vm_flags &= ~VM_MAYEXEC;
5341 +#endif
5342 +
5343 + }
5344 +#endif
5345 +
5346 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5347 down_write(&current->mm->mmap_sem);
5348 if (insert_vm_struct(current->mm, vma)) {
5349 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5350 index 40b3ee9..8c2c112 100644
5351 --- a/arch/m32r/include/asm/cache.h
5352 +++ b/arch/m32r/include/asm/cache.h
5353 @@ -1,8 +1,10 @@
5354 #ifndef _ASM_M32R_CACHE_H
5355 #define _ASM_M32R_CACHE_H
5356
5357 +#include <linux/const.h>
5358 +
5359 /* L1 cache line size */
5360 #define L1_CACHE_SHIFT 4
5361 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5362 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5363
5364 #endif /* _ASM_M32R_CACHE_H */
5365 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5366 index 82abd15..d95ae5d 100644
5367 --- a/arch/m32r/lib/usercopy.c
5368 +++ b/arch/m32r/lib/usercopy.c
5369 @@ -14,6 +14,9 @@
5370 unsigned long
5371 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5372 {
5373 + if ((long)n < 0)
5374 + return n;
5375 +
5376 prefetch(from);
5377 if (access_ok(VERIFY_WRITE, to, n))
5378 __copy_user(to,from,n);
5379 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5380 unsigned long
5381 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5382 {
5383 + if ((long)n < 0)
5384 + return n;
5385 +
5386 prefetchw(to);
5387 if (access_ok(VERIFY_READ, from, n))
5388 __copy_user_zeroing(to,from,n);
5389 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5390 index 0395c51..5f26031 100644
5391 --- a/arch/m68k/include/asm/cache.h
5392 +++ b/arch/m68k/include/asm/cache.h
5393 @@ -4,9 +4,11 @@
5394 #ifndef __ARCH_M68K_CACHE_H
5395 #define __ARCH_M68K_CACHE_H
5396
5397 +#include <linux/const.h>
5398 +
5399 /* bytes per L1 cache line */
5400 #define L1_CACHE_SHIFT 4
5401 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5402 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5403
5404 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5405
5406 diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
5407 index 3c52fa6..11b2ad8 100644
5408 --- a/arch/metag/mm/hugetlbpage.c
5409 +++ b/arch/metag/mm/hugetlbpage.c
5410 @@ -200,6 +200,7 @@ hugetlb_get_unmapped_area_new_pmd(unsigned long len)
5411 info.high_limit = TASK_SIZE;
5412 info.align_mask = PAGE_MASK & HUGEPT_MASK;
5413 info.align_offset = 0;
5414 + info.threadstack_offset = 0;
5415 return vm_unmapped_area(&info);
5416 }
5417
5418 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5419 index 4efe96a..60e8699 100644
5420 --- a/arch/microblaze/include/asm/cache.h
5421 +++ b/arch/microblaze/include/asm/cache.h
5422 @@ -13,11 +13,12 @@
5423 #ifndef _ASM_MICROBLAZE_CACHE_H
5424 #define _ASM_MICROBLAZE_CACHE_H
5425
5426 +#include <linux/const.h>
5427 #include <asm/registers.h>
5428
5429 #define L1_CACHE_SHIFT 5
5430 /* word-granular cache in microblaze */
5431 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5432 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5433
5434 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5435
5436 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5437 index 08b6079..8b554d2 100644
5438 --- a/arch/mips/include/asm/atomic.h
5439 +++ b/arch/mips/include/asm/atomic.h
5440 @@ -21,15 +21,39 @@
5441 #include <asm/cmpxchg.h>
5442 #include <asm/war.h>
5443
5444 +#ifdef CONFIG_GENERIC_ATOMIC64
5445 +#include <asm-generic/atomic64.h>
5446 +#endif
5447 +
5448 #define ATOMIC_INIT(i) { (i) }
5449
5450 +#ifdef CONFIG_64BIT
5451 +#define _ASM_EXTABLE(from, to) \
5452 +" .section __ex_table,\"a\"\n" \
5453 +" .dword " #from ", " #to"\n" \
5454 +" .previous\n"
5455 +#else
5456 +#define _ASM_EXTABLE(from, to) \
5457 +" .section __ex_table,\"a\"\n" \
5458 +" .word " #from ", " #to"\n" \
5459 +" .previous\n"
5460 +#endif
5461 +
5462 /*
5463 * atomic_read - read atomic variable
5464 * @v: pointer of type atomic_t
5465 *
5466 * Atomically reads the value of @v.
5467 */
5468 -#define atomic_read(v) (*(volatile int *)&(v)->counter)
5469 +static inline int atomic_read(const atomic_t *v)
5470 +{
5471 + return (*(volatile const int *) &v->counter);
5472 +}
5473 +
5474 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
5475 +{
5476 + return (*(volatile const int *) &v->counter);
5477 +}
5478
5479 /*
5480 * atomic_set - set atomic variable
5481 @@ -38,7 +62,15 @@
5482 *
5483 * Atomically sets the value of @v to @i.
5484 */
5485 -#define atomic_set(v, i) ((v)->counter = (i))
5486 +static inline void atomic_set(atomic_t *v, int i)
5487 +{
5488 + v->counter = i;
5489 +}
5490 +
5491 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
5492 +{
5493 + v->counter = i;
5494 +}
5495
5496 /*
5497 * atomic_add - add integer to atomic variable
5498 @@ -47,7 +79,67 @@
5499 *
5500 * Atomically adds @i to @v.
5501 */
5502 -static __inline__ void atomic_add(int i, atomic_t * v)
5503 +static __inline__ void atomic_add(int i, atomic_t *v)
5504 +{
5505 + int temp;
5506 +
5507 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5508 + __asm__ __volatile__(
5509 + " .set mips3 \n"
5510 + "1: ll %0, %1 # atomic_add \n"
5511 +#ifdef CONFIG_PAX_REFCOUNT
5512 + /* Exception on overflow. */
5513 + "2: add %0, %2 \n"
5514 +#else
5515 + " addu %0, %2 \n"
5516 +#endif
5517 + " sc %0, %1 \n"
5518 + " beqzl %0, 1b \n"
5519 +#ifdef CONFIG_PAX_REFCOUNT
5520 + "3: \n"
5521 + _ASM_EXTABLE(2b, 3b)
5522 +#endif
5523 + " .set mips0 \n"
5524 + : "=&r" (temp), "+m" (v->counter)
5525 + : "Ir" (i));
5526 + } else if (kernel_uses_llsc) {
5527 + __asm__ __volatile__(
5528 + " .set mips3 \n"
5529 + "1: ll %0, %1 # atomic_add \n"
5530 +#ifdef CONFIG_PAX_REFCOUNT
5531 + /* Exception on overflow. */
5532 + "2: add %0, %2 \n"
5533 +#else
5534 + " addu %0, %2 \n"
5535 +#endif
5536 + " sc %0, %1 \n"
5537 + " beqz %0, 1b \n"
5538 +#ifdef CONFIG_PAX_REFCOUNT
5539 + "3: \n"
5540 + _ASM_EXTABLE(2b, 3b)
5541 +#endif
5542 + " .set mips0 \n"
5543 + : "=&r" (temp), "+m" (v->counter)
5544 + : "Ir" (i));
5545 + } else {
5546 + unsigned long flags;
5547 +
5548 + raw_local_irq_save(flags);
5549 + __asm__ __volatile__(
5550 +#ifdef CONFIG_PAX_REFCOUNT
5551 + /* Exception on overflow. */
5552 + "1: add %0, %1 \n"
5553 + "2: \n"
5554 + _ASM_EXTABLE(1b, 2b)
5555 +#else
5556 + " addu %0, %1 \n"
5557 +#endif
5558 + : "+r" (v->counter) : "Ir" (i));
5559 + raw_local_irq_restore(flags);
5560 + }
5561 +}
5562 +
5563 +static __inline__ void atomic_add_unchecked(int i, atomic_unchecked_t *v)
5564 {
5565 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5566 int temp;
5567 @@ -90,7 +182,67 @@ static __inline__ void atomic_add(int i, atomic_t * v)
5568 *
5569 * Atomically subtracts @i from @v.
5570 */
5571 -static __inline__ void atomic_sub(int i, atomic_t * v)
5572 +static __inline__ void atomic_sub(int i, atomic_t *v)
5573 +{
5574 + int temp;
5575 +
5576 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5577 + __asm__ __volatile__(
5578 + " .set mips3 \n"
5579 + "1: ll %0, %1 # atomic64_sub \n"
5580 +#ifdef CONFIG_PAX_REFCOUNT
5581 + /* Exception on overflow. */
5582 + "2: sub %0, %2 \n"
5583 +#else
5584 + " subu %0, %2 \n"
5585 +#endif
5586 + " sc %0, %1 \n"
5587 + " beqzl %0, 1b \n"
5588 +#ifdef CONFIG_PAX_REFCOUNT
5589 + "3: \n"
5590 + _ASM_EXTABLE(2b, 3b)
5591 +#endif
5592 + " .set mips0 \n"
5593 + : "=&r" (temp), "+m" (v->counter)
5594 + : "Ir" (i));
5595 + } else if (kernel_uses_llsc) {
5596 + __asm__ __volatile__(
5597 + " .set mips3 \n"
5598 + "1: ll %0, %1 # atomic64_sub \n"
5599 +#ifdef CONFIG_PAX_REFCOUNT
5600 + /* Exception on overflow. */
5601 + "2: sub %0, %2 \n"
5602 +#else
5603 + " subu %0, %2 \n"
5604 +#endif
5605 + " sc %0, %1 \n"
5606 + " beqz %0, 1b \n"
5607 +#ifdef CONFIG_PAX_REFCOUNT
5608 + "3: \n"
5609 + _ASM_EXTABLE(2b, 3b)
5610 +#endif
5611 + " .set mips0 \n"
5612 + : "=&r" (temp), "+m" (v->counter)
5613 + : "Ir" (i));
5614 + } else {
5615 + unsigned long flags;
5616 +
5617 + raw_local_irq_save(flags);
5618 + __asm__ __volatile__(
5619 +#ifdef CONFIG_PAX_REFCOUNT
5620 + /* Exception on overflow. */
5621 + "1: sub %0, %1 \n"
5622 + "2: \n"
5623 + _ASM_EXTABLE(1b, 2b)
5624 +#else
5625 + " subu %0, %1 \n"
5626 +#endif
5627 + : "+r" (v->counter) : "Ir" (i));
5628 + raw_local_irq_restore(flags);
5629 + }
5630 +}
5631 +
5632 +static __inline__ void atomic_sub_unchecked(long i, atomic_unchecked_t *v)
5633 {
5634 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5635 int temp;
5636 @@ -129,7 +281,93 @@ static __inline__ void atomic_sub(int i, atomic_t * v)
5637 /*
5638 * Same as above, but return the result value
5639 */
5640 -static __inline__ int atomic_add_return(int i, atomic_t * v)
5641 +static __inline__ int atomic_add_return(int i, atomic_t *v)
5642 +{
5643 + int result;
5644 + int temp;
5645 +
5646 + smp_mb__before_llsc();
5647 +
5648 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5649 + __asm__ __volatile__(
5650 + " .set mips3 \n"
5651 + "1: ll %1, %2 # atomic_add_return \n"
5652 +#ifdef CONFIG_PAX_REFCOUNT
5653 + "2: add %0, %1, %3 \n"
5654 +#else
5655 + " addu %0, %1, %3 \n"
5656 +#endif
5657 + " sc %0, %2 \n"
5658 + " beqzl %0, 1b \n"
5659 +#ifdef CONFIG_PAX_REFCOUNT
5660 + " b 4f \n"
5661 + " .set noreorder \n"
5662 + "3: b 5f \n"
5663 + " move %0, %1 \n"
5664 + " .set reorder \n"
5665 + _ASM_EXTABLE(2b, 3b)
5666 +#endif
5667 + "4: addu %0, %1, %3 \n"
5668 +#ifdef CONFIG_PAX_REFCOUNT
5669 + "5: \n"
5670 +#endif
5671 + " .set mips0 \n"
5672 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5673 + : "Ir" (i));
5674 + } else if (kernel_uses_llsc) {
5675 + __asm__ __volatile__(
5676 + " .set mips3 \n"
5677 + "1: ll %1, %2 # atomic_add_return \n"
5678 +#ifdef CONFIG_PAX_REFCOUNT
5679 + "2: add %0, %1, %3 \n"
5680 +#else
5681 + " addu %0, %1, %3 \n"
5682 +#endif
5683 + " sc %0, %2 \n"
5684 + " bnez %0, 4f \n"
5685 + " b 1b \n"
5686 +#ifdef CONFIG_PAX_REFCOUNT
5687 + " .set noreorder \n"
5688 + "3: b 5f \n"
5689 + " move %0, %1 \n"
5690 + " .set reorder \n"
5691 + _ASM_EXTABLE(2b, 3b)
5692 +#endif
5693 + "4: addu %0, %1, %3 \n"
5694 +#ifdef CONFIG_PAX_REFCOUNT
5695 + "5: \n"
5696 +#endif
5697 + " .set mips0 \n"
5698 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5699 + : "Ir" (i));
5700 + } else {
5701 + unsigned long flags;
5702 +
5703 + raw_local_irq_save(flags);
5704 + __asm__ __volatile__(
5705 + " lw %0, %1 \n"
5706 +#ifdef CONFIG_PAX_REFCOUNT
5707 + /* Exception on overflow. */
5708 + "1: add %0, %2 \n"
5709 +#else
5710 + " addu %0, %2 \n"
5711 +#endif
5712 + " sw %0, %1 \n"
5713 +#ifdef CONFIG_PAX_REFCOUNT
5714 + /* Note: Dest reg is not modified on overflow */
5715 + "2: \n"
5716 + _ASM_EXTABLE(1b, 2b)
5717 +#endif
5718 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
5719 + raw_local_irq_restore(flags);
5720 + }
5721 +
5722 + smp_llsc_mb();
5723 +
5724 + return result;
5725 +}
5726 +
5727 +static __inline__ int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
5728 {
5729 int result;
5730
5731 @@ -178,7 +416,93 @@ static __inline__ int atomic_add_return(int i, atomic_t * v)
5732 return result;
5733 }
5734
5735 -static __inline__ int atomic_sub_return(int i, atomic_t * v)
5736 +static __inline__ int atomic_sub_return(int i, atomic_t *v)
5737 +{
5738 + int result;
5739 + int temp;
5740 +
5741 + smp_mb__before_llsc();
5742 +
5743 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5744 + __asm__ __volatile__(
5745 + " .set mips3 \n"
5746 + "1: ll %1, %2 # atomic_sub_return \n"
5747 +#ifdef CONFIG_PAX_REFCOUNT
5748 + "2: sub %0, %1, %3 \n"
5749 +#else
5750 + " subu %0, %1, %3 \n"
5751 +#endif
5752 + " sc %0, %2 \n"
5753 + " beqzl %0, 1b \n"
5754 +#ifdef CONFIG_PAX_REFCOUNT
5755 + " b 4f \n"
5756 + " .set noreorder \n"
5757 + "3: b 5f \n"
5758 + " move %0, %1 \n"
5759 + " .set reorder \n"
5760 + _ASM_EXTABLE(2b, 3b)
5761 +#endif
5762 + "4: subu %0, %1, %3 \n"
5763 +#ifdef CONFIG_PAX_REFCOUNT
5764 + "5: \n"
5765 +#endif
5766 + " .set mips0 \n"
5767 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
5768 + : "Ir" (i), "m" (v->counter)
5769 + : "memory");
5770 + } else if (kernel_uses_llsc) {
5771 + __asm__ __volatile__(
5772 + " .set mips3 \n"
5773 + "1: ll %1, %2 # atomic_sub_return \n"
5774 +#ifdef CONFIG_PAX_REFCOUNT
5775 + "2: sub %0, %1, %3 \n"
5776 +#else
5777 + " subu %0, %1, %3 \n"
5778 +#endif
5779 + " sc %0, %2 \n"
5780 + " bnez %0, 4f \n"
5781 + " b 1b \n"
5782 +#ifdef CONFIG_PAX_REFCOUNT
5783 + " .set noreorder \n"
5784 + "3: b 5f \n"
5785 + " move %0, %1 \n"
5786 + " .set reorder \n"
5787 + _ASM_EXTABLE(2b, 3b)
5788 +#endif
5789 + "4: subu %0, %1, %3 \n"
5790 +#ifdef CONFIG_PAX_REFCOUNT
5791 + "5: \n"
5792 +#endif
5793 + " .set mips0 \n"
5794 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5795 + : "Ir" (i));
5796 + } else {
5797 + unsigned long flags;
5798 +
5799 + raw_local_irq_save(flags);
5800 + __asm__ __volatile__(
5801 + " lw %0, %1 \n"
5802 +#ifdef CONFIG_PAX_REFCOUNT
5803 + /* Exception on overflow. */
5804 + "1: sub %0, %2 \n"
5805 +#else
5806 + " subu %0, %2 \n"
5807 +#endif
5808 + " sw %0, %1 \n"
5809 +#ifdef CONFIG_PAX_REFCOUNT
5810 + /* Note: Dest reg is not modified on overflow */
5811 + "2: \n"
5812 + _ASM_EXTABLE(1b, 2b)
5813 +#endif
5814 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
5815 + raw_local_irq_restore(flags);
5816 + }
5817 +
5818 + smp_llsc_mb();
5819 +
5820 + return result;
5821 +}
5822 +static __inline__ int atomic_sub_return_unchecked(int i, atomic_unchecked_t *v)
5823 {
5824 int result;
5825
5826 @@ -238,7 +562,7 @@ static __inline__ int atomic_sub_return(int i, atomic_t * v)
5827 * Atomically test @v and subtract @i if @v is greater or equal than @i.
5828 * The function returns the old value of @v minus @i.
5829 */
5830 -static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
5831 +static __inline__ int atomic_sub_if_positive(int i, atomic_t *v)
5832 {
5833 int result;
5834
5835 @@ -295,8 +619,26 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
5836 return result;
5837 }
5838
5839 -#define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
5840 -#define atomic_xchg(v, new) (xchg(&((v)->counter), (new)))
5841 +static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
5842 +{
5843 + return cmpxchg(&v->counter, old, new);
5844 +}
5845 +
5846 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old,
5847 + int new)
5848 +{
5849 + return cmpxchg(&(v->counter), old, new);
5850 +}
5851 +
5852 +static inline int atomic_xchg(atomic_t *v, int new)
5853 +{
5854 + return xchg(&v->counter, new);
5855 +}
5856 +
5857 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
5858 +{
5859 + return xchg(&(v->counter), new);
5860 +}
5861
5862 /**
5863 * __atomic_add_unless - add unless the number is a given value
5864 @@ -324,6 +666,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5865
5866 #define atomic_dec_return(v) atomic_sub_return(1, (v))
5867 #define atomic_inc_return(v) atomic_add_return(1, (v))
5868 +static __inline__ int atomic_inc_return_unchecked(atomic_unchecked_t *v)
5869 +{
5870 + return atomic_add_return_unchecked(1, v);
5871 +}
5872
5873 /*
5874 * atomic_sub_and_test - subtract value from variable and test result
5875 @@ -345,6 +691,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5876 * other cases.
5877 */
5878 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
5879 +static __inline__ int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
5880 +{
5881 + return atomic_add_return_unchecked(1, v) == 0;
5882 +}
5883
5884 /*
5885 * atomic_dec_and_test - decrement by 1 and test
5886 @@ -369,6 +719,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5887 * Atomically increments @v by 1.
5888 */
5889 #define atomic_inc(v) atomic_add(1, (v))
5890 +static __inline__ void atomic_inc_unchecked(atomic_unchecked_t *v)
5891 +{
5892 + atomic_add_unchecked(1, v);
5893 +}
5894
5895 /*
5896 * atomic_dec - decrement and test
5897 @@ -377,6 +731,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5898 * Atomically decrements @v by 1.
5899 */
5900 #define atomic_dec(v) atomic_sub(1, (v))
5901 +static __inline__ void atomic_dec_unchecked(atomic_unchecked_t *v)
5902 +{
5903 + atomic_sub_unchecked(1, v);
5904 +}
5905
5906 /*
5907 * atomic_add_negative - add and test if negative
5908 @@ -398,14 +756,30 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5909 * @v: pointer of type atomic64_t
5910 *
5911 */
5912 -#define atomic64_read(v) (*(volatile long *)&(v)->counter)
5913 +static inline long atomic64_read(const atomic64_t *v)
5914 +{
5915 + return (*(volatile const long *) &v->counter);
5916 +}
5917 +
5918 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
5919 +{
5920 + return (*(volatile const long *) &v->counter);
5921 +}
5922
5923 /*
5924 * atomic64_set - set atomic variable
5925 * @v: pointer of type atomic64_t
5926 * @i: required value
5927 */
5928 -#define atomic64_set(v, i) ((v)->counter = (i))
5929 +static inline void atomic64_set(atomic64_t *v, long i)
5930 +{
5931 + v->counter = i;
5932 +}
5933 +
5934 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
5935 +{
5936 + v->counter = i;
5937 +}
5938
5939 /*
5940 * atomic64_add - add integer to atomic variable
5941 @@ -414,7 +788,66 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5942 *
5943 * Atomically adds @i to @v.
5944 */
5945 -static __inline__ void atomic64_add(long i, atomic64_t * v)
5946 +static __inline__ void atomic64_add(long i, atomic64_t *v)
5947 +{
5948 + long temp;
5949 +
5950 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5951 + __asm__ __volatile__(
5952 + " .set mips3 \n"
5953 + "1: lld %0, %1 # atomic64_add \n"
5954 +#ifdef CONFIG_PAX_REFCOUNT
5955 + /* Exception on overflow. */
5956 + "2: dadd %0, %2 \n"
5957 +#else
5958 + " daddu %0, %2 \n"
5959 +#endif
5960 + " scd %0, %1 \n"
5961 + " beqzl %0, 1b \n"
5962 +#ifdef CONFIG_PAX_REFCOUNT
5963 + "3: \n"
5964 + _ASM_EXTABLE(2b, 3b)
5965 +#endif
5966 + " .set mips0 \n"
5967 + : "=&r" (temp), "+m" (v->counter)
5968 + : "Ir" (i));
5969 + } else if (kernel_uses_llsc) {
5970 + __asm__ __volatile__(
5971 + " .set mips3 \n"
5972 + "1: lld %0, %1 # atomic64_add \n"
5973 +#ifdef CONFIG_PAX_REFCOUNT
5974 + /* Exception on overflow. */
5975 + "2: dadd %0, %2 \n"
5976 +#else
5977 + " daddu %0, %2 \n"
5978 +#endif
5979 + " scd %0, %1 \n"
5980 + " beqz %0, 1b \n"
5981 +#ifdef CONFIG_PAX_REFCOUNT
5982 + "3: \n"
5983 + _ASM_EXTABLE(2b, 3b)
5984 +#endif
5985 + " .set mips0 \n"
5986 + : "=&r" (temp), "+m" (v->counter)
5987 + : "Ir" (i));
5988 + } else {
5989 + unsigned long flags;
5990 +
5991 + raw_local_irq_save(flags);
5992 + __asm__ __volatile__(
5993 +#ifdef CONFIG_PAX_REFCOUNT
5994 + /* Exception on overflow. */
5995 + "1: dadd %0, %1 \n"
5996 + "2: \n"
5997 + _ASM_EXTABLE(1b, 2b)
5998 +#else
5999 + " daddu %0, %1 \n"
6000 +#endif
6001 + : "+r" (v->counter) : "Ir" (i));
6002 + raw_local_irq_restore(flags);
6003 + }
6004 +}
6005 +static __inline__ void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
6006 {
6007 if (kernel_uses_llsc && R10000_LLSC_WAR) {
6008 long temp;
6009 @@ -457,7 +890,67 @@ static __inline__ void atomic64_add(long i, atomic64_t * v)
6010 *
6011 * Atomically subtracts @i from @v.
6012 */
6013 -static __inline__ void atomic64_sub(long i, atomic64_t * v)
6014 +static __inline__ void atomic64_sub(long i, atomic64_t *v)
6015 +{
6016 + long temp;
6017 +
6018 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6019 + __asm__ __volatile__(
6020 + " .set mips3 \n"
6021 + "1: lld %0, %1 # atomic64_sub \n"
6022 +#ifdef CONFIG_PAX_REFCOUNT
6023 + /* Exception on overflow. */
6024 + "2: dsub %0, %2 \n"
6025 +#else
6026 + " dsubu %0, %2 \n"
6027 +#endif
6028 + " scd %0, %1 \n"
6029 + " beqzl %0, 1b \n"
6030 +#ifdef CONFIG_PAX_REFCOUNT
6031 + "3: \n"
6032 + _ASM_EXTABLE(2b, 3b)
6033 +#endif
6034 + " .set mips0 \n"
6035 + : "=&r" (temp), "+m" (v->counter)
6036 + : "Ir" (i));
6037 + } else if (kernel_uses_llsc) {
6038 + __asm__ __volatile__(
6039 + " .set mips3 \n"
6040 + "1: lld %0, %1 # atomic64_sub \n"
6041 +#ifdef CONFIG_PAX_REFCOUNT
6042 + /* Exception on overflow. */
6043 + "2: dsub %0, %2 \n"
6044 +#else
6045 + " dsubu %0, %2 \n"
6046 +#endif
6047 + " scd %0, %1 \n"
6048 + " beqz %0, 1b \n"
6049 +#ifdef CONFIG_PAX_REFCOUNT
6050 + "3: \n"
6051 + _ASM_EXTABLE(2b, 3b)
6052 +#endif
6053 + " .set mips0 \n"
6054 + : "=&r" (temp), "+m" (v->counter)
6055 + : "Ir" (i));
6056 + } else {
6057 + unsigned long flags;
6058 +
6059 + raw_local_irq_save(flags);
6060 + __asm__ __volatile__(
6061 +#ifdef CONFIG_PAX_REFCOUNT
6062 + /* Exception on overflow. */
6063 + "1: dsub %0, %1 \n"
6064 + "2: \n"
6065 + _ASM_EXTABLE(1b, 2b)
6066 +#else
6067 + " dsubu %0, %1 \n"
6068 +#endif
6069 + : "+r" (v->counter) : "Ir" (i));
6070 + raw_local_irq_restore(flags);
6071 + }
6072 +}
6073 +
6074 +static __inline__ void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
6075 {
6076 if (kernel_uses_llsc && R10000_LLSC_WAR) {
6077 long temp;
6078 @@ -496,7 +989,93 @@ static __inline__ void atomic64_sub(long i, atomic64_t * v)
6079 /*
6080 * Same as above, but return the result value
6081 */
6082 -static __inline__ long atomic64_add_return(long i, atomic64_t * v)
6083 +static __inline__ long atomic64_add_return(long i, atomic64_t *v)
6084 +{
6085 + long result;
6086 + long temp;
6087 +
6088 + smp_mb__before_llsc();
6089 +
6090 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6091 + __asm__ __volatile__(
6092 + " .set mips3 \n"
6093 + "1: lld %1, %2 # atomic64_add_return \n"
6094 +#ifdef CONFIG_PAX_REFCOUNT
6095 + "2: dadd %0, %1, %3 \n"
6096 +#else
6097 + " daddu %0, %1, %3 \n"
6098 +#endif
6099 + " scd %0, %2 \n"
6100 + " beqzl %0, 1b \n"
6101 +#ifdef CONFIG_PAX_REFCOUNT
6102 + " b 4f \n"
6103 + " .set noreorder \n"
6104 + "3: b 5f \n"
6105 + " move %0, %1 \n"
6106 + " .set reorder \n"
6107 + _ASM_EXTABLE(2b, 3b)
6108 +#endif
6109 + "4: daddu %0, %1, %3 \n"
6110 +#ifdef CONFIG_PAX_REFCOUNT
6111 + "5: \n"
6112 +#endif
6113 + " .set mips0 \n"
6114 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
6115 + : "Ir" (i));
6116 + } else if (kernel_uses_llsc) {
6117 + __asm__ __volatile__(
6118 + " .set mips3 \n"
6119 + "1: lld %1, %2 # atomic64_add_return \n"
6120 +#ifdef CONFIG_PAX_REFCOUNT
6121 + "2: dadd %0, %1, %3 \n"
6122 +#else
6123 + " daddu %0, %1, %3 \n"
6124 +#endif
6125 + " scd %0, %2 \n"
6126 + " bnez %0, 4f \n"
6127 + " b 1b \n"
6128 +#ifdef CONFIG_PAX_REFCOUNT
6129 + " .set noreorder \n"
6130 + "3: b 5f \n"
6131 + " move %0, %1 \n"
6132 + " .set reorder \n"
6133 + _ASM_EXTABLE(2b, 3b)
6134 +#endif
6135 + "4: daddu %0, %1, %3 \n"
6136 +#ifdef CONFIG_PAX_REFCOUNT
6137 + "5: \n"
6138 +#endif
6139 + " .set mips0 \n"
6140 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6141 + : "Ir" (i), "m" (v->counter)
6142 + : "memory");
6143 + } else {
6144 + unsigned long flags;
6145 +
6146 + raw_local_irq_save(flags);
6147 + __asm__ __volatile__(
6148 + " ld %0, %1 \n"
6149 +#ifdef CONFIG_PAX_REFCOUNT
6150 + /* Exception on overflow. */
6151 + "1: dadd %0, %2 \n"
6152 +#else
6153 + " daddu %0, %2 \n"
6154 +#endif
6155 + " sd %0, %1 \n"
6156 +#ifdef CONFIG_PAX_REFCOUNT
6157 + /* Note: Dest reg is not modified on overflow */
6158 + "2: \n"
6159 + _ASM_EXTABLE(1b, 2b)
6160 +#endif
6161 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
6162 + raw_local_irq_restore(flags);
6163 + }
6164 +
6165 + smp_llsc_mb();
6166 +
6167 + return result;
6168 +}
6169 +static __inline__ long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
6170 {
6171 long result;
6172
6173 @@ -546,7 +1125,97 @@ static __inline__ long atomic64_add_return(long i, atomic64_t * v)
6174 return result;
6175 }
6176
6177 -static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
6178 +static __inline__ long atomic64_sub_return(long i, atomic64_t *v)
6179 +{
6180 + long result;
6181 + long temp;
6182 +
6183 + smp_mb__before_llsc();
6184 +
6185 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6186 + long temp;
6187 +
6188 + __asm__ __volatile__(
6189 + " .set mips3 \n"
6190 + "1: lld %1, %2 # atomic64_sub_return \n"
6191 +#ifdef CONFIG_PAX_REFCOUNT
6192 + "2: dsub %0, %1, %3 \n"
6193 +#else
6194 + " dsubu %0, %1, %3 \n"
6195 +#endif
6196 + " scd %0, %2 \n"
6197 + " beqzl %0, 1b \n"
6198 +#ifdef CONFIG_PAX_REFCOUNT
6199 + " b 4f \n"
6200 + " .set noreorder \n"
6201 + "3: b 5f \n"
6202 + " move %0, %1 \n"
6203 + " .set reorder \n"
6204 + _ASM_EXTABLE(2b, 3b)
6205 +#endif
6206 + "4: dsubu %0, %1, %3 \n"
6207 +#ifdef CONFIG_PAX_REFCOUNT
6208 + "5: \n"
6209 +#endif
6210 + " .set mips0 \n"
6211 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6212 + : "Ir" (i), "m" (v->counter)
6213 + : "memory");
6214 + } else if (kernel_uses_llsc) {
6215 + __asm__ __volatile__(
6216 + " .set mips3 \n"
6217 + "1: lld %1, %2 # atomic64_sub_return \n"
6218 +#ifdef CONFIG_PAX_REFCOUNT
6219 + "2: dsub %0, %1, %3 \n"
6220 +#else
6221 + " dsubu %0, %1, %3 \n"
6222 +#endif
6223 + " scd %0, %2 \n"
6224 + " bnez %0, 4f \n"
6225 + " b 1b \n"
6226 +#ifdef CONFIG_PAX_REFCOUNT
6227 + " .set noreorder \n"
6228 + "3: b 5f \n"
6229 + " move %0, %1 \n"
6230 + " .set reorder \n"
6231 + _ASM_EXTABLE(2b, 3b)
6232 +#endif
6233 + "4: dsubu %0, %1, %3 \n"
6234 +#ifdef CONFIG_PAX_REFCOUNT
6235 + "5: \n"
6236 +#endif
6237 + " .set mips0 \n"
6238 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6239 + : "Ir" (i), "m" (v->counter)
6240 + : "memory");
6241 + } else {
6242 + unsigned long flags;
6243 +
6244 + raw_local_irq_save(flags);
6245 + __asm__ __volatile__(
6246 + " ld %0, %1 \n"
6247 +#ifdef CONFIG_PAX_REFCOUNT
6248 + /* Exception on overflow. */
6249 + "1: dsub %0, %2 \n"
6250 +#else
6251 + " dsubu %0, %2 \n"
6252 +#endif
6253 + " sd %0, %1 \n"
6254 +#ifdef CONFIG_PAX_REFCOUNT
6255 + /* Note: Dest reg is not modified on overflow */
6256 + "2: \n"
6257 + _ASM_EXTABLE(1b, 2b)
6258 +#endif
6259 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
6260 + raw_local_irq_restore(flags);
6261 + }
6262 +
6263 + smp_llsc_mb();
6264 +
6265 + return result;
6266 +}
6267 +
6268 +static __inline__ long atomic64_sub_return_unchecked(long i, atomic64_unchecked_t *v)
6269 {
6270 long result;
6271
6272 @@ -605,7 +1274,7 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
6273 * Atomically test @v and subtract @i if @v is greater or equal than @i.
6274 * The function returns the old value of @v minus @i.
6275 */
6276 -static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6277 +static __inline__ long atomic64_sub_if_positive(long i, atomic64_t *v)
6278 {
6279 long result;
6280
6281 @@ -662,9 +1331,26 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6282 return result;
6283 }
6284
6285 -#define atomic64_cmpxchg(v, o, n) \
6286 - ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
6287 -#define atomic64_xchg(v, new) (xchg(&((v)->counter), (new)))
6288 +static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
6289 +{
6290 + return cmpxchg(&v->counter, old, new);
6291 +}
6292 +
6293 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old,
6294 + long new)
6295 +{
6296 + return cmpxchg(&(v->counter), old, new);
6297 +}
6298 +
6299 +static inline long atomic64_xchg(atomic64_t *v, long new)
6300 +{
6301 + return xchg(&v->counter, new);
6302 +}
6303 +
6304 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
6305 +{
6306 + return xchg(&(v->counter), new);
6307 +}
6308
6309 /**
6310 * atomic64_add_unless - add unless the number is a given value
6311 @@ -694,6 +1380,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6312
6313 #define atomic64_dec_return(v) atomic64_sub_return(1, (v))
6314 #define atomic64_inc_return(v) atomic64_add_return(1, (v))
6315 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1, (v))
6316
6317 /*
6318 * atomic64_sub_and_test - subtract value from variable and test result
6319 @@ -715,6 +1402,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6320 * other cases.
6321 */
6322 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
6323 +#define atomic64_inc_and_test_unchecked(v) atomic64_add_return_unchecked(1, (v)) == 0)
6324
6325 /*
6326 * atomic64_dec_and_test - decrement by 1 and test
6327 @@ -739,6 +1427,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6328 * Atomically increments @v by 1.
6329 */
6330 #define atomic64_inc(v) atomic64_add(1, (v))
6331 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1, (v))
6332
6333 /*
6334 * atomic64_dec - decrement and test
6335 @@ -747,6 +1436,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6336 * Atomically decrements @v by 1.
6337 */
6338 #define atomic64_dec(v) atomic64_sub(1, (v))
6339 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1, (v))
6340
6341 /*
6342 * atomic64_add_negative - add and test if negative
6343 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
6344 index b4db69f..8f3b093 100644
6345 --- a/arch/mips/include/asm/cache.h
6346 +++ b/arch/mips/include/asm/cache.h
6347 @@ -9,10 +9,11 @@
6348 #ifndef _ASM_CACHE_H
6349 #define _ASM_CACHE_H
6350
6351 +#include <linux/const.h>
6352 #include <kmalloc.h>
6353
6354 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
6355 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6356 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6357
6358 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
6359 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6360 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
6361 index cf3ae24..238d22f 100644
6362 --- a/arch/mips/include/asm/elf.h
6363 +++ b/arch/mips/include/asm/elf.h
6364 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
6365 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
6366 #endif
6367
6368 +#ifdef CONFIG_PAX_ASLR
6369 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6370 +
6371 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6372 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6373 +#endif
6374 +
6375 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
6376 struct linux_binprm;
6377 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6378 int uses_interp);
6379
6380 -struct mm_struct;
6381 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6382 -#define arch_randomize_brk arch_randomize_brk
6383 -
6384 #endif /* _ASM_ELF_H */
6385 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
6386 index c1f6afa..38cc6e9 100644
6387 --- a/arch/mips/include/asm/exec.h
6388 +++ b/arch/mips/include/asm/exec.h
6389 @@ -12,6 +12,6 @@
6390 #ifndef _ASM_EXEC_H
6391 #define _ASM_EXEC_H
6392
6393 -extern unsigned long arch_align_stack(unsigned long sp);
6394 +#define arch_align_stack(x) ((x) & ~0xfUL)
6395
6396 #endif /* _ASM_EXEC_H */
6397 diff --git a/arch/mips/include/asm/local.h b/arch/mips/include/asm/local.h
6398 index d44622c..64990d2 100644
6399 --- a/arch/mips/include/asm/local.h
6400 +++ b/arch/mips/include/asm/local.h
6401 @@ -12,15 +12,25 @@ typedef struct
6402 atomic_long_t a;
6403 } local_t;
6404
6405 +typedef struct {
6406 + atomic_long_unchecked_t a;
6407 +} local_unchecked_t;
6408 +
6409 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
6410
6411 #define local_read(l) atomic_long_read(&(l)->a)
6412 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
6413 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
6414 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
6415
6416 #define local_add(i, l) atomic_long_add((i), (&(l)->a))
6417 +#define local_add_unchecked(i, l) atomic_long_add_unchecked((i), (&(l)->a))
6418 #define local_sub(i, l) atomic_long_sub((i), (&(l)->a))
6419 +#define local_sub_unchecked(i, l) atomic_long_sub_unchecked((i), (&(l)->a))
6420 #define local_inc(l) atomic_long_inc(&(l)->a)
6421 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
6422 #define local_dec(l) atomic_long_dec(&(l)->a)
6423 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
6424
6425 /*
6426 * Same as above, but return the result value
6427 @@ -70,6 +80,51 @@ static __inline__ long local_add_return(long i, local_t * l)
6428 return result;
6429 }
6430
6431 +static __inline__ long local_add_return_unchecked(long i, local_unchecked_t * l)
6432 +{
6433 + unsigned long result;
6434 +
6435 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6436 + unsigned long temp;
6437 +
6438 + __asm__ __volatile__(
6439 + " .set mips3 \n"
6440 + "1:" __LL "%1, %2 # local_add_return \n"
6441 + " addu %0, %1, %3 \n"
6442 + __SC "%0, %2 \n"
6443 + " beqzl %0, 1b \n"
6444 + " addu %0, %1, %3 \n"
6445 + " .set mips0 \n"
6446 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6447 + : "Ir" (i), "m" (l->a.counter)
6448 + : "memory");
6449 + } else if (kernel_uses_llsc) {
6450 + unsigned long temp;
6451 +
6452 + __asm__ __volatile__(
6453 + " .set mips3 \n"
6454 + "1:" __LL "%1, %2 # local_add_return \n"
6455 + " addu %0, %1, %3 \n"
6456 + __SC "%0, %2 \n"
6457 + " beqz %0, 1b \n"
6458 + " addu %0, %1, %3 \n"
6459 + " .set mips0 \n"
6460 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6461 + : "Ir" (i), "m" (l->a.counter)
6462 + : "memory");
6463 + } else {
6464 + unsigned long flags;
6465 +
6466 + local_irq_save(flags);
6467 + result = l->a.counter;
6468 + result += i;
6469 + l->a.counter = result;
6470 + local_irq_restore(flags);
6471 + }
6472 +
6473 + return result;
6474 +}
6475 +
6476 static __inline__ long local_sub_return(long i, local_t * l)
6477 {
6478 unsigned long result;
6479 @@ -117,6 +172,8 @@ static __inline__ long local_sub_return(long i, local_t * l)
6480
6481 #define local_cmpxchg(l, o, n) \
6482 ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6483 +#define local_cmpxchg_unchecked(l, o, n) \
6484 + ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6485 #define local_xchg(l, n) (atomic_long_xchg((&(l)->a), (n)))
6486
6487 /**
6488 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
6489 index f59552f..3abe9b9 100644
6490 --- a/arch/mips/include/asm/page.h
6491 +++ b/arch/mips/include/asm/page.h
6492 @@ -95,7 +95,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
6493 #ifdef CONFIG_CPU_MIPS32
6494 typedef struct { unsigned long pte_low, pte_high; } pte_t;
6495 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
6496 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
6497 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
6498 #else
6499 typedef struct { unsigned long long pte; } pte_t;
6500 #define pte_val(x) ((x).pte)
6501 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
6502 index 881d18b..cea38bc 100644
6503 --- a/arch/mips/include/asm/pgalloc.h
6504 +++ b/arch/mips/include/asm/pgalloc.h
6505 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6506 {
6507 set_pud(pud, __pud((unsigned long)pmd));
6508 }
6509 +
6510 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6511 +{
6512 + pud_populate(mm, pud, pmd);
6513 +}
6514 #endif
6515
6516 /*
6517 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
6518 index 895320e..bf63e10 100644
6519 --- a/arch/mips/include/asm/thread_info.h
6520 +++ b/arch/mips/include/asm/thread_info.h
6521 @@ -115,6 +115,8 @@ static inline struct thread_info *current_thread_info(void)
6522 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
6523 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
6524 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
6525 +/* li takes a 32bit immediate */
6526 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
6527 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
6528
6529 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6530 @@ -130,15 +132,18 @@ static inline struct thread_info *current_thread_info(void)
6531 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
6532 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
6533 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
6534 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6535 +
6536 +#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
6537
6538 /* work to do in syscall_trace_leave() */
6539 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT)
6540 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
6541
6542 /* work to do on interrupt/exception return */
6543 #define _TIF_WORK_MASK \
6544 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
6545 /* work to do on any return to u-space */
6546 -#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT)
6547 +#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
6548
6549 #endif /* __KERNEL__ */
6550
6551 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
6552 index 1188e00..41cf144 100644
6553 --- a/arch/mips/kernel/binfmt_elfn32.c
6554 +++ b/arch/mips/kernel/binfmt_elfn32.c
6555 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6556 #undef ELF_ET_DYN_BASE
6557 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6558
6559 +#ifdef CONFIG_PAX_ASLR
6560 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6561 +
6562 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6563 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6564 +#endif
6565 +
6566 #include <asm/processor.h>
6567 #include <linux/module.h>
6568 #include <linux/elfcore.h>
6569 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
6570 index 202e581..689ca79 100644
6571 --- a/arch/mips/kernel/binfmt_elfo32.c
6572 +++ b/arch/mips/kernel/binfmt_elfo32.c
6573 @@ -56,6 +56,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6574 #undef ELF_ET_DYN_BASE
6575 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6576
6577 +#ifdef CONFIG_PAX_ASLR
6578 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6579 +
6580 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6581 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6582 +#endif
6583 +
6584 #include <asm/processor.h>
6585
6586 /*
6587 diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c
6588 index d1fea7a..45602ea 100644
6589 --- a/arch/mips/kernel/irq.c
6590 +++ b/arch/mips/kernel/irq.c
6591 @@ -77,17 +77,17 @@ void ack_bad_irq(unsigned int irq)
6592 printk("unexpected IRQ # %d\n", irq);
6593 }
6594
6595 -atomic_t irq_err_count;
6596 +atomic_unchecked_t irq_err_count;
6597
6598 int arch_show_interrupts(struct seq_file *p, int prec)
6599 {
6600 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
6601 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
6602 return 0;
6603 }
6604
6605 asmlinkage void spurious_interrupt(void)
6606 {
6607 - atomic_inc(&irq_err_count);
6608 + atomic_inc_unchecked(&irq_err_count);
6609 }
6610
6611 void __init init_IRQ(void)
6612 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
6613 index c6a041d..b3e7318 100644
6614 --- a/arch/mips/kernel/process.c
6615 +++ b/arch/mips/kernel/process.c
6616 @@ -563,15 +563,3 @@ unsigned long get_wchan(struct task_struct *task)
6617 out:
6618 return pc;
6619 }
6620 -
6621 -/*
6622 - * Don't forget that the stack pointer must be aligned on a 8 bytes
6623 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
6624 - */
6625 -unsigned long arch_align_stack(unsigned long sp)
6626 -{
6627 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6628 - sp -= get_random_int() & ~PAGE_MASK;
6629 -
6630 - return sp & ALMASK;
6631 -}
6632 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
6633 index 9c6299c..2fb4c22 100644
6634 --- a/arch/mips/kernel/ptrace.c
6635 +++ b/arch/mips/kernel/ptrace.c
6636 @@ -528,6 +528,10 @@ static inline int audit_arch(void)
6637 return arch;
6638 }
6639
6640 +#ifdef CONFIG_GRKERNSEC_SETXID
6641 +extern void gr_delayed_cred_worker(void);
6642 +#endif
6643 +
6644 /*
6645 * Notification of system call entry/exit
6646 * - triggered by current->work.syscall_trace
6647 @@ -537,6 +541,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
6648 /* do the secure computing check first */
6649 secure_computing_strict(regs->regs[2]);
6650
6651 +#ifdef CONFIG_GRKERNSEC_SETXID
6652 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6653 + gr_delayed_cred_worker();
6654 +#endif
6655 +
6656 if (!(current->ptrace & PT_PTRACED))
6657 goto out;
6658
6659 diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
6660 index 9b36424..e7f4154 100644
6661 --- a/arch/mips/kernel/scall32-o32.S
6662 +++ b/arch/mips/kernel/scall32-o32.S
6663 @@ -52,7 +52,7 @@ NESTED(handle_sys, PT_SIZE, sp)
6664
6665 stack_done:
6666 lw t0, TI_FLAGS($28) # syscall tracing enabled?
6667 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
6668 + li t1, _TIF_SYSCALL_WORK
6669 and t0, t1
6670 bnez t0, syscall_trace_entry # -> yes
6671
6672 diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
6673 index 97a5909..59622f8 100644
6674 --- a/arch/mips/kernel/scall64-64.S
6675 +++ b/arch/mips/kernel/scall64-64.S
6676 @@ -54,7 +54,7 @@ NESTED(handle_sys64, PT_SIZE, sp)
6677
6678 sd a3, PT_R26(sp) # save a3 for syscall restarting
6679
6680 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
6681 + li t1, _TIF_SYSCALL_WORK
6682 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
6683 and t0, t1, t0
6684 bnez t0, syscall_trace_entry
6685 diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
6686 index edcb659..fb2ab09 100644
6687 --- a/arch/mips/kernel/scall64-n32.S
6688 +++ b/arch/mips/kernel/scall64-n32.S
6689 @@ -47,7 +47,7 @@ NESTED(handle_sysn32, PT_SIZE, sp)
6690
6691 sd a3, PT_R26(sp) # save a3 for syscall restarting
6692
6693 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
6694 + li t1, _TIF_SYSCALL_WORK
6695 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
6696 and t0, t1, t0
6697 bnez t0, n32_syscall_trace_entry
6698 diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
6699 index 74f485d..47d2c38 100644
6700 --- a/arch/mips/kernel/scall64-o32.S
6701 +++ b/arch/mips/kernel/scall64-o32.S
6702 @@ -81,7 +81,7 @@ NESTED(handle_sys, PT_SIZE, sp)
6703 PTR 4b, bad_stack
6704 .previous
6705
6706 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
6707 + li t1, _TIF_SYSCALL_WORK
6708 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
6709 and t0, t1, t0
6710 bnez t0, trace_a_syscall
6711 diff --git a/arch/mips/kernel/sync-r4k.c b/arch/mips/kernel/sync-r4k.c
6712 index 1ff43d5..96fec68 100644
6713 --- a/arch/mips/kernel/sync-r4k.c
6714 +++ b/arch/mips/kernel/sync-r4k.c
6715 @@ -21,8 +21,8 @@
6716 #include <asm/mipsregs.h>
6717
6718 static atomic_t __cpuinitdata count_start_flag = ATOMIC_INIT(0);
6719 -static atomic_t __cpuinitdata count_count_start = ATOMIC_INIT(0);
6720 -static atomic_t __cpuinitdata count_count_stop = ATOMIC_INIT(0);
6721 +static atomic_unchecked_t __cpuinitdata count_count_start = ATOMIC_INIT(0);
6722 +static atomic_unchecked_t __cpuinitdata count_count_stop = ATOMIC_INIT(0);
6723 static atomic_t __cpuinitdata count_reference = ATOMIC_INIT(0);
6724
6725 #define COUNTON 100
6726 @@ -69,13 +69,13 @@ void __cpuinit synchronise_count_master(int cpu)
6727
6728 for (i = 0; i < NR_LOOPS; i++) {
6729 /* slaves loop on '!= 2' */
6730 - while (atomic_read(&count_count_start) != 1)
6731 + while (atomic_read_unchecked(&count_count_start) != 1)
6732 mb();
6733 - atomic_set(&count_count_stop, 0);
6734 + atomic_set_unchecked(&count_count_stop, 0);
6735 smp_wmb();
6736
6737 /* this lets the slaves write their count register */
6738 - atomic_inc(&count_count_start);
6739 + atomic_inc_unchecked(&count_count_start);
6740
6741 /*
6742 * Everyone initialises count in the last loop:
6743 @@ -86,11 +86,11 @@ void __cpuinit synchronise_count_master(int cpu)
6744 /*
6745 * Wait for all slaves to leave the synchronization point:
6746 */
6747 - while (atomic_read(&count_count_stop) != 1)
6748 + while (atomic_read_unchecked(&count_count_stop) != 1)
6749 mb();
6750 - atomic_set(&count_count_start, 0);
6751 + atomic_set_unchecked(&count_count_start, 0);
6752 smp_wmb();
6753 - atomic_inc(&count_count_stop);
6754 + atomic_inc_unchecked(&count_count_stop);
6755 }
6756 /* Arrange for an interrupt in a short while */
6757 write_c0_compare(read_c0_count() + COUNTON);
6758 @@ -131,8 +131,8 @@ void __cpuinit synchronise_count_slave(int cpu)
6759 initcount = atomic_read(&count_reference);
6760
6761 for (i = 0; i < NR_LOOPS; i++) {
6762 - atomic_inc(&count_count_start);
6763 - while (atomic_read(&count_count_start) != 2)
6764 + atomic_inc_unchecked(&count_count_start);
6765 + while (atomic_read_unchecked(&count_count_start) != 2)
6766 mb();
6767
6768 /*
6769 @@ -141,8 +141,8 @@ void __cpuinit synchronise_count_slave(int cpu)
6770 if (i == NR_LOOPS-1)
6771 write_c0_count(initcount);
6772
6773 - atomic_inc(&count_count_stop);
6774 - while (atomic_read(&count_count_stop) != 2)
6775 + atomic_inc_unchecked(&count_count_stop);
6776 + while (atomic_read_unchecked(&count_count_stop) != 2)
6777 mb();
6778 }
6779 /* Arrange for an interrupt in a short while */
6780 diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
6781 index a75ae40..0d0f56a 100644
6782 --- a/arch/mips/kernel/traps.c
6783 +++ b/arch/mips/kernel/traps.c
6784 @@ -675,7 +675,17 @@ asmlinkage void do_ov(struct pt_regs *regs)
6785 {
6786 siginfo_t info;
6787
6788 - die_if_kernel("Integer overflow", regs);
6789 + if (unlikely(!user_mode(regs))) {
6790 +
6791 +#ifdef CONFIG_PAX_REFCOUNT
6792 + if (fixup_exception(regs)) {
6793 + pax_report_refcount_overflow(regs);
6794 + return;
6795 + }
6796 +#endif
6797 +
6798 + die("Integer overflow", regs);
6799 + }
6800
6801 info.si_code = FPE_INTOVF;
6802 info.si_signo = SIGFPE;
6803 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
6804 index 0fead53..eeb00a6 100644
6805 --- a/arch/mips/mm/fault.c
6806 +++ b/arch/mips/mm/fault.c
6807 @@ -27,6 +27,23 @@
6808 #include <asm/highmem.h> /* For VMALLOC_END */
6809 #include <linux/kdebug.h>
6810
6811 +#ifdef CONFIG_PAX_PAGEEXEC
6812 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6813 +{
6814 + unsigned long i;
6815 +
6816 + printk(KERN_ERR "PAX: bytes at PC: ");
6817 + for (i = 0; i < 5; i++) {
6818 + unsigned int c;
6819 + if (get_user(c, (unsigned int *)pc+i))
6820 + printk(KERN_CONT "???????? ");
6821 + else
6822 + printk(KERN_CONT "%08x ", c);
6823 + }
6824 + printk("\n");
6825 +}
6826 +#endif
6827 +
6828 /*
6829 * This routine handles page faults. It determines the address,
6830 * and the problem, and then passes it off to one of the appropriate
6831 @@ -196,6 +213,14 @@ bad_area:
6832 bad_area_nosemaphore:
6833 /* User mode accesses just cause a SIGSEGV */
6834 if (user_mode(regs)) {
6835 +
6836 +#ifdef CONFIG_PAX_PAGEEXEC
6837 + if (cpu_has_rixi && (mm->pax_flags & MF_PAX_PAGEEXEC) && !write && address == instruction_pointer(regs)) {
6838 + pax_report_fault(regs, (void *)address, (void *)user_stack_pointer(regs));
6839 + do_group_exit(SIGKILL);
6840 + }
6841 +#endif
6842 +
6843 tsk->thread.cp0_badvaddr = address;
6844 tsk->thread.error_code = write;
6845 #if 0
6846 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
6847 index 7e5fe27..9656513 100644
6848 --- a/arch/mips/mm/mmap.c
6849 +++ b/arch/mips/mm/mmap.c
6850 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6851 struct vm_area_struct *vma;
6852 unsigned long addr = addr0;
6853 int do_color_align;
6854 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
6855 struct vm_unmapped_area_info info;
6856
6857 if (unlikely(len > TASK_SIZE))
6858 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6859 do_color_align = 1;
6860
6861 /* requesting a specific address */
6862 +
6863 +#ifdef CONFIG_PAX_RANDMMAP
6864 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
6865 +#endif
6866 +
6867 if (addr) {
6868 if (do_color_align)
6869 addr = COLOUR_ALIGN(addr, pgoff);
6870 @@ -91,14 +97,14 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6871 addr = PAGE_ALIGN(addr);
6872
6873 vma = find_vma(mm, addr);
6874 - if (TASK_SIZE - len >= addr &&
6875 - (!vma || addr + len <= vma->vm_start))
6876 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
6877 return addr;
6878 }
6879
6880 info.length = len;
6881 info.align_mask = do_color_align ? (PAGE_MASK & shm_align_mask) : 0;
6882 info.align_offset = pgoff << PAGE_SHIFT;
6883 + info.threadstack_offset = offset;
6884
6885 if (dir == DOWN) {
6886 info.flags = VM_UNMAPPED_AREA_TOPDOWN;
6887 @@ -146,6 +152,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
6888 {
6889 unsigned long random_factor = 0UL;
6890
6891 +#ifdef CONFIG_PAX_RANDMMAP
6892 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
6893 +#endif
6894 +
6895 if (current->flags & PF_RANDOMIZE) {
6896 random_factor = get_random_int();
6897 random_factor = random_factor << PAGE_SHIFT;
6898 @@ -157,42 +167,27 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
6899
6900 if (mmap_is_legacy()) {
6901 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
6902 +
6903 +#ifdef CONFIG_PAX_RANDMMAP
6904 + if (mm->pax_flags & MF_PAX_RANDMMAP)
6905 + mm->mmap_base += mm->delta_mmap;
6906 +#endif
6907 +
6908 mm->get_unmapped_area = arch_get_unmapped_area;
6909 mm->unmap_area = arch_unmap_area;
6910 } else {
6911 mm->mmap_base = mmap_base(random_factor);
6912 +
6913 +#ifdef CONFIG_PAX_RANDMMAP
6914 + if (mm->pax_flags & MF_PAX_RANDMMAP)
6915 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
6916 +#endif
6917 +
6918 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
6919 mm->unmap_area = arch_unmap_area_topdown;
6920 }
6921 }
6922
6923 -static inline unsigned long brk_rnd(void)
6924 -{
6925 - unsigned long rnd = get_random_int();
6926 -
6927 - rnd = rnd << PAGE_SHIFT;
6928 - /* 8MB for 32bit, 256MB for 64bit */
6929 - if (TASK_IS_32BIT_ADDR)
6930 - rnd = rnd & 0x7ffffful;
6931 - else
6932 - rnd = rnd & 0xffffffful;
6933 -
6934 - return rnd;
6935 -}
6936 -
6937 -unsigned long arch_randomize_brk(struct mm_struct *mm)
6938 -{
6939 - unsigned long base = mm->brk;
6940 - unsigned long ret;
6941 -
6942 - ret = PAGE_ALIGN(base + brk_rnd());
6943 -
6944 - if (ret < mm->brk)
6945 - return mm->brk;
6946 -
6947 - return ret;
6948 -}
6949 -
6950 int __virt_addr_valid(const volatile void *kaddr)
6951 {
6952 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
6953 diff --git a/arch/mips/sgi-ip27/ip27-nmi.c b/arch/mips/sgi-ip27/ip27-nmi.c
6954 index a2358b4..7cead4f 100644
6955 --- a/arch/mips/sgi-ip27/ip27-nmi.c
6956 +++ b/arch/mips/sgi-ip27/ip27-nmi.c
6957 @@ -187,9 +187,9 @@ void
6958 cont_nmi_dump(void)
6959 {
6960 #ifndef REAL_NMI_SIGNAL
6961 - static atomic_t nmied_cpus = ATOMIC_INIT(0);
6962 + static atomic_unchecked_t nmied_cpus = ATOMIC_INIT(0);
6963
6964 - atomic_inc(&nmied_cpus);
6965 + atomic_inc_unchecked(&nmied_cpus);
6966 #endif
6967 /*
6968 * Only allow 1 cpu to proceed
6969 @@ -233,7 +233,7 @@ cont_nmi_dump(void)
6970 udelay(10000);
6971 }
6972 #else
6973 - while (atomic_read(&nmied_cpus) != num_online_cpus());
6974 + while (atomic_read_unchecked(&nmied_cpus) != num_online_cpus());
6975 #endif
6976
6977 /*
6978 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
6979 index 967d144..db12197 100644
6980 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
6981 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
6982 @@ -11,12 +11,14 @@
6983 #ifndef _ASM_PROC_CACHE_H
6984 #define _ASM_PROC_CACHE_H
6985
6986 +#include <linux/const.h>
6987 +
6988 /* L1 cache */
6989
6990 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
6991 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
6992 -#define L1_CACHE_BYTES 16 /* bytes per entry */
6993 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
6994 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
6995 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
6996
6997 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
6998 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6999 index bcb5df2..84fabd2 100644
7000 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
7001 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
7002 @@ -16,13 +16,15 @@
7003 #ifndef _ASM_PROC_CACHE_H
7004 #define _ASM_PROC_CACHE_H
7005
7006 +#include <linux/const.h>
7007 +
7008 /*
7009 * L1 cache
7010 */
7011 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
7012 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
7013 -#define L1_CACHE_BYTES 32 /* bytes per entry */
7014 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
7015 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
7016 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
7017
7018 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
7019 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
7020 index 4ce7a01..449202a 100644
7021 --- a/arch/openrisc/include/asm/cache.h
7022 +++ b/arch/openrisc/include/asm/cache.h
7023 @@ -19,11 +19,13 @@
7024 #ifndef __ASM_OPENRISC_CACHE_H
7025 #define __ASM_OPENRISC_CACHE_H
7026
7027 +#include <linux/const.h>
7028 +
7029 /* FIXME: How can we replace these with values from the CPU...
7030 * they shouldn't be hard-coded!
7031 */
7032
7033 -#define L1_CACHE_BYTES 16
7034 #define L1_CACHE_SHIFT 4
7035 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7036
7037 #endif /* __ASM_OPENRISC_CACHE_H */
7038 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
7039 index 472886c..00e7df9 100644
7040 --- a/arch/parisc/include/asm/atomic.h
7041 +++ b/arch/parisc/include/asm/atomic.h
7042 @@ -252,6 +252,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
7043 return dec;
7044 }
7045
7046 +#define atomic64_read_unchecked(v) atomic64_read(v)
7047 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7048 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7049 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7050 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7051 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7052 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7053 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7054 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7055 +
7056 #endif /* !CONFIG_64BIT */
7057
7058
7059 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
7060 index 47f11c7..3420df2 100644
7061 --- a/arch/parisc/include/asm/cache.h
7062 +++ b/arch/parisc/include/asm/cache.h
7063 @@ -5,6 +5,7 @@
7064 #ifndef __ARCH_PARISC_CACHE_H
7065 #define __ARCH_PARISC_CACHE_H
7066
7067 +#include <linux/const.h>
7068
7069 /*
7070 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
7071 @@ -15,13 +16,13 @@
7072 * just ruin performance.
7073 */
7074 #ifdef CONFIG_PA20
7075 -#define L1_CACHE_BYTES 64
7076 #define L1_CACHE_SHIFT 6
7077 #else
7078 -#define L1_CACHE_BYTES 32
7079 #define L1_CACHE_SHIFT 5
7080 #endif
7081
7082 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7083 +
7084 #ifndef __ASSEMBLY__
7085
7086 #define SMP_CACHE_BYTES L1_CACHE_BYTES
7087 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
7088 index ad2b503..bdf1651 100644
7089 --- a/arch/parisc/include/asm/elf.h
7090 +++ b/arch/parisc/include/asm/elf.h
7091 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
7092
7093 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
7094
7095 +#ifdef CONFIG_PAX_ASLR
7096 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
7097 +
7098 +#define PAX_DELTA_MMAP_LEN 16
7099 +#define PAX_DELTA_STACK_LEN 16
7100 +#endif
7101 +
7102 /* This yields a mask that user programs can use to figure out what
7103 instruction set this CPU supports. This could be done in user space,
7104 but it's not easy, and we've already done it here. */
7105 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
7106 index fc987a1..6e068ef 100644
7107 --- a/arch/parisc/include/asm/pgalloc.h
7108 +++ b/arch/parisc/include/asm/pgalloc.h
7109 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7110 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
7111 }
7112
7113 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7114 +{
7115 + pgd_populate(mm, pgd, pmd);
7116 +}
7117 +
7118 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
7119 {
7120 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
7121 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
7122 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
7123 #define pmd_free(mm, x) do { } while (0)
7124 #define pgd_populate(mm, pmd, pte) BUG()
7125 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
7126
7127 #endif
7128
7129 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
7130 index 1e40d7f..a3eb445 100644
7131 --- a/arch/parisc/include/asm/pgtable.h
7132 +++ b/arch/parisc/include/asm/pgtable.h
7133 @@ -223,6 +223,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
7134 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
7135 #define PAGE_COPY PAGE_EXECREAD
7136 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
7137 +
7138 +#ifdef CONFIG_PAX_PAGEEXEC
7139 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
7140 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7141 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7142 +#else
7143 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
7144 +# define PAGE_COPY_NOEXEC PAGE_COPY
7145 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
7146 +#endif
7147 +
7148 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
7149 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
7150 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
7151 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
7152 index e0a8235..ce2f1e1 100644
7153 --- a/arch/parisc/include/asm/uaccess.h
7154 +++ b/arch/parisc/include/asm/uaccess.h
7155 @@ -245,10 +245,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
7156 const void __user *from,
7157 unsigned long n)
7158 {
7159 - int sz = __compiletime_object_size(to);
7160 + size_t sz = __compiletime_object_size(to);
7161 int ret = -EFAULT;
7162
7163 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
7164 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
7165 ret = __copy_from_user(to, from, n);
7166 else
7167 copy_from_user_overflow();
7168 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
7169 index 2a625fb..9908930 100644
7170 --- a/arch/parisc/kernel/module.c
7171 +++ b/arch/parisc/kernel/module.c
7172 @@ -98,16 +98,38 @@
7173
7174 /* three functions to determine where in the module core
7175 * or init pieces the location is */
7176 +static inline int in_init_rx(struct module *me, void *loc)
7177 +{
7178 + return (loc >= me->module_init_rx &&
7179 + loc < (me->module_init_rx + me->init_size_rx));
7180 +}
7181 +
7182 +static inline int in_init_rw(struct module *me, void *loc)
7183 +{
7184 + return (loc >= me->module_init_rw &&
7185 + loc < (me->module_init_rw + me->init_size_rw));
7186 +}
7187 +
7188 static inline int in_init(struct module *me, void *loc)
7189 {
7190 - return (loc >= me->module_init &&
7191 - loc <= (me->module_init + me->init_size));
7192 + return in_init_rx(me, loc) || in_init_rw(me, loc);
7193 +}
7194 +
7195 +static inline int in_core_rx(struct module *me, void *loc)
7196 +{
7197 + return (loc >= me->module_core_rx &&
7198 + loc < (me->module_core_rx + me->core_size_rx));
7199 +}
7200 +
7201 +static inline int in_core_rw(struct module *me, void *loc)
7202 +{
7203 + return (loc >= me->module_core_rw &&
7204 + loc < (me->module_core_rw + me->core_size_rw));
7205 }
7206
7207 static inline int in_core(struct module *me, void *loc)
7208 {
7209 - return (loc >= me->module_core &&
7210 - loc <= (me->module_core + me->core_size));
7211 + return in_core_rx(me, loc) || in_core_rw(me, loc);
7212 }
7213
7214 static inline int in_local(struct module *me, void *loc)
7215 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
7216 }
7217
7218 /* align things a bit */
7219 - me->core_size = ALIGN(me->core_size, 16);
7220 - me->arch.got_offset = me->core_size;
7221 - me->core_size += gots * sizeof(struct got_entry);
7222 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
7223 + me->arch.got_offset = me->core_size_rw;
7224 + me->core_size_rw += gots * sizeof(struct got_entry);
7225
7226 - me->core_size = ALIGN(me->core_size, 16);
7227 - me->arch.fdesc_offset = me->core_size;
7228 - me->core_size += fdescs * sizeof(Elf_Fdesc);
7229 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
7230 + me->arch.fdesc_offset = me->core_size_rw;
7231 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
7232
7233 me->arch.got_max = gots;
7234 me->arch.fdesc_max = fdescs;
7235 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7236
7237 BUG_ON(value == 0);
7238
7239 - got = me->module_core + me->arch.got_offset;
7240 + got = me->module_core_rw + me->arch.got_offset;
7241 for (i = 0; got[i].addr; i++)
7242 if (got[i].addr == value)
7243 goto out;
7244 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7245 #ifdef CONFIG_64BIT
7246 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7247 {
7248 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
7249 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
7250
7251 if (!value) {
7252 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
7253 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7254
7255 /* Create new one */
7256 fdesc->addr = value;
7257 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7258 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7259 return (Elf_Addr)fdesc;
7260 }
7261 #endif /* CONFIG_64BIT */
7262 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
7263
7264 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
7265 end = table + sechdrs[me->arch.unwind_section].sh_size;
7266 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7267 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7268
7269 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
7270 me->arch.unwind_section, table, end, gp);
7271 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
7272 index 5dfd248..64914ac 100644
7273 --- a/arch/parisc/kernel/sys_parisc.c
7274 +++ b/arch/parisc/kernel/sys_parisc.c
7275 @@ -33,9 +33,11 @@
7276 #include <linux/utsname.h>
7277 #include <linux/personality.h>
7278
7279 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
7280 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
7281 + unsigned long flags)
7282 {
7283 struct vm_unmapped_area_info info;
7284 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7285
7286 info.flags = 0;
7287 info.length = len;
7288 @@ -43,6 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
7289 info.high_limit = TASK_SIZE;
7290 info.align_mask = 0;
7291 info.align_offset = 0;
7292 + info.threadstack_offset = offset;
7293 return vm_unmapped_area(&info);
7294 }
7295
7296 @@ -61,10 +64,11 @@ static int get_offset(struct address_space *mapping)
7297 return (unsigned long) mapping >> 8;
7298 }
7299
7300 -static unsigned long get_shared_area(struct address_space *mapping,
7301 - unsigned long addr, unsigned long len, unsigned long pgoff)
7302 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
7303 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
7304 {
7305 struct vm_unmapped_area_info info;
7306 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7307
7308 info.flags = 0;
7309 info.length = len;
7310 @@ -72,6 +76,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
7311 info.high_limit = TASK_SIZE;
7312 info.align_mask = PAGE_MASK & (SHMLBA - 1);
7313 info.align_offset = (get_offset(mapping) + pgoff) << PAGE_SHIFT;
7314 + info.threadstack_offset = offset;
7315 return vm_unmapped_area(&info);
7316 }
7317
7318 @@ -86,15 +91,22 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7319 return -EINVAL;
7320 return addr;
7321 }
7322 - if (!addr)
7323 + if (!addr) {
7324 addr = TASK_UNMAPPED_BASE;
7325
7326 +#ifdef CONFIG_PAX_RANDMMAP
7327 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
7328 + addr += current->mm->delta_mmap;
7329 +#endif
7330 +
7331 + }
7332 +
7333 if (filp) {
7334 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
7335 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
7336 } else if(flags & MAP_SHARED) {
7337 - addr = get_shared_area(NULL, addr, len, pgoff);
7338 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
7339 } else {
7340 - addr = get_unshared_area(addr, len);
7341 + addr = get_unshared_area(filp, addr, len, flags);
7342 }
7343 return addr;
7344 }
7345 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
7346 index 04e47c6..7a8faf6 100644
7347 --- a/arch/parisc/kernel/traps.c
7348 +++ b/arch/parisc/kernel/traps.c
7349 @@ -727,9 +727,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
7350
7351 down_read(&current->mm->mmap_sem);
7352 vma = find_vma(current->mm,regs->iaoq[0]);
7353 - if (vma && (regs->iaoq[0] >= vma->vm_start)
7354 - && (vma->vm_flags & VM_EXEC)) {
7355 -
7356 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
7357 fault_address = regs->iaoq[0];
7358 fault_space = regs->iasq[0];
7359
7360 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
7361 index f247a34..dc0f219 100644
7362 --- a/arch/parisc/mm/fault.c
7363 +++ b/arch/parisc/mm/fault.c
7364 @@ -15,6 +15,7 @@
7365 #include <linux/sched.h>
7366 #include <linux/interrupt.h>
7367 #include <linux/module.h>
7368 +#include <linux/unistd.h>
7369
7370 #include <asm/uaccess.h>
7371 #include <asm/traps.h>
7372 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
7373 static unsigned long
7374 parisc_acctyp(unsigned long code, unsigned int inst)
7375 {
7376 - if (code == 6 || code == 16)
7377 + if (code == 6 || code == 7 || code == 16)
7378 return VM_EXEC;
7379
7380 switch (inst & 0xf0000000) {
7381 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
7382 }
7383 #endif
7384
7385 +#ifdef CONFIG_PAX_PAGEEXEC
7386 +/*
7387 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
7388 + *
7389 + * returns 1 when task should be killed
7390 + * 2 when rt_sigreturn trampoline was detected
7391 + * 3 when unpatched PLT trampoline was detected
7392 + */
7393 +static int pax_handle_fetch_fault(struct pt_regs *regs)
7394 +{
7395 +
7396 +#ifdef CONFIG_PAX_EMUPLT
7397 + int err;
7398 +
7399 + do { /* PaX: unpatched PLT emulation */
7400 + unsigned int bl, depwi;
7401 +
7402 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
7403 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
7404 +
7405 + if (err)
7406 + break;
7407 +
7408 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
7409 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
7410 +
7411 + err = get_user(ldw, (unsigned int *)addr);
7412 + err |= get_user(bv, (unsigned int *)(addr+4));
7413 + err |= get_user(ldw2, (unsigned int *)(addr+8));
7414 +
7415 + if (err)
7416 + break;
7417 +
7418 + if (ldw == 0x0E801096U &&
7419 + bv == 0xEAC0C000U &&
7420 + ldw2 == 0x0E881095U)
7421 + {
7422 + unsigned int resolver, map;
7423 +
7424 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
7425 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
7426 + if (err)
7427 + break;
7428 +
7429 + regs->gr[20] = instruction_pointer(regs)+8;
7430 + regs->gr[21] = map;
7431 + regs->gr[22] = resolver;
7432 + regs->iaoq[0] = resolver | 3UL;
7433 + regs->iaoq[1] = regs->iaoq[0] + 4;
7434 + return 3;
7435 + }
7436 + }
7437 + } while (0);
7438 +#endif
7439 +
7440 +#ifdef CONFIG_PAX_EMUTRAMP
7441 +
7442 +#ifndef CONFIG_PAX_EMUSIGRT
7443 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
7444 + return 1;
7445 +#endif
7446 +
7447 + do { /* PaX: rt_sigreturn emulation */
7448 + unsigned int ldi1, ldi2, bel, nop;
7449 +
7450 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
7451 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
7452 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
7453 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
7454 +
7455 + if (err)
7456 + break;
7457 +
7458 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
7459 + ldi2 == 0x3414015AU &&
7460 + bel == 0xE4008200U &&
7461 + nop == 0x08000240U)
7462 + {
7463 + regs->gr[25] = (ldi1 & 2) >> 1;
7464 + regs->gr[20] = __NR_rt_sigreturn;
7465 + regs->gr[31] = regs->iaoq[1] + 16;
7466 + regs->sr[0] = regs->iasq[1];
7467 + regs->iaoq[0] = 0x100UL;
7468 + regs->iaoq[1] = regs->iaoq[0] + 4;
7469 + regs->iasq[0] = regs->sr[2];
7470 + regs->iasq[1] = regs->sr[2];
7471 + return 2;
7472 + }
7473 + } while (0);
7474 +#endif
7475 +
7476 + return 1;
7477 +}
7478 +
7479 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7480 +{
7481 + unsigned long i;
7482 +
7483 + printk(KERN_ERR "PAX: bytes at PC: ");
7484 + for (i = 0; i < 5; i++) {
7485 + unsigned int c;
7486 + if (get_user(c, (unsigned int *)pc+i))
7487 + printk(KERN_CONT "???????? ");
7488 + else
7489 + printk(KERN_CONT "%08x ", c);
7490 + }
7491 + printk("\n");
7492 +}
7493 +#endif
7494 +
7495 int fixup_exception(struct pt_regs *regs)
7496 {
7497 const struct exception_table_entry *fix;
7498 @@ -194,8 +305,33 @@ good_area:
7499
7500 acc_type = parisc_acctyp(code,regs->iir);
7501
7502 - if ((vma->vm_flags & acc_type) != acc_type)
7503 + if ((vma->vm_flags & acc_type) != acc_type) {
7504 +
7505 +#ifdef CONFIG_PAX_PAGEEXEC
7506 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
7507 + (address & ~3UL) == instruction_pointer(regs))
7508 + {
7509 + up_read(&mm->mmap_sem);
7510 + switch (pax_handle_fetch_fault(regs)) {
7511 +
7512 +#ifdef CONFIG_PAX_EMUPLT
7513 + case 3:
7514 + return;
7515 +#endif
7516 +
7517 +#ifdef CONFIG_PAX_EMUTRAMP
7518 + case 2:
7519 + return;
7520 +#endif
7521 +
7522 + }
7523 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
7524 + do_group_exit(SIGKILL);
7525 + }
7526 +#endif
7527 +
7528 goto bad_area;
7529 + }
7530
7531 /*
7532 * If for any reason at all we couldn't handle the fault, make
7533 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
7534 index e3b1d41..8e81edf 100644
7535 --- a/arch/powerpc/include/asm/atomic.h
7536 +++ b/arch/powerpc/include/asm/atomic.h
7537 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
7538 return t1;
7539 }
7540
7541 +#define atomic64_read_unchecked(v) atomic64_read(v)
7542 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7543 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7544 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7545 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7546 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7547 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7548 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7549 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7550 +
7551 #endif /* __powerpc64__ */
7552
7553 #endif /* __KERNEL__ */
7554 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
7555 index 9e495c9..b6878e5 100644
7556 --- a/arch/powerpc/include/asm/cache.h
7557 +++ b/arch/powerpc/include/asm/cache.h
7558 @@ -3,6 +3,7 @@
7559
7560 #ifdef __KERNEL__
7561
7562 +#include <linux/const.h>
7563
7564 /* bytes per L1 cache line */
7565 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
7566 @@ -22,7 +23,7 @@
7567 #define L1_CACHE_SHIFT 7
7568 #endif
7569
7570 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7571 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7572
7573 #define SMP_CACHE_BYTES L1_CACHE_BYTES
7574
7575 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
7576 index cc0655a..13eac2e 100644
7577 --- a/arch/powerpc/include/asm/elf.h
7578 +++ b/arch/powerpc/include/asm/elf.h
7579 @@ -28,8 +28,19 @@
7580 the loader. We need to make sure that it is out of the way of the program
7581 that it will "exec", and that there is sufficient room for the brk. */
7582
7583 -extern unsigned long randomize_et_dyn(unsigned long base);
7584 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
7585 +#define ELF_ET_DYN_BASE (0x20000000)
7586 +
7587 +#ifdef CONFIG_PAX_ASLR
7588 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
7589 +
7590 +#ifdef __powerpc64__
7591 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
7592 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
7593 +#else
7594 +#define PAX_DELTA_MMAP_LEN 15
7595 +#define PAX_DELTA_STACK_LEN 15
7596 +#endif
7597 +#endif
7598
7599 /*
7600 * Our registers are always unsigned longs, whether we're a 32 bit
7601 @@ -123,10 +134,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
7602 (0x7ff >> (PAGE_SHIFT - 12)) : \
7603 (0x3ffff >> (PAGE_SHIFT - 12)))
7604
7605 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7606 -#define arch_randomize_brk arch_randomize_brk
7607 -
7608 -
7609 #ifdef CONFIG_SPU_BASE
7610 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
7611 #define NT_SPU 1
7612 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
7613 index 8196e9c..d83a9f3 100644
7614 --- a/arch/powerpc/include/asm/exec.h
7615 +++ b/arch/powerpc/include/asm/exec.h
7616 @@ -4,6 +4,6 @@
7617 #ifndef _ASM_POWERPC_EXEC_H
7618 #define _ASM_POWERPC_EXEC_H
7619
7620 -extern unsigned long arch_align_stack(unsigned long sp);
7621 +#define arch_align_stack(x) ((x) & ~0xfUL)
7622
7623 #endif /* _ASM_POWERPC_EXEC_H */
7624 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
7625 index 5acabbd..7ea14fa 100644
7626 --- a/arch/powerpc/include/asm/kmap_types.h
7627 +++ b/arch/powerpc/include/asm/kmap_types.h
7628 @@ -10,7 +10,7 @@
7629 * 2 of the License, or (at your option) any later version.
7630 */
7631
7632 -#define KM_TYPE_NR 16
7633 +#define KM_TYPE_NR 17
7634
7635 #endif /* __KERNEL__ */
7636 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
7637 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
7638 index 8565c25..2865190 100644
7639 --- a/arch/powerpc/include/asm/mman.h
7640 +++ b/arch/powerpc/include/asm/mman.h
7641 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
7642 }
7643 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
7644
7645 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
7646 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
7647 {
7648 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
7649 }
7650 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
7651 index 988c812..63c7d70 100644
7652 --- a/arch/powerpc/include/asm/page.h
7653 +++ b/arch/powerpc/include/asm/page.h
7654 @@ -220,8 +220,9 @@ extern long long virt_phys_offset;
7655 * and needs to be executable. This means the whole heap ends
7656 * up being executable.
7657 */
7658 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
7659 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7660 +#define VM_DATA_DEFAULT_FLAGS32 \
7661 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
7662 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7663
7664 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
7665 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7666 @@ -249,6 +250,9 @@ extern long long virt_phys_offset;
7667 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
7668 #endif
7669
7670 +#define ktla_ktva(addr) (addr)
7671 +#define ktva_ktla(addr) (addr)
7672 +
7673 #ifndef CONFIG_PPC_BOOK3S_64
7674 /*
7675 * Use the top bit of the higher-level page table entries to indicate whether
7676 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
7677 index 88693ce..ac6f9ab 100644
7678 --- a/arch/powerpc/include/asm/page_64.h
7679 +++ b/arch/powerpc/include/asm/page_64.h
7680 @@ -153,15 +153,18 @@ do { \
7681 * stack by default, so in the absence of a PT_GNU_STACK program header
7682 * we turn execute permission off.
7683 */
7684 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
7685 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7686 +#define VM_STACK_DEFAULT_FLAGS32 \
7687 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
7688 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7689
7690 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
7691 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7692
7693 +#ifndef CONFIG_PAX_PAGEEXEC
7694 #define VM_STACK_DEFAULT_FLAGS \
7695 (is_32bit_task() ? \
7696 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
7697 +#endif
7698
7699 #include <asm-generic/getorder.h>
7700
7701 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
7702 index b66ae72..4a378cd 100644
7703 --- a/arch/powerpc/include/asm/pgalloc-64.h
7704 +++ b/arch/powerpc/include/asm/pgalloc-64.h
7705 @@ -53,6 +53,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
7706 #ifndef CONFIG_PPC_64K_PAGES
7707
7708 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
7709 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
7710
7711 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
7712 {
7713 @@ -70,6 +71,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
7714 pud_set(pud, (unsigned long)pmd);
7715 }
7716
7717 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
7718 +{
7719 + pud_populate(mm, pud, pmd);
7720 +}
7721 +
7722 #define pmd_populate(mm, pmd, pte_page) \
7723 pmd_populate_kernel(mm, pmd, page_address(pte_page))
7724 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
7725 @@ -171,6 +177,7 @@ extern void __tlb_remove_table(void *_table);
7726 #endif
7727
7728 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
7729 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
7730
7731 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
7732 pte_t *pte)
7733 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
7734 index 7aeb955..19f748e 100644
7735 --- a/arch/powerpc/include/asm/pgtable.h
7736 +++ b/arch/powerpc/include/asm/pgtable.h
7737 @@ -2,6 +2,7 @@
7738 #define _ASM_POWERPC_PGTABLE_H
7739 #ifdef __KERNEL__
7740
7741 +#include <linux/const.h>
7742 #ifndef __ASSEMBLY__
7743 #include <asm/processor.h> /* For TASK_SIZE */
7744 #include <asm/mmu.h>
7745 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
7746 index 4aad413..85d86bf 100644
7747 --- a/arch/powerpc/include/asm/pte-hash32.h
7748 +++ b/arch/powerpc/include/asm/pte-hash32.h
7749 @@ -21,6 +21,7 @@
7750 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
7751 #define _PAGE_USER 0x004 /* usermode access allowed */
7752 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
7753 +#define _PAGE_EXEC _PAGE_GUARDED
7754 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
7755 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
7756 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
7757 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
7758 index e1fb161..2290d1d 100644
7759 --- a/arch/powerpc/include/asm/reg.h
7760 +++ b/arch/powerpc/include/asm/reg.h
7761 @@ -234,6 +234,7 @@
7762 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
7763 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
7764 #define DSISR_NOHPTE 0x40000000 /* no translation found */
7765 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
7766 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
7767 #define DSISR_ISSTORE 0x02000000 /* access was a store */
7768 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
7769 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
7770 index 48cfc85..891382f 100644
7771 --- a/arch/powerpc/include/asm/smp.h
7772 +++ b/arch/powerpc/include/asm/smp.h
7773 @@ -50,7 +50,7 @@ struct smp_ops_t {
7774 int (*cpu_disable)(void);
7775 void (*cpu_die)(unsigned int nr);
7776 int (*cpu_bootable)(unsigned int nr);
7777 -};
7778 +} __no_const;
7779
7780 extern void smp_send_debugger_break(void);
7781 extern void start_secondary_resume(void);
7782 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
7783 index ba7b197..d292e26 100644
7784 --- a/arch/powerpc/include/asm/thread_info.h
7785 +++ b/arch/powerpc/include/asm/thread_info.h
7786 @@ -93,7 +93,6 @@ static inline struct thread_info *current_thread_info(void)
7787 #define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
7788 TIF_NEED_RESCHED */
7789 #define TIF_32BIT 4 /* 32 bit binary */
7790 -#define TIF_PERFMON_WORK 5 /* work for pfm_handle_work() */
7791 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
7792 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
7793 #define TIF_SINGLESTEP 8 /* singlestepping active */
7794 @@ -107,6 +106,9 @@ static inline struct thread_info *current_thread_info(void)
7795 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
7796 for stack store? */
7797 #define TIF_MEMDIE 17 /* is terminating due to OOM killer */
7798 +#define TIF_PERFMON_WORK 18 /* work for pfm_handle_work() */
7799 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
7800 +#define TIF_GRSEC_SETXID 5 /* update credentials on syscall entry/exit */
7801
7802 /* as above, but as bit values */
7803 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
7804 @@ -126,9 +128,10 @@ static inline struct thread_info *current_thread_info(void)
7805 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
7806 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
7807 #define _TIF_NOHZ (1<<TIF_NOHZ)
7808 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
7809 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
7810 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
7811 - _TIF_NOHZ)
7812 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
7813
7814 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
7815 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
7816 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
7817 index 4db4959..aba5c41 100644
7818 --- a/arch/powerpc/include/asm/uaccess.h
7819 +++ b/arch/powerpc/include/asm/uaccess.h
7820 @@ -318,52 +318,6 @@ do { \
7821 extern unsigned long __copy_tofrom_user(void __user *to,
7822 const void __user *from, unsigned long size);
7823
7824 -#ifndef __powerpc64__
7825 -
7826 -static inline unsigned long copy_from_user(void *to,
7827 - const void __user *from, unsigned long n)
7828 -{
7829 - unsigned long over;
7830 -
7831 - if (access_ok(VERIFY_READ, from, n))
7832 - return __copy_tofrom_user((__force void __user *)to, from, n);
7833 - if ((unsigned long)from < TASK_SIZE) {
7834 - over = (unsigned long)from + n - TASK_SIZE;
7835 - return __copy_tofrom_user((__force void __user *)to, from,
7836 - n - over) + over;
7837 - }
7838 - return n;
7839 -}
7840 -
7841 -static inline unsigned long copy_to_user(void __user *to,
7842 - const void *from, unsigned long n)
7843 -{
7844 - unsigned long over;
7845 -
7846 - if (access_ok(VERIFY_WRITE, to, n))
7847 - return __copy_tofrom_user(to, (__force void __user *)from, n);
7848 - if ((unsigned long)to < TASK_SIZE) {
7849 - over = (unsigned long)to + n - TASK_SIZE;
7850 - return __copy_tofrom_user(to, (__force void __user *)from,
7851 - n - over) + over;
7852 - }
7853 - return n;
7854 -}
7855 -
7856 -#else /* __powerpc64__ */
7857 -
7858 -#define __copy_in_user(to, from, size) \
7859 - __copy_tofrom_user((to), (from), (size))
7860 -
7861 -extern unsigned long copy_from_user(void *to, const void __user *from,
7862 - unsigned long n);
7863 -extern unsigned long copy_to_user(void __user *to, const void *from,
7864 - unsigned long n);
7865 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
7866 - unsigned long n);
7867 -
7868 -#endif /* __powerpc64__ */
7869 -
7870 static inline unsigned long __copy_from_user_inatomic(void *to,
7871 const void __user *from, unsigned long n)
7872 {
7873 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
7874 if (ret == 0)
7875 return 0;
7876 }
7877 +
7878 + if (!__builtin_constant_p(n))
7879 + check_object_size(to, n, false);
7880 +
7881 return __copy_tofrom_user((__force void __user *)to, from, n);
7882 }
7883
7884 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
7885 if (ret == 0)
7886 return 0;
7887 }
7888 +
7889 + if (!__builtin_constant_p(n))
7890 + check_object_size(from, n, true);
7891 +
7892 return __copy_tofrom_user(to, (__force const void __user *)from, n);
7893 }
7894
7895 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
7896 return __copy_to_user_inatomic(to, from, size);
7897 }
7898
7899 +#ifndef __powerpc64__
7900 +
7901 +static inline unsigned long __must_check copy_from_user(void *to,
7902 + const void __user *from, unsigned long n)
7903 +{
7904 + unsigned long over;
7905 +
7906 + if ((long)n < 0)
7907 + return n;
7908 +
7909 + if (access_ok(VERIFY_READ, from, n)) {
7910 + if (!__builtin_constant_p(n))
7911 + check_object_size(to, n, false);
7912 + return __copy_tofrom_user((__force void __user *)to, from, n);
7913 + }
7914 + if ((unsigned long)from < TASK_SIZE) {
7915 + over = (unsigned long)from + n - TASK_SIZE;
7916 + if (!__builtin_constant_p(n - over))
7917 + check_object_size(to, n - over, false);
7918 + return __copy_tofrom_user((__force void __user *)to, from,
7919 + n - over) + over;
7920 + }
7921 + return n;
7922 +}
7923 +
7924 +static inline unsigned long __must_check copy_to_user(void __user *to,
7925 + const void *from, unsigned long n)
7926 +{
7927 + unsigned long over;
7928 +
7929 + if ((long)n < 0)
7930 + return n;
7931 +
7932 + if (access_ok(VERIFY_WRITE, to, n)) {
7933 + if (!__builtin_constant_p(n))
7934 + check_object_size(from, n, true);
7935 + return __copy_tofrom_user(to, (__force void __user *)from, n);
7936 + }
7937 + if ((unsigned long)to < TASK_SIZE) {
7938 + over = (unsigned long)to + n - TASK_SIZE;
7939 + if (!__builtin_constant_p(n))
7940 + check_object_size(from, n - over, true);
7941 + return __copy_tofrom_user(to, (__force void __user *)from,
7942 + n - over) + over;
7943 + }
7944 + return n;
7945 +}
7946 +
7947 +#else /* __powerpc64__ */
7948 +
7949 +#define __copy_in_user(to, from, size) \
7950 + __copy_tofrom_user((to), (from), (size))
7951 +
7952 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
7953 +{
7954 + if ((long)n < 0 || n > INT_MAX)
7955 + return n;
7956 +
7957 + if (!__builtin_constant_p(n))
7958 + check_object_size(to, n, false);
7959 +
7960 + if (likely(access_ok(VERIFY_READ, from, n)))
7961 + n = __copy_from_user(to, from, n);
7962 + else
7963 + memset(to, 0, n);
7964 + return n;
7965 +}
7966 +
7967 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
7968 +{
7969 + if ((long)n < 0 || n > INT_MAX)
7970 + return n;
7971 +
7972 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
7973 + if (!__builtin_constant_p(n))
7974 + check_object_size(from, n, true);
7975 + n = __copy_to_user(to, from, n);
7976 + }
7977 + return n;
7978 +}
7979 +
7980 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
7981 + unsigned long n);
7982 +
7983 +#endif /* __powerpc64__ */
7984 +
7985 extern unsigned long __clear_user(void __user *addr, unsigned long size);
7986
7987 static inline unsigned long clear_user(void __user *addr, unsigned long size)
7988 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
7989 index 645170a..6cf0271 100644
7990 --- a/arch/powerpc/kernel/exceptions-64e.S
7991 +++ b/arch/powerpc/kernel/exceptions-64e.S
7992 @@ -757,6 +757,7 @@ storage_fault_common:
7993 std r14,_DAR(r1)
7994 std r15,_DSISR(r1)
7995 addi r3,r1,STACK_FRAME_OVERHEAD
7996 + bl .save_nvgprs
7997 mr r4,r14
7998 mr r5,r15
7999 ld r14,PACA_EXGEN+EX_R14(r13)
8000 @@ -765,8 +766,7 @@ storage_fault_common:
8001 cmpdi r3,0
8002 bne- 1f
8003 b .ret_from_except_lite
8004 -1: bl .save_nvgprs
8005 - mr r5,r3
8006 +1: mr r5,r3
8007 addi r3,r1,STACK_FRAME_OVERHEAD
8008 ld r4,_DAR(r1)
8009 bl .bad_page_fault
8010 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
8011 index 902ca3c..e942155 100644
8012 --- a/arch/powerpc/kernel/exceptions-64s.S
8013 +++ b/arch/powerpc/kernel/exceptions-64s.S
8014 @@ -1357,10 +1357,10 @@ handle_page_fault:
8015 11: ld r4,_DAR(r1)
8016 ld r5,_DSISR(r1)
8017 addi r3,r1,STACK_FRAME_OVERHEAD
8018 + bl .save_nvgprs
8019 bl .do_page_fault
8020 cmpdi r3,0
8021 beq+ 12f
8022 - bl .save_nvgprs
8023 mr r5,r3
8024 addi r3,r1,STACK_FRAME_OVERHEAD
8025 lwz r4,_DAR(r1)
8026 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
8027 index 2e3200c..72095ce 100644
8028 --- a/arch/powerpc/kernel/module_32.c
8029 +++ b/arch/powerpc/kernel/module_32.c
8030 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
8031 me->arch.core_plt_section = i;
8032 }
8033 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
8034 - printk("Module doesn't contain .plt or .init.plt sections.\n");
8035 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
8036 return -ENOEXEC;
8037 }
8038
8039 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
8040
8041 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
8042 /* Init, or core PLT? */
8043 - if (location >= mod->module_core
8044 - && location < mod->module_core + mod->core_size)
8045 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
8046 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
8047 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
8048 - else
8049 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
8050 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
8051 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
8052 + else {
8053 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
8054 + return ~0UL;
8055 + }
8056
8057 /* Find this entry, or if that fails, the next avail. entry */
8058 while (entry->jump[0]) {
8059 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
8060 index 7baa27b..f6b394a 100644
8061 --- a/arch/powerpc/kernel/process.c
8062 +++ b/arch/powerpc/kernel/process.c
8063 @@ -884,8 +884,8 @@ void show_regs(struct pt_regs * regs)
8064 * Lookup NIP late so we have the best change of getting the
8065 * above info out without failing
8066 */
8067 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
8068 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
8069 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
8070 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
8071 #endif
8072 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
8073 printk("PACATMSCRATCH [%llx]\n", get_paca()->tm_scratch);
8074 @@ -1345,10 +1345,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
8075 newsp = stack[0];
8076 ip = stack[STACK_FRAME_LR_SAVE];
8077 if (!firstframe || ip != lr) {
8078 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
8079 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
8080 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
8081 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
8082 - printk(" (%pS)",
8083 + printk(" (%pA)",
8084 (void *)current->ret_stack[curr_frame].ret);
8085 curr_frame--;
8086 }
8087 @@ -1368,7 +1368,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
8088 struct pt_regs *regs = (struct pt_regs *)
8089 (sp + STACK_FRAME_OVERHEAD);
8090 lr = regs->link;
8091 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
8092 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
8093 regs->trap, (void *)regs->nip, (void *)lr);
8094 firstframe = 1;
8095 }
8096 @@ -1404,58 +1404,3 @@ void notrace __ppc64_runlatch_off(void)
8097 mtspr(SPRN_CTRLT, ctrl);
8098 }
8099 #endif /* CONFIG_PPC64 */
8100 -
8101 -unsigned long arch_align_stack(unsigned long sp)
8102 -{
8103 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
8104 - sp -= get_random_int() & ~PAGE_MASK;
8105 - return sp & ~0xf;
8106 -}
8107 -
8108 -static inline unsigned long brk_rnd(void)
8109 -{
8110 - unsigned long rnd = 0;
8111 -
8112 - /* 8MB for 32bit, 1GB for 64bit */
8113 - if (is_32bit_task())
8114 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
8115 - else
8116 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
8117 -
8118 - return rnd << PAGE_SHIFT;
8119 -}
8120 -
8121 -unsigned long arch_randomize_brk(struct mm_struct *mm)
8122 -{
8123 - unsigned long base = mm->brk;
8124 - unsigned long ret;
8125 -
8126 -#ifdef CONFIG_PPC_STD_MMU_64
8127 - /*
8128 - * If we are using 1TB segments and we are allowed to randomise
8129 - * the heap, we can put it above 1TB so it is backed by a 1TB
8130 - * segment. Otherwise the heap will be in the bottom 1TB
8131 - * which always uses 256MB segments and this may result in a
8132 - * performance penalty.
8133 - */
8134 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
8135 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
8136 -#endif
8137 -
8138 - ret = PAGE_ALIGN(base + brk_rnd());
8139 -
8140 - if (ret < mm->brk)
8141 - return mm->brk;
8142 -
8143 - return ret;
8144 -}
8145 -
8146 -unsigned long randomize_et_dyn(unsigned long base)
8147 -{
8148 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
8149 -
8150 - if (ret < base)
8151 - return base;
8152 -
8153 - return ret;
8154 -}
8155 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
8156 index 64f7bd5..8dd550f 100644
8157 --- a/arch/powerpc/kernel/ptrace.c
8158 +++ b/arch/powerpc/kernel/ptrace.c
8159 @@ -1783,6 +1783,10 @@ long arch_ptrace(struct task_struct *child, long request,
8160 return ret;
8161 }
8162
8163 +#ifdef CONFIG_GRKERNSEC_SETXID
8164 +extern void gr_delayed_cred_worker(void);
8165 +#endif
8166 +
8167 /*
8168 * We must return the syscall number to actually look up in the table.
8169 * This can be -1L to skip running any syscall at all.
8170 @@ -1795,6 +1799,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
8171
8172 secure_computing_strict(regs->gpr[0]);
8173
8174 +#ifdef CONFIG_GRKERNSEC_SETXID
8175 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8176 + gr_delayed_cred_worker();
8177 +#endif
8178 +
8179 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
8180 tracehook_report_syscall_entry(regs))
8181 /*
8182 @@ -1829,6 +1838,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
8183 {
8184 int step;
8185
8186 +#ifdef CONFIG_GRKERNSEC_SETXID
8187 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8188 + gr_delayed_cred_worker();
8189 +#endif
8190 +
8191 audit_syscall_exit(regs);
8192
8193 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8194 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
8195 index 0f83122..c0aca6a 100644
8196 --- a/arch/powerpc/kernel/signal_32.c
8197 +++ b/arch/powerpc/kernel/signal_32.c
8198 @@ -987,7 +987,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
8199 /* Save user registers on the stack */
8200 frame = &rt_sf->uc.uc_mcontext;
8201 addr = frame;
8202 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
8203 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8204 sigret = 0;
8205 tramp = current->mm->context.vdso_base + vdso32_rt_sigtramp;
8206 } else {
8207 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
8208 index 887e99d..310bc11 100644
8209 --- a/arch/powerpc/kernel/signal_64.c
8210 +++ b/arch/powerpc/kernel/signal_64.c
8211 @@ -751,7 +751,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
8212 #endif
8213
8214 /* Set up to return from userspace. */
8215 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
8216 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8217 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
8218 } else {
8219 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
8220 diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
8221 index e68a845..8b140e6 100644
8222 --- a/arch/powerpc/kernel/sysfs.c
8223 +++ b/arch/powerpc/kernel/sysfs.c
8224 @@ -522,7 +522,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
8225 return NOTIFY_OK;
8226 }
8227
8228 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
8229 +static struct notifier_block sysfs_cpu_nb = {
8230 .notifier_call = sysfs_cpu_notify,
8231 };
8232
8233 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
8234 index 88929b1..bece8f8 100644
8235 --- a/arch/powerpc/kernel/traps.c
8236 +++ b/arch/powerpc/kernel/traps.c
8237 @@ -141,6 +141,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
8238 return flags;
8239 }
8240
8241 +extern void gr_handle_kernel_exploit(void);
8242 +
8243 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8244 int signr)
8245 {
8246 @@ -190,6 +192,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8247 panic("Fatal exception in interrupt");
8248 if (panic_on_oops)
8249 panic("Fatal exception");
8250 +
8251 + gr_handle_kernel_exploit();
8252 +
8253 do_exit(signr);
8254 }
8255
8256 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
8257 index d4f463a..8fb7431 100644
8258 --- a/arch/powerpc/kernel/vdso.c
8259 +++ b/arch/powerpc/kernel/vdso.c
8260 @@ -34,6 +34,7 @@
8261 #include <asm/firmware.h>
8262 #include <asm/vdso.h>
8263 #include <asm/vdso_datapage.h>
8264 +#include <asm/mman.h>
8265
8266 #include "setup.h"
8267
8268 @@ -222,7 +223,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8269 vdso_base = VDSO32_MBASE;
8270 #endif
8271
8272 - current->mm->context.vdso_base = 0;
8273 + current->mm->context.vdso_base = ~0UL;
8274
8275 /* vDSO has a problem and was disabled, just don't "enable" it for the
8276 * process
8277 @@ -242,7 +243,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8278 vdso_base = get_unmapped_area(NULL, vdso_base,
8279 (vdso_pages << PAGE_SHIFT) +
8280 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
8281 - 0, 0);
8282 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
8283 if (IS_ERR_VALUE(vdso_base)) {
8284 rc = vdso_base;
8285 goto fail_mmapsem;
8286 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
8287 index 5eea6f3..5d10396 100644
8288 --- a/arch/powerpc/lib/usercopy_64.c
8289 +++ b/arch/powerpc/lib/usercopy_64.c
8290 @@ -9,22 +9,6 @@
8291 #include <linux/module.h>
8292 #include <asm/uaccess.h>
8293
8294 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8295 -{
8296 - if (likely(access_ok(VERIFY_READ, from, n)))
8297 - n = __copy_from_user(to, from, n);
8298 - else
8299 - memset(to, 0, n);
8300 - return n;
8301 -}
8302 -
8303 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8304 -{
8305 - if (likely(access_ok(VERIFY_WRITE, to, n)))
8306 - n = __copy_to_user(to, from, n);
8307 - return n;
8308 -}
8309 -
8310 unsigned long copy_in_user(void __user *to, const void __user *from,
8311 unsigned long n)
8312 {
8313 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
8314 return n;
8315 }
8316
8317 -EXPORT_SYMBOL(copy_from_user);
8318 -EXPORT_SYMBOL(copy_to_user);
8319 EXPORT_SYMBOL(copy_in_user);
8320
8321 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
8322 index 8726779..a33c512 100644
8323 --- a/arch/powerpc/mm/fault.c
8324 +++ b/arch/powerpc/mm/fault.c
8325 @@ -33,6 +33,10 @@
8326 #include <linux/magic.h>
8327 #include <linux/ratelimit.h>
8328 #include <linux/context_tracking.h>
8329 +#include <linux/slab.h>
8330 +#include <linux/pagemap.h>
8331 +#include <linux/compiler.h>
8332 +#include <linux/unistd.h>
8333
8334 #include <asm/firmware.h>
8335 #include <asm/page.h>
8336 @@ -69,6 +73,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
8337 }
8338 #endif
8339
8340 +#ifdef CONFIG_PAX_PAGEEXEC
8341 +/*
8342 + * PaX: decide what to do with offenders (regs->nip = fault address)
8343 + *
8344 + * returns 1 when task should be killed
8345 + */
8346 +static int pax_handle_fetch_fault(struct pt_regs *regs)
8347 +{
8348 + return 1;
8349 +}
8350 +
8351 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
8352 +{
8353 + unsigned long i;
8354 +
8355 + printk(KERN_ERR "PAX: bytes at PC: ");
8356 + for (i = 0; i < 5; i++) {
8357 + unsigned int c;
8358 + if (get_user(c, (unsigned int __user *)pc+i))
8359 + printk(KERN_CONT "???????? ");
8360 + else
8361 + printk(KERN_CONT "%08x ", c);
8362 + }
8363 + printk("\n");
8364 +}
8365 +#endif
8366 +
8367 /*
8368 * Check whether the instruction at regs->nip is a store using
8369 * an update addressing form which will update r1.
8370 @@ -216,7 +247,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
8371 * indicate errors in DSISR but can validly be set in SRR1.
8372 */
8373 if (trap == 0x400)
8374 - error_code &= 0x48200000;
8375 + error_code &= 0x58200000;
8376 else
8377 is_write = error_code & DSISR_ISSTORE;
8378 #else
8379 @@ -371,7 +402,7 @@ good_area:
8380 * "undefined". Of those that can be set, this is the only
8381 * one which seems bad.
8382 */
8383 - if (error_code & 0x10000000)
8384 + if (error_code & DSISR_GUARDED)
8385 /* Guarded storage error. */
8386 goto bad_area;
8387 #endif /* CONFIG_8xx */
8388 @@ -386,7 +417,7 @@ good_area:
8389 * processors use the same I/D cache coherency mechanism
8390 * as embedded.
8391 */
8392 - if (error_code & DSISR_PROTFAULT)
8393 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
8394 goto bad_area;
8395 #endif /* CONFIG_PPC_STD_MMU */
8396
8397 @@ -471,6 +502,23 @@ bad_area:
8398 bad_area_nosemaphore:
8399 /* User mode accesses cause a SIGSEGV */
8400 if (user_mode(regs)) {
8401 +
8402 +#ifdef CONFIG_PAX_PAGEEXEC
8403 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
8404 +#ifdef CONFIG_PPC_STD_MMU
8405 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
8406 +#else
8407 + if (is_exec && regs->nip == address) {
8408 +#endif
8409 + switch (pax_handle_fetch_fault(regs)) {
8410 + }
8411 +
8412 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
8413 + do_group_exit(SIGKILL);
8414 + }
8415 + }
8416 +#endif
8417 +
8418 _exception(SIGSEGV, regs, code, address);
8419 goto bail;
8420 }
8421 diff --git a/arch/powerpc/mm/mmap_64.c b/arch/powerpc/mm/mmap_64.c
8422 index 67a42ed..cd463e0 100644
8423 --- a/arch/powerpc/mm/mmap_64.c
8424 +++ b/arch/powerpc/mm/mmap_64.c
8425 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
8426 {
8427 unsigned long rnd = 0;
8428
8429 +#ifdef CONFIG_PAX_RANDMMAP
8430 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8431 +#endif
8432 +
8433 if (current->flags & PF_RANDOMIZE) {
8434 /* 8MB for 32bit, 1GB for 64bit */
8435 if (is_32bit_task())
8436 @@ -91,10 +95,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8437 */
8438 if (mmap_is_legacy()) {
8439 mm->mmap_base = TASK_UNMAPPED_BASE;
8440 +
8441 +#ifdef CONFIG_PAX_RANDMMAP
8442 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8443 + mm->mmap_base += mm->delta_mmap;
8444 +#endif
8445 +
8446 mm->get_unmapped_area = arch_get_unmapped_area;
8447 mm->unmap_area = arch_unmap_area;
8448 } else {
8449 mm->mmap_base = mmap_base();
8450 +
8451 +#ifdef CONFIG_PAX_RANDMMAP
8452 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8453 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8454 +#endif
8455 +
8456 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8457 mm->unmap_area = arch_unmap_area_topdown;
8458 }
8459 diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/mmu_context_nohash.c
8460 index e779642..e5bb889 100644
8461 --- a/arch/powerpc/mm/mmu_context_nohash.c
8462 +++ b/arch/powerpc/mm/mmu_context_nohash.c
8463 @@ -363,7 +363,7 @@ static int __cpuinit mmu_context_cpu_notify(struct notifier_block *self,
8464 return NOTIFY_OK;
8465 }
8466
8467 -static struct notifier_block __cpuinitdata mmu_context_cpu_nb = {
8468 +static struct notifier_block mmu_context_cpu_nb = {
8469 .notifier_call = mmu_context_cpu_notify,
8470 };
8471
8472 diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
8473 index cafad40..9cbc0fc 100644
8474 --- a/arch/powerpc/mm/numa.c
8475 +++ b/arch/powerpc/mm/numa.c
8476 @@ -920,7 +920,7 @@ static void __init *careful_zallocation(int nid, unsigned long size,
8477 return ret;
8478 }
8479
8480 -static struct notifier_block __cpuinitdata ppc64_numa_nb = {
8481 +static struct notifier_block ppc64_numa_nb = {
8482 .notifier_call = cpu_numa_callback,
8483 .priority = 1 /* Must run before sched domains notifier. */
8484 };
8485 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
8486 index 3e99c14..f00953c 100644
8487 --- a/arch/powerpc/mm/slice.c
8488 +++ b/arch/powerpc/mm/slice.c
8489 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
8490 if ((mm->task_size - len) < addr)
8491 return 0;
8492 vma = find_vma(mm, addr);
8493 - return (!vma || (addr + len) <= vma->vm_start);
8494 + return check_heap_stack_gap(vma, addr, len, 0);
8495 }
8496
8497 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
8498 @@ -277,6 +277,12 @@ static unsigned long slice_find_area_bottomup(struct mm_struct *mm,
8499 info.align_offset = 0;
8500
8501 addr = TASK_UNMAPPED_BASE;
8502 +
8503 +#ifdef CONFIG_PAX_RANDMMAP
8504 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8505 + addr += mm->delta_mmap;
8506 +#endif
8507 +
8508 while (addr < TASK_SIZE) {
8509 info.low_limit = addr;
8510 if (!slice_scan_available(addr, available, 1, &addr))
8511 @@ -410,6 +416,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
8512 if (fixed && addr > (mm->task_size - len))
8513 return -EINVAL;
8514
8515 +#ifdef CONFIG_PAX_RANDMMAP
8516 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
8517 + addr = 0;
8518 +#endif
8519 +
8520 /* If hint, make sure it matches our alignment restrictions */
8521 if (!fixed && addr) {
8522 addr = _ALIGN_UP(addr, 1ul << pshift);
8523 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
8524 index 9098692..3d54cd1 100644
8525 --- a/arch/powerpc/platforms/cell/spufs/file.c
8526 +++ b/arch/powerpc/platforms/cell/spufs/file.c
8527 @@ -280,9 +280,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
8528 return VM_FAULT_NOPAGE;
8529 }
8530
8531 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
8532 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
8533 unsigned long address,
8534 - void *buf, int len, int write)
8535 + void *buf, size_t len, int write)
8536 {
8537 struct spu_context *ctx = vma->vm_file->private_data;
8538 unsigned long offset = address - vma->vm_start;
8539 diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
8540 index bdb738a..49c9f95 100644
8541 --- a/arch/powerpc/platforms/powermac/smp.c
8542 +++ b/arch/powerpc/platforms/powermac/smp.c
8543 @@ -885,7 +885,7 @@ static int smp_core99_cpu_notify(struct notifier_block *self,
8544 return NOTIFY_OK;
8545 }
8546
8547 -static struct notifier_block __cpuinitdata smp_core99_cpu_nb = {
8548 +static struct notifier_block smp_core99_cpu_nb = {
8549 .notifier_call = smp_core99_cpu_notify,
8550 };
8551 #endif /* CONFIG_HOTPLUG_CPU */
8552 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
8553 index c797832..ce575c8 100644
8554 --- a/arch/s390/include/asm/atomic.h
8555 +++ b/arch/s390/include/asm/atomic.h
8556 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
8557 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
8558 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
8559
8560 +#define atomic64_read_unchecked(v) atomic64_read(v)
8561 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
8562 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
8563 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
8564 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
8565 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
8566 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
8567 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
8568 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
8569 +
8570 #define smp_mb__before_atomic_dec() smp_mb()
8571 #define smp_mb__after_atomic_dec() smp_mb()
8572 #define smp_mb__before_atomic_inc() smp_mb()
8573 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
8574 index 4d7ccac..d03d0ad 100644
8575 --- a/arch/s390/include/asm/cache.h
8576 +++ b/arch/s390/include/asm/cache.h
8577 @@ -9,8 +9,10 @@
8578 #ifndef __ARCH_S390_CACHE_H
8579 #define __ARCH_S390_CACHE_H
8580
8581 -#define L1_CACHE_BYTES 256
8582 +#include <linux/const.h>
8583 +
8584 #define L1_CACHE_SHIFT 8
8585 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8586 #define NET_SKB_PAD 32
8587
8588 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
8589 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
8590 index 78f4f87..598ce39 100644
8591 --- a/arch/s390/include/asm/elf.h
8592 +++ b/arch/s390/include/asm/elf.h
8593 @@ -162,8 +162,14 @@ extern unsigned int vdso_enabled;
8594 the loader. We need to make sure that it is out of the way of the program
8595 that it will "exec", and that there is sufficient room for the brk. */
8596
8597 -extern unsigned long randomize_et_dyn(unsigned long base);
8598 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
8599 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
8600 +
8601 +#ifdef CONFIG_PAX_ASLR
8602 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
8603 +
8604 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
8605 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
8606 +#endif
8607
8608 /* This yields a mask that user programs can use to figure out what
8609 instruction set this CPU supports. */
8610 @@ -222,9 +228,6 @@ struct linux_binprm;
8611 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
8612 int arch_setup_additional_pages(struct linux_binprm *, int);
8613
8614 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
8615 -#define arch_randomize_brk arch_randomize_brk
8616 -
8617 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
8618
8619 #endif
8620 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
8621 index c4a93d6..4d2a9b4 100644
8622 --- a/arch/s390/include/asm/exec.h
8623 +++ b/arch/s390/include/asm/exec.h
8624 @@ -7,6 +7,6 @@
8625 #ifndef __ASM_EXEC_H
8626 #define __ASM_EXEC_H
8627
8628 -extern unsigned long arch_align_stack(unsigned long sp);
8629 +#define arch_align_stack(x) ((x) & ~0xfUL)
8630
8631 #endif /* __ASM_EXEC_H */
8632 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
8633 index 9c33ed4..e40cbef 100644
8634 --- a/arch/s390/include/asm/uaccess.h
8635 +++ b/arch/s390/include/asm/uaccess.h
8636 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
8637 copy_to_user(void __user *to, const void *from, unsigned long n)
8638 {
8639 might_fault();
8640 +
8641 + if ((long)n < 0)
8642 + return n;
8643 +
8644 return __copy_to_user(to, from, n);
8645 }
8646
8647 @@ -275,6 +279,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
8648 static inline unsigned long __must_check
8649 __copy_from_user(void *to, const void __user *from, unsigned long n)
8650 {
8651 + if ((long)n < 0)
8652 + return n;
8653 +
8654 if (__builtin_constant_p(n) && (n <= 256))
8655 return uaccess.copy_from_user_small(n, from, to);
8656 else
8657 @@ -306,10 +313,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
8658 static inline unsigned long __must_check
8659 copy_from_user(void *to, const void __user *from, unsigned long n)
8660 {
8661 - unsigned int sz = __compiletime_object_size(to);
8662 + size_t sz = __compiletime_object_size(to);
8663
8664 might_fault();
8665 - if (unlikely(sz != -1 && sz < n)) {
8666 +
8667 + if ((long)n < 0)
8668 + return n;
8669 +
8670 + if (unlikely(sz != (size_t)-1 && sz < n)) {
8671 copy_from_user_overflow();
8672 return n;
8673 }
8674 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
8675 index 7845e15..59c4353 100644
8676 --- a/arch/s390/kernel/module.c
8677 +++ b/arch/s390/kernel/module.c
8678 @@ -169,11 +169,11 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
8679
8680 /* Increase core size by size of got & plt and set start
8681 offsets for got and plt. */
8682 - me->core_size = ALIGN(me->core_size, 4);
8683 - me->arch.got_offset = me->core_size;
8684 - me->core_size += me->arch.got_size;
8685 - me->arch.plt_offset = me->core_size;
8686 - me->core_size += me->arch.plt_size;
8687 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
8688 + me->arch.got_offset = me->core_size_rw;
8689 + me->core_size_rw += me->arch.got_size;
8690 + me->arch.plt_offset = me->core_size_rx;
8691 + me->core_size_rx += me->arch.plt_size;
8692 return 0;
8693 }
8694
8695 @@ -289,7 +289,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8696 if (info->got_initialized == 0) {
8697 Elf_Addr *gotent;
8698
8699 - gotent = me->module_core + me->arch.got_offset +
8700 + gotent = me->module_core_rw + me->arch.got_offset +
8701 info->got_offset;
8702 *gotent = val;
8703 info->got_initialized = 1;
8704 @@ -312,7 +312,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8705 rc = apply_rela_bits(loc, val, 0, 64, 0);
8706 else if (r_type == R_390_GOTENT ||
8707 r_type == R_390_GOTPLTENT) {
8708 - val += (Elf_Addr) me->module_core - loc;
8709 + val += (Elf_Addr) me->module_core_rw - loc;
8710 rc = apply_rela_bits(loc, val, 1, 32, 1);
8711 }
8712 break;
8713 @@ -325,7 +325,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8714 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
8715 if (info->plt_initialized == 0) {
8716 unsigned int *ip;
8717 - ip = me->module_core + me->arch.plt_offset +
8718 + ip = me->module_core_rx + me->arch.plt_offset +
8719 info->plt_offset;
8720 #ifndef CONFIG_64BIT
8721 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
8722 @@ -350,7 +350,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8723 val - loc + 0xffffUL < 0x1ffffeUL) ||
8724 (r_type == R_390_PLT32DBL &&
8725 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
8726 - val = (Elf_Addr) me->module_core +
8727 + val = (Elf_Addr) me->module_core_rx +
8728 me->arch.plt_offset +
8729 info->plt_offset;
8730 val += rela->r_addend - loc;
8731 @@ -372,7 +372,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8732 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
8733 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
8734 val = val + rela->r_addend -
8735 - ((Elf_Addr) me->module_core + me->arch.got_offset);
8736 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
8737 if (r_type == R_390_GOTOFF16)
8738 rc = apply_rela_bits(loc, val, 0, 16, 0);
8739 else if (r_type == R_390_GOTOFF32)
8740 @@ -382,7 +382,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8741 break;
8742 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
8743 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
8744 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
8745 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
8746 rela->r_addend - loc;
8747 if (r_type == R_390_GOTPC)
8748 rc = apply_rela_bits(loc, val, 1, 32, 0);
8749 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
8750 index 2bc3edd..ab9d598 100644
8751 --- a/arch/s390/kernel/process.c
8752 +++ b/arch/s390/kernel/process.c
8753 @@ -236,39 +236,3 @@ unsigned long get_wchan(struct task_struct *p)
8754 }
8755 return 0;
8756 }
8757 -
8758 -unsigned long arch_align_stack(unsigned long sp)
8759 -{
8760 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
8761 - sp -= get_random_int() & ~PAGE_MASK;
8762 - return sp & ~0xf;
8763 -}
8764 -
8765 -static inline unsigned long brk_rnd(void)
8766 -{
8767 - /* 8MB for 32bit, 1GB for 64bit */
8768 - if (is_32bit_task())
8769 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
8770 - else
8771 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
8772 -}
8773 -
8774 -unsigned long arch_randomize_brk(struct mm_struct *mm)
8775 -{
8776 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
8777 -
8778 - if (ret < mm->brk)
8779 - return mm->brk;
8780 - return ret;
8781 -}
8782 -
8783 -unsigned long randomize_et_dyn(unsigned long base)
8784 -{
8785 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
8786 -
8787 - if (!(current->flags & PF_RANDOMIZE))
8788 - return base;
8789 - if (ret < base)
8790 - return base;
8791 - return ret;
8792 -}
8793 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
8794 index 06bafec..2bca531 100644
8795 --- a/arch/s390/mm/mmap.c
8796 +++ b/arch/s390/mm/mmap.c
8797 @@ -90,10 +90,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8798 */
8799 if (mmap_is_legacy()) {
8800 mm->mmap_base = TASK_UNMAPPED_BASE;
8801 +
8802 +#ifdef CONFIG_PAX_RANDMMAP
8803 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8804 + mm->mmap_base += mm->delta_mmap;
8805 +#endif
8806 +
8807 mm->get_unmapped_area = arch_get_unmapped_area;
8808 mm->unmap_area = arch_unmap_area;
8809 } else {
8810 mm->mmap_base = mmap_base();
8811 +
8812 +#ifdef CONFIG_PAX_RANDMMAP
8813 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8814 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8815 +#endif
8816 +
8817 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8818 mm->unmap_area = arch_unmap_area_topdown;
8819 }
8820 @@ -175,10 +187,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8821 */
8822 if (mmap_is_legacy()) {
8823 mm->mmap_base = TASK_UNMAPPED_BASE;
8824 +
8825 +#ifdef CONFIG_PAX_RANDMMAP
8826 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8827 + mm->mmap_base += mm->delta_mmap;
8828 +#endif
8829 +
8830 mm->get_unmapped_area = s390_get_unmapped_area;
8831 mm->unmap_area = arch_unmap_area;
8832 } else {
8833 mm->mmap_base = mmap_base();
8834 +
8835 +#ifdef CONFIG_PAX_RANDMMAP
8836 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8837 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8838 +#endif
8839 +
8840 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
8841 mm->unmap_area = arch_unmap_area_topdown;
8842 }
8843 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
8844 index ae3d59f..f65f075 100644
8845 --- a/arch/score/include/asm/cache.h
8846 +++ b/arch/score/include/asm/cache.h
8847 @@ -1,7 +1,9 @@
8848 #ifndef _ASM_SCORE_CACHE_H
8849 #define _ASM_SCORE_CACHE_H
8850
8851 +#include <linux/const.h>
8852 +
8853 #define L1_CACHE_SHIFT 4
8854 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8855 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8856
8857 #endif /* _ASM_SCORE_CACHE_H */
8858 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
8859 index f9f3cd5..58ff438 100644
8860 --- a/arch/score/include/asm/exec.h
8861 +++ b/arch/score/include/asm/exec.h
8862 @@ -1,6 +1,6 @@
8863 #ifndef _ASM_SCORE_EXEC_H
8864 #define _ASM_SCORE_EXEC_H
8865
8866 -extern unsigned long arch_align_stack(unsigned long sp);
8867 +#define arch_align_stack(x) (x)
8868
8869 #endif /* _ASM_SCORE_EXEC_H */
8870 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
8871 index f4c6d02..e9355c3 100644
8872 --- a/arch/score/kernel/process.c
8873 +++ b/arch/score/kernel/process.c
8874 @@ -116,8 +116,3 @@ unsigned long get_wchan(struct task_struct *task)
8875
8876 return task_pt_regs(task)->cp0_epc;
8877 }
8878 -
8879 -unsigned long arch_align_stack(unsigned long sp)
8880 -{
8881 - return sp;
8882 -}
8883 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
8884 index ef9e555..331bd29 100644
8885 --- a/arch/sh/include/asm/cache.h
8886 +++ b/arch/sh/include/asm/cache.h
8887 @@ -9,10 +9,11 @@
8888 #define __ASM_SH_CACHE_H
8889 #ifdef __KERNEL__
8890
8891 +#include <linux/const.h>
8892 #include <linux/init.h>
8893 #include <cpu/cache.h>
8894
8895 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8896 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8897
8898 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
8899
8900 diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
8901 index 03f2b55..b0270327 100644
8902 --- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c
8903 +++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
8904 @@ -143,7 +143,7 @@ shx3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
8905 return NOTIFY_OK;
8906 }
8907
8908 -static struct notifier_block __cpuinitdata shx3_cpu_notifier = {
8909 +static struct notifier_block shx3_cpu_notifier = {
8910 .notifier_call = shx3_cpu_callback,
8911 };
8912
8913 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
8914 index 6777177..cb5e44f 100644
8915 --- a/arch/sh/mm/mmap.c
8916 +++ b/arch/sh/mm/mmap.c
8917 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8918 struct mm_struct *mm = current->mm;
8919 struct vm_area_struct *vma;
8920 int do_colour_align;
8921 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8922 struct vm_unmapped_area_info info;
8923
8924 if (flags & MAP_FIXED) {
8925 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8926 if (filp || (flags & MAP_SHARED))
8927 do_colour_align = 1;
8928
8929 +#ifdef CONFIG_PAX_RANDMMAP
8930 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8931 +#endif
8932 +
8933 if (addr) {
8934 if (do_colour_align)
8935 addr = COLOUR_ALIGN(addr, pgoff);
8936 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8937 addr = PAGE_ALIGN(addr);
8938
8939 vma = find_vma(mm, addr);
8940 - if (TASK_SIZE - len >= addr &&
8941 - (!vma || addr + len <= vma->vm_start))
8942 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8943 return addr;
8944 }
8945
8946 info.flags = 0;
8947 info.length = len;
8948 - info.low_limit = TASK_UNMAPPED_BASE;
8949 + info.low_limit = mm->mmap_base;
8950 info.high_limit = TASK_SIZE;
8951 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
8952 info.align_offset = pgoff << PAGE_SHIFT;
8953 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8954 struct mm_struct *mm = current->mm;
8955 unsigned long addr = addr0;
8956 int do_colour_align;
8957 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8958 struct vm_unmapped_area_info info;
8959
8960 if (flags & MAP_FIXED) {
8961 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8962 if (filp || (flags & MAP_SHARED))
8963 do_colour_align = 1;
8964
8965 +#ifdef CONFIG_PAX_RANDMMAP
8966 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8967 +#endif
8968 +
8969 /* requesting a specific address */
8970 if (addr) {
8971 if (do_colour_align)
8972 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8973 addr = PAGE_ALIGN(addr);
8974
8975 vma = find_vma(mm, addr);
8976 - if (TASK_SIZE - len >= addr &&
8977 - (!vma || addr + len <= vma->vm_start))
8978 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8979 return addr;
8980 }
8981
8982 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8983 VM_BUG_ON(addr != -ENOMEM);
8984 info.flags = 0;
8985 info.low_limit = TASK_UNMAPPED_BASE;
8986 +
8987 +#ifdef CONFIG_PAX_RANDMMAP
8988 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8989 + info.low_limit += mm->delta_mmap;
8990 +#endif
8991 +
8992 info.high_limit = TASK_SIZE;
8993 addr = vm_unmapped_area(&info);
8994 }
8995 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
8996 index be56a24..443328f 100644
8997 --- a/arch/sparc/include/asm/atomic_64.h
8998 +++ b/arch/sparc/include/asm/atomic_64.h
8999 @@ -14,18 +14,40 @@
9000 #define ATOMIC64_INIT(i) { (i) }
9001
9002 #define atomic_read(v) (*(volatile int *)&(v)->counter)
9003 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
9004 +{
9005 + return v->counter;
9006 +}
9007 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
9008 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
9009 +{
9010 + return v->counter;
9011 +}
9012
9013 #define atomic_set(v, i) (((v)->counter) = i)
9014 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
9015 +{
9016 + v->counter = i;
9017 +}
9018 #define atomic64_set(v, i) (((v)->counter) = i)
9019 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
9020 +{
9021 + v->counter = i;
9022 +}
9023
9024 extern void atomic_add(int, atomic_t *);
9025 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
9026 extern void atomic64_add(long, atomic64_t *);
9027 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
9028 extern void atomic_sub(int, atomic_t *);
9029 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
9030 extern void atomic64_sub(long, atomic64_t *);
9031 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
9032
9033 extern int atomic_add_ret(int, atomic_t *);
9034 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
9035 extern long atomic64_add_ret(long, atomic64_t *);
9036 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
9037 extern int atomic_sub_ret(int, atomic_t *);
9038 extern long atomic64_sub_ret(long, atomic64_t *);
9039
9040 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
9041 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
9042
9043 #define atomic_inc_return(v) atomic_add_ret(1, v)
9044 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
9045 +{
9046 + return atomic_add_ret_unchecked(1, v);
9047 +}
9048 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
9049 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
9050 +{
9051 + return atomic64_add_ret_unchecked(1, v);
9052 +}
9053
9054 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
9055 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
9056
9057 #define atomic_add_return(i, v) atomic_add_ret(i, v)
9058 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
9059 +{
9060 + return atomic_add_ret_unchecked(i, v);
9061 +}
9062 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
9063 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
9064 +{
9065 + return atomic64_add_ret_unchecked(i, v);
9066 +}
9067
9068 /*
9069 * atomic_inc_and_test - increment and test
9070 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
9071 * other cases.
9072 */
9073 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
9074 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
9075 +{
9076 + return atomic_inc_return_unchecked(v) == 0;
9077 +}
9078 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
9079
9080 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
9081 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
9082 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
9083
9084 #define atomic_inc(v) atomic_add(1, v)
9085 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
9086 +{
9087 + atomic_add_unchecked(1, v);
9088 +}
9089 #define atomic64_inc(v) atomic64_add(1, v)
9090 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
9091 +{
9092 + atomic64_add_unchecked(1, v);
9093 +}
9094
9095 #define atomic_dec(v) atomic_sub(1, v)
9096 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
9097 +{
9098 + atomic_sub_unchecked(1, v);
9099 +}
9100 #define atomic64_dec(v) atomic64_sub(1, v)
9101 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
9102 +{
9103 + atomic64_sub_unchecked(1, v);
9104 +}
9105
9106 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
9107 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
9108
9109 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
9110 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
9111 +{
9112 + return cmpxchg(&v->counter, old, new);
9113 +}
9114 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
9115 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
9116 +{
9117 + return xchg(&v->counter, new);
9118 +}
9119
9120 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
9121 {
9122 - int c, old;
9123 + int c, old, new;
9124 c = atomic_read(v);
9125 for (;;) {
9126 - if (unlikely(c == (u)))
9127 + if (unlikely(c == u))
9128 break;
9129 - old = atomic_cmpxchg((v), c, c + (a));
9130 +
9131 + asm volatile("addcc %2, %0, %0\n"
9132 +
9133 +#ifdef CONFIG_PAX_REFCOUNT
9134 + "tvs %%icc, 6\n"
9135 +#endif
9136 +
9137 + : "=r" (new)
9138 + : "0" (c), "ir" (a)
9139 + : "cc");
9140 +
9141 + old = atomic_cmpxchg(v, c, new);
9142 if (likely(old == c))
9143 break;
9144 c = old;
9145 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
9146 #define atomic64_cmpxchg(v, o, n) \
9147 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
9148 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
9149 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
9150 +{
9151 + return xchg(&v->counter, new);
9152 +}
9153
9154 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
9155 {
9156 - long c, old;
9157 + long c, old, new;
9158 c = atomic64_read(v);
9159 for (;;) {
9160 - if (unlikely(c == (u)))
9161 + if (unlikely(c == u))
9162 break;
9163 - old = atomic64_cmpxchg((v), c, c + (a));
9164 +
9165 + asm volatile("addcc %2, %0, %0\n"
9166 +
9167 +#ifdef CONFIG_PAX_REFCOUNT
9168 + "tvs %%xcc, 6\n"
9169 +#endif
9170 +
9171 + : "=r" (new)
9172 + : "0" (c), "ir" (a)
9173 + : "cc");
9174 +
9175 + old = atomic64_cmpxchg(v, c, new);
9176 if (likely(old == c))
9177 break;
9178 c = old;
9179 }
9180 - return c != (u);
9181 + return c != u;
9182 }
9183
9184 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
9185 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
9186 index 5bb6991..5c2132e 100644
9187 --- a/arch/sparc/include/asm/cache.h
9188 +++ b/arch/sparc/include/asm/cache.h
9189 @@ -7,10 +7,12 @@
9190 #ifndef _SPARC_CACHE_H
9191 #define _SPARC_CACHE_H
9192
9193 +#include <linux/const.h>
9194 +
9195 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
9196
9197 #define L1_CACHE_SHIFT 5
9198 -#define L1_CACHE_BYTES 32
9199 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
9200
9201 #ifdef CONFIG_SPARC32
9202 #define SMP_CACHE_BYTES_SHIFT 5
9203 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
9204 index a24e41f..47677ff 100644
9205 --- a/arch/sparc/include/asm/elf_32.h
9206 +++ b/arch/sparc/include/asm/elf_32.h
9207 @@ -114,6 +114,13 @@ typedef struct {
9208
9209 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
9210
9211 +#ifdef CONFIG_PAX_ASLR
9212 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
9213 +
9214 +#define PAX_DELTA_MMAP_LEN 16
9215 +#define PAX_DELTA_STACK_LEN 16
9216 +#endif
9217 +
9218 /* This yields a mask that user programs can use to figure out what
9219 instruction set this cpu supports. This can NOT be done in userspace
9220 on Sparc. */
9221 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
9222 index 370ca1e..d4f4a98 100644
9223 --- a/arch/sparc/include/asm/elf_64.h
9224 +++ b/arch/sparc/include/asm/elf_64.h
9225 @@ -189,6 +189,13 @@ typedef struct {
9226 #define ELF_ET_DYN_BASE 0x0000010000000000UL
9227 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
9228
9229 +#ifdef CONFIG_PAX_ASLR
9230 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
9231 +
9232 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
9233 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
9234 +#endif
9235 +
9236 extern unsigned long sparc64_elf_hwcap;
9237 #define ELF_HWCAP sparc64_elf_hwcap
9238
9239 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
9240 index 9b1c36d..209298b 100644
9241 --- a/arch/sparc/include/asm/pgalloc_32.h
9242 +++ b/arch/sparc/include/asm/pgalloc_32.h
9243 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
9244 }
9245
9246 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
9247 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
9248
9249 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
9250 unsigned long address)
9251 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
9252 index bcfe063..b333142 100644
9253 --- a/arch/sparc/include/asm/pgalloc_64.h
9254 +++ b/arch/sparc/include/asm/pgalloc_64.h
9255 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
9256 }
9257
9258 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
9259 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
9260
9261 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
9262 {
9263 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
9264 index 6fc1348..390c50a 100644
9265 --- a/arch/sparc/include/asm/pgtable_32.h
9266 +++ b/arch/sparc/include/asm/pgtable_32.h
9267 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
9268 #define PAGE_SHARED SRMMU_PAGE_SHARED
9269 #define PAGE_COPY SRMMU_PAGE_COPY
9270 #define PAGE_READONLY SRMMU_PAGE_RDONLY
9271 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
9272 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
9273 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
9274 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
9275
9276 /* Top-level page directory - dummy used by init-mm.
9277 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
9278
9279 /* xwr */
9280 #define __P000 PAGE_NONE
9281 -#define __P001 PAGE_READONLY
9282 -#define __P010 PAGE_COPY
9283 -#define __P011 PAGE_COPY
9284 +#define __P001 PAGE_READONLY_NOEXEC
9285 +#define __P010 PAGE_COPY_NOEXEC
9286 +#define __P011 PAGE_COPY_NOEXEC
9287 #define __P100 PAGE_READONLY
9288 #define __P101 PAGE_READONLY
9289 #define __P110 PAGE_COPY
9290 #define __P111 PAGE_COPY
9291
9292 #define __S000 PAGE_NONE
9293 -#define __S001 PAGE_READONLY
9294 -#define __S010 PAGE_SHARED
9295 -#define __S011 PAGE_SHARED
9296 +#define __S001 PAGE_READONLY_NOEXEC
9297 +#define __S010 PAGE_SHARED_NOEXEC
9298 +#define __S011 PAGE_SHARED_NOEXEC
9299 #define __S100 PAGE_READONLY
9300 #define __S101 PAGE_READONLY
9301 #define __S110 PAGE_SHARED
9302 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
9303 index 79da178..c2eede8 100644
9304 --- a/arch/sparc/include/asm/pgtsrmmu.h
9305 +++ b/arch/sparc/include/asm/pgtsrmmu.h
9306 @@ -115,6 +115,11 @@
9307 SRMMU_EXEC | SRMMU_REF)
9308 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
9309 SRMMU_EXEC | SRMMU_REF)
9310 +
9311 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
9312 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9313 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9314 +
9315 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
9316 SRMMU_DIRTY | SRMMU_REF)
9317
9318 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
9319 index 9689176..63c18ea 100644
9320 --- a/arch/sparc/include/asm/spinlock_64.h
9321 +++ b/arch/sparc/include/asm/spinlock_64.h
9322 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
9323
9324 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
9325
9326 -static void inline arch_read_lock(arch_rwlock_t *lock)
9327 +static inline void arch_read_lock(arch_rwlock_t *lock)
9328 {
9329 unsigned long tmp1, tmp2;
9330
9331 __asm__ __volatile__ (
9332 "1: ldsw [%2], %0\n"
9333 " brlz,pn %0, 2f\n"
9334 -"4: add %0, 1, %1\n"
9335 +"4: addcc %0, 1, %1\n"
9336 +
9337 +#ifdef CONFIG_PAX_REFCOUNT
9338 +" tvs %%icc, 6\n"
9339 +#endif
9340 +
9341 " cas [%2], %0, %1\n"
9342 " cmp %0, %1\n"
9343 " bne,pn %%icc, 1b\n"
9344 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
9345 " .previous"
9346 : "=&r" (tmp1), "=&r" (tmp2)
9347 : "r" (lock)
9348 - : "memory");
9349 + : "memory", "cc");
9350 }
9351
9352 -static int inline arch_read_trylock(arch_rwlock_t *lock)
9353 +static inline int arch_read_trylock(arch_rwlock_t *lock)
9354 {
9355 int tmp1, tmp2;
9356
9357 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9358 "1: ldsw [%2], %0\n"
9359 " brlz,a,pn %0, 2f\n"
9360 " mov 0, %0\n"
9361 -" add %0, 1, %1\n"
9362 +" addcc %0, 1, %1\n"
9363 +
9364 +#ifdef CONFIG_PAX_REFCOUNT
9365 +" tvs %%icc, 6\n"
9366 +#endif
9367 +
9368 " cas [%2], %0, %1\n"
9369 " cmp %0, %1\n"
9370 " bne,pn %%icc, 1b\n"
9371 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9372 return tmp1;
9373 }
9374
9375 -static void inline arch_read_unlock(arch_rwlock_t *lock)
9376 +static inline void arch_read_unlock(arch_rwlock_t *lock)
9377 {
9378 unsigned long tmp1, tmp2;
9379
9380 __asm__ __volatile__(
9381 "1: lduw [%2], %0\n"
9382 -" sub %0, 1, %1\n"
9383 +" subcc %0, 1, %1\n"
9384 +
9385 +#ifdef CONFIG_PAX_REFCOUNT
9386 +" tvs %%icc, 6\n"
9387 +#endif
9388 +
9389 " cas [%2], %0, %1\n"
9390 " cmp %0, %1\n"
9391 " bne,pn %%xcc, 1b\n"
9392 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
9393 : "memory");
9394 }
9395
9396 -static void inline arch_write_lock(arch_rwlock_t *lock)
9397 +static inline void arch_write_lock(arch_rwlock_t *lock)
9398 {
9399 unsigned long mask, tmp1, tmp2;
9400
9401 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
9402 : "memory");
9403 }
9404
9405 -static void inline arch_write_unlock(arch_rwlock_t *lock)
9406 +static inline void arch_write_unlock(arch_rwlock_t *lock)
9407 {
9408 __asm__ __volatile__(
9409 " stw %%g0, [%0]"
9410 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
9411 : "memory");
9412 }
9413
9414 -static int inline arch_write_trylock(arch_rwlock_t *lock)
9415 +static inline int arch_write_trylock(arch_rwlock_t *lock)
9416 {
9417 unsigned long mask, tmp1, tmp2, result;
9418
9419 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
9420 index dd38075..e7cac83 100644
9421 --- a/arch/sparc/include/asm/thread_info_32.h
9422 +++ b/arch/sparc/include/asm/thread_info_32.h
9423 @@ -49,6 +49,8 @@ struct thread_info {
9424 unsigned long w_saved;
9425
9426 struct restart_block restart_block;
9427 +
9428 + unsigned long lowest_stack;
9429 };
9430
9431 /*
9432 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
9433 index d5e5042..9bfee76 100644
9434 --- a/arch/sparc/include/asm/thread_info_64.h
9435 +++ b/arch/sparc/include/asm/thread_info_64.h
9436 @@ -63,6 +63,8 @@ struct thread_info {
9437 struct pt_regs *kern_una_regs;
9438 unsigned int kern_una_insn;
9439
9440 + unsigned long lowest_stack;
9441 +
9442 unsigned long fpregs[0] __attribute__ ((aligned(64)));
9443 };
9444
9445 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
9446 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
9447 /* flag bit 6 is available */
9448 #define TIF_32BIT 7 /* 32-bit binary */
9449 -/* flag bit 8 is available */
9450 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
9451 #define TIF_SECCOMP 9 /* secure computing */
9452 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
9453 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
9454 +
9455 /* NOTE: Thread flags >= 12 should be ones we have no interest
9456 * in using in assembly, else we can't use the mask as
9457 * an immediate value in instructions such as andcc.
9458 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
9459 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
9460 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
9461 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
9462 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
9463
9464 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
9465 _TIF_DO_NOTIFY_RESUME_MASK | \
9466 _TIF_NEED_RESCHED)
9467 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
9468
9469 +#define _TIF_WORK_SYSCALL \
9470 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
9471 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
9472 +
9473 +
9474 /*
9475 * Thread-synchronous status.
9476 *
9477 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
9478 index 0167d26..767bb0c 100644
9479 --- a/arch/sparc/include/asm/uaccess.h
9480 +++ b/arch/sparc/include/asm/uaccess.h
9481 @@ -1,5 +1,6 @@
9482 #ifndef ___ASM_SPARC_UACCESS_H
9483 #define ___ASM_SPARC_UACCESS_H
9484 +
9485 #if defined(__sparc__) && defined(__arch64__)
9486 #include <asm/uaccess_64.h>
9487 #else
9488 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
9489 index 53a28dd..50c38c3 100644
9490 --- a/arch/sparc/include/asm/uaccess_32.h
9491 +++ b/arch/sparc/include/asm/uaccess_32.h
9492 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
9493
9494 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
9495 {
9496 - if (n && __access_ok((unsigned long) to, n))
9497 + if ((long)n < 0)
9498 + return n;
9499 +
9500 + if (n && __access_ok((unsigned long) to, n)) {
9501 + if (!__builtin_constant_p(n))
9502 + check_object_size(from, n, true);
9503 return __copy_user(to, (__force void __user *) from, n);
9504 - else
9505 + } else
9506 return n;
9507 }
9508
9509 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
9510 {
9511 + if ((long)n < 0)
9512 + return n;
9513 +
9514 + if (!__builtin_constant_p(n))
9515 + check_object_size(from, n, true);
9516 +
9517 return __copy_user(to, (__force void __user *) from, n);
9518 }
9519
9520 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
9521 {
9522 - if (n && __access_ok((unsigned long) from, n))
9523 + if ((long)n < 0)
9524 + return n;
9525 +
9526 + if (n && __access_ok((unsigned long) from, n)) {
9527 + if (!__builtin_constant_p(n))
9528 + check_object_size(to, n, false);
9529 return __copy_user((__force void __user *) to, from, n);
9530 - else
9531 + } else
9532 return n;
9533 }
9534
9535 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
9536 {
9537 + if ((long)n < 0)
9538 + return n;
9539 +
9540 return __copy_user((__force void __user *) to, from, n);
9541 }
9542
9543 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
9544 index e562d3c..191f176 100644
9545 --- a/arch/sparc/include/asm/uaccess_64.h
9546 +++ b/arch/sparc/include/asm/uaccess_64.h
9547 @@ -10,6 +10,7 @@
9548 #include <linux/compiler.h>
9549 #include <linux/string.h>
9550 #include <linux/thread_info.h>
9551 +#include <linux/kernel.h>
9552 #include <asm/asi.h>
9553 #include <asm/spitfire.h>
9554 #include <asm-generic/uaccess-unaligned.h>
9555 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
9556 static inline unsigned long __must_check
9557 copy_from_user(void *to, const void __user *from, unsigned long size)
9558 {
9559 - unsigned long ret = ___copy_from_user(to, from, size);
9560 + unsigned long ret;
9561
9562 + if ((long)size < 0 || size > INT_MAX)
9563 + return size;
9564 +
9565 + if (!__builtin_constant_p(size))
9566 + check_object_size(to, size, false);
9567 +
9568 + ret = ___copy_from_user(to, from, size);
9569 if (unlikely(ret))
9570 ret = copy_from_user_fixup(to, from, size);
9571
9572 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
9573 static inline unsigned long __must_check
9574 copy_to_user(void __user *to, const void *from, unsigned long size)
9575 {
9576 - unsigned long ret = ___copy_to_user(to, from, size);
9577 + unsigned long ret;
9578
9579 + if ((long)size < 0 || size > INT_MAX)
9580 + return size;
9581 +
9582 + if (!__builtin_constant_p(size))
9583 + check_object_size(from, size, true);
9584 +
9585 + ret = ___copy_to_user(to, from, size);
9586 if (unlikely(ret))
9587 ret = copy_to_user_fixup(to, from, size);
9588 return ret;
9589 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
9590 index d432fb2..6056af1 100644
9591 --- a/arch/sparc/kernel/Makefile
9592 +++ b/arch/sparc/kernel/Makefile
9593 @@ -3,7 +3,7 @@
9594 #
9595
9596 asflags-y := -ansi
9597 -ccflags-y := -Werror
9598 +#ccflags-y := -Werror
9599
9600 extra-y := head_$(BITS).o
9601
9602 diff --git a/arch/sparc/kernel/ds.c b/arch/sparc/kernel/ds.c
9603 index 5ef48da..11d460f 100644
9604 --- a/arch/sparc/kernel/ds.c
9605 +++ b/arch/sparc/kernel/ds.c
9606 @@ -783,6 +783,16 @@ void ldom_set_var(const char *var, const char *value)
9607 char *base, *p;
9608 int msg_len, loops;
9609
9610 + if (strlen(var) + strlen(value) + 2 >
9611 + sizeof(pkt) - sizeof(pkt.header)) {
9612 + printk(KERN_ERR PFX
9613 + "contents length: %zu, which more than max: %lu,"
9614 + "so could not set (%s) variable to (%s).\n",
9615 + strlen(var) + strlen(value) + 2,
9616 + sizeof(pkt) - sizeof(pkt.header), var, value);
9617 + return;
9618 + }
9619 +
9620 memset(&pkt, 0, sizeof(pkt));
9621 pkt.header.data.tag.type = DS_DATA;
9622 pkt.header.data.handle = cp->handle;
9623 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
9624 index fdd819d..5af08c8 100644
9625 --- a/arch/sparc/kernel/process_32.c
9626 +++ b/arch/sparc/kernel/process_32.c
9627 @@ -116,14 +116,14 @@ void show_regs(struct pt_regs *r)
9628
9629 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
9630 r->psr, r->pc, r->npc, r->y, print_tainted());
9631 - printk("PC: <%pS>\n", (void *) r->pc);
9632 + printk("PC: <%pA>\n", (void *) r->pc);
9633 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9634 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
9635 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
9636 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9637 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
9638 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
9639 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
9640 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
9641
9642 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9643 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
9644 @@ -160,7 +160,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
9645 rw = (struct reg_window32 *) fp;
9646 pc = rw->ins[7];
9647 printk("[%08lx : ", pc);
9648 - printk("%pS ] ", (void *) pc);
9649 + printk("%pA ] ", (void *) pc);
9650 fp = rw->ins[6];
9651 } while (++count < 16);
9652 printk("\n");
9653 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
9654 index baebab2..9cd13b1 100644
9655 --- a/arch/sparc/kernel/process_64.c
9656 +++ b/arch/sparc/kernel/process_64.c
9657 @@ -158,7 +158,7 @@ static void show_regwindow(struct pt_regs *regs)
9658 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
9659 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
9660 if (regs->tstate & TSTATE_PRIV)
9661 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
9662 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
9663 }
9664
9665 void show_regs(struct pt_regs *regs)
9666 @@ -167,7 +167,7 @@ void show_regs(struct pt_regs *regs)
9667
9668 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
9669 regs->tpc, regs->tnpc, regs->y, print_tainted());
9670 - printk("TPC: <%pS>\n", (void *) regs->tpc);
9671 + printk("TPC: <%pA>\n", (void *) regs->tpc);
9672 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
9673 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
9674 regs->u_regs[3]);
9675 @@ -180,7 +180,7 @@ void show_regs(struct pt_regs *regs)
9676 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
9677 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
9678 regs->u_regs[15]);
9679 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
9680 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
9681 show_regwindow(regs);
9682 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
9683 }
9684 @@ -269,7 +269,7 @@ void arch_trigger_all_cpu_backtrace(void)
9685 ((tp && tp->task) ? tp->task->pid : -1));
9686
9687 if (gp->tstate & TSTATE_PRIV) {
9688 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
9689 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
9690 (void *) gp->tpc,
9691 (void *) gp->o7,
9692 (void *) gp->i7,
9693 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
9694 index 79cc0d1..ec62734 100644
9695 --- a/arch/sparc/kernel/prom_common.c
9696 +++ b/arch/sparc/kernel/prom_common.c
9697 @@ -144,7 +144,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
9698
9699 unsigned int prom_early_allocated __initdata;
9700
9701 -static struct of_pdt_ops prom_sparc_ops __initdata = {
9702 +static struct of_pdt_ops prom_sparc_ops __initconst = {
9703 .nextprop = prom_common_nextprop,
9704 .getproplen = prom_getproplen,
9705 .getproperty = prom_getproperty,
9706 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
9707 index 7ff45e4..a58f271 100644
9708 --- a/arch/sparc/kernel/ptrace_64.c
9709 +++ b/arch/sparc/kernel/ptrace_64.c
9710 @@ -1057,6 +1057,10 @@ long arch_ptrace(struct task_struct *child, long request,
9711 return ret;
9712 }
9713
9714 +#ifdef CONFIG_GRKERNSEC_SETXID
9715 +extern void gr_delayed_cred_worker(void);
9716 +#endif
9717 +
9718 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9719 {
9720 int ret = 0;
9721 @@ -1064,6 +1068,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9722 /* do the secure computing check first */
9723 secure_computing_strict(regs->u_regs[UREG_G1]);
9724
9725 +#ifdef CONFIG_GRKERNSEC_SETXID
9726 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9727 + gr_delayed_cred_worker();
9728 +#endif
9729 +
9730 if (test_thread_flag(TIF_SYSCALL_TRACE))
9731 ret = tracehook_report_syscall_entry(regs);
9732
9733 @@ -1084,6 +1093,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9734
9735 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
9736 {
9737 +#ifdef CONFIG_GRKERNSEC_SETXID
9738 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9739 + gr_delayed_cred_worker();
9740 +#endif
9741 +
9742 audit_syscall_exit(regs);
9743
9744 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
9745 diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
9746 index 77539ed..3ffffe7 100644
9747 --- a/arch/sparc/kernel/smp_64.c
9748 +++ b/arch/sparc/kernel/smp_64.c
9749 @@ -868,8 +868,8 @@ extern unsigned long xcall_flush_dcache_page_cheetah;
9750 extern unsigned long xcall_flush_dcache_page_spitfire;
9751
9752 #ifdef CONFIG_DEBUG_DCFLUSH
9753 -extern atomic_t dcpage_flushes;
9754 -extern atomic_t dcpage_flushes_xcall;
9755 +extern atomic_unchecked_t dcpage_flushes;
9756 +extern atomic_unchecked_t dcpage_flushes_xcall;
9757 #endif
9758
9759 static inline void __local_flush_dcache_page(struct page *page)
9760 @@ -893,7 +893,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9761 return;
9762
9763 #ifdef CONFIG_DEBUG_DCFLUSH
9764 - atomic_inc(&dcpage_flushes);
9765 + atomic_inc_unchecked(&dcpage_flushes);
9766 #endif
9767
9768 this_cpu = get_cpu();
9769 @@ -917,7 +917,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9770 xcall_deliver(data0, __pa(pg_addr),
9771 (u64) pg_addr, cpumask_of(cpu));
9772 #ifdef CONFIG_DEBUG_DCFLUSH
9773 - atomic_inc(&dcpage_flushes_xcall);
9774 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9775 #endif
9776 }
9777 }
9778 @@ -936,7 +936,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9779 preempt_disable();
9780
9781 #ifdef CONFIG_DEBUG_DCFLUSH
9782 - atomic_inc(&dcpage_flushes);
9783 + atomic_inc_unchecked(&dcpage_flushes);
9784 #endif
9785 data0 = 0;
9786 pg_addr = page_address(page);
9787 @@ -953,7 +953,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9788 xcall_deliver(data0, __pa(pg_addr),
9789 (u64) pg_addr, cpu_online_mask);
9790 #ifdef CONFIG_DEBUG_DCFLUSH
9791 - atomic_inc(&dcpage_flushes_xcall);
9792 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9793 #endif
9794 }
9795 __local_flush_dcache_page(page);
9796 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
9797 index 3a8d184..49498a8 100644
9798 --- a/arch/sparc/kernel/sys_sparc_32.c
9799 +++ b/arch/sparc/kernel/sys_sparc_32.c
9800 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9801 if (len > TASK_SIZE - PAGE_SIZE)
9802 return -ENOMEM;
9803 if (!addr)
9804 - addr = TASK_UNMAPPED_BASE;
9805 + addr = current->mm->mmap_base;
9806
9807 info.flags = 0;
9808 info.length = len;
9809 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
9810 index 2daaaa6..4fb84dc 100644
9811 --- a/arch/sparc/kernel/sys_sparc_64.c
9812 +++ b/arch/sparc/kernel/sys_sparc_64.c
9813 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9814 struct vm_area_struct * vma;
9815 unsigned long task_size = TASK_SIZE;
9816 int do_color_align;
9817 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9818 struct vm_unmapped_area_info info;
9819
9820 if (flags & MAP_FIXED) {
9821 /* We do not accept a shared mapping if it would violate
9822 * cache aliasing constraints.
9823 */
9824 - if ((flags & MAP_SHARED) &&
9825 + if ((filp || (flags & MAP_SHARED)) &&
9826 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9827 return -EINVAL;
9828 return addr;
9829 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9830 if (filp || (flags & MAP_SHARED))
9831 do_color_align = 1;
9832
9833 +#ifdef CONFIG_PAX_RANDMMAP
9834 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9835 +#endif
9836 +
9837 if (addr) {
9838 if (do_color_align)
9839 addr = COLOR_ALIGN(addr, pgoff);
9840 @@ -118,22 +123,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9841 addr = PAGE_ALIGN(addr);
9842
9843 vma = find_vma(mm, addr);
9844 - if (task_size - len >= addr &&
9845 - (!vma || addr + len <= vma->vm_start))
9846 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9847 return addr;
9848 }
9849
9850 info.flags = 0;
9851 info.length = len;
9852 - info.low_limit = TASK_UNMAPPED_BASE;
9853 + info.low_limit = mm->mmap_base;
9854 info.high_limit = min(task_size, VA_EXCLUDE_START);
9855 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9856 info.align_offset = pgoff << PAGE_SHIFT;
9857 + info.threadstack_offset = offset;
9858 addr = vm_unmapped_area(&info);
9859
9860 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
9861 VM_BUG_ON(addr != -ENOMEM);
9862 info.low_limit = VA_EXCLUDE_END;
9863 +
9864 +#ifdef CONFIG_PAX_RANDMMAP
9865 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9866 + info.low_limit += mm->delta_mmap;
9867 +#endif
9868 +
9869 info.high_limit = task_size;
9870 addr = vm_unmapped_area(&info);
9871 }
9872 @@ -151,6 +162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9873 unsigned long task_size = STACK_TOP32;
9874 unsigned long addr = addr0;
9875 int do_color_align;
9876 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9877 struct vm_unmapped_area_info info;
9878
9879 /* This should only ever run for 32-bit processes. */
9880 @@ -160,7 +172,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9881 /* We do not accept a shared mapping if it would violate
9882 * cache aliasing constraints.
9883 */
9884 - if ((flags & MAP_SHARED) &&
9885 + if ((filp || (flags & MAP_SHARED)) &&
9886 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9887 return -EINVAL;
9888 return addr;
9889 @@ -173,6 +185,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9890 if (filp || (flags & MAP_SHARED))
9891 do_color_align = 1;
9892
9893 +#ifdef CONFIG_PAX_RANDMMAP
9894 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9895 +#endif
9896 +
9897 /* requesting a specific address */
9898 if (addr) {
9899 if (do_color_align)
9900 @@ -181,8 +197,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9901 addr = PAGE_ALIGN(addr);
9902
9903 vma = find_vma(mm, addr);
9904 - if (task_size - len >= addr &&
9905 - (!vma || addr + len <= vma->vm_start))
9906 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9907 return addr;
9908 }
9909
9910 @@ -192,6 +207,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9911 info.high_limit = mm->mmap_base;
9912 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9913 info.align_offset = pgoff << PAGE_SHIFT;
9914 + info.threadstack_offset = offset;
9915 addr = vm_unmapped_area(&info);
9916
9917 /*
9918 @@ -204,6 +220,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9919 VM_BUG_ON(addr != -ENOMEM);
9920 info.flags = 0;
9921 info.low_limit = TASK_UNMAPPED_BASE;
9922 +
9923 +#ifdef CONFIG_PAX_RANDMMAP
9924 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9925 + info.low_limit += mm->delta_mmap;
9926 +#endif
9927 +
9928 info.high_limit = STACK_TOP32;
9929 addr = vm_unmapped_area(&info);
9930 }
9931 @@ -260,10 +282,14 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, u
9932 EXPORT_SYMBOL(get_fb_unmapped_area);
9933
9934 /* Essentially the same as PowerPC. */
9935 -static unsigned long mmap_rnd(void)
9936 +static unsigned long mmap_rnd(struct mm_struct *mm)
9937 {
9938 unsigned long rnd = 0UL;
9939
9940 +#ifdef CONFIG_PAX_RANDMMAP
9941 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9942 +#endif
9943 +
9944 if (current->flags & PF_RANDOMIZE) {
9945 unsigned long val = get_random_int();
9946 if (test_thread_flag(TIF_32BIT))
9947 @@ -276,7 +302,7 @@ static unsigned long mmap_rnd(void)
9948
9949 void arch_pick_mmap_layout(struct mm_struct *mm)
9950 {
9951 - unsigned long random_factor = mmap_rnd();
9952 + unsigned long random_factor = mmap_rnd(mm);
9953 unsigned long gap;
9954
9955 /*
9956 @@ -289,6 +315,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9957 gap == RLIM_INFINITY ||
9958 sysctl_legacy_va_layout) {
9959 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
9960 +
9961 +#ifdef CONFIG_PAX_RANDMMAP
9962 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9963 + mm->mmap_base += mm->delta_mmap;
9964 +#endif
9965 +
9966 mm->get_unmapped_area = arch_get_unmapped_area;
9967 mm->unmap_area = arch_unmap_area;
9968 } else {
9969 @@ -301,6 +333,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9970 gap = (task_size / 6 * 5);
9971
9972 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
9973 +
9974 +#ifdef CONFIG_PAX_RANDMMAP
9975 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9976 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
9977 +#endif
9978 +
9979 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
9980 mm->unmap_area = arch_unmap_area_topdown;
9981 }
9982 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
9983 index 22a1098..6255eb9 100644
9984 --- a/arch/sparc/kernel/syscalls.S
9985 +++ b/arch/sparc/kernel/syscalls.S
9986 @@ -52,7 +52,7 @@ sys32_rt_sigreturn:
9987 #endif
9988 .align 32
9989 1: ldx [%g6 + TI_FLAGS], %l5
9990 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9991 + andcc %l5, _TIF_WORK_SYSCALL, %g0
9992 be,pt %icc, rtrap
9993 nop
9994 call syscall_trace_leave
9995 @@ -184,7 +184,7 @@ linux_sparc_syscall32:
9996
9997 srl %i5, 0, %o5 ! IEU1
9998 srl %i2, 0, %o2 ! IEU0 Group
9999 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
10000 + andcc %l0, _TIF_WORK_SYSCALL, %g0
10001 bne,pn %icc, linux_syscall_trace32 ! CTI
10002 mov %i0, %l5 ! IEU1
10003 call %l7 ! CTI Group brk forced
10004 @@ -207,7 +207,7 @@ linux_sparc_syscall:
10005
10006 mov %i3, %o3 ! IEU1
10007 mov %i4, %o4 ! IEU0 Group
10008 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
10009 + andcc %l0, _TIF_WORK_SYSCALL, %g0
10010 bne,pn %icc, linux_syscall_trace ! CTI Group
10011 mov %i0, %l5 ! IEU0
10012 2: call %l7 ! CTI Group brk forced
10013 @@ -223,7 +223,7 @@ ret_sys_call:
10014
10015 cmp %o0, -ERESTART_RESTARTBLOCK
10016 bgeu,pn %xcc, 1f
10017 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
10018 + andcc %l0, _TIF_WORK_SYSCALL, %g0
10019 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
10020
10021 2:
10022 diff --git a/arch/sparc/kernel/sysfs.c b/arch/sparc/kernel/sysfs.c
10023 index 654e8aa..45f431b 100644
10024 --- a/arch/sparc/kernel/sysfs.c
10025 +++ b/arch/sparc/kernel/sysfs.c
10026 @@ -266,7 +266,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
10027 return NOTIFY_OK;
10028 }
10029
10030 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
10031 +static struct notifier_block sysfs_cpu_nb = {
10032 .notifier_call = sysfs_cpu_notify,
10033 };
10034
10035 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
10036 index 6629829..036032d 100644
10037 --- a/arch/sparc/kernel/traps_32.c
10038 +++ b/arch/sparc/kernel/traps_32.c
10039 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
10040 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
10041 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
10042
10043 +extern void gr_handle_kernel_exploit(void);
10044 +
10045 void die_if_kernel(char *str, struct pt_regs *regs)
10046 {
10047 static int die_counter;
10048 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10049 count++ < 30 &&
10050 (((unsigned long) rw) >= PAGE_OFFSET) &&
10051 !(((unsigned long) rw) & 0x7)) {
10052 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
10053 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
10054 (void *) rw->ins[7]);
10055 rw = (struct reg_window32 *)rw->ins[6];
10056 }
10057 }
10058 printk("Instruction DUMP:");
10059 instruction_dump ((unsigned long *) regs->pc);
10060 - if(regs->psr & PSR_PS)
10061 + if(regs->psr & PSR_PS) {
10062 + gr_handle_kernel_exploit();
10063 do_exit(SIGKILL);
10064 + }
10065 do_exit(SIGSEGV);
10066 }
10067
10068 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
10069 index b3f833a..f485f80 100644
10070 --- a/arch/sparc/kernel/traps_64.c
10071 +++ b/arch/sparc/kernel/traps_64.c
10072 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
10073 i + 1,
10074 p->trapstack[i].tstate, p->trapstack[i].tpc,
10075 p->trapstack[i].tnpc, p->trapstack[i].tt);
10076 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
10077 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
10078 }
10079 }
10080
10081 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
10082
10083 lvl -= 0x100;
10084 if (regs->tstate & TSTATE_PRIV) {
10085 +
10086 +#ifdef CONFIG_PAX_REFCOUNT
10087 + if (lvl == 6)
10088 + pax_report_refcount_overflow(regs);
10089 +#endif
10090 +
10091 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
10092 die_if_kernel(buffer, regs);
10093 }
10094 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
10095 void bad_trap_tl1(struct pt_regs *regs, long lvl)
10096 {
10097 char buffer[32];
10098 -
10099 +
10100 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
10101 0, lvl, SIGTRAP) == NOTIFY_STOP)
10102 return;
10103
10104 +#ifdef CONFIG_PAX_REFCOUNT
10105 + if (lvl == 6)
10106 + pax_report_refcount_overflow(regs);
10107 +#endif
10108 +
10109 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
10110
10111 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
10112 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
10113 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
10114 printk("%s" "ERROR(%d): ",
10115 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
10116 - printk("TPC<%pS>\n", (void *) regs->tpc);
10117 + printk("TPC<%pA>\n", (void *) regs->tpc);
10118 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
10119 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
10120 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
10121 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
10122 smp_processor_id(),
10123 (type & 0x1) ? 'I' : 'D',
10124 regs->tpc);
10125 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
10126 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
10127 panic("Irrecoverable Cheetah+ parity error.");
10128 }
10129
10130 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
10131 smp_processor_id(),
10132 (type & 0x1) ? 'I' : 'D',
10133 regs->tpc);
10134 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
10135 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
10136 }
10137
10138 struct sun4v_error_entry {
10139 @@ -1830,8 +1841,8 @@ struct sun4v_error_entry {
10140 /*0x38*/u64 reserved_5;
10141 };
10142
10143 -static atomic_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
10144 -static atomic_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
10145 +static atomic_unchecked_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
10146 +static atomic_unchecked_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
10147
10148 static const char *sun4v_err_type_to_str(u8 type)
10149 {
10150 @@ -1923,7 +1934,7 @@ static void sun4v_report_real_raddr(const char *pfx, struct pt_regs *regs)
10151 }
10152
10153 static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
10154 - int cpu, const char *pfx, atomic_t *ocnt)
10155 + int cpu, const char *pfx, atomic_unchecked_t *ocnt)
10156 {
10157 u64 *raw_ptr = (u64 *) ent;
10158 u32 attrs;
10159 @@ -1981,8 +1992,8 @@ static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
10160
10161 show_regs(regs);
10162
10163 - if ((cnt = atomic_read(ocnt)) != 0) {
10164 - atomic_set(ocnt, 0);
10165 + if ((cnt = atomic_read_unchecked(ocnt)) != 0) {
10166 + atomic_set_unchecked(ocnt, 0);
10167 wmb();
10168 printk("%s: Queue overflowed %d times.\n",
10169 pfx, cnt);
10170 @@ -2036,7 +2047,7 @@ void sun4v_resum_error(struct pt_regs *regs, unsigned long offset)
10171 */
10172 void sun4v_resum_overflow(struct pt_regs *regs)
10173 {
10174 - atomic_inc(&sun4v_resum_oflow_cnt);
10175 + atomic_inc_unchecked(&sun4v_resum_oflow_cnt);
10176 }
10177
10178 /* We run with %pil set to PIL_NORMAL_MAX and PSTATE_IE enabled in %pstate.
10179 @@ -2089,7 +2100,7 @@ void sun4v_nonresum_overflow(struct pt_regs *regs)
10180 /* XXX Actually even this can make not that much sense. Perhaps
10181 * XXX we should just pull the plug and panic directly from here?
10182 */
10183 - atomic_inc(&sun4v_nonresum_oflow_cnt);
10184 + atomic_inc_unchecked(&sun4v_nonresum_oflow_cnt);
10185 }
10186
10187 unsigned long sun4v_err_itlb_vaddr;
10188 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
10189
10190 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
10191 regs->tpc, tl);
10192 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
10193 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
10194 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10195 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
10196 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
10197 (void *) regs->u_regs[UREG_I7]);
10198 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
10199 "pte[%lx] error[%lx]\n",
10200 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
10201
10202 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
10203 regs->tpc, tl);
10204 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
10205 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
10206 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10207 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
10208 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
10209 (void *) regs->u_regs[UREG_I7]);
10210 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
10211 "pte[%lx] error[%lx]\n",
10212 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
10213 fp = (unsigned long)sf->fp + STACK_BIAS;
10214 }
10215
10216 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10217 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10218 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
10219 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
10220 int index = tsk->curr_ret_stack;
10221 if (tsk->ret_stack && index >= graph) {
10222 pc = tsk->ret_stack[index - graph].ret;
10223 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10224 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10225 graph++;
10226 }
10227 }
10228 @@ -2360,6 +2371,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
10229 return (struct reg_window *) (fp + STACK_BIAS);
10230 }
10231
10232 +extern void gr_handle_kernel_exploit(void);
10233 +
10234 void die_if_kernel(char *str, struct pt_regs *regs)
10235 {
10236 static int die_counter;
10237 @@ -2388,7 +2401,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10238 while (rw &&
10239 count++ < 30 &&
10240 kstack_valid(tp, (unsigned long) rw)) {
10241 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
10242 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
10243 (void *) rw->ins[7]);
10244
10245 rw = kernel_stack_up(rw);
10246 @@ -2401,8 +2414,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10247 }
10248 user_instruction_dump ((unsigned int __user *) regs->tpc);
10249 }
10250 - if (regs->tstate & TSTATE_PRIV)
10251 + if (regs->tstate & TSTATE_PRIV) {
10252 + gr_handle_kernel_exploit();
10253 do_exit(SIGKILL);
10254 + }
10255 do_exit(SIGSEGV);
10256 }
10257 EXPORT_SYMBOL(die_if_kernel);
10258 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
10259 index 8201c25e..072a2a7 100644
10260 --- a/arch/sparc/kernel/unaligned_64.c
10261 +++ b/arch/sparc/kernel/unaligned_64.c
10262 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
10263 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
10264
10265 if (__ratelimit(&ratelimit)) {
10266 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
10267 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
10268 regs->tpc, (void *) regs->tpc);
10269 }
10270 }
10271 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
10272 index dbe119b..089c7c1 100644
10273 --- a/arch/sparc/lib/Makefile
10274 +++ b/arch/sparc/lib/Makefile
10275 @@ -2,7 +2,7 @@
10276 #
10277
10278 asflags-y := -ansi -DST_DIV0=0x02
10279 -ccflags-y := -Werror
10280 +#ccflags-y := -Werror
10281
10282 lib-$(CONFIG_SPARC32) += ashrdi3.o
10283 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
10284 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
10285 index 85c233d..68500e0 100644
10286 --- a/arch/sparc/lib/atomic_64.S
10287 +++ b/arch/sparc/lib/atomic_64.S
10288 @@ -17,7 +17,12 @@
10289 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10290 BACKOFF_SETUP(%o2)
10291 1: lduw [%o1], %g1
10292 - add %g1, %o0, %g7
10293 + addcc %g1, %o0, %g7
10294 +
10295 +#ifdef CONFIG_PAX_REFCOUNT
10296 + tvs %icc, 6
10297 +#endif
10298 +
10299 cas [%o1], %g1, %g7
10300 cmp %g1, %g7
10301 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10302 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10303 2: BACKOFF_SPIN(%o2, %o3, 1b)
10304 ENDPROC(atomic_add)
10305
10306 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10307 + BACKOFF_SETUP(%o2)
10308 +1: lduw [%o1], %g1
10309 + add %g1, %o0, %g7
10310 + cas [%o1], %g1, %g7
10311 + cmp %g1, %g7
10312 + bne,pn %icc, 2f
10313 + nop
10314 + retl
10315 + nop
10316 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10317 +ENDPROC(atomic_add_unchecked)
10318 +
10319 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10320 BACKOFF_SETUP(%o2)
10321 1: lduw [%o1], %g1
10322 - sub %g1, %o0, %g7
10323 + subcc %g1, %o0, %g7
10324 +
10325 +#ifdef CONFIG_PAX_REFCOUNT
10326 + tvs %icc, 6
10327 +#endif
10328 +
10329 cas [%o1], %g1, %g7
10330 cmp %g1, %g7
10331 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10332 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10333 2: BACKOFF_SPIN(%o2, %o3, 1b)
10334 ENDPROC(atomic_sub)
10335
10336 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10337 + BACKOFF_SETUP(%o2)
10338 +1: lduw [%o1], %g1
10339 + sub %g1, %o0, %g7
10340 + cas [%o1], %g1, %g7
10341 + cmp %g1, %g7
10342 + bne,pn %icc, 2f
10343 + nop
10344 + retl
10345 + nop
10346 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10347 +ENDPROC(atomic_sub_unchecked)
10348 +
10349 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10350 BACKOFF_SETUP(%o2)
10351 1: lduw [%o1], %g1
10352 - add %g1, %o0, %g7
10353 + addcc %g1, %o0, %g7
10354 +
10355 +#ifdef CONFIG_PAX_REFCOUNT
10356 + tvs %icc, 6
10357 +#endif
10358 +
10359 cas [%o1], %g1, %g7
10360 cmp %g1, %g7
10361 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10362 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10363 2: BACKOFF_SPIN(%o2, %o3, 1b)
10364 ENDPROC(atomic_add_ret)
10365
10366 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10367 + BACKOFF_SETUP(%o2)
10368 +1: lduw [%o1], %g1
10369 + addcc %g1, %o0, %g7
10370 + cas [%o1], %g1, %g7
10371 + cmp %g1, %g7
10372 + bne,pn %icc, 2f
10373 + add %g7, %o0, %g7
10374 + sra %g7, 0, %o0
10375 + retl
10376 + nop
10377 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10378 +ENDPROC(atomic_add_ret_unchecked)
10379 +
10380 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10381 BACKOFF_SETUP(%o2)
10382 1: lduw [%o1], %g1
10383 - sub %g1, %o0, %g7
10384 + subcc %g1, %o0, %g7
10385 +
10386 +#ifdef CONFIG_PAX_REFCOUNT
10387 + tvs %icc, 6
10388 +#endif
10389 +
10390 cas [%o1], %g1, %g7
10391 cmp %g1, %g7
10392 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10393 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
10394 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10395 BACKOFF_SETUP(%o2)
10396 1: ldx [%o1], %g1
10397 - add %g1, %o0, %g7
10398 + addcc %g1, %o0, %g7
10399 +
10400 +#ifdef CONFIG_PAX_REFCOUNT
10401 + tvs %xcc, 6
10402 +#endif
10403 +
10404 casx [%o1], %g1, %g7
10405 cmp %g1, %g7
10406 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10407 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10408 2: BACKOFF_SPIN(%o2, %o3, 1b)
10409 ENDPROC(atomic64_add)
10410
10411 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10412 + BACKOFF_SETUP(%o2)
10413 +1: ldx [%o1], %g1
10414 + addcc %g1, %o0, %g7
10415 + casx [%o1], %g1, %g7
10416 + cmp %g1, %g7
10417 + bne,pn %xcc, 2f
10418 + nop
10419 + retl
10420 + nop
10421 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10422 +ENDPROC(atomic64_add_unchecked)
10423 +
10424 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10425 BACKOFF_SETUP(%o2)
10426 1: ldx [%o1], %g1
10427 - sub %g1, %o0, %g7
10428 + subcc %g1, %o0, %g7
10429 +
10430 +#ifdef CONFIG_PAX_REFCOUNT
10431 + tvs %xcc, 6
10432 +#endif
10433 +
10434 casx [%o1], %g1, %g7
10435 cmp %g1, %g7
10436 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10437 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10438 2: BACKOFF_SPIN(%o2, %o3, 1b)
10439 ENDPROC(atomic64_sub)
10440
10441 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10442 + BACKOFF_SETUP(%o2)
10443 +1: ldx [%o1], %g1
10444 + subcc %g1, %o0, %g7
10445 + casx [%o1], %g1, %g7
10446 + cmp %g1, %g7
10447 + bne,pn %xcc, 2f
10448 + nop
10449 + retl
10450 + nop
10451 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10452 +ENDPROC(atomic64_sub_unchecked)
10453 +
10454 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10455 BACKOFF_SETUP(%o2)
10456 1: ldx [%o1], %g1
10457 - add %g1, %o0, %g7
10458 + addcc %g1, %o0, %g7
10459 +
10460 +#ifdef CONFIG_PAX_REFCOUNT
10461 + tvs %xcc, 6
10462 +#endif
10463 +
10464 casx [%o1], %g1, %g7
10465 cmp %g1, %g7
10466 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10467 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10468 2: BACKOFF_SPIN(%o2, %o3, 1b)
10469 ENDPROC(atomic64_add_ret)
10470
10471 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10472 + BACKOFF_SETUP(%o2)
10473 +1: ldx [%o1], %g1
10474 + addcc %g1, %o0, %g7
10475 + casx [%o1], %g1, %g7
10476 + cmp %g1, %g7
10477 + bne,pn %xcc, 2f
10478 + add %g7, %o0, %g7
10479 + mov %g7, %o0
10480 + retl
10481 + nop
10482 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10483 +ENDPROC(atomic64_add_ret_unchecked)
10484 +
10485 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10486 BACKOFF_SETUP(%o2)
10487 1: ldx [%o1], %g1
10488 - sub %g1, %o0, %g7
10489 + subcc %g1, %o0, %g7
10490 +
10491 +#ifdef CONFIG_PAX_REFCOUNT
10492 + tvs %xcc, 6
10493 +#endif
10494 +
10495 casx [%o1], %g1, %g7
10496 cmp %g1, %g7
10497 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10498 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
10499 index 0c4e35e..745d3e4 100644
10500 --- a/arch/sparc/lib/ksyms.c
10501 +++ b/arch/sparc/lib/ksyms.c
10502 @@ -109,12 +109,18 @@ EXPORT_SYMBOL(__downgrade_write);
10503
10504 /* Atomic counter implementation. */
10505 EXPORT_SYMBOL(atomic_add);
10506 +EXPORT_SYMBOL(atomic_add_unchecked);
10507 EXPORT_SYMBOL(atomic_add_ret);
10508 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
10509 EXPORT_SYMBOL(atomic_sub);
10510 +EXPORT_SYMBOL(atomic_sub_unchecked);
10511 EXPORT_SYMBOL(atomic_sub_ret);
10512 EXPORT_SYMBOL(atomic64_add);
10513 +EXPORT_SYMBOL(atomic64_add_unchecked);
10514 EXPORT_SYMBOL(atomic64_add_ret);
10515 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
10516 EXPORT_SYMBOL(atomic64_sub);
10517 +EXPORT_SYMBOL(atomic64_sub_unchecked);
10518 EXPORT_SYMBOL(atomic64_sub_ret);
10519 EXPORT_SYMBOL(atomic64_dec_if_positive);
10520
10521 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
10522 index 30c3ecc..736f015 100644
10523 --- a/arch/sparc/mm/Makefile
10524 +++ b/arch/sparc/mm/Makefile
10525 @@ -2,7 +2,7 @@
10526 #
10527
10528 asflags-y := -ansi
10529 -ccflags-y := -Werror
10530 +#ccflags-y := -Werror
10531
10532 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
10533 obj-y += fault_$(BITS).o
10534 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
10535 index e98bfda..ea8d221 100644
10536 --- a/arch/sparc/mm/fault_32.c
10537 +++ b/arch/sparc/mm/fault_32.c
10538 @@ -21,6 +21,9 @@
10539 #include <linux/perf_event.h>
10540 #include <linux/interrupt.h>
10541 #include <linux/kdebug.h>
10542 +#include <linux/slab.h>
10543 +#include <linux/pagemap.h>
10544 +#include <linux/compiler.h>
10545
10546 #include <asm/page.h>
10547 #include <asm/pgtable.h>
10548 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
10549 return safe_compute_effective_address(regs, insn);
10550 }
10551
10552 +#ifdef CONFIG_PAX_PAGEEXEC
10553 +#ifdef CONFIG_PAX_DLRESOLVE
10554 +static void pax_emuplt_close(struct vm_area_struct *vma)
10555 +{
10556 + vma->vm_mm->call_dl_resolve = 0UL;
10557 +}
10558 +
10559 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10560 +{
10561 + unsigned int *kaddr;
10562 +
10563 + vmf->page = alloc_page(GFP_HIGHUSER);
10564 + if (!vmf->page)
10565 + return VM_FAULT_OOM;
10566 +
10567 + kaddr = kmap(vmf->page);
10568 + memset(kaddr, 0, PAGE_SIZE);
10569 + kaddr[0] = 0x9DE3BFA8U; /* save */
10570 + flush_dcache_page(vmf->page);
10571 + kunmap(vmf->page);
10572 + return VM_FAULT_MAJOR;
10573 +}
10574 +
10575 +static const struct vm_operations_struct pax_vm_ops = {
10576 + .close = pax_emuplt_close,
10577 + .fault = pax_emuplt_fault
10578 +};
10579 +
10580 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10581 +{
10582 + int ret;
10583 +
10584 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10585 + vma->vm_mm = current->mm;
10586 + vma->vm_start = addr;
10587 + vma->vm_end = addr + PAGE_SIZE;
10588 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10589 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10590 + vma->vm_ops = &pax_vm_ops;
10591 +
10592 + ret = insert_vm_struct(current->mm, vma);
10593 + if (ret)
10594 + return ret;
10595 +
10596 + ++current->mm->total_vm;
10597 + return 0;
10598 +}
10599 +#endif
10600 +
10601 +/*
10602 + * PaX: decide what to do with offenders (regs->pc = fault address)
10603 + *
10604 + * returns 1 when task should be killed
10605 + * 2 when patched PLT trampoline was detected
10606 + * 3 when unpatched PLT trampoline was detected
10607 + */
10608 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10609 +{
10610 +
10611 +#ifdef CONFIG_PAX_EMUPLT
10612 + int err;
10613 +
10614 + do { /* PaX: patched PLT emulation #1 */
10615 + unsigned int sethi1, sethi2, jmpl;
10616 +
10617 + err = get_user(sethi1, (unsigned int *)regs->pc);
10618 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
10619 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
10620 +
10621 + if (err)
10622 + break;
10623 +
10624 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10625 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10626 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10627 + {
10628 + unsigned int addr;
10629 +
10630 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10631 + addr = regs->u_regs[UREG_G1];
10632 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10633 + regs->pc = addr;
10634 + regs->npc = addr+4;
10635 + return 2;
10636 + }
10637 + } while (0);
10638 +
10639 + do { /* PaX: patched PLT emulation #2 */
10640 + unsigned int ba;
10641 +
10642 + err = get_user(ba, (unsigned int *)regs->pc);
10643 +
10644 + if (err)
10645 + break;
10646 +
10647 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10648 + unsigned int addr;
10649 +
10650 + if ((ba & 0xFFC00000U) == 0x30800000U)
10651 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10652 + else
10653 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10654 + regs->pc = addr;
10655 + regs->npc = addr+4;
10656 + return 2;
10657 + }
10658 + } while (0);
10659 +
10660 + do { /* PaX: patched PLT emulation #3 */
10661 + unsigned int sethi, bajmpl, nop;
10662 +
10663 + err = get_user(sethi, (unsigned int *)regs->pc);
10664 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
10665 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10666 +
10667 + if (err)
10668 + break;
10669 +
10670 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10671 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10672 + nop == 0x01000000U)
10673 + {
10674 + unsigned int addr;
10675 +
10676 + addr = (sethi & 0x003FFFFFU) << 10;
10677 + regs->u_regs[UREG_G1] = addr;
10678 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10679 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10680 + else
10681 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10682 + regs->pc = addr;
10683 + regs->npc = addr+4;
10684 + return 2;
10685 + }
10686 + } while (0);
10687 +
10688 + do { /* PaX: unpatched PLT emulation step 1 */
10689 + unsigned int sethi, ba, nop;
10690 +
10691 + err = get_user(sethi, (unsigned int *)regs->pc);
10692 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
10693 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10694 +
10695 + if (err)
10696 + break;
10697 +
10698 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10699 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10700 + nop == 0x01000000U)
10701 + {
10702 + unsigned int addr, save, call;
10703 +
10704 + if ((ba & 0xFFC00000U) == 0x30800000U)
10705 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10706 + else
10707 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10708 +
10709 + err = get_user(save, (unsigned int *)addr);
10710 + err |= get_user(call, (unsigned int *)(addr+4));
10711 + err |= get_user(nop, (unsigned int *)(addr+8));
10712 + if (err)
10713 + break;
10714 +
10715 +#ifdef CONFIG_PAX_DLRESOLVE
10716 + if (save == 0x9DE3BFA8U &&
10717 + (call & 0xC0000000U) == 0x40000000U &&
10718 + nop == 0x01000000U)
10719 + {
10720 + struct vm_area_struct *vma;
10721 + unsigned long call_dl_resolve;
10722 +
10723 + down_read(&current->mm->mmap_sem);
10724 + call_dl_resolve = current->mm->call_dl_resolve;
10725 + up_read(&current->mm->mmap_sem);
10726 + if (likely(call_dl_resolve))
10727 + goto emulate;
10728 +
10729 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10730 +
10731 + down_write(&current->mm->mmap_sem);
10732 + if (current->mm->call_dl_resolve) {
10733 + call_dl_resolve = current->mm->call_dl_resolve;
10734 + up_write(&current->mm->mmap_sem);
10735 + if (vma)
10736 + kmem_cache_free(vm_area_cachep, vma);
10737 + goto emulate;
10738 + }
10739 +
10740 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
10741 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
10742 + up_write(&current->mm->mmap_sem);
10743 + if (vma)
10744 + kmem_cache_free(vm_area_cachep, vma);
10745 + return 1;
10746 + }
10747 +
10748 + if (pax_insert_vma(vma, call_dl_resolve)) {
10749 + up_write(&current->mm->mmap_sem);
10750 + kmem_cache_free(vm_area_cachep, vma);
10751 + return 1;
10752 + }
10753 +
10754 + current->mm->call_dl_resolve = call_dl_resolve;
10755 + up_write(&current->mm->mmap_sem);
10756 +
10757 +emulate:
10758 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10759 + regs->pc = call_dl_resolve;
10760 + regs->npc = addr+4;
10761 + return 3;
10762 + }
10763 +#endif
10764 +
10765 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
10766 + if ((save & 0xFFC00000U) == 0x05000000U &&
10767 + (call & 0xFFFFE000U) == 0x85C0A000U &&
10768 + nop == 0x01000000U)
10769 + {
10770 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10771 + regs->u_regs[UREG_G2] = addr + 4;
10772 + addr = (save & 0x003FFFFFU) << 10;
10773 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10774 + regs->pc = addr;
10775 + regs->npc = addr+4;
10776 + return 3;
10777 + }
10778 + }
10779 + } while (0);
10780 +
10781 + do { /* PaX: unpatched PLT emulation step 2 */
10782 + unsigned int save, call, nop;
10783 +
10784 + err = get_user(save, (unsigned int *)(regs->pc-4));
10785 + err |= get_user(call, (unsigned int *)regs->pc);
10786 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
10787 + if (err)
10788 + break;
10789 +
10790 + if (save == 0x9DE3BFA8U &&
10791 + (call & 0xC0000000U) == 0x40000000U &&
10792 + nop == 0x01000000U)
10793 + {
10794 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
10795 +
10796 + regs->u_regs[UREG_RETPC] = regs->pc;
10797 + regs->pc = dl_resolve;
10798 + regs->npc = dl_resolve+4;
10799 + return 3;
10800 + }
10801 + } while (0);
10802 +#endif
10803 +
10804 + return 1;
10805 +}
10806 +
10807 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
10808 +{
10809 + unsigned long i;
10810 +
10811 + printk(KERN_ERR "PAX: bytes at PC: ");
10812 + for (i = 0; i < 8; i++) {
10813 + unsigned int c;
10814 + if (get_user(c, (unsigned int *)pc+i))
10815 + printk(KERN_CONT "???????? ");
10816 + else
10817 + printk(KERN_CONT "%08x ", c);
10818 + }
10819 + printk("\n");
10820 +}
10821 +#endif
10822 +
10823 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
10824 int text_fault)
10825 {
10826 @@ -230,6 +504,24 @@ good_area:
10827 if (!(vma->vm_flags & VM_WRITE))
10828 goto bad_area;
10829 } else {
10830 +
10831 +#ifdef CONFIG_PAX_PAGEEXEC
10832 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
10833 + up_read(&mm->mmap_sem);
10834 + switch (pax_handle_fetch_fault(regs)) {
10835 +
10836 +#ifdef CONFIG_PAX_EMUPLT
10837 + case 2:
10838 + case 3:
10839 + return;
10840 +#endif
10841 +
10842 + }
10843 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
10844 + do_group_exit(SIGKILL);
10845 + }
10846 +#endif
10847 +
10848 /* Allow reads even for write-only mappings */
10849 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
10850 goto bad_area;
10851 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
10852 index 5062ff3..e0b75f3 100644
10853 --- a/arch/sparc/mm/fault_64.c
10854 +++ b/arch/sparc/mm/fault_64.c
10855 @@ -21,6 +21,9 @@
10856 #include <linux/kprobes.h>
10857 #include <linux/kdebug.h>
10858 #include <linux/percpu.h>
10859 +#include <linux/slab.h>
10860 +#include <linux/pagemap.h>
10861 +#include <linux/compiler.h>
10862
10863 #include <asm/page.h>
10864 #include <asm/pgtable.h>
10865 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
10866 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
10867 regs->tpc);
10868 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
10869 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
10870 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
10871 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
10872 dump_stack();
10873 unhandled_fault(regs->tpc, current, regs);
10874 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
10875 show_regs(regs);
10876 }
10877
10878 +#ifdef CONFIG_PAX_PAGEEXEC
10879 +#ifdef CONFIG_PAX_DLRESOLVE
10880 +static void pax_emuplt_close(struct vm_area_struct *vma)
10881 +{
10882 + vma->vm_mm->call_dl_resolve = 0UL;
10883 +}
10884 +
10885 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10886 +{
10887 + unsigned int *kaddr;
10888 +
10889 + vmf->page = alloc_page(GFP_HIGHUSER);
10890 + if (!vmf->page)
10891 + return VM_FAULT_OOM;
10892 +
10893 + kaddr = kmap(vmf->page);
10894 + memset(kaddr, 0, PAGE_SIZE);
10895 + kaddr[0] = 0x9DE3BFA8U; /* save */
10896 + flush_dcache_page(vmf->page);
10897 + kunmap(vmf->page);
10898 + return VM_FAULT_MAJOR;
10899 +}
10900 +
10901 +static const struct vm_operations_struct pax_vm_ops = {
10902 + .close = pax_emuplt_close,
10903 + .fault = pax_emuplt_fault
10904 +};
10905 +
10906 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10907 +{
10908 + int ret;
10909 +
10910 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10911 + vma->vm_mm = current->mm;
10912 + vma->vm_start = addr;
10913 + vma->vm_end = addr + PAGE_SIZE;
10914 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10915 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10916 + vma->vm_ops = &pax_vm_ops;
10917 +
10918 + ret = insert_vm_struct(current->mm, vma);
10919 + if (ret)
10920 + return ret;
10921 +
10922 + ++current->mm->total_vm;
10923 + return 0;
10924 +}
10925 +#endif
10926 +
10927 +/*
10928 + * PaX: decide what to do with offenders (regs->tpc = fault address)
10929 + *
10930 + * returns 1 when task should be killed
10931 + * 2 when patched PLT trampoline was detected
10932 + * 3 when unpatched PLT trampoline was detected
10933 + */
10934 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10935 +{
10936 +
10937 +#ifdef CONFIG_PAX_EMUPLT
10938 + int err;
10939 +
10940 + do { /* PaX: patched PLT emulation #1 */
10941 + unsigned int sethi1, sethi2, jmpl;
10942 +
10943 + err = get_user(sethi1, (unsigned int *)regs->tpc);
10944 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
10945 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
10946 +
10947 + if (err)
10948 + break;
10949 +
10950 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10951 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10952 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10953 + {
10954 + unsigned long addr;
10955 +
10956 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10957 + addr = regs->u_regs[UREG_G1];
10958 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10959 +
10960 + if (test_thread_flag(TIF_32BIT))
10961 + addr &= 0xFFFFFFFFUL;
10962 +
10963 + regs->tpc = addr;
10964 + regs->tnpc = addr+4;
10965 + return 2;
10966 + }
10967 + } while (0);
10968 +
10969 + do { /* PaX: patched PLT emulation #2 */
10970 + unsigned int ba;
10971 +
10972 + err = get_user(ba, (unsigned int *)regs->tpc);
10973 +
10974 + if (err)
10975 + break;
10976 +
10977 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10978 + unsigned long addr;
10979 +
10980 + if ((ba & 0xFFC00000U) == 0x30800000U)
10981 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10982 + else
10983 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10984 +
10985 + if (test_thread_flag(TIF_32BIT))
10986 + addr &= 0xFFFFFFFFUL;
10987 +
10988 + regs->tpc = addr;
10989 + regs->tnpc = addr+4;
10990 + return 2;
10991 + }
10992 + } while (0);
10993 +
10994 + do { /* PaX: patched PLT emulation #3 */
10995 + unsigned int sethi, bajmpl, nop;
10996 +
10997 + err = get_user(sethi, (unsigned int *)regs->tpc);
10998 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
10999 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
11000 +
11001 + if (err)
11002 + break;
11003 +
11004 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11005 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
11006 + nop == 0x01000000U)
11007 + {
11008 + unsigned long addr;
11009 +
11010 + addr = (sethi & 0x003FFFFFU) << 10;
11011 + regs->u_regs[UREG_G1] = addr;
11012 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
11013 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
11014 + else
11015 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
11016 +
11017 + if (test_thread_flag(TIF_32BIT))
11018 + addr &= 0xFFFFFFFFUL;
11019 +
11020 + regs->tpc = addr;
11021 + regs->tnpc = addr+4;
11022 + return 2;
11023 + }
11024 + } while (0);
11025 +
11026 + do { /* PaX: patched PLT emulation #4 */
11027 + unsigned int sethi, mov1, call, mov2;
11028 +
11029 + err = get_user(sethi, (unsigned int *)regs->tpc);
11030 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
11031 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
11032 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
11033 +
11034 + if (err)
11035 + break;
11036 +
11037 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11038 + mov1 == 0x8210000FU &&
11039 + (call & 0xC0000000U) == 0x40000000U &&
11040 + mov2 == 0x9E100001U)
11041 + {
11042 + unsigned long addr;
11043 +
11044 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
11045 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
11046 +
11047 + if (test_thread_flag(TIF_32BIT))
11048 + addr &= 0xFFFFFFFFUL;
11049 +
11050 + regs->tpc = addr;
11051 + regs->tnpc = addr+4;
11052 + return 2;
11053 + }
11054 + } while (0);
11055 +
11056 + do { /* PaX: patched PLT emulation #5 */
11057 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
11058 +
11059 + err = get_user(sethi, (unsigned int *)regs->tpc);
11060 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
11061 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
11062 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
11063 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
11064 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
11065 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
11066 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
11067 +
11068 + if (err)
11069 + break;
11070 +
11071 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11072 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
11073 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
11074 + (or1 & 0xFFFFE000U) == 0x82106000U &&
11075 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
11076 + sllx == 0x83287020U &&
11077 + jmpl == 0x81C04005U &&
11078 + nop == 0x01000000U)
11079 + {
11080 + unsigned long addr;
11081 +
11082 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
11083 + regs->u_regs[UREG_G1] <<= 32;
11084 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
11085 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
11086 + regs->tpc = addr;
11087 + regs->tnpc = addr+4;
11088 + return 2;
11089 + }
11090 + } while (0);
11091 +
11092 + do { /* PaX: patched PLT emulation #6 */
11093 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
11094 +
11095 + err = get_user(sethi, (unsigned int *)regs->tpc);
11096 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
11097 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
11098 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
11099 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
11100 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
11101 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
11102 +
11103 + if (err)
11104 + break;
11105 +
11106 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11107 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
11108 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
11109 + sllx == 0x83287020U &&
11110 + (or & 0xFFFFE000U) == 0x8A116000U &&
11111 + jmpl == 0x81C04005U &&
11112 + nop == 0x01000000U)
11113 + {
11114 + unsigned long addr;
11115 +
11116 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
11117 + regs->u_regs[UREG_G1] <<= 32;
11118 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
11119 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
11120 + regs->tpc = addr;
11121 + regs->tnpc = addr+4;
11122 + return 2;
11123 + }
11124 + } while (0);
11125 +
11126 + do { /* PaX: unpatched PLT emulation step 1 */
11127 + unsigned int sethi, ba, nop;
11128 +
11129 + err = get_user(sethi, (unsigned int *)regs->tpc);
11130 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
11131 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
11132 +
11133 + if (err)
11134 + break;
11135 +
11136 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11137 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
11138 + nop == 0x01000000U)
11139 + {
11140 + unsigned long addr;
11141 + unsigned int save, call;
11142 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
11143 +
11144 + if ((ba & 0xFFC00000U) == 0x30800000U)
11145 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
11146 + else
11147 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
11148 +
11149 + if (test_thread_flag(TIF_32BIT))
11150 + addr &= 0xFFFFFFFFUL;
11151 +
11152 + err = get_user(save, (unsigned int *)addr);
11153 + err |= get_user(call, (unsigned int *)(addr+4));
11154 + err |= get_user(nop, (unsigned int *)(addr+8));
11155 + if (err)
11156 + break;
11157 +
11158 +#ifdef CONFIG_PAX_DLRESOLVE
11159 + if (save == 0x9DE3BFA8U &&
11160 + (call & 0xC0000000U) == 0x40000000U &&
11161 + nop == 0x01000000U)
11162 + {
11163 + struct vm_area_struct *vma;
11164 + unsigned long call_dl_resolve;
11165 +
11166 + down_read(&current->mm->mmap_sem);
11167 + call_dl_resolve = current->mm->call_dl_resolve;
11168 + up_read(&current->mm->mmap_sem);
11169 + if (likely(call_dl_resolve))
11170 + goto emulate;
11171 +
11172 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
11173 +
11174 + down_write(&current->mm->mmap_sem);
11175 + if (current->mm->call_dl_resolve) {
11176 + call_dl_resolve = current->mm->call_dl_resolve;
11177 + up_write(&current->mm->mmap_sem);
11178 + if (vma)
11179 + kmem_cache_free(vm_area_cachep, vma);
11180 + goto emulate;
11181 + }
11182 +
11183 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
11184 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
11185 + up_write(&current->mm->mmap_sem);
11186 + if (vma)
11187 + kmem_cache_free(vm_area_cachep, vma);
11188 + return 1;
11189 + }
11190 +
11191 + if (pax_insert_vma(vma, call_dl_resolve)) {
11192 + up_write(&current->mm->mmap_sem);
11193 + kmem_cache_free(vm_area_cachep, vma);
11194 + return 1;
11195 + }
11196 +
11197 + current->mm->call_dl_resolve = call_dl_resolve;
11198 + up_write(&current->mm->mmap_sem);
11199 +
11200 +emulate:
11201 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11202 + regs->tpc = call_dl_resolve;
11203 + regs->tnpc = addr+4;
11204 + return 3;
11205 + }
11206 +#endif
11207 +
11208 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
11209 + if ((save & 0xFFC00000U) == 0x05000000U &&
11210 + (call & 0xFFFFE000U) == 0x85C0A000U &&
11211 + nop == 0x01000000U)
11212 + {
11213 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11214 + regs->u_regs[UREG_G2] = addr + 4;
11215 + addr = (save & 0x003FFFFFU) << 10;
11216 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
11217 +
11218 + if (test_thread_flag(TIF_32BIT))
11219 + addr &= 0xFFFFFFFFUL;
11220 +
11221 + regs->tpc = addr;
11222 + regs->tnpc = addr+4;
11223 + return 3;
11224 + }
11225 +
11226 + /* PaX: 64-bit PLT stub */
11227 + err = get_user(sethi1, (unsigned int *)addr);
11228 + err |= get_user(sethi2, (unsigned int *)(addr+4));
11229 + err |= get_user(or1, (unsigned int *)(addr+8));
11230 + err |= get_user(or2, (unsigned int *)(addr+12));
11231 + err |= get_user(sllx, (unsigned int *)(addr+16));
11232 + err |= get_user(add, (unsigned int *)(addr+20));
11233 + err |= get_user(jmpl, (unsigned int *)(addr+24));
11234 + err |= get_user(nop, (unsigned int *)(addr+28));
11235 + if (err)
11236 + break;
11237 +
11238 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
11239 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
11240 + (or1 & 0xFFFFE000U) == 0x88112000U &&
11241 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
11242 + sllx == 0x89293020U &&
11243 + add == 0x8A010005U &&
11244 + jmpl == 0x89C14000U &&
11245 + nop == 0x01000000U)
11246 + {
11247 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11248 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
11249 + regs->u_regs[UREG_G4] <<= 32;
11250 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
11251 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
11252 + regs->u_regs[UREG_G4] = addr + 24;
11253 + addr = regs->u_regs[UREG_G5];
11254 + regs->tpc = addr;
11255 + regs->tnpc = addr+4;
11256 + return 3;
11257 + }
11258 + }
11259 + } while (0);
11260 +
11261 +#ifdef CONFIG_PAX_DLRESOLVE
11262 + do { /* PaX: unpatched PLT emulation step 2 */
11263 + unsigned int save, call, nop;
11264 +
11265 + err = get_user(save, (unsigned int *)(regs->tpc-4));
11266 + err |= get_user(call, (unsigned int *)regs->tpc);
11267 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
11268 + if (err)
11269 + break;
11270 +
11271 + if (save == 0x9DE3BFA8U &&
11272 + (call & 0xC0000000U) == 0x40000000U &&
11273 + nop == 0x01000000U)
11274 + {
11275 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
11276 +
11277 + if (test_thread_flag(TIF_32BIT))
11278 + dl_resolve &= 0xFFFFFFFFUL;
11279 +
11280 + regs->u_regs[UREG_RETPC] = regs->tpc;
11281 + regs->tpc = dl_resolve;
11282 + regs->tnpc = dl_resolve+4;
11283 + return 3;
11284 + }
11285 + } while (0);
11286 +#endif
11287 +
11288 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
11289 + unsigned int sethi, ba, nop;
11290 +
11291 + err = get_user(sethi, (unsigned int *)regs->tpc);
11292 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
11293 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
11294 +
11295 + if (err)
11296 + break;
11297 +
11298 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11299 + (ba & 0xFFF00000U) == 0x30600000U &&
11300 + nop == 0x01000000U)
11301 + {
11302 + unsigned long addr;
11303 +
11304 + addr = (sethi & 0x003FFFFFU) << 10;
11305 + regs->u_regs[UREG_G1] = addr;
11306 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
11307 +
11308 + if (test_thread_flag(TIF_32BIT))
11309 + addr &= 0xFFFFFFFFUL;
11310 +
11311 + regs->tpc = addr;
11312 + regs->tnpc = addr+4;
11313 + return 2;
11314 + }
11315 + } while (0);
11316 +
11317 +#endif
11318 +
11319 + return 1;
11320 +}
11321 +
11322 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
11323 +{
11324 + unsigned long i;
11325 +
11326 + printk(KERN_ERR "PAX: bytes at PC: ");
11327 + for (i = 0; i < 8; i++) {
11328 + unsigned int c;
11329 + if (get_user(c, (unsigned int *)pc+i))
11330 + printk(KERN_CONT "???????? ");
11331 + else
11332 + printk(KERN_CONT "%08x ", c);
11333 + }
11334 + printk("\n");
11335 +}
11336 +#endif
11337 +
11338 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
11339 {
11340 struct mm_struct *mm = current->mm;
11341 @@ -341,6 +804,29 @@ retry:
11342 if (!vma)
11343 goto bad_area;
11344
11345 +#ifdef CONFIG_PAX_PAGEEXEC
11346 + /* PaX: detect ITLB misses on non-exec pages */
11347 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
11348 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
11349 + {
11350 + if (address != regs->tpc)
11351 + goto good_area;
11352 +
11353 + up_read(&mm->mmap_sem);
11354 + switch (pax_handle_fetch_fault(regs)) {
11355 +
11356 +#ifdef CONFIG_PAX_EMUPLT
11357 + case 2:
11358 + case 3:
11359 + return;
11360 +#endif
11361 +
11362 + }
11363 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
11364 + do_group_exit(SIGKILL);
11365 + }
11366 +#endif
11367 +
11368 /* Pure DTLB misses do not tell us whether the fault causing
11369 * load/store/atomic was a write or not, it only says that there
11370 * was no match. So in such a case we (carefully) read the
11371 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
11372 index d2b5944..d878f3c 100644
11373 --- a/arch/sparc/mm/hugetlbpage.c
11374 +++ b/arch/sparc/mm/hugetlbpage.c
11375 @@ -28,7 +28,8 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11376 unsigned long addr,
11377 unsigned long len,
11378 unsigned long pgoff,
11379 - unsigned long flags)
11380 + unsigned long flags,
11381 + unsigned long offset)
11382 {
11383 unsigned long task_size = TASK_SIZE;
11384 struct vm_unmapped_area_info info;
11385 @@ -38,15 +39,22 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11386
11387 info.flags = 0;
11388 info.length = len;
11389 - info.low_limit = TASK_UNMAPPED_BASE;
11390 + info.low_limit = mm->mmap_base;
11391 info.high_limit = min(task_size, VA_EXCLUDE_START);
11392 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11393 info.align_offset = 0;
11394 + info.threadstack_offset = offset;
11395 addr = vm_unmapped_area(&info);
11396
11397 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
11398 VM_BUG_ON(addr != -ENOMEM);
11399 info.low_limit = VA_EXCLUDE_END;
11400 +
11401 +#ifdef CONFIG_PAX_RANDMMAP
11402 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11403 + info.low_limit += mm->delta_mmap;
11404 +#endif
11405 +
11406 info.high_limit = task_size;
11407 addr = vm_unmapped_area(&info);
11408 }
11409 @@ -58,7 +66,8 @@ static unsigned long
11410 hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11411 const unsigned long len,
11412 const unsigned long pgoff,
11413 - const unsigned long flags)
11414 + const unsigned long flags,
11415 + const unsigned long offset)
11416 {
11417 struct mm_struct *mm = current->mm;
11418 unsigned long addr = addr0;
11419 @@ -73,6 +82,7 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11420 info.high_limit = mm->mmap_base;
11421 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11422 info.align_offset = 0;
11423 + info.threadstack_offset = offset;
11424 addr = vm_unmapped_area(&info);
11425
11426 /*
11427 @@ -85,6 +95,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11428 VM_BUG_ON(addr != -ENOMEM);
11429 info.flags = 0;
11430 info.low_limit = TASK_UNMAPPED_BASE;
11431 +
11432 +#ifdef CONFIG_PAX_RANDMMAP
11433 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11434 + info.low_limit += mm->delta_mmap;
11435 +#endif
11436 +
11437 info.high_limit = STACK_TOP32;
11438 addr = vm_unmapped_area(&info);
11439 }
11440 @@ -99,6 +115,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11441 struct mm_struct *mm = current->mm;
11442 struct vm_area_struct *vma;
11443 unsigned long task_size = TASK_SIZE;
11444 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
11445
11446 if (test_thread_flag(TIF_32BIT))
11447 task_size = STACK_TOP32;
11448 @@ -114,19 +131,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11449 return addr;
11450 }
11451
11452 +#ifdef CONFIG_PAX_RANDMMAP
11453 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
11454 +#endif
11455 +
11456 if (addr) {
11457 addr = ALIGN(addr, HPAGE_SIZE);
11458 vma = find_vma(mm, addr);
11459 - if (task_size - len >= addr &&
11460 - (!vma || addr + len <= vma->vm_start))
11461 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
11462 return addr;
11463 }
11464 if (mm->get_unmapped_area == arch_get_unmapped_area)
11465 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
11466 - pgoff, flags);
11467 + pgoff, flags, offset);
11468 else
11469 return hugetlb_get_unmapped_area_topdown(file, addr, len,
11470 - pgoff, flags);
11471 + pgoff, flags, offset);
11472 }
11473
11474 pte_t *huge_pte_alloc(struct mm_struct *mm,
11475 diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
11476 index 04fd55a..4ede686 100644
11477 --- a/arch/sparc/mm/init_64.c
11478 +++ b/arch/sparc/mm/init_64.c
11479 @@ -188,9 +188,9 @@ unsigned long sparc64_kern_sec_context __read_mostly;
11480 int num_kernel_image_mappings;
11481
11482 #ifdef CONFIG_DEBUG_DCFLUSH
11483 -atomic_t dcpage_flushes = ATOMIC_INIT(0);
11484 +atomic_unchecked_t dcpage_flushes = ATOMIC_INIT(0);
11485 #ifdef CONFIG_SMP
11486 -atomic_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11487 +atomic_unchecked_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11488 #endif
11489 #endif
11490
11491 @@ -198,7 +198,7 @@ inline void flush_dcache_page_impl(struct page *page)
11492 {
11493 BUG_ON(tlb_type == hypervisor);
11494 #ifdef CONFIG_DEBUG_DCFLUSH
11495 - atomic_inc(&dcpage_flushes);
11496 + atomic_inc_unchecked(&dcpage_flushes);
11497 #endif
11498
11499 #ifdef DCACHE_ALIASING_POSSIBLE
11500 @@ -466,10 +466,10 @@ void mmu_info(struct seq_file *m)
11501
11502 #ifdef CONFIG_DEBUG_DCFLUSH
11503 seq_printf(m, "DCPageFlushes\t: %d\n",
11504 - atomic_read(&dcpage_flushes));
11505 + atomic_read_unchecked(&dcpage_flushes));
11506 #ifdef CONFIG_SMP
11507 seq_printf(m, "DCPageFlushesXC\t: %d\n",
11508 - atomic_read(&dcpage_flushes_xcall));
11509 + atomic_read_unchecked(&dcpage_flushes_xcall));
11510 #endif /* CONFIG_SMP */
11511 #endif /* CONFIG_DEBUG_DCFLUSH */
11512 }
11513 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
11514 index f4500c6..889656c 100644
11515 --- a/arch/tile/include/asm/atomic_64.h
11516 +++ b/arch/tile/include/asm/atomic_64.h
11517 @@ -143,6 +143,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
11518
11519 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
11520
11521 +#define atomic64_read_unchecked(v) atomic64_read(v)
11522 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
11523 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
11524 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
11525 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
11526 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
11527 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
11528 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
11529 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
11530 +
11531 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
11532 #define smp_mb__before_atomic_dec() smp_mb()
11533 #define smp_mb__after_atomic_dec() smp_mb()
11534 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
11535 index a9a5299..0fce79e 100644
11536 --- a/arch/tile/include/asm/cache.h
11537 +++ b/arch/tile/include/asm/cache.h
11538 @@ -15,11 +15,12 @@
11539 #ifndef _ASM_TILE_CACHE_H
11540 #define _ASM_TILE_CACHE_H
11541
11542 +#include <linux/const.h>
11543 #include <arch/chip.h>
11544
11545 /* bytes per L1 data cache line */
11546 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
11547 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11548 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11549
11550 /* bytes per L2 cache line */
11551 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
11552 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
11553 index 8a082bc..7a6bf87 100644
11554 --- a/arch/tile/include/asm/uaccess.h
11555 +++ b/arch/tile/include/asm/uaccess.h
11556 @@ -408,9 +408,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
11557 const void __user *from,
11558 unsigned long n)
11559 {
11560 - int sz = __compiletime_object_size(to);
11561 + size_t sz = __compiletime_object_size(to);
11562
11563 - if (likely(sz == -1 || sz >= n))
11564 + if (likely(sz == (size_t)-1 || sz >= n))
11565 n = _copy_from_user(to, from, n);
11566 else
11567 copy_from_user_overflow();
11568 diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
11569 index 650ccff..45fe2d6 100644
11570 --- a/arch/tile/mm/hugetlbpage.c
11571 +++ b/arch/tile/mm/hugetlbpage.c
11572 @@ -239,6 +239,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
11573 info.high_limit = TASK_SIZE;
11574 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11575 info.align_offset = 0;
11576 + info.threadstack_offset = 0;
11577 return vm_unmapped_area(&info);
11578 }
11579
11580 @@ -256,6 +257,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
11581 info.high_limit = current->mm->mmap_base;
11582 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11583 info.align_offset = 0;
11584 + info.threadstack_offset = 0;
11585 addr = vm_unmapped_area(&info);
11586
11587 /*
11588 diff --git a/arch/um/Makefile b/arch/um/Makefile
11589 index 133f7de..1d6f2f1 100644
11590 --- a/arch/um/Makefile
11591 +++ b/arch/um/Makefile
11592 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
11593 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
11594 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
11595
11596 +ifdef CONSTIFY_PLUGIN
11597 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11598 +endif
11599 +
11600 #This will adjust *FLAGS accordingly to the platform.
11601 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
11602
11603 diff --git a/arch/um/defconfig b/arch/um/defconfig
11604 index 08107a7..ab22afe 100644
11605 --- a/arch/um/defconfig
11606 +++ b/arch/um/defconfig
11607 @@ -51,7 +51,6 @@ CONFIG_X86_CMPXCHG=y
11608 CONFIG_X86_L1_CACHE_SHIFT=5
11609 CONFIG_X86_XADD=y
11610 CONFIG_X86_PPRO_FENCE=y
11611 -CONFIG_X86_WP_WORKS_OK=y
11612 CONFIG_X86_INVLPG=y
11613 CONFIG_X86_BSWAP=y
11614 CONFIG_X86_POPAD_OK=y
11615 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
11616 index 19e1bdd..3665b77 100644
11617 --- a/arch/um/include/asm/cache.h
11618 +++ b/arch/um/include/asm/cache.h
11619 @@ -1,6 +1,7 @@
11620 #ifndef __UM_CACHE_H
11621 #define __UM_CACHE_H
11622
11623 +#include <linux/const.h>
11624
11625 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
11626 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
11627 @@ -12,6 +13,6 @@
11628 # define L1_CACHE_SHIFT 5
11629 #endif
11630
11631 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11632 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11633
11634 #endif
11635 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
11636 index 2e0a6b1..a64d0f5 100644
11637 --- a/arch/um/include/asm/kmap_types.h
11638 +++ b/arch/um/include/asm/kmap_types.h
11639 @@ -8,6 +8,6 @@
11640
11641 /* No more #include "asm/arch/kmap_types.h" ! */
11642
11643 -#define KM_TYPE_NR 14
11644 +#define KM_TYPE_NR 15
11645
11646 #endif
11647 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
11648 index 5ff53d9..5850cdf 100644
11649 --- a/arch/um/include/asm/page.h
11650 +++ b/arch/um/include/asm/page.h
11651 @@ -14,6 +14,9 @@
11652 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
11653 #define PAGE_MASK (~(PAGE_SIZE-1))
11654
11655 +#define ktla_ktva(addr) (addr)
11656 +#define ktva_ktla(addr) (addr)
11657 +
11658 #ifndef __ASSEMBLY__
11659
11660 struct page;
11661 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
11662 index 0032f92..cd151e0 100644
11663 --- a/arch/um/include/asm/pgtable-3level.h
11664 +++ b/arch/um/include/asm/pgtable-3level.h
11665 @@ -58,6 +58,7 @@
11666 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
11667 #define pud_populate(mm, pud, pmd) \
11668 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
11669 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
11670
11671 #ifdef CONFIG_64BIT
11672 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
11673 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
11674 index bbcef52..6a2a483 100644
11675 --- a/arch/um/kernel/process.c
11676 +++ b/arch/um/kernel/process.c
11677 @@ -367,22 +367,6 @@ int singlestepping(void * t)
11678 return 2;
11679 }
11680
11681 -/*
11682 - * Only x86 and x86_64 have an arch_align_stack().
11683 - * All other arches have "#define arch_align_stack(x) (x)"
11684 - * in their asm/system.h
11685 - * As this is included in UML from asm-um/system-generic.h,
11686 - * we can use it to behave as the subarch does.
11687 - */
11688 -#ifndef arch_align_stack
11689 -unsigned long arch_align_stack(unsigned long sp)
11690 -{
11691 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
11692 - sp -= get_random_int() % 8192;
11693 - return sp & ~0xf;
11694 -}
11695 -#endif
11696 -
11697 unsigned long get_wchan(struct task_struct *p)
11698 {
11699 unsigned long stack_page, sp, ip;
11700 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
11701 index ad8f795..2c7eec6 100644
11702 --- a/arch/unicore32/include/asm/cache.h
11703 +++ b/arch/unicore32/include/asm/cache.h
11704 @@ -12,8 +12,10 @@
11705 #ifndef __UNICORE_CACHE_H__
11706 #define __UNICORE_CACHE_H__
11707
11708 -#define L1_CACHE_SHIFT (5)
11709 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11710 +#include <linux/const.h>
11711 +
11712 +#define L1_CACHE_SHIFT 5
11713 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11714
11715 /*
11716 * Memory returned by kmalloc() may be used for DMA, so we must make
11717 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
11718 index fe120da..24177f7 100644
11719 --- a/arch/x86/Kconfig
11720 +++ b/arch/x86/Kconfig
11721 @@ -239,7 +239,7 @@ config X86_HT
11722
11723 config X86_32_LAZY_GS
11724 def_bool y
11725 - depends on X86_32 && !CC_STACKPROTECTOR
11726 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
11727
11728 config ARCH_HWEIGHT_CFLAGS
11729 string
11730 @@ -1073,6 +1073,7 @@ config MICROCODE_EARLY
11731
11732 config X86_MSR
11733 tristate "/dev/cpu/*/msr - Model-specific register support"
11734 + depends on !GRKERNSEC_KMEM
11735 ---help---
11736 This device gives privileged processes access to the x86
11737 Model-Specific Registers (MSRs). It is a character device with
11738 @@ -1096,7 +1097,7 @@ choice
11739
11740 config NOHIGHMEM
11741 bool "off"
11742 - depends on !X86_NUMAQ
11743 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11744 ---help---
11745 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
11746 However, the address space of 32-bit x86 processors is only 4
11747 @@ -1133,7 +1134,7 @@ config NOHIGHMEM
11748
11749 config HIGHMEM4G
11750 bool "4GB"
11751 - depends on !X86_NUMAQ
11752 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11753 ---help---
11754 Select this if you have a 32-bit processor and between 1 and 4
11755 gigabytes of physical RAM.
11756 @@ -1186,7 +1187,7 @@ config PAGE_OFFSET
11757 hex
11758 default 0xB0000000 if VMSPLIT_3G_OPT
11759 default 0x80000000 if VMSPLIT_2G
11760 - default 0x78000000 if VMSPLIT_2G_OPT
11761 + default 0x70000000 if VMSPLIT_2G_OPT
11762 default 0x40000000 if VMSPLIT_1G
11763 default 0xC0000000
11764 depends on X86_32
11765 @@ -1584,6 +1585,7 @@ config SECCOMP
11766
11767 config CC_STACKPROTECTOR
11768 bool "Enable -fstack-protector buffer overflow detection"
11769 + depends on X86_64 || !PAX_MEMORY_UDEREF
11770 ---help---
11771 This option turns on the -fstack-protector GCC feature. This
11772 feature puts, at the beginning of functions, a canary value on
11773 @@ -1703,6 +1705,8 @@ config X86_NEED_RELOCS
11774 config PHYSICAL_ALIGN
11775 hex "Alignment value to which kernel should be aligned" if X86_32
11776 default "0x1000000"
11777 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
11778 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
11779 range 0x2000 0x1000000
11780 ---help---
11781 This value puts the alignment restrictions on physical address
11782 @@ -1778,9 +1782,10 @@ config DEBUG_HOTPLUG_CPU0
11783 If unsure, say N.
11784
11785 config COMPAT_VDSO
11786 - def_bool y
11787 + def_bool n
11788 prompt "Compat VDSO support"
11789 depends on X86_32 || IA32_EMULATION
11790 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
11791 ---help---
11792 Map the 32-bit VDSO to the predictable old-style address too.
11793
11794 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
11795 index c026cca..14657ae 100644
11796 --- a/arch/x86/Kconfig.cpu
11797 +++ b/arch/x86/Kconfig.cpu
11798 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
11799
11800 config X86_F00F_BUG
11801 def_bool y
11802 - depends on M586MMX || M586TSC || M586 || M486
11803 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
11804
11805 config X86_INVD_BUG
11806 def_bool y
11807 @@ -327,7 +327,7 @@ config X86_INVD_BUG
11808
11809 config X86_ALIGNMENT_16
11810 def_bool y
11811 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11812 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11813
11814 config X86_INTEL_USERCOPY
11815 def_bool y
11816 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
11817 # generates cmov.
11818 config X86_CMOV
11819 def_bool y
11820 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11821 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11822
11823 config X86_MINIMUM_CPU_FAMILY
11824 int
11825 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
11826 index c198b7e..63eea60 100644
11827 --- a/arch/x86/Kconfig.debug
11828 +++ b/arch/x86/Kconfig.debug
11829 @@ -84,7 +84,7 @@ config X86_PTDUMP
11830 config DEBUG_RODATA
11831 bool "Write protect kernel read-only data structures"
11832 default y
11833 - depends on DEBUG_KERNEL
11834 + depends on DEBUG_KERNEL && BROKEN
11835 ---help---
11836 Mark the kernel read-only data as write-protected in the pagetables,
11837 in order to catch accidental (and incorrect) writes to such const
11838 @@ -102,7 +102,7 @@ config DEBUG_RODATA_TEST
11839
11840 config DEBUG_SET_MODULE_RONX
11841 bool "Set loadable kernel module data as NX and text as RO"
11842 - depends on MODULES
11843 + depends on MODULES && BROKEN
11844 ---help---
11845 This option helps catch unintended modifications to loadable
11846 kernel module's text and read-only data. It also prevents execution
11847 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
11848 index 5c47726..8c4fa67 100644
11849 --- a/arch/x86/Makefile
11850 +++ b/arch/x86/Makefile
11851 @@ -54,6 +54,7 @@ else
11852 UTS_MACHINE := x86_64
11853 CHECKFLAGS += -D__x86_64__ -m64
11854
11855 + biarch := $(call cc-option,-m64)
11856 KBUILD_AFLAGS += -m64
11857 KBUILD_CFLAGS += -m64
11858
11859 @@ -234,3 +235,12 @@ define archhelp
11860 echo ' FDARGS="..." arguments for the booted kernel'
11861 echo ' FDINITRD=file initrd for the booted kernel'
11862 endef
11863 +
11864 +define OLD_LD
11865 +
11866 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
11867 +*** Please upgrade your binutils to 2.18 or newer
11868 +endef
11869 +
11870 +archprepare:
11871 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
11872 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
11873 index 379814b..add62ce 100644
11874 --- a/arch/x86/boot/Makefile
11875 +++ b/arch/x86/boot/Makefile
11876 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
11877 $(call cc-option, -fno-stack-protector) \
11878 $(call cc-option, -mpreferred-stack-boundary=2)
11879 KBUILD_CFLAGS += $(call cc-option, -m32)
11880 +ifdef CONSTIFY_PLUGIN
11881 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11882 +endif
11883 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11884 GCOV_PROFILE := n
11885
11886 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
11887 index 878e4b9..20537ab 100644
11888 --- a/arch/x86/boot/bitops.h
11889 +++ b/arch/x86/boot/bitops.h
11890 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11891 u8 v;
11892 const u32 *p = (const u32 *)addr;
11893
11894 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11895 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11896 return v;
11897 }
11898
11899 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11900
11901 static inline void set_bit(int nr, void *addr)
11902 {
11903 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11904 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11905 }
11906
11907 #endif /* BOOT_BITOPS_H */
11908 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
11909 index 5b75319..331a4ca 100644
11910 --- a/arch/x86/boot/boot.h
11911 +++ b/arch/x86/boot/boot.h
11912 @@ -85,7 +85,7 @@ static inline void io_delay(void)
11913 static inline u16 ds(void)
11914 {
11915 u16 seg;
11916 - asm("movw %%ds,%0" : "=rm" (seg));
11917 + asm volatile("movw %%ds,%0" : "=rm" (seg));
11918 return seg;
11919 }
11920
11921 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
11922 static inline int memcmp(const void *s1, const void *s2, size_t len)
11923 {
11924 u8 diff;
11925 - asm("repe; cmpsb; setnz %0"
11926 + asm volatile("repe; cmpsb; setnz %0"
11927 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
11928 return diff;
11929 }
11930 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
11931 index 5ef205c..342191d 100644
11932 --- a/arch/x86/boot/compressed/Makefile
11933 +++ b/arch/x86/boot/compressed/Makefile
11934 @@ -14,6 +14,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
11935 KBUILD_CFLAGS += $(cflags-y)
11936 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
11937 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
11938 +ifdef CONSTIFY_PLUGIN
11939 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11940 +endif
11941
11942 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11943 GCOV_PROFILE := n
11944 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
11945 index d606463..b887794 100644
11946 --- a/arch/x86/boot/compressed/eboot.c
11947 +++ b/arch/x86/boot/compressed/eboot.c
11948 @@ -150,7 +150,6 @@ again:
11949 *addr = max_addr;
11950 }
11951
11952 -free_pool:
11953 efi_call_phys1(sys_table->boottime->free_pool, map);
11954
11955 fail:
11956 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
11957 if (i == map_size / desc_size)
11958 status = EFI_NOT_FOUND;
11959
11960 -free_pool:
11961 efi_call_phys1(sys_table->boottime->free_pool, map);
11962 fail:
11963 return status;
11964 diff --git a/arch/x86/boot/compressed/efi_stub_32.S b/arch/x86/boot/compressed/efi_stub_32.S
11965 index a53440e..c3dbf1e 100644
11966 --- a/arch/x86/boot/compressed/efi_stub_32.S
11967 +++ b/arch/x86/boot/compressed/efi_stub_32.S
11968 @@ -46,16 +46,13 @@ ENTRY(efi_call_phys)
11969 * parameter 2, ..., param n. To make things easy, we save the return
11970 * address of efi_call_phys in a global variable.
11971 */
11972 - popl %ecx
11973 - movl %ecx, saved_return_addr(%edx)
11974 - /* get the function pointer into ECX*/
11975 - popl %ecx
11976 - movl %ecx, efi_rt_function_ptr(%edx)
11977 + popl saved_return_addr(%edx)
11978 + popl efi_rt_function_ptr(%edx)
11979
11980 /*
11981 * 3. Call the physical function.
11982 */
11983 - call *%ecx
11984 + call *efi_rt_function_ptr(%edx)
11985
11986 /*
11987 * 4. Balance the stack. And because EAX contain the return value,
11988 @@ -67,15 +64,12 @@ ENTRY(efi_call_phys)
11989 1: popl %edx
11990 subl $1b, %edx
11991
11992 - movl efi_rt_function_ptr(%edx), %ecx
11993 - pushl %ecx
11994 + pushl efi_rt_function_ptr(%edx)
11995
11996 /*
11997 * 10. Push the saved return address onto the stack and return.
11998 */
11999 - movl saved_return_addr(%edx), %ecx
12000 - pushl %ecx
12001 - ret
12002 + jmpl *saved_return_addr(%edx)
12003 ENDPROC(efi_call_phys)
12004 .previous
12005
12006 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
12007 index 1e3184f..0d11e2e 100644
12008 --- a/arch/x86/boot/compressed/head_32.S
12009 +++ b/arch/x86/boot/compressed/head_32.S
12010 @@ -118,7 +118,7 @@ preferred_addr:
12011 notl %eax
12012 andl %eax, %ebx
12013 #else
12014 - movl $LOAD_PHYSICAL_ADDR, %ebx
12015 + movl $____LOAD_PHYSICAL_ADDR, %ebx
12016 #endif
12017
12018 /* Target address to relocate to for decompression */
12019 @@ -204,7 +204,7 @@ relocated:
12020 * and where it was actually loaded.
12021 */
12022 movl %ebp, %ebx
12023 - subl $LOAD_PHYSICAL_ADDR, %ebx
12024 + subl $____LOAD_PHYSICAL_ADDR, %ebx
12025 jz 2f /* Nothing to be done if loaded at compiled addr. */
12026 /*
12027 * Process relocations.
12028 @@ -212,8 +212,7 @@ relocated:
12029
12030 1: subl $4, %edi
12031 movl (%edi), %ecx
12032 - testl %ecx, %ecx
12033 - jz 2f
12034 + jecxz 2f
12035 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
12036 jmp 1b
12037 2:
12038 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
12039 index 16f24e6..47491a3 100644
12040 --- a/arch/x86/boot/compressed/head_64.S
12041 +++ b/arch/x86/boot/compressed/head_64.S
12042 @@ -97,7 +97,7 @@ ENTRY(startup_32)
12043 notl %eax
12044 andl %eax, %ebx
12045 #else
12046 - movl $LOAD_PHYSICAL_ADDR, %ebx
12047 + movl $____LOAD_PHYSICAL_ADDR, %ebx
12048 #endif
12049
12050 /* Target address to relocate to for decompression */
12051 @@ -272,7 +272,7 @@ preferred_addr:
12052 notq %rax
12053 andq %rax, %rbp
12054 #else
12055 - movq $LOAD_PHYSICAL_ADDR, %rbp
12056 + movq $____LOAD_PHYSICAL_ADDR, %rbp
12057 #endif
12058
12059 /* Target address to relocate to for decompression */
12060 @@ -363,8 +363,8 @@ gdt:
12061 .long gdt
12062 .word 0
12063 .quad 0x0000000000000000 /* NULL descriptor */
12064 - .quad 0x00af9a000000ffff /* __KERNEL_CS */
12065 - .quad 0x00cf92000000ffff /* __KERNEL_DS */
12066 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
12067 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
12068 .quad 0x0080890000000000 /* TS descriptor */
12069 .quad 0x0000000000000000 /* TS continued */
12070 gdt_end:
12071 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
12072 index 7cb56c6..d382d84 100644
12073 --- a/arch/x86/boot/compressed/misc.c
12074 +++ b/arch/x86/boot/compressed/misc.c
12075 @@ -303,7 +303,7 @@ static void parse_elf(void *output)
12076 case PT_LOAD:
12077 #ifdef CONFIG_RELOCATABLE
12078 dest = output;
12079 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
12080 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
12081 #else
12082 dest = (void *)(phdr->p_paddr);
12083 #endif
12084 @@ -354,7 +354,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
12085 error("Destination address too large");
12086 #endif
12087 #ifndef CONFIG_RELOCATABLE
12088 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
12089 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
12090 error("Wrong destination address");
12091 #endif
12092
12093 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
12094 index 4d3ff03..e4972ff 100644
12095 --- a/arch/x86/boot/cpucheck.c
12096 +++ b/arch/x86/boot/cpucheck.c
12097 @@ -74,7 +74,7 @@ static int has_fpu(void)
12098 u16 fcw = -1, fsw = -1;
12099 u32 cr0;
12100
12101 - asm("movl %%cr0,%0" : "=r" (cr0));
12102 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
12103 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
12104 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
12105 asm volatile("movl %0,%%cr0" : : "r" (cr0));
12106 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
12107 {
12108 u32 f0, f1;
12109
12110 - asm("pushfl ; "
12111 + asm volatile("pushfl ; "
12112 "pushfl ; "
12113 "popl %0 ; "
12114 "movl %0,%1 ; "
12115 @@ -115,7 +115,7 @@ static void get_flags(void)
12116 set_bit(X86_FEATURE_FPU, cpu.flags);
12117
12118 if (has_eflag(X86_EFLAGS_ID)) {
12119 - asm("cpuid"
12120 + asm volatile("cpuid"
12121 : "=a" (max_intel_level),
12122 "=b" (cpu_vendor[0]),
12123 "=d" (cpu_vendor[1]),
12124 @@ -124,7 +124,7 @@ static void get_flags(void)
12125
12126 if (max_intel_level >= 0x00000001 &&
12127 max_intel_level <= 0x0000ffff) {
12128 - asm("cpuid"
12129 + asm volatile("cpuid"
12130 : "=a" (tfms),
12131 "=c" (cpu.flags[4]),
12132 "=d" (cpu.flags[0])
12133 @@ -136,7 +136,7 @@ static void get_flags(void)
12134 cpu.model += ((tfms >> 16) & 0xf) << 4;
12135 }
12136
12137 - asm("cpuid"
12138 + asm volatile("cpuid"
12139 : "=a" (max_amd_level)
12140 : "a" (0x80000000)
12141 : "ebx", "ecx", "edx");
12142 @@ -144,7 +144,7 @@ static void get_flags(void)
12143 if (max_amd_level >= 0x80000001 &&
12144 max_amd_level <= 0x8000ffff) {
12145 u32 eax = 0x80000001;
12146 - asm("cpuid"
12147 + asm volatile("cpuid"
12148 : "+a" (eax),
12149 "=c" (cpu.flags[6]),
12150 "=d" (cpu.flags[1])
12151 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
12152 u32 ecx = MSR_K7_HWCR;
12153 u32 eax, edx;
12154
12155 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12156 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12157 eax &= ~(1 << 15);
12158 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12159 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12160
12161 get_flags(); /* Make sure it really did something */
12162 err = check_flags();
12163 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
12164 u32 ecx = MSR_VIA_FCR;
12165 u32 eax, edx;
12166
12167 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12168 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12169 eax |= (1<<1)|(1<<7);
12170 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12171 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12172
12173 set_bit(X86_FEATURE_CX8, cpu.flags);
12174 err = check_flags();
12175 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
12176 u32 eax, edx;
12177 u32 level = 1;
12178
12179 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12180 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
12181 - asm("cpuid"
12182 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12183 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
12184 + asm volatile("cpuid"
12185 : "+a" (level), "=d" (cpu.flags[0])
12186 : : "ecx", "ebx");
12187 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12188 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12189
12190 err = check_flags();
12191 }
12192 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
12193 index 9ec06a1..2c25e79 100644
12194 --- a/arch/x86/boot/header.S
12195 +++ b/arch/x86/boot/header.S
12196 @@ -409,10 +409,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
12197 # single linked list of
12198 # struct setup_data
12199
12200 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
12201 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
12202
12203 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
12204 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
12205 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
12206 +#else
12207 #define VO_INIT_SIZE (VO__end - VO__text)
12208 +#endif
12209 #if ZO_INIT_SIZE > VO_INIT_SIZE
12210 #define INIT_SIZE ZO_INIT_SIZE
12211 #else
12212 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
12213 index db75d07..8e6d0af 100644
12214 --- a/arch/x86/boot/memory.c
12215 +++ b/arch/x86/boot/memory.c
12216 @@ -19,7 +19,7 @@
12217
12218 static int detect_memory_e820(void)
12219 {
12220 - int count = 0;
12221 + unsigned int count = 0;
12222 struct biosregs ireg, oreg;
12223 struct e820entry *desc = boot_params.e820_map;
12224 static struct e820entry buf; /* static so it is zeroed */
12225 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
12226 index 11e8c6e..fdbb1ed 100644
12227 --- a/arch/x86/boot/video-vesa.c
12228 +++ b/arch/x86/boot/video-vesa.c
12229 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
12230
12231 boot_params.screen_info.vesapm_seg = oreg.es;
12232 boot_params.screen_info.vesapm_off = oreg.di;
12233 + boot_params.screen_info.vesapm_size = oreg.cx;
12234 }
12235
12236 /*
12237 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
12238 index 43eda28..5ab5fdb 100644
12239 --- a/arch/x86/boot/video.c
12240 +++ b/arch/x86/boot/video.c
12241 @@ -96,7 +96,7 @@ static void store_mode_params(void)
12242 static unsigned int get_entry(void)
12243 {
12244 char entry_buf[4];
12245 - int i, len = 0;
12246 + unsigned int i, len = 0;
12247 int key;
12248 unsigned int v;
12249
12250 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
12251 index 9105655..5e37f27 100644
12252 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
12253 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
12254 @@ -8,6 +8,8 @@
12255 * including this sentence is retained in full.
12256 */
12257
12258 +#include <asm/alternative-asm.h>
12259 +
12260 .extern crypto_ft_tab
12261 .extern crypto_it_tab
12262 .extern crypto_fl_tab
12263 @@ -70,6 +72,8 @@
12264 je B192; \
12265 leaq 32(r9),r9;
12266
12267 +#define ret pax_force_retaddr 0, 1; ret
12268 +
12269 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
12270 movq r1,r2; \
12271 movq r3,r4; \
12272 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
12273 index 477e9d7..3ab339f 100644
12274 --- a/arch/x86/crypto/aesni-intel_asm.S
12275 +++ b/arch/x86/crypto/aesni-intel_asm.S
12276 @@ -31,6 +31,7 @@
12277
12278 #include <linux/linkage.h>
12279 #include <asm/inst.h>
12280 +#include <asm/alternative-asm.h>
12281
12282 #ifdef __x86_64__
12283 .data
12284 @@ -1441,6 +1442,7 @@ _return_T_done_decrypt:
12285 pop %r14
12286 pop %r13
12287 pop %r12
12288 + pax_force_retaddr 0, 1
12289 ret
12290 ENDPROC(aesni_gcm_dec)
12291
12292 @@ -1705,6 +1707,7 @@ _return_T_done_encrypt:
12293 pop %r14
12294 pop %r13
12295 pop %r12
12296 + pax_force_retaddr 0, 1
12297 ret
12298 ENDPROC(aesni_gcm_enc)
12299
12300 @@ -1722,6 +1725,7 @@ _key_expansion_256a:
12301 pxor %xmm1, %xmm0
12302 movaps %xmm0, (TKEYP)
12303 add $0x10, TKEYP
12304 + pax_force_retaddr_bts
12305 ret
12306 ENDPROC(_key_expansion_128)
12307 ENDPROC(_key_expansion_256a)
12308 @@ -1748,6 +1752,7 @@ _key_expansion_192a:
12309 shufps $0b01001110, %xmm2, %xmm1
12310 movaps %xmm1, 0x10(TKEYP)
12311 add $0x20, TKEYP
12312 + pax_force_retaddr_bts
12313 ret
12314 ENDPROC(_key_expansion_192a)
12315
12316 @@ -1768,6 +1773,7 @@ _key_expansion_192b:
12317
12318 movaps %xmm0, (TKEYP)
12319 add $0x10, TKEYP
12320 + pax_force_retaddr_bts
12321 ret
12322 ENDPROC(_key_expansion_192b)
12323
12324 @@ -1781,6 +1787,7 @@ _key_expansion_256b:
12325 pxor %xmm1, %xmm2
12326 movaps %xmm2, (TKEYP)
12327 add $0x10, TKEYP
12328 + pax_force_retaddr_bts
12329 ret
12330 ENDPROC(_key_expansion_256b)
12331
12332 @@ -1894,6 +1901,7 @@ ENTRY(aesni_set_key)
12333 #ifndef __x86_64__
12334 popl KEYP
12335 #endif
12336 + pax_force_retaddr 0, 1
12337 ret
12338 ENDPROC(aesni_set_key)
12339
12340 @@ -1916,6 +1924,7 @@ ENTRY(aesni_enc)
12341 popl KLEN
12342 popl KEYP
12343 #endif
12344 + pax_force_retaddr 0, 1
12345 ret
12346 ENDPROC(aesni_enc)
12347
12348 @@ -1974,6 +1983,7 @@ _aesni_enc1:
12349 AESENC KEY STATE
12350 movaps 0x70(TKEYP), KEY
12351 AESENCLAST KEY STATE
12352 + pax_force_retaddr_bts
12353 ret
12354 ENDPROC(_aesni_enc1)
12355
12356 @@ -2083,6 +2093,7 @@ _aesni_enc4:
12357 AESENCLAST KEY STATE2
12358 AESENCLAST KEY STATE3
12359 AESENCLAST KEY STATE4
12360 + pax_force_retaddr_bts
12361 ret
12362 ENDPROC(_aesni_enc4)
12363
12364 @@ -2106,6 +2117,7 @@ ENTRY(aesni_dec)
12365 popl KLEN
12366 popl KEYP
12367 #endif
12368 + pax_force_retaddr 0, 1
12369 ret
12370 ENDPROC(aesni_dec)
12371
12372 @@ -2164,6 +2176,7 @@ _aesni_dec1:
12373 AESDEC KEY STATE
12374 movaps 0x70(TKEYP), KEY
12375 AESDECLAST KEY STATE
12376 + pax_force_retaddr_bts
12377 ret
12378 ENDPROC(_aesni_dec1)
12379
12380 @@ -2273,6 +2286,7 @@ _aesni_dec4:
12381 AESDECLAST KEY STATE2
12382 AESDECLAST KEY STATE3
12383 AESDECLAST KEY STATE4
12384 + pax_force_retaddr_bts
12385 ret
12386 ENDPROC(_aesni_dec4)
12387
12388 @@ -2331,6 +2345,7 @@ ENTRY(aesni_ecb_enc)
12389 popl KEYP
12390 popl LEN
12391 #endif
12392 + pax_force_retaddr 0, 1
12393 ret
12394 ENDPROC(aesni_ecb_enc)
12395
12396 @@ -2390,6 +2405,7 @@ ENTRY(aesni_ecb_dec)
12397 popl KEYP
12398 popl LEN
12399 #endif
12400 + pax_force_retaddr 0, 1
12401 ret
12402 ENDPROC(aesni_ecb_dec)
12403
12404 @@ -2432,6 +2448,7 @@ ENTRY(aesni_cbc_enc)
12405 popl LEN
12406 popl IVP
12407 #endif
12408 + pax_force_retaddr 0, 1
12409 ret
12410 ENDPROC(aesni_cbc_enc)
12411
12412 @@ -2523,6 +2540,7 @@ ENTRY(aesni_cbc_dec)
12413 popl LEN
12414 popl IVP
12415 #endif
12416 + pax_force_retaddr 0, 1
12417 ret
12418 ENDPROC(aesni_cbc_dec)
12419
12420 @@ -2550,6 +2568,7 @@ _aesni_inc_init:
12421 mov $1, TCTR_LOW
12422 MOVQ_R64_XMM TCTR_LOW INC
12423 MOVQ_R64_XMM CTR TCTR_LOW
12424 + pax_force_retaddr_bts
12425 ret
12426 ENDPROC(_aesni_inc_init)
12427
12428 @@ -2579,6 +2598,7 @@ _aesni_inc:
12429 .Linc_low:
12430 movaps CTR, IV
12431 PSHUFB_XMM BSWAP_MASK IV
12432 + pax_force_retaddr_bts
12433 ret
12434 ENDPROC(_aesni_inc)
12435
12436 @@ -2640,6 +2660,7 @@ ENTRY(aesni_ctr_enc)
12437 .Lctr_enc_ret:
12438 movups IV, (IVP)
12439 .Lctr_enc_just_ret:
12440 + pax_force_retaddr 0, 1
12441 ret
12442 ENDPROC(aesni_ctr_enc)
12443
12444 @@ -2766,6 +2787,7 @@ ENTRY(aesni_xts_crypt8)
12445 pxor INC, STATE4
12446 movdqu STATE4, 0x70(OUTP)
12447
12448 + pax_force_retaddr 0, 1
12449 ret
12450 ENDPROC(aesni_xts_crypt8)
12451
12452 diff --git a/arch/x86/crypto/blowfish-avx2-asm_64.S b/arch/x86/crypto/blowfish-avx2-asm_64.S
12453 index 784452e..46982c7 100644
12454 --- a/arch/x86/crypto/blowfish-avx2-asm_64.S
12455 +++ b/arch/x86/crypto/blowfish-avx2-asm_64.S
12456 @@ -221,6 +221,7 @@ __blowfish_enc_blk32:
12457
12458 write_block(RXl, RXr);
12459
12460 + pax_force_retaddr 0, 1
12461 ret;
12462 ENDPROC(__blowfish_enc_blk32)
12463
12464 @@ -250,6 +251,7 @@ __blowfish_dec_blk32:
12465
12466 write_block(RXl, RXr);
12467
12468 + pax_force_retaddr 0, 1
12469 ret;
12470 ENDPROC(__blowfish_dec_blk32)
12471
12472 @@ -284,6 +286,7 @@ ENTRY(blowfish_ecb_enc_32way)
12473
12474 vzeroupper;
12475
12476 + pax_force_retaddr 0, 1
12477 ret;
12478 ENDPROC(blowfish_ecb_enc_32way)
12479
12480 @@ -318,6 +321,7 @@ ENTRY(blowfish_ecb_dec_32way)
12481
12482 vzeroupper;
12483
12484 + pax_force_retaddr 0, 1
12485 ret;
12486 ENDPROC(blowfish_ecb_dec_32way)
12487
12488 @@ -365,6 +369,7 @@ ENTRY(blowfish_cbc_dec_32way)
12489
12490 vzeroupper;
12491
12492 + pax_force_retaddr 0, 1
12493 ret;
12494 ENDPROC(blowfish_cbc_dec_32way)
12495
12496 @@ -445,5 +450,6 @@ ENTRY(blowfish_ctr_32way)
12497
12498 vzeroupper;
12499
12500 + pax_force_retaddr 0, 1
12501 ret;
12502 ENDPROC(blowfish_ctr_32way)
12503 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12504 index 246c670..4d1ed00 100644
12505 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
12506 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12507 @@ -21,6 +21,7 @@
12508 */
12509
12510 #include <linux/linkage.h>
12511 +#include <asm/alternative-asm.h>
12512
12513 .file "blowfish-x86_64-asm.S"
12514 .text
12515 @@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
12516 jnz .L__enc_xor;
12517
12518 write_block();
12519 + pax_force_retaddr 0, 1
12520 ret;
12521 .L__enc_xor:
12522 xor_block();
12523 + pax_force_retaddr 0, 1
12524 ret;
12525 ENDPROC(__blowfish_enc_blk)
12526
12527 @@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
12528
12529 movq %r11, %rbp;
12530
12531 + pax_force_retaddr 0, 1
12532 ret;
12533 ENDPROC(blowfish_dec_blk)
12534
12535 @@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
12536
12537 popq %rbx;
12538 popq %rbp;
12539 + pax_force_retaddr 0, 1
12540 ret;
12541
12542 .L__enc_xor4:
12543 @@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
12544
12545 popq %rbx;
12546 popq %rbp;
12547 + pax_force_retaddr 0, 1
12548 ret;
12549 ENDPROC(__blowfish_enc_blk_4way)
12550
12551 @@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
12552 popq %rbx;
12553 popq %rbp;
12554
12555 + pax_force_retaddr 0, 1
12556 ret;
12557 ENDPROC(blowfish_dec_blk_4way)
12558 diff --git a/arch/x86/crypto/camellia-aesni-avx-asm_64.S b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12559 index ce71f92..2dd5b1e 100644
12560 --- a/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12561 +++ b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12562 @@ -16,6 +16,7 @@
12563 */
12564
12565 #include <linux/linkage.h>
12566 +#include <asm/alternative-asm.h>
12567
12568 #define CAMELLIA_TABLE_BYTE_LEN 272
12569
12570 @@ -191,6 +192,7 @@ roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12571 roundsm16(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
12572 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14, %xmm15,
12573 %rcx, (%r9));
12574 + pax_force_retaddr_bts
12575 ret;
12576 ENDPROC(roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12577
12578 @@ -199,6 +201,7 @@ roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12579 roundsm16(%xmm4, %xmm5, %xmm6, %xmm7, %xmm0, %xmm1, %xmm2, %xmm3,
12580 %xmm12, %xmm13, %xmm14, %xmm15, %xmm8, %xmm9, %xmm10, %xmm11,
12581 %rax, (%r9));
12582 + pax_force_retaddr_bts
12583 ret;
12584 ENDPROC(roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12585
12586 @@ -780,6 +783,7 @@ __camellia_enc_blk16:
12587 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12588 %xmm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 16(%rax));
12589
12590 + pax_force_retaddr_bts
12591 ret;
12592
12593 .align 8
12594 @@ -865,6 +869,7 @@ __camellia_dec_blk16:
12595 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12596 %xmm15, (key_table)(CTX), (%rax), 1 * 16(%rax));
12597
12598 + pax_force_retaddr_bts
12599 ret;
12600
12601 .align 8
12602 @@ -904,6 +909,7 @@ ENTRY(camellia_ecb_enc_16way)
12603 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12604 %xmm8, %rsi);
12605
12606 + pax_force_retaddr 0, 1
12607 ret;
12608 ENDPROC(camellia_ecb_enc_16way)
12609
12610 @@ -932,6 +938,7 @@ ENTRY(camellia_ecb_dec_16way)
12611 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12612 %xmm8, %rsi);
12613
12614 + pax_force_retaddr 0, 1
12615 ret;
12616 ENDPROC(camellia_ecb_dec_16way)
12617
12618 @@ -981,6 +988,7 @@ ENTRY(camellia_cbc_dec_16way)
12619 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12620 %xmm8, %rsi);
12621
12622 + pax_force_retaddr 0, 1
12623 ret;
12624 ENDPROC(camellia_cbc_dec_16way)
12625
12626 @@ -1092,6 +1100,7 @@ ENTRY(camellia_ctr_16way)
12627 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12628 %xmm8, %rsi);
12629
12630 + pax_force_retaddr 0, 1
12631 ret;
12632 ENDPROC(camellia_ctr_16way)
12633
12634 @@ -1234,6 +1243,7 @@ camellia_xts_crypt_16way:
12635 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12636 %xmm8, %rsi);
12637
12638 + pax_force_retaddr 0, 1
12639 ret;
12640 ENDPROC(camellia_xts_crypt_16way)
12641
12642 diff --git a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12643 index 91a1878..bcf340a 100644
12644 --- a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12645 +++ b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12646 @@ -11,6 +11,7 @@
12647 */
12648
12649 #include <linux/linkage.h>
12650 +#include <asm/alternative-asm.h>
12651
12652 #define CAMELLIA_TABLE_BYTE_LEN 272
12653
12654 @@ -212,6 +213,7 @@ roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12655 roundsm32(%ymm0, %ymm1, %ymm2, %ymm3, %ymm4, %ymm5, %ymm6, %ymm7,
12656 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, %ymm15,
12657 %rcx, (%r9));
12658 + pax_force_retaddr_bts
12659 ret;
12660 ENDPROC(roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12661
12662 @@ -220,6 +222,7 @@ roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12663 roundsm32(%ymm4, %ymm5, %ymm6, %ymm7, %ymm0, %ymm1, %ymm2, %ymm3,
12664 %ymm12, %ymm13, %ymm14, %ymm15, %ymm8, %ymm9, %ymm10, %ymm11,
12665 %rax, (%r9));
12666 + pax_force_retaddr_bts
12667 ret;
12668 ENDPROC(roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12669
12670 @@ -802,6 +805,7 @@ __camellia_enc_blk32:
12671 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12672 %ymm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 32(%rax));
12673
12674 + pax_force_retaddr_bts
12675 ret;
12676
12677 .align 8
12678 @@ -887,6 +891,7 @@ __camellia_dec_blk32:
12679 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12680 %ymm15, (key_table)(CTX), (%rax), 1 * 32(%rax));
12681
12682 + pax_force_retaddr_bts
12683 ret;
12684
12685 .align 8
12686 @@ -930,6 +935,7 @@ ENTRY(camellia_ecb_enc_32way)
12687
12688 vzeroupper;
12689
12690 + pax_force_retaddr 0, 1
12691 ret;
12692 ENDPROC(camellia_ecb_enc_32way)
12693
12694 @@ -962,6 +968,7 @@ ENTRY(camellia_ecb_dec_32way)
12695
12696 vzeroupper;
12697
12698 + pax_force_retaddr 0, 1
12699 ret;
12700 ENDPROC(camellia_ecb_dec_32way)
12701
12702 @@ -1028,6 +1035,7 @@ ENTRY(camellia_cbc_dec_32way)
12703
12704 vzeroupper;
12705
12706 + pax_force_retaddr 0, 1
12707 ret;
12708 ENDPROC(camellia_cbc_dec_32way)
12709
12710 @@ -1166,6 +1174,7 @@ ENTRY(camellia_ctr_32way)
12711
12712 vzeroupper;
12713
12714 + pax_force_retaddr 0, 1
12715 ret;
12716 ENDPROC(camellia_ctr_32way)
12717
12718 @@ -1331,6 +1340,7 @@ camellia_xts_crypt_32way:
12719
12720 vzeroupper;
12721
12722 + pax_force_retaddr 0, 1
12723 ret;
12724 ENDPROC(camellia_xts_crypt_32way)
12725
12726 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
12727 index 310319c..ce174a4 100644
12728 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
12729 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
12730 @@ -21,6 +21,7 @@
12731 */
12732
12733 #include <linux/linkage.h>
12734 +#include <asm/alternative-asm.h>
12735
12736 .file "camellia-x86_64-asm_64.S"
12737 .text
12738 @@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
12739 enc_outunpack(mov, RT1);
12740
12741 movq RRBP, %rbp;
12742 + pax_force_retaddr 0, 1
12743 ret;
12744
12745 .L__enc_xor:
12746 enc_outunpack(xor, RT1);
12747
12748 movq RRBP, %rbp;
12749 + pax_force_retaddr 0, 1
12750 ret;
12751 ENDPROC(__camellia_enc_blk)
12752
12753 @@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
12754 dec_outunpack();
12755
12756 movq RRBP, %rbp;
12757 + pax_force_retaddr 0, 1
12758 ret;
12759 ENDPROC(camellia_dec_blk)
12760
12761 @@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
12762
12763 movq RRBP, %rbp;
12764 popq %rbx;
12765 + pax_force_retaddr 0, 1
12766 ret;
12767
12768 .L__enc2_xor:
12769 @@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
12770
12771 movq RRBP, %rbp;
12772 popq %rbx;
12773 + pax_force_retaddr 0, 1
12774 ret;
12775 ENDPROC(__camellia_enc_blk_2way)
12776
12777 @@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
12778
12779 movq RRBP, %rbp;
12780 movq RXOR, %rbx;
12781 + pax_force_retaddr 0, 1
12782 ret;
12783 ENDPROC(camellia_dec_blk_2way)
12784 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12785 index c35fd5d..c1ee236 100644
12786 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12787 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12788 @@ -24,6 +24,7 @@
12789 */
12790
12791 #include <linux/linkage.h>
12792 +#include <asm/alternative-asm.h>
12793
12794 .file "cast5-avx-x86_64-asm_64.S"
12795
12796 @@ -281,6 +282,7 @@ __cast5_enc_blk16:
12797 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12798 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12799
12800 + pax_force_retaddr 0, 1
12801 ret;
12802 ENDPROC(__cast5_enc_blk16)
12803
12804 @@ -352,6 +354,7 @@ __cast5_dec_blk16:
12805 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12806 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12807
12808 + pax_force_retaddr 0, 1
12809 ret;
12810
12811 .L__skip_dec:
12812 @@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
12813 vmovdqu RR4, (6*4*4)(%r11);
12814 vmovdqu RL4, (7*4*4)(%r11);
12815
12816 + pax_force_retaddr
12817 ret;
12818 ENDPROC(cast5_ecb_enc_16way)
12819
12820 @@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
12821 vmovdqu RR4, (6*4*4)(%r11);
12822 vmovdqu RL4, (7*4*4)(%r11);
12823
12824 + pax_force_retaddr
12825 ret;
12826 ENDPROC(cast5_ecb_dec_16way)
12827
12828 @@ -469,6 +474,7 @@ ENTRY(cast5_cbc_dec_16way)
12829
12830 popq %r12;
12831
12832 + pax_force_retaddr
12833 ret;
12834 ENDPROC(cast5_cbc_dec_16way)
12835
12836 @@ -542,5 +548,6 @@ ENTRY(cast5_ctr_16way)
12837
12838 popq %r12;
12839
12840 + pax_force_retaddr
12841 ret;
12842 ENDPROC(cast5_ctr_16way)
12843 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12844 index e3531f8..18ded3a 100644
12845 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12846 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12847 @@ -24,6 +24,7 @@
12848 */
12849
12850 #include <linux/linkage.h>
12851 +#include <asm/alternative-asm.h>
12852 #include "glue_helper-asm-avx.S"
12853
12854 .file "cast6-avx-x86_64-asm_64.S"
12855 @@ -295,6 +296,7 @@ __cast6_enc_blk8:
12856 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
12857 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
12858
12859 + pax_force_retaddr 0, 1
12860 ret;
12861 ENDPROC(__cast6_enc_blk8)
12862
12863 @@ -340,6 +342,7 @@ __cast6_dec_blk8:
12864 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
12865 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
12866
12867 + pax_force_retaddr 0, 1
12868 ret;
12869 ENDPROC(__cast6_dec_blk8)
12870
12871 @@ -358,6 +361,7 @@ ENTRY(cast6_ecb_enc_8way)
12872
12873 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12874
12875 + pax_force_retaddr
12876 ret;
12877 ENDPROC(cast6_ecb_enc_8way)
12878
12879 @@ -376,6 +380,7 @@ ENTRY(cast6_ecb_dec_8way)
12880
12881 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12882
12883 + pax_force_retaddr
12884 ret;
12885 ENDPROC(cast6_ecb_dec_8way)
12886
12887 @@ -399,6 +404,7 @@ ENTRY(cast6_cbc_dec_8way)
12888
12889 popq %r12;
12890
12891 + pax_force_retaddr
12892 ret;
12893 ENDPROC(cast6_cbc_dec_8way)
12894
12895 @@ -424,6 +430,7 @@ ENTRY(cast6_ctr_8way)
12896
12897 popq %r12;
12898
12899 + pax_force_retaddr
12900 ret;
12901 ENDPROC(cast6_ctr_8way)
12902
12903 @@ -446,6 +453,7 @@ ENTRY(cast6_xts_enc_8way)
12904 /* dst <= regs xor IVs(in dst) */
12905 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12906
12907 + pax_force_retaddr
12908 ret;
12909 ENDPROC(cast6_xts_enc_8way)
12910
12911 @@ -468,5 +476,6 @@ ENTRY(cast6_xts_dec_8way)
12912 /* dst <= regs xor IVs(in dst) */
12913 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12914
12915 + pax_force_retaddr
12916 ret;
12917 ENDPROC(cast6_xts_dec_8way)
12918 diff --git a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12919 index dbc4339..3d868c5 100644
12920 --- a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12921 +++ b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12922 @@ -45,6 +45,7 @@
12923
12924 #include <asm/inst.h>
12925 #include <linux/linkage.h>
12926 +#include <asm/alternative-asm.h>
12927
12928 ## ISCSI CRC 32 Implementation with crc32 and pclmulqdq Instruction
12929
12930 @@ -312,6 +313,7 @@ do_return:
12931 popq %rsi
12932 popq %rdi
12933 popq %rbx
12934 + pax_force_retaddr 0, 1
12935 ret
12936
12937 ################################################################
12938 diff --git a/arch/x86/crypto/ghash-clmulni-intel_asm.S b/arch/x86/crypto/ghash-clmulni-intel_asm.S
12939 index 586f41a..d02851e 100644
12940 --- a/arch/x86/crypto/ghash-clmulni-intel_asm.S
12941 +++ b/arch/x86/crypto/ghash-clmulni-intel_asm.S
12942 @@ -18,6 +18,7 @@
12943
12944 #include <linux/linkage.h>
12945 #include <asm/inst.h>
12946 +#include <asm/alternative-asm.h>
12947
12948 .data
12949
12950 @@ -93,6 +94,7 @@ __clmul_gf128mul_ble:
12951 psrlq $1, T2
12952 pxor T2, T1
12953 pxor T1, DATA
12954 + pax_force_retaddr
12955 ret
12956 ENDPROC(__clmul_gf128mul_ble)
12957
12958 @@ -105,6 +107,7 @@ ENTRY(clmul_ghash_mul)
12959 call __clmul_gf128mul_ble
12960 PSHUFB_XMM BSWAP DATA
12961 movups DATA, (%rdi)
12962 + pax_force_retaddr
12963 ret
12964 ENDPROC(clmul_ghash_mul)
12965
12966 @@ -132,6 +135,7 @@ ENTRY(clmul_ghash_update)
12967 PSHUFB_XMM BSWAP DATA
12968 movups DATA, (%rdi)
12969 .Lupdate_just_ret:
12970 + pax_force_retaddr
12971 ret
12972 ENDPROC(clmul_ghash_update)
12973
12974 @@ -157,5 +161,6 @@ ENTRY(clmul_ghash_setkey)
12975 pand .Lpoly, %xmm1
12976 pxor %xmm1, %xmm0
12977 movups %xmm0, (%rdi)
12978 + pax_force_retaddr
12979 ret
12980 ENDPROC(clmul_ghash_setkey)
12981 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
12982 index 9279e0b..9270820 100644
12983 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
12984 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
12985 @@ -1,4 +1,5 @@
12986 #include <linux/linkage.h>
12987 +#include <asm/alternative-asm.h>
12988
12989 # enter salsa20_encrypt_bytes
12990 ENTRY(salsa20_encrypt_bytes)
12991 @@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
12992 add %r11,%rsp
12993 mov %rdi,%rax
12994 mov %rsi,%rdx
12995 + pax_force_retaddr 0, 1
12996 ret
12997 # bytesatleast65:
12998 ._bytesatleast65:
12999 @@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
13000 add %r11,%rsp
13001 mov %rdi,%rax
13002 mov %rsi,%rdx
13003 + pax_force_retaddr
13004 ret
13005 ENDPROC(salsa20_keysetup)
13006
13007 @@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
13008 add %r11,%rsp
13009 mov %rdi,%rax
13010 mov %rsi,%rdx
13011 + pax_force_retaddr
13012 ret
13013 ENDPROC(salsa20_ivsetup)
13014 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
13015 index 2f202f4..d9164d6 100644
13016 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
13017 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
13018 @@ -24,6 +24,7 @@
13019 */
13020
13021 #include <linux/linkage.h>
13022 +#include <asm/alternative-asm.h>
13023 #include "glue_helper-asm-avx.S"
13024
13025 .file "serpent-avx-x86_64-asm_64.S"
13026 @@ -618,6 +619,7 @@ __serpent_enc_blk8_avx:
13027 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
13028 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
13029
13030 + pax_force_retaddr
13031 ret;
13032 ENDPROC(__serpent_enc_blk8_avx)
13033
13034 @@ -672,6 +674,7 @@ __serpent_dec_blk8_avx:
13035 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
13036 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
13037
13038 + pax_force_retaddr
13039 ret;
13040 ENDPROC(__serpent_dec_blk8_avx)
13041
13042 @@ -688,6 +691,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
13043
13044 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13045
13046 + pax_force_retaddr
13047 ret;
13048 ENDPROC(serpent_ecb_enc_8way_avx)
13049
13050 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
13051
13052 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
13053
13054 + pax_force_retaddr
13055 ret;
13056 ENDPROC(serpent_ecb_dec_8way_avx)
13057
13058 @@ -720,6 +725,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
13059
13060 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
13061
13062 + pax_force_retaddr
13063 ret;
13064 ENDPROC(serpent_cbc_dec_8way_avx)
13065
13066 @@ -738,6 +744,7 @@ ENTRY(serpent_ctr_8way_avx)
13067
13068 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13069
13070 + pax_force_retaddr
13071 ret;
13072 ENDPROC(serpent_ctr_8way_avx)
13073
13074 @@ -758,6 +765,7 @@ ENTRY(serpent_xts_enc_8way_avx)
13075 /* dst <= regs xor IVs(in dst) */
13076 store_xts_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13077
13078 + pax_force_retaddr
13079 ret;
13080 ENDPROC(serpent_xts_enc_8way_avx)
13081
13082 @@ -778,5 +786,6 @@ ENTRY(serpent_xts_dec_8way_avx)
13083 /* dst <= regs xor IVs(in dst) */
13084 store_xts_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
13085
13086 + pax_force_retaddr
13087 ret;
13088 ENDPROC(serpent_xts_dec_8way_avx)
13089 diff --git a/arch/x86/crypto/serpent-avx2-asm_64.S b/arch/x86/crypto/serpent-avx2-asm_64.S
13090 index b222085..abd483c 100644
13091 --- a/arch/x86/crypto/serpent-avx2-asm_64.S
13092 +++ b/arch/x86/crypto/serpent-avx2-asm_64.S
13093 @@ -15,6 +15,7 @@
13094 */
13095
13096 #include <linux/linkage.h>
13097 +#include <asm/alternative-asm.h>
13098 #include "glue_helper-asm-avx2.S"
13099
13100 .file "serpent-avx2-asm_64.S"
13101 @@ -610,6 +611,7 @@ __serpent_enc_blk16:
13102 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
13103 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
13104
13105 + pax_force_retaddr
13106 ret;
13107 ENDPROC(__serpent_enc_blk16)
13108
13109 @@ -664,6 +666,7 @@ __serpent_dec_blk16:
13110 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
13111 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
13112
13113 + pax_force_retaddr
13114 ret;
13115 ENDPROC(__serpent_dec_blk16)
13116
13117 @@ -684,6 +687,7 @@ ENTRY(serpent_ecb_enc_16way)
13118
13119 vzeroupper;
13120
13121 + pax_force_retaddr
13122 ret;
13123 ENDPROC(serpent_ecb_enc_16way)
13124
13125 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_16way)
13126
13127 vzeroupper;
13128
13129 + pax_force_retaddr
13130 ret;
13131 ENDPROC(serpent_ecb_dec_16way)
13132
13133 @@ -725,6 +730,7 @@ ENTRY(serpent_cbc_dec_16way)
13134
13135 vzeroupper;
13136
13137 + pax_force_retaddr
13138 ret;
13139 ENDPROC(serpent_cbc_dec_16way)
13140
13141 @@ -748,6 +754,7 @@ ENTRY(serpent_ctr_16way)
13142
13143 vzeroupper;
13144
13145 + pax_force_retaddr
13146 ret;
13147 ENDPROC(serpent_ctr_16way)
13148
13149 @@ -772,6 +779,7 @@ ENTRY(serpent_xts_enc_16way)
13150
13151 vzeroupper;
13152
13153 + pax_force_retaddr
13154 ret;
13155 ENDPROC(serpent_xts_enc_16way)
13156
13157 @@ -796,5 +804,6 @@ ENTRY(serpent_xts_dec_16way)
13158
13159 vzeroupper;
13160
13161 + pax_force_retaddr
13162 ret;
13163 ENDPROC(serpent_xts_dec_16way)
13164 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
13165 index acc066c..1559cc4 100644
13166 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
13167 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
13168 @@ -25,6 +25,7 @@
13169 */
13170
13171 #include <linux/linkage.h>
13172 +#include <asm/alternative-asm.h>
13173
13174 .file "serpent-sse2-x86_64-asm_64.S"
13175 .text
13176 @@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
13177 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
13178 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
13179
13180 + pax_force_retaddr
13181 ret;
13182
13183 .L__enc_xor8:
13184 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
13185 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
13186
13187 + pax_force_retaddr
13188 ret;
13189 ENDPROC(__serpent_enc_blk_8way)
13190
13191 @@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
13192 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
13193 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
13194
13195 + pax_force_retaddr
13196 ret;
13197 ENDPROC(serpent_dec_blk_8way)
13198 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
13199 index a410950..3356d42 100644
13200 --- a/arch/x86/crypto/sha1_ssse3_asm.S
13201 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
13202 @@ -29,6 +29,7 @@
13203 */
13204
13205 #include <linux/linkage.h>
13206 +#include <asm/alternative-asm.h>
13207
13208 #define CTX %rdi // arg1
13209 #define BUF %rsi // arg2
13210 @@ -104,6 +105,7 @@
13211 pop %r12
13212 pop %rbp
13213 pop %rbx
13214 + pax_force_retaddr 0, 1
13215 ret
13216
13217 ENDPROC(\name)
13218 diff --git a/arch/x86/crypto/sha256-avx-asm.S b/arch/x86/crypto/sha256-avx-asm.S
13219 index 642f156..4ab07b9 100644
13220 --- a/arch/x86/crypto/sha256-avx-asm.S
13221 +++ b/arch/x86/crypto/sha256-avx-asm.S
13222 @@ -49,6 +49,7 @@
13223
13224 #ifdef CONFIG_AS_AVX
13225 #include <linux/linkage.h>
13226 +#include <asm/alternative-asm.h>
13227
13228 ## assume buffers not aligned
13229 #define VMOVDQ vmovdqu
13230 @@ -460,6 +461,7 @@ done_hash:
13231 popq %r13
13232 popq %rbp
13233 popq %rbx
13234 + pax_force_retaddr 0, 1
13235 ret
13236 ENDPROC(sha256_transform_avx)
13237
13238 diff --git a/arch/x86/crypto/sha256-avx2-asm.S b/arch/x86/crypto/sha256-avx2-asm.S
13239 index 9e86944..2e7f95a 100644
13240 --- a/arch/x86/crypto/sha256-avx2-asm.S
13241 +++ b/arch/x86/crypto/sha256-avx2-asm.S
13242 @@ -50,6 +50,7 @@
13243
13244 #ifdef CONFIG_AS_AVX2
13245 #include <linux/linkage.h>
13246 +#include <asm/alternative-asm.h>
13247
13248 ## assume buffers not aligned
13249 #define VMOVDQ vmovdqu
13250 @@ -720,6 +721,7 @@ done_hash:
13251 popq %r12
13252 popq %rbp
13253 popq %rbx
13254 + pax_force_retaddr 0, 1
13255 ret
13256 ENDPROC(sha256_transform_rorx)
13257
13258 diff --git a/arch/x86/crypto/sha256-ssse3-asm.S b/arch/x86/crypto/sha256-ssse3-asm.S
13259 index f833b74..c36ed14 100644
13260 --- a/arch/x86/crypto/sha256-ssse3-asm.S
13261 +++ b/arch/x86/crypto/sha256-ssse3-asm.S
13262 @@ -47,6 +47,7 @@
13263 ########################################################################
13264
13265 #include <linux/linkage.h>
13266 +#include <asm/alternative-asm.h>
13267
13268 ## assume buffers not aligned
13269 #define MOVDQ movdqu
13270 @@ -471,6 +472,7 @@ done_hash:
13271 popq %rbp
13272 popq %rbx
13273
13274 + pax_force_retaddr 0, 1
13275 ret
13276 ENDPROC(sha256_transform_ssse3)
13277
13278 diff --git a/arch/x86/crypto/sha512-avx-asm.S b/arch/x86/crypto/sha512-avx-asm.S
13279 index 974dde9..4533d34 100644
13280 --- a/arch/x86/crypto/sha512-avx-asm.S
13281 +++ b/arch/x86/crypto/sha512-avx-asm.S
13282 @@ -49,6 +49,7 @@
13283
13284 #ifdef CONFIG_AS_AVX
13285 #include <linux/linkage.h>
13286 +#include <asm/alternative-asm.h>
13287
13288 .text
13289
13290 @@ -364,6 +365,7 @@ updateblock:
13291 mov frame_RSPSAVE(%rsp), %rsp
13292
13293 nowork:
13294 + pax_force_retaddr 0, 1
13295 ret
13296 ENDPROC(sha512_transform_avx)
13297
13298 diff --git a/arch/x86/crypto/sha512-avx2-asm.S b/arch/x86/crypto/sha512-avx2-asm.S
13299 index 568b961..061ef1d 100644
13300 --- a/arch/x86/crypto/sha512-avx2-asm.S
13301 +++ b/arch/x86/crypto/sha512-avx2-asm.S
13302 @@ -51,6 +51,7 @@
13303
13304 #ifdef CONFIG_AS_AVX2
13305 #include <linux/linkage.h>
13306 +#include <asm/alternative-asm.h>
13307
13308 .text
13309
13310 @@ -678,6 +679,7 @@ done_hash:
13311
13312 # Restore Stack Pointer
13313 mov frame_RSPSAVE(%rsp), %rsp
13314 + pax_force_retaddr 0, 1
13315 ret
13316 ENDPROC(sha512_transform_rorx)
13317
13318 diff --git a/arch/x86/crypto/sha512-ssse3-asm.S b/arch/x86/crypto/sha512-ssse3-asm.S
13319 index fb56855..e23914f 100644
13320 --- a/arch/x86/crypto/sha512-ssse3-asm.S
13321 +++ b/arch/x86/crypto/sha512-ssse3-asm.S
13322 @@ -48,6 +48,7 @@
13323 ########################################################################
13324
13325 #include <linux/linkage.h>
13326 +#include <asm/alternative-asm.h>
13327
13328 .text
13329
13330 @@ -363,6 +364,7 @@ updateblock:
13331 mov frame_RSPSAVE(%rsp), %rsp
13332
13333 nowork:
13334 + pax_force_retaddr 0, 1
13335 ret
13336 ENDPROC(sha512_transform_ssse3)
13337
13338 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13339 index 0505813..63b1d00 100644
13340 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13341 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13342 @@ -24,6 +24,7 @@
13343 */
13344
13345 #include <linux/linkage.h>
13346 +#include <asm/alternative-asm.h>
13347 #include "glue_helper-asm-avx.S"
13348
13349 .file "twofish-avx-x86_64-asm_64.S"
13350 @@ -284,6 +285,7 @@ __twofish_enc_blk8:
13351 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
13352 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
13353
13354 + pax_force_retaddr 0, 1
13355 ret;
13356 ENDPROC(__twofish_enc_blk8)
13357
13358 @@ -324,6 +326,7 @@ __twofish_dec_blk8:
13359 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
13360 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
13361
13362 + pax_force_retaddr 0, 1
13363 ret;
13364 ENDPROC(__twofish_dec_blk8)
13365
13366 @@ -342,6 +345,7 @@ ENTRY(twofish_ecb_enc_8way)
13367
13368 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13369
13370 + pax_force_retaddr 0, 1
13371 ret;
13372 ENDPROC(twofish_ecb_enc_8way)
13373
13374 @@ -360,6 +364,7 @@ ENTRY(twofish_ecb_dec_8way)
13375
13376 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13377
13378 + pax_force_retaddr 0, 1
13379 ret;
13380 ENDPROC(twofish_ecb_dec_8way)
13381
13382 @@ -383,6 +388,7 @@ ENTRY(twofish_cbc_dec_8way)
13383
13384 popq %r12;
13385
13386 + pax_force_retaddr 0, 1
13387 ret;
13388 ENDPROC(twofish_cbc_dec_8way)
13389
13390 @@ -408,6 +414,7 @@ ENTRY(twofish_ctr_8way)
13391
13392 popq %r12;
13393
13394 + pax_force_retaddr 0, 1
13395 ret;
13396 ENDPROC(twofish_ctr_8way)
13397
13398 @@ -430,6 +437,7 @@ ENTRY(twofish_xts_enc_8way)
13399 /* dst <= regs xor IVs(in dst) */
13400 store_xts_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13401
13402 + pax_force_retaddr 0, 1
13403 ret;
13404 ENDPROC(twofish_xts_enc_8way)
13405
13406 @@ -452,5 +460,6 @@ ENTRY(twofish_xts_dec_8way)
13407 /* dst <= regs xor IVs(in dst) */
13408 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13409
13410 + pax_force_retaddr 0, 1
13411 ret;
13412 ENDPROC(twofish_xts_dec_8way)
13413 diff --git a/arch/x86/crypto/twofish-avx2-asm_64.S b/arch/x86/crypto/twofish-avx2-asm_64.S
13414 index e1a83b9..33006b9 100644
13415 --- a/arch/x86/crypto/twofish-avx2-asm_64.S
13416 +++ b/arch/x86/crypto/twofish-avx2-asm_64.S
13417 @@ -11,6 +11,7 @@
13418 */
13419
13420 #include <linux/linkage.h>
13421 +#include <asm/alternative-asm.h>
13422 #include "glue_helper-asm-avx2.S"
13423
13424 .file "twofish-avx2-asm_64.S"
13425 @@ -422,6 +423,7 @@ __twofish_enc_blk16:
13426 outunpack_enc16(RA, RB, RC, RD);
13427 write_blocks16(RA, RB, RC, RD);
13428
13429 + pax_force_retaddr_bts
13430 ret;
13431 ENDPROC(__twofish_enc_blk16)
13432
13433 @@ -454,6 +456,7 @@ __twofish_dec_blk16:
13434 outunpack_dec16(RA, RB, RC, RD);
13435 write_blocks16(RA, RB, RC, RD);
13436
13437 + pax_force_retaddr_bts
13438 ret;
13439 ENDPROC(__twofish_dec_blk16)
13440
13441 @@ -476,6 +479,7 @@ ENTRY(twofish_ecb_enc_16way)
13442 popq %r12;
13443 vzeroupper;
13444
13445 + pax_force_retaddr 0, 1
13446 ret;
13447 ENDPROC(twofish_ecb_enc_16way)
13448
13449 @@ -498,6 +502,7 @@ ENTRY(twofish_ecb_dec_16way)
13450 popq %r12;
13451 vzeroupper;
13452
13453 + pax_force_retaddr 0, 1
13454 ret;
13455 ENDPROC(twofish_ecb_dec_16way)
13456
13457 @@ -521,6 +526,7 @@ ENTRY(twofish_cbc_dec_16way)
13458 popq %r12;
13459 vzeroupper;
13460
13461 + pax_force_retaddr 0, 1
13462 ret;
13463 ENDPROC(twofish_cbc_dec_16way)
13464
13465 @@ -546,6 +552,7 @@ ENTRY(twofish_ctr_16way)
13466 popq %r12;
13467 vzeroupper;
13468
13469 + pax_force_retaddr 0, 1
13470 ret;
13471 ENDPROC(twofish_ctr_16way)
13472
13473 @@ -574,6 +581,7 @@ twofish_xts_crypt_16way:
13474 popq %r12;
13475 vzeroupper;
13476
13477 + pax_force_retaddr 0, 1
13478 ret;
13479 ENDPROC(twofish_xts_crypt_16way)
13480
13481 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13482 index 1c3b7ce..b365c5e 100644
13483 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13484 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13485 @@ -21,6 +21,7 @@
13486 */
13487
13488 #include <linux/linkage.h>
13489 +#include <asm/alternative-asm.h>
13490
13491 .file "twofish-x86_64-asm-3way.S"
13492 .text
13493 @@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
13494 popq %r13;
13495 popq %r14;
13496 popq %r15;
13497 + pax_force_retaddr 0, 1
13498 ret;
13499
13500 .L__enc_xor3:
13501 @@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
13502 popq %r13;
13503 popq %r14;
13504 popq %r15;
13505 + pax_force_retaddr 0, 1
13506 ret;
13507 ENDPROC(__twofish_enc_blk_3way)
13508
13509 @@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
13510 popq %r13;
13511 popq %r14;
13512 popq %r15;
13513 + pax_force_retaddr 0, 1
13514 ret;
13515 ENDPROC(twofish_dec_blk_3way)
13516 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
13517 index a039d21..29e7615 100644
13518 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
13519 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
13520 @@ -22,6 +22,7 @@
13521
13522 #include <linux/linkage.h>
13523 #include <asm/asm-offsets.h>
13524 +#include <asm/alternative-asm.h>
13525
13526 #define a_offset 0
13527 #define b_offset 4
13528 @@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
13529
13530 popq R1
13531 movq $1,%rax
13532 + pax_force_retaddr 0, 1
13533 ret
13534 ENDPROC(twofish_enc_blk)
13535
13536 @@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
13537
13538 popq R1
13539 movq $1,%rax
13540 + pax_force_retaddr 0, 1
13541 ret
13542 ENDPROC(twofish_dec_blk)
13543 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
13544 index 52ff81c..98af645 100644
13545 --- a/arch/x86/ia32/ia32_aout.c
13546 +++ b/arch/x86/ia32/ia32_aout.c
13547 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
13548 unsigned long dump_start, dump_size;
13549 struct user32 dump;
13550
13551 + memset(&dump, 0, sizeof(dump));
13552 +
13553 fs = get_fs();
13554 set_fs(KERNEL_DS);
13555 has_dumped = 1;
13556 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
13557 index cf1a471..5ba2673 100644
13558 --- a/arch/x86/ia32/ia32_signal.c
13559 +++ b/arch/x86/ia32/ia32_signal.c
13560 @@ -340,7 +340,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
13561 sp -= frame_size;
13562 /* Align the stack pointer according to the i386 ABI,
13563 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
13564 - sp = ((sp + 4) & -16ul) - 4;
13565 + sp = ((sp - 12) & -16ul) - 4;
13566 return (void __user *) sp;
13567 }
13568
13569 @@ -398,7 +398,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
13570 * These are actually not used anymore, but left because some
13571 * gdb versions depend on them as a marker.
13572 */
13573 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13574 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13575 } put_user_catch(err);
13576
13577 if (err)
13578 @@ -440,7 +440,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13579 0xb8,
13580 __NR_ia32_rt_sigreturn,
13581 0x80cd,
13582 - 0,
13583 + 0
13584 };
13585
13586 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
13587 @@ -459,20 +459,22 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13588 else
13589 put_user_ex(0, &frame->uc.uc_flags);
13590 put_user_ex(0, &frame->uc.uc_link);
13591 - err |= __compat_save_altstack(&frame->uc.uc_stack, regs->sp);
13592 + __compat_save_altstack_ex(&frame->uc.uc_stack, regs->sp);
13593
13594 if (ksig->ka.sa.sa_flags & SA_RESTORER)
13595 restorer = ksig->ka.sa.sa_restorer;
13596 + else if (current->mm->context.vdso)
13597 + /* Return stub is in 32bit vsyscall page */
13598 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
13599 else
13600 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
13601 - rt_sigreturn);
13602 + restorer = &frame->retcode;
13603 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
13604
13605 /*
13606 * Not actually used anymore, but left because some gdb
13607 * versions need it.
13608 */
13609 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13610 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13611 } put_user_catch(err);
13612
13613 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
13614 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
13615 index 474dc1b..9297c58 100644
13616 --- a/arch/x86/ia32/ia32entry.S
13617 +++ b/arch/x86/ia32/ia32entry.S
13618 @@ -15,8 +15,10 @@
13619 #include <asm/irqflags.h>
13620 #include <asm/asm.h>
13621 #include <asm/smap.h>
13622 +#include <asm/pgtable.h>
13623 #include <linux/linkage.h>
13624 #include <linux/err.h>
13625 +#include <asm/alternative-asm.h>
13626
13627 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
13628 #include <linux/elf-em.h>
13629 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
13630 ENDPROC(native_irq_enable_sysexit)
13631 #endif
13632
13633 + .macro pax_enter_kernel_user
13634 + pax_set_fptr_mask
13635 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13636 + call pax_enter_kernel_user
13637 +#endif
13638 + .endm
13639 +
13640 + .macro pax_exit_kernel_user
13641 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13642 + call pax_exit_kernel_user
13643 +#endif
13644 +#ifdef CONFIG_PAX_RANDKSTACK
13645 + pushq %rax
13646 + pushq %r11
13647 + call pax_randomize_kstack
13648 + popq %r11
13649 + popq %rax
13650 +#endif
13651 + .endm
13652 +
13653 + .macro pax_erase_kstack
13654 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
13655 + call pax_erase_kstack
13656 +#endif
13657 + .endm
13658 +
13659 /*
13660 * 32bit SYSENTER instruction entry.
13661 *
13662 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
13663 CFI_REGISTER rsp,rbp
13664 SWAPGS_UNSAFE_STACK
13665 movq PER_CPU_VAR(kernel_stack), %rsp
13666 - addq $(KERNEL_STACK_OFFSET),%rsp
13667 - /*
13668 - * No need to follow this irqs on/off section: the syscall
13669 - * disabled irqs, here we enable it straight after entry:
13670 - */
13671 - ENABLE_INTERRUPTS(CLBR_NONE)
13672 movl %ebp,%ebp /* zero extension */
13673 pushq_cfi $__USER32_DS
13674 /*CFI_REL_OFFSET ss,0*/
13675 @@ -135,24 +157,49 @@ ENTRY(ia32_sysenter_target)
13676 CFI_REL_OFFSET rsp,0
13677 pushfq_cfi
13678 /*CFI_REL_OFFSET rflags,0*/
13679 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
13680 - CFI_REGISTER rip,r10
13681 + orl $X86_EFLAGS_IF,(%rsp)
13682 + GET_THREAD_INFO(%r11)
13683 + movl TI_sysenter_return(%r11), %r11d
13684 + CFI_REGISTER rip,r11
13685 pushq_cfi $__USER32_CS
13686 /*CFI_REL_OFFSET cs,0*/
13687 movl %eax, %eax
13688 - pushq_cfi %r10
13689 + pushq_cfi %r11
13690 CFI_REL_OFFSET rip,0
13691 pushq_cfi %rax
13692 cld
13693 SAVE_ARGS 0,1,0
13694 + pax_enter_kernel_user
13695 +
13696 +#ifdef CONFIG_PAX_RANDKSTACK
13697 + pax_erase_kstack
13698 +#endif
13699 +
13700 + /*
13701 + * No need to follow this irqs on/off section: the syscall
13702 + * disabled irqs, here we enable it straight after entry:
13703 + */
13704 + ENABLE_INTERRUPTS(CLBR_NONE)
13705 /* no need to do an access_ok check here because rbp has been
13706 32bit zero extended */
13707 +
13708 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13709 + addq pax_user_shadow_base,%rbp
13710 + ASM_PAX_OPEN_USERLAND
13711 +#endif
13712 +
13713 ASM_STAC
13714 1: movl (%rbp),%ebp
13715 _ASM_EXTABLE(1b,ia32_badarg)
13716 ASM_CLAC
13717 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13718 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13719 +
13720 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13721 + ASM_PAX_CLOSE_USERLAND
13722 +#endif
13723 +
13724 + GET_THREAD_INFO(%r11)
13725 + orl $TS_COMPAT,TI_status(%r11)
13726 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13727 CFI_REMEMBER_STATE
13728 jnz sysenter_tracesys
13729 cmpq $(IA32_NR_syscalls-1),%rax
13730 @@ -162,12 +209,15 @@ sysenter_do_call:
13731 sysenter_dispatch:
13732 call *ia32_sys_call_table(,%rax,8)
13733 movq %rax,RAX-ARGOFFSET(%rsp)
13734 + GET_THREAD_INFO(%r11)
13735 DISABLE_INTERRUPTS(CLBR_NONE)
13736 TRACE_IRQS_OFF
13737 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13738 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
13739 jnz sysexit_audit
13740 sysexit_from_sys_call:
13741 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13742 + pax_exit_kernel_user
13743 + pax_erase_kstack
13744 + andl $~TS_COMPAT,TI_status(%r11)
13745 /* clear IF, that popfq doesn't enable interrupts early */
13746 andl $~0x200,EFLAGS-R11(%rsp)
13747 movl RIP-R11(%rsp),%edx /* User %eip */
13748 @@ -193,6 +243,9 @@ sysexit_from_sys_call:
13749 movl %eax,%esi /* 2nd arg: syscall number */
13750 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
13751 call __audit_syscall_entry
13752 +
13753 + pax_erase_kstack
13754 +
13755 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
13756 cmpq $(IA32_NR_syscalls-1),%rax
13757 ja ia32_badsys
13758 @@ -204,7 +257,7 @@ sysexit_from_sys_call:
13759 .endm
13760
13761 .macro auditsys_exit exit
13762 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13763 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13764 jnz ia32_ret_from_sys_call
13765 TRACE_IRQS_ON
13766 ENABLE_INTERRUPTS(CLBR_NONE)
13767 @@ -215,11 +268,12 @@ sysexit_from_sys_call:
13768 1: setbe %al /* 1 if error, 0 if not */
13769 movzbl %al,%edi /* zero-extend that into %edi */
13770 call __audit_syscall_exit
13771 + GET_THREAD_INFO(%r11)
13772 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
13773 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
13774 DISABLE_INTERRUPTS(CLBR_NONE)
13775 TRACE_IRQS_OFF
13776 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13777 + testl %edi,TI_flags(%r11)
13778 jz \exit
13779 CLEAR_RREGS -ARGOFFSET
13780 jmp int_with_check
13781 @@ -237,7 +291,7 @@ sysexit_audit:
13782
13783 sysenter_tracesys:
13784 #ifdef CONFIG_AUDITSYSCALL
13785 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13786 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13787 jz sysenter_auditsys
13788 #endif
13789 SAVE_REST
13790 @@ -249,6 +303,9 @@ sysenter_tracesys:
13791 RESTORE_REST
13792 cmpq $(IA32_NR_syscalls-1),%rax
13793 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
13794 +
13795 + pax_erase_kstack
13796 +
13797 jmp sysenter_do_call
13798 CFI_ENDPROC
13799 ENDPROC(ia32_sysenter_target)
13800 @@ -276,19 +333,25 @@ ENDPROC(ia32_sysenter_target)
13801 ENTRY(ia32_cstar_target)
13802 CFI_STARTPROC32 simple
13803 CFI_SIGNAL_FRAME
13804 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
13805 + CFI_DEF_CFA rsp,0
13806 CFI_REGISTER rip,rcx
13807 /*CFI_REGISTER rflags,r11*/
13808 SWAPGS_UNSAFE_STACK
13809 movl %esp,%r8d
13810 CFI_REGISTER rsp,r8
13811 movq PER_CPU_VAR(kernel_stack),%rsp
13812 + SAVE_ARGS 8*6,0,0
13813 + pax_enter_kernel_user
13814 +
13815 +#ifdef CONFIG_PAX_RANDKSTACK
13816 + pax_erase_kstack
13817 +#endif
13818 +
13819 /*
13820 * No need to follow this irqs on/off section: the syscall
13821 * disabled irqs and here we enable it straight after entry:
13822 */
13823 ENABLE_INTERRUPTS(CLBR_NONE)
13824 - SAVE_ARGS 8,0,0
13825 movl %eax,%eax /* zero extension */
13826 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
13827 movq %rcx,RIP-ARGOFFSET(%rsp)
13828 @@ -304,12 +367,25 @@ ENTRY(ia32_cstar_target)
13829 /* no need to do an access_ok check here because r8 has been
13830 32bit zero extended */
13831 /* hardware stack frame is complete now */
13832 +
13833 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13834 + ASM_PAX_OPEN_USERLAND
13835 + movq pax_user_shadow_base,%r8
13836 + addq RSP-ARGOFFSET(%rsp),%r8
13837 +#endif
13838 +
13839 ASM_STAC
13840 1: movl (%r8),%r9d
13841 _ASM_EXTABLE(1b,ia32_badarg)
13842 ASM_CLAC
13843 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13844 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13845 +
13846 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13847 + ASM_PAX_CLOSE_USERLAND
13848 +#endif
13849 +
13850 + GET_THREAD_INFO(%r11)
13851 + orl $TS_COMPAT,TI_status(%r11)
13852 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13853 CFI_REMEMBER_STATE
13854 jnz cstar_tracesys
13855 cmpq $IA32_NR_syscalls-1,%rax
13856 @@ -319,12 +395,15 @@ cstar_do_call:
13857 cstar_dispatch:
13858 call *ia32_sys_call_table(,%rax,8)
13859 movq %rax,RAX-ARGOFFSET(%rsp)
13860 + GET_THREAD_INFO(%r11)
13861 DISABLE_INTERRUPTS(CLBR_NONE)
13862 TRACE_IRQS_OFF
13863 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13864 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
13865 jnz sysretl_audit
13866 sysretl_from_sys_call:
13867 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13868 + pax_exit_kernel_user
13869 + pax_erase_kstack
13870 + andl $~TS_COMPAT,TI_status(%r11)
13871 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
13872 movl RIP-ARGOFFSET(%rsp),%ecx
13873 CFI_REGISTER rip,rcx
13874 @@ -352,7 +431,7 @@ sysretl_audit:
13875
13876 cstar_tracesys:
13877 #ifdef CONFIG_AUDITSYSCALL
13878 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13879 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13880 jz cstar_auditsys
13881 #endif
13882 xchgl %r9d,%ebp
13883 @@ -366,11 +445,19 @@ cstar_tracesys:
13884 xchgl %ebp,%r9d
13885 cmpq $(IA32_NR_syscalls-1),%rax
13886 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
13887 +
13888 + pax_erase_kstack
13889 +
13890 jmp cstar_do_call
13891 END(ia32_cstar_target)
13892
13893 ia32_badarg:
13894 ASM_CLAC
13895 +
13896 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13897 + ASM_PAX_CLOSE_USERLAND
13898 +#endif
13899 +
13900 movq $-EFAULT,%rax
13901 jmp ia32_sysret
13902 CFI_ENDPROC
13903 @@ -407,19 +494,26 @@ ENTRY(ia32_syscall)
13904 CFI_REL_OFFSET rip,RIP-RIP
13905 PARAVIRT_ADJUST_EXCEPTION_FRAME
13906 SWAPGS
13907 - /*
13908 - * No need to follow this irqs on/off section: the syscall
13909 - * disabled irqs and here we enable it straight after entry:
13910 - */
13911 - ENABLE_INTERRUPTS(CLBR_NONE)
13912 movl %eax,%eax
13913 pushq_cfi %rax
13914 cld
13915 /* note the registers are not zero extended to the sf.
13916 this could be a problem. */
13917 SAVE_ARGS 0,1,0
13918 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13919 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13920 + pax_enter_kernel_user
13921 +
13922 +#ifdef CONFIG_PAX_RANDKSTACK
13923 + pax_erase_kstack
13924 +#endif
13925 +
13926 + /*
13927 + * No need to follow this irqs on/off section: the syscall
13928 + * disabled irqs and here we enable it straight after entry:
13929 + */
13930 + ENABLE_INTERRUPTS(CLBR_NONE)
13931 + GET_THREAD_INFO(%r11)
13932 + orl $TS_COMPAT,TI_status(%r11)
13933 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13934 jnz ia32_tracesys
13935 cmpq $(IA32_NR_syscalls-1),%rax
13936 ja ia32_badsys
13937 @@ -442,6 +536,9 @@ ia32_tracesys:
13938 RESTORE_REST
13939 cmpq $(IA32_NR_syscalls-1),%rax
13940 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
13941 +
13942 + pax_erase_kstack
13943 +
13944 jmp ia32_do_call
13945 END(ia32_syscall)
13946
13947 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
13948 index 8e0ceec..af13504 100644
13949 --- a/arch/x86/ia32/sys_ia32.c
13950 +++ b/arch/x86/ia32/sys_ia32.c
13951 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
13952 */
13953 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
13954 {
13955 - typeof(ubuf->st_uid) uid = 0;
13956 - typeof(ubuf->st_gid) gid = 0;
13957 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
13958 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
13959 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
13960 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
13961 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
13962 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
13963 index 372231c..a5aa1a1 100644
13964 --- a/arch/x86/include/asm/alternative-asm.h
13965 +++ b/arch/x86/include/asm/alternative-asm.h
13966 @@ -18,6 +18,45 @@
13967 .endm
13968 #endif
13969
13970 +#ifdef KERNEXEC_PLUGIN
13971 + .macro pax_force_retaddr_bts rip=0
13972 + btsq $63,\rip(%rsp)
13973 + .endm
13974 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
13975 + .macro pax_force_retaddr rip=0, reload=0
13976 + btsq $63,\rip(%rsp)
13977 + .endm
13978 + .macro pax_force_fptr ptr
13979 + btsq $63,\ptr
13980 + .endm
13981 + .macro pax_set_fptr_mask
13982 + .endm
13983 +#endif
13984 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
13985 + .macro pax_force_retaddr rip=0, reload=0
13986 + .if \reload
13987 + pax_set_fptr_mask
13988 + .endif
13989 + orq %r10,\rip(%rsp)
13990 + .endm
13991 + .macro pax_force_fptr ptr
13992 + orq %r10,\ptr
13993 + .endm
13994 + .macro pax_set_fptr_mask
13995 + movabs $0x8000000000000000,%r10
13996 + .endm
13997 +#endif
13998 +#else
13999 + .macro pax_force_retaddr rip=0, reload=0
14000 + .endm
14001 + .macro pax_force_fptr ptr
14002 + .endm
14003 + .macro pax_force_retaddr_bts rip=0
14004 + .endm
14005 + .macro pax_set_fptr_mask
14006 + .endm
14007 +#endif
14008 +
14009 .macro altinstruction_entry orig alt feature orig_len alt_len
14010 .long \orig - .
14011 .long \alt - .
14012 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
14013 index 58ed6d9..f1cbe58 100644
14014 --- a/arch/x86/include/asm/alternative.h
14015 +++ b/arch/x86/include/asm/alternative.h
14016 @@ -105,7 +105,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
14017 ".pushsection .discard,\"aw\",@progbits\n" \
14018 DISCARD_ENTRY(1) \
14019 ".popsection\n" \
14020 - ".pushsection .altinstr_replacement, \"ax\"\n" \
14021 + ".pushsection .altinstr_replacement, \"a\"\n" \
14022 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
14023 ".popsection"
14024
14025 @@ -119,7 +119,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
14026 DISCARD_ENTRY(1) \
14027 DISCARD_ENTRY(2) \
14028 ".popsection\n" \
14029 - ".pushsection .altinstr_replacement, \"ax\"\n" \
14030 + ".pushsection .altinstr_replacement, \"a\"\n" \
14031 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
14032 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
14033 ".popsection"
14034 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
14035 index 3388034..050f0b9 100644
14036 --- a/arch/x86/include/asm/apic.h
14037 +++ b/arch/x86/include/asm/apic.h
14038 @@ -44,7 +44,7 @@ static inline void generic_apic_probe(void)
14039
14040 #ifdef CONFIG_X86_LOCAL_APIC
14041
14042 -extern unsigned int apic_verbosity;
14043 +extern int apic_verbosity;
14044 extern int local_apic_timer_c2_ok;
14045
14046 extern int disable_apic;
14047 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
14048 index 20370c6..a2eb9b0 100644
14049 --- a/arch/x86/include/asm/apm.h
14050 +++ b/arch/x86/include/asm/apm.h
14051 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
14052 __asm__ __volatile__(APM_DO_ZERO_SEGS
14053 "pushl %%edi\n\t"
14054 "pushl %%ebp\n\t"
14055 - "lcall *%%cs:apm_bios_entry\n\t"
14056 + "lcall *%%ss:apm_bios_entry\n\t"
14057 "setc %%al\n\t"
14058 "popl %%ebp\n\t"
14059 "popl %%edi\n\t"
14060 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
14061 __asm__ __volatile__(APM_DO_ZERO_SEGS
14062 "pushl %%edi\n\t"
14063 "pushl %%ebp\n\t"
14064 - "lcall *%%cs:apm_bios_entry\n\t"
14065 + "lcall *%%ss:apm_bios_entry\n\t"
14066 "setc %%bl\n\t"
14067 "popl %%ebp\n\t"
14068 "popl %%edi\n\t"
14069 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
14070 index 722aa3b..3a0bb27 100644
14071 --- a/arch/x86/include/asm/atomic.h
14072 +++ b/arch/x86/include/asm/atomic.h
14073 @@ -22,7 +22,18 @@
14074 */
14075 static inline int atomic_read(const atomic_t *v)
14076 {
14077 - return (*(volatile int *)&(v)->counter);
14078 + return (*(volatile const int *)&(v)->counter);
14079 +}
14080 +
14081 +/**
14082 + * atomic_read_unchecked - read atomic variable
14083 + * @v: pointer of type atomic_unchecked_t
14084 + *
14085 + * Atomically reads the value of @v.
14086 + */
14087 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
14088 +{
14089 + return (*(volatile const int *)&(v)->counter);
14090 }
14091
14092 /**
14093 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
14094 }
14095
14096 /**
14097 + * atomic_set_unchecked - set atomic variable
14098 + * @v: pointer of type atomic_unchecked_t
14099 + * @i: required value
14100 + *
14101 + * Atomically sets the value of @v to @i.
14102 + */
14103 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
14104 +{
14105 + v->counter = i;
14106 +}
14107 +
14108 +/**
14109 * atomic_add - add integer to atomic variable
14110 * @i: integer value to add
14111 * @v: pointer of type atomic_t
14112 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
14113 */
14114 static inline void atomic_add(int i, atomic_t *v)
14115 {
14116 - asm volatile(LOCK_PREFIX "addl %1,%0"
14117 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
14118 +
14119 +#ifdef CONFIG_PAX_REFCOUNT
14120 + "jno 0f\n"
14121 + LOCK_PREFIX "subl %1,%0\n"
14122 + "int $4\n0:\n"
14123 + _ASM_EXTABLE(0b, 0b)
14124 +#endif
14125 +
14126 + : "+m" (v->counter)
14127 + : "ir" (i));
14128 +}
14129 +
14130 +/**
14131 + * atomic_add_unchecked - add integer to atomic variable
14132 + * @i: integer value to add
14133 + * @v: pointer of type atomic_unchecked_t
14134 + *
14135 + * Atomically adds @i to @v.
14136 + */
14137 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
14138 +{
14139 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
14140 : "+m" (v->counter)
14141 : "ir" (i));
14142 }
14143 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
14144 */
14145 static inline void atomic_sub(int i, atomic_t *v)
14146 {
14147 - asm volatile(LOCK_PREFIX "subl %1,%0"
14148 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
14149 +
14150 +#ifdef CONFIG_PAX_REFCOUNT
14151 + "jno 0f\n"
14152 + LOCK_PREFIX "addl %1,%0\n"
14153 + "int $4\n0:\n"
14154 + _ASM_EXTABLE(0b, 0b)
14155 +#endif
14156 +
14157 + : "+m" (v->counter)
14158 + : "ir" (i));
14159 +}
14160 +
14161 +/**
14162 + * atomic_sub_unchecked - subtract integer from atomic variable
14163 + * @i: integer value to subtract
14164 + * @v: pointer of type atomic_unchecked_t
14165 + *
14166 + * Atomically subtracts @i from @v.
14167 + */
14168 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
14169 +{
14170 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
14171 : "+m" (v->counter)
14172 : "ir" (i));
14173 }
14174 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
14175 {
14176 unsigned char c;
14177
14178 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
14179 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
14180 +
14181 +#ifdef CONFIG_PAX_REFCOUNT
14182 + "jno 0f\n"
14183 + LOCK_PREFIX "addl %2,%0\n"
14184 + "int $4\n0:\n"
14185 + _ASM_EXTABLE(0b, 0b)
14186 +#endif
14187 +
14188 + "sete %1\n"
14189 : "+m" (v->counter), "=qm" (c)
14190 : "ir" (i) : "memory");
14191 return c;
14192 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
14193 */
14194 static inline void atomic_inc(atomic_t *v)
14195 {
14196 - asm volatile(LOCK_PREFIX "incl %0"
14197 + asm volatile(LOCK_PREFIX "incl %0\n"
14198 +
14199 +#ifdef CONFIG_PAX_REFCOUNT
14200 + "jno 0f\n"
14201 + LOCK_PREFIX "decl %0\n"
14202 + "int $4\n0:\n"
14203 + _ASM_EXTABLE(0b, 0b)
14204 +#endif
14205 +
14206 + : "+m" (v->counter));
14207 +}
14208 +
14209 +/**
14210 + * atomic_inc_unchecked - increment atomic variable
14211 + * @v: pointer of type atomic_unchecked_t
14212 + *
14213 + * Atomically increments @v by 1.
14214 + */
14215 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
14216 +{
14217 + asm volatile(LOCK_PREFIX "incl %0\n"
14218 : "+m" (v->counter));
14219 }
14220
14221 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
14222 */
14223 static inline void atomic_dec(atomic_t *v)
14224 {
14225 - asm volatile(LOCK_PREFIX "decl %0"
14226 + asm volatile(LOCK_PREFIX "decl %0\n"
14227 +
14228 +#ifdef CONFIG_PAX_REFCOUNT
14229 + "jno 0f\n"
14230 + LOCK_PREFIX "incl %0\n"
14231 + "int $4\n0:\n"
14232 + _ASM_EXTABLE(0b, 0b)
14233 +#endif
14234 +
14235 + : "+m" (v->counter));
14236 +}
14237 +
14238 +/**
14239 + * atomic_dec_unchecked - decrement atomic variable
14240 + * @v: pointer of type atomic_unchecked_t
14241 + *
14242 + * Atomically decrements @v by 1.
14243 + */
14244 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
14245 +{
14246 + asm volatile(LOCK_PREFIX "decl %0\n"
14247 : "+m" (v->counter));
14248 }
14249
14250 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
14251 {
14252 unsigned char c;
14253
14254 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
14255 + asm volatile(LOCK_PREFIX "decl %0\n"
14256 +
14257 +#ifdef CONFIG_PAX_REFCOUNT
14258 + "jno 0f\n"
14259 + LOCK_PREFIX "incl %0\n"
14260 + "int $4\n0:\n"
14261 + _ASM_EXTABLE(0b, 0b)
14262 +#endif
14263 +
14264 + "sete %1\n"
14265 : "+m" (v->counter), "=qm" (c)
14266 : : "memory");
14267 return c != 0;
14268 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
14269 {
14270 unsigned char c;
14271
14272 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
14273 + asm volatile(LOCK_PREFIX "incl %0\n"
14274 +
14275 +#ifdef CONFIG_PAX_REFCOUNT
14276 + "jno 0f\n"
14277 + LOCK_PREFIX "decl %0\n"
14278 + "int $4\n0:\n"
14279 + _ASM_EXTABLE(0b, 0b)
14280 +#endif
14281 +
14282 + "sete %1\n"
14283 + : "+m" (v->counter), "=qm" (c)
14284 + : : "memory");
14285 + return c != 0;
14286 +}
14287 +
14288 +/**
14289 + * atomic_inc_and_test_unchecked - increment and test
14290 + * @v: pointer of type atomic_unchecked_t
14291 + *
14292 + * Atomically increments @v by 1
14293 + * and returns true if the result is zero, or false for all
14294 + * other cases.
14295 + */
14296 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
14297 +{
14298 + unsigned char c;
14299 +
14300 + asm volatile(LOCK_PREFIX "incl %0\n"
14301 + "sete %1\n"
14302 : "+m" (v->counter), "=qm" (c)
14303 : : "memory");
14304 return c != 0;
14305 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
14306 {
14307 unsigned char c;
14308
14309 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
14310 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
14311 +
14312 +#ifdef CONFIG_PAX_REFCOUNT
14313 + "jno 0f\n"
14314 + LOCK_PREFIX "subl %2,%0\n"
14315 + "int $4\n0:\n"
14316 + _ASM_EXTABLE(0b, 0b)
14317 +#endif
14318 +
14319 + "sets %1\n"
14320 : "+m" (v->counter), "=qm" (c)
14321 : "ir" (i) : "memory");
14322 return c;
14323 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
14324 */
14325 static inline int atomic_add_return(int i, atomic_t *v)
14326 {
14327 + return i + xadd_check_overflow(&v->counter, i);
14328 +}
14329 +
14330 +/**
14331 + * atomic_add_return_unchecked - add integer and return
14332 + * @i: integer value to add
14333 + * @v: pointer of type atomic_unchecked_t
14334 + *
14335 + * Atomically adds @i to @v and returns @i + @v
14336 + */
14337 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
14338 +{
14339 return i + xadd(&v->counter, i);
14340 }
14341
14342 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
14343 }
14344
14345 #define atomic_inc_return(v) (atomic_add_return(1, v))
14346 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
14347 +{
14348 + return atomic_add_return_unchecked(1, v);
14349 +}
14350 #define atomic_dec_return(v) (atomic_sub_return(1, v))
14351
14352 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
14353 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
14354 return cmpxchg(&v->counter, old, new);
14355 }
14356
14357 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
14358 +{
14359 + return cmpxchg(&v->counter, old, new);
14360 +}
14361 +
14362 static inline int atomic_xchg(atomic_t *v, int new)
14363 {
14364 return xchg(&v->counter, new);
14365 }
14366
14367 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
14368 +{
14369 + return xchg(&v->counter, new);
14370 +}
14371 +
14372 /**
14373 * __atomic_add_unless - add unless the number is already a given value
14374 * @v: pointer of type atomic_t
14375 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
14376 */
14377 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14378 {
14379 - int c, old;
14380 + int c, old, new;
14381 c = atomic_read(v);
14382 for (;;) {
14383 - if (unlikely(c == (u)))
14384 + if (unlikely(c == u))
14385 break;
14386 - old = atomic_cmpxchg((v), c, c + (a));
14387 +
14388 + asm volatile("addl %2,%0\n"
14389 +
14390 +#ifdef CONFIG_PAX_REFCOUNT
14391 + "jno 0f\n"
14392 + "subl %2,%0\n"
14393 + "int $4\n0:\n"
14394 + _ASM_EXTABLE(0b, 0b)
14395 +#endif
14396 +
14397 + : "=r" (new)
14398 + : "0" (c), "ir" (a));
14399 +
14400 + old = atomic_cmpxchg(v, c, new);
14401 if (likely(old == c))
14402 break;
14403 c = old;
14404 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14405 }
14406
14407 /**
14408 + * atomic_inc_not_zero_hint - increment if not null
14409 + * @v: pointer of type atomic_t
14410 + * @hint: probable value of the atomic before the increment
14411 + *
14412 + * This version of atomic_inc_not_zero() gives a hint of probable
14413 + * value of the atomic. This helps processor to not read the memory
14414 + * before doing the atomic read/modify/write cycle, lowering
14415 + * number of bus transactions on some arches.
14416 + *
14417 + * Returns: 0 if increment was not done, 1 otherwise.
14418 + */
14419 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
14420 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
14421 +{
14422 + int val, c = hint, new;
14423 +
14424 + /* sanity test, should be removed by compiler if hint is a constant */
14425 + if (!hint)
14426 + return __atomic_add_unless(v, 1, 0);
14427 +
14428 + do {
14429 + asm volatile("incl %0\n"
14430 +
14431 +#ifdef CONFIG_PAX_REFCOUNT
14432 + "jno 0f\n"
14433 + "decl %0\n"
14434 + "int $4\n0:\n"
14435 + _ASM_EXTABLE(0b, 0b)
14436 +#endif
14437 +
14438 + : "=r" (new)
14439 + : "0" (c));
14440 +
14441 + val = atomic_cmpxchg(v, c, new);
14442 + if (val == c)
14443 + return 1;
14444 + c = val;
14445 + } while (c);
14446 +
14447 + return 0;
14448 +}
14449 +
14450 +/**
14451 * atomic_inc_short - increment of a short integer
14452 * @v: pointer to type int
14453 *
14454 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
14455 #endif
14456
14457 /* These are x86-specific, used by some header files */
14458 -#define atomic_clear_mask(mask, addr) \
14459 - asm volatile(LOCK_PREFIX "andl %0,%1" \
14460 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
14461 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
14462 +{
14463 + asm volatile(LOCK_PREFIX "andl %1,%0"
14464 + : "+m" (v->counter)
14465 + : "r" (~(mask))
14466 + : "memory");
14467 +}
14468
14469 -#define atomic_set_mask(mask, addr) \
14470 - asm volatile(LOCK_PREFIX "orl %0,%1" \
14471 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
14472 - : "memory")
14473 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14474 +{
14475 + asm volatile(LOCK_PREFIX "andl %1,%0"
14476 + : "+m" (v->counter)
14477 + : "r" (~(mask))
14478 + : "memory");
14479 +}
14480 +
14481 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
14482 +{
14483 + asm volatile(LOCK_PREFIX "orl %1,%0"
14484 + : "+m" (v->counter)
14485 + : "r" (mask)
14486 + : "memory");
14487 +}
14488 +
14489 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14490 +{
14491 + asm volatile(LOCK_PREFIX "orl %1,%0"
14492 + : "+m" (v->counter)
14493 + : "r" (mask)
14494 + : "memory");
14495 +}
14496
14497 /* Atomic operations are already serializing on x86 */
14498 #define smp_mb__before_atomic_dec() barrier()
14499 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
14500 index b154de7..aadebd8 100644
14501 --- a/arch/x86/include/asm/atomic64_32.h
14502 +++ b/arch/x86/include/asm/atomic64_32.h
14503 @@ -12,6 +12,14 @@ typedef struct {
14504 u64 __aligned(8) counter;
14505 } atomic64_t;
14506
14507 +#ifdef CONFIG_PAX_REFCOUNT
14508 +typedef struct {
14509 + u64 __aligned(8) counter;
14510 +} atomic64_unchecked_t;
14511 +#else
14512 +typedef atomic64_t atomic64_unchecked_t;
14513 +#endif
14514 +
14515 #define ATOMIC64_INIT(val) { (val) }
14516
14517 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
14518 @@ -37,21 +45,31 @@ typedef struct {
14519 ATOMIC64_DECL_ONE(sym##_386)
14520
14521 ATOMIC64_DECL_ONE(add_386);
14522 +ATOMIC64_DECL_ONE(add_unchecked_386);
14523 ATOMIC64_DECL_ONE(sub_386);
14524 +ATOMIC64_DECL_ONE(sub_unchecked_386);
14525 ATOMIC64_DECL_ONE(inc_386);
14526 +ATOMIC64_DECL_ONE(inc_unchecked_386);
14527 ATOMIC64_DECL_ONE(dec_386);
14528 +ATOMIC64_DECL_ONE(dec_unchecked_386);
14529 #endif
14530
14531 #define alternative_atomic64(f, out, in...) \
14532 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
14533
14534 ATOMIC64_DECL(read);
14535 +ATOMIC64_DECL(read_unchecked);
14536 ATOMIC64_DECL(set);
14537 +ATOMIC64_DECL(set_unchecked);
14538 ATOMIC64_DECL(xchg);
14539 ATOMIC64_DECL(add_return);
14540 +ATOMIC64_DECL(add_return_unchecked);
14541 ATOMIC64_DECL(sub_return);
14542 +ATOMIC64_DECL(sub_return_unchecked);
14543 ATOMIC64_DECL(inc_return);
14544 +ATOMIC64_DECL(inc_return_unchecked);
14545 ATOMIC64_DECL(dec_return);
14546 +ATOMIC64_DECL(dec_return_unchecked);
14547 ATOMIC64_DECL(dec_if_positive);
14548 ATOMIC64_DECL(inc_not_zero);
14549 ATOMIC64_DECL(add_unless);
14550 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
14551 }
14552
14553 /**
14554 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
14555 + * @p: pointer to type atomic64_unchecked_t
14556 + * @o: expected value
14557 + * @n: new value
14558 + *
14559 + * Atomically sets @v to @n if it was equal to @o and returns
14560 + * the old value.
14561 + */
14562 +
14563 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
14564 +{
14565 + return cmpxchg64(&v->counter, o, n);
14566 +}
14567 +
14568 +/**
14569 * atomic64_xchg - xchg atomic64 variable
14570 * @v: pointer to type atomic64_t
14571 * @n: value to assign
14572 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
14573 }
14574
14575 /**
14576 + * atomic64_set_unchecked - set atomic64 variable
14577 + * @v: pointer to type atomic64_unchecked_t
14578 + * @n: value to assign
14579 + *
14580 + * Atomically sets the value of @v to @n.
14581 + */
14582 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
14583 +{
14584 + unsigned high = (unsigned)(i >> 32);
14585 + unsigned low = (unsigned)i;
14586 + alternative_atomic64(set, /* no output */,
14587 + "S" (v), "b" (low), "c" (high)
14588 + : "eax", "edx", "memory");
14589 +}
14590 +
14591 +/**
14592 * atomic64_read - read atomic64 variable
14593 * @v: pointer to type atomic64_t
14594 *
14595 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
14596 }
14597
14598 /**
14599 + * atomic64_read_unchecked - read atomic64 variable
14600 + * @v: pointer to type atomic64_unchecked_t
14601 + *
14602 + * Atomically reads the value of @v and returns it.
14603 + */
14604 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
14605 +{
14606 + long long r;
14607 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
14608 + return r;
14609 + }
14610 +
14611 +/**
14612 * atomic64_add_return - add and return
14613 * @i: integer value to add
14614 * @v: pointer to type atomic64_t
14615 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
14616 return i;
14617 }
14618
14619 +/**
14620 + * atomic64_add_return_unchecked - add and return
14621 + * @i: integer value to add
14622 + * @v: pointer to type atomic64_unchecked_t
14623 + *
14624 + * Atomically adds @i to @v and returns @i + *@v
14625 + */
14626 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
14627 +{
14628 + alternative_atomic64(add_return_unchecked,
14629 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14630 + ASM_NO_INPUT_CLOBBER("memory"));
14631 + return i;
14632 +}
14633 +
14634 /*
14635 * Other variants with different arithmetic operators:
14636 */
14637 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
14638 return a;
14639 }
14640
14641 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
14642 +{
14643 + long long a;
14644 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
14645 + "S" (v) : "memory", "ecx");
14646 + return a;
14647 +}
14648 +
14649 static inline long long atomic64_dec_return(atomic64_t *v)
14650 {
14651 long long a;
14652 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
14653 }
14654
14655 /**
14656 + * atomic64_add_unchecked - add integer to atomic64 variable
14657 + * @i: integer value to add
14658 + * @v: pointer to type atomic64_unchecked_t
14659 + *
14660 + * Atomically adds @i to @v.
14661 + */
14662 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
14663 +{
14664 + __alternative_atomic64(add_unchecked, add_return_unchecked,
14665 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14666 + ASM_NO_INPUT_CLOBBER("memory"));
14667 + return i;
14668 +}
14669 +
14670 +/**
14671 * atomic64_sub - subtract the atomic64 variable
14672 * @i: integer value to subtract
14673 * @v: pointer to type atomic64_t
14674 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
14675 index 0e1cbfc..5623683 100644
14676 --- a/arch/x86/include/asm/atomic64_64.h
14677 +++ b/arch/x86/include/asm/atomic64_64.h
14678 @@ -18,7 +18,19 @@
14679 */
14680 static inline long atomic64_read(const atomic64_t *v)
14681 {
14682 - return (*(volatile long *)&(v)->counter);
14683 + return (*(volatile const long *)&(v)->counter);
14684 +}
14685 +
14686 +/**
14687 + * atomic64_read_unchecked - read atomic64 variable
14688 + * @v: pointer of type atomic64_unchecked_t
14689 + *
14690 + * Atomically reads the value of @v.
14691 + * Doesn't imply a read memory barrier.
14692 + */
14693 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
14694 +{
14695 + return (*(volatile const long *)&(v)->counter);
14696 }
14697
14698 /**
14699 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
14700 }
14701
14702 /**
14703 + * atomic64_set_unchecked - set atomic64 variable
14704 + * @v: pointer to type atomic64_unchecked_t
14705 + * @i: required value
14706 + *
14707 + * Atomically sets the value of @v to @i.
14708 + */
14709 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
14710 +{
14711 + v->counter = i;
14712 +}
14713 +
14714 +/**
14715 * atomic64_add - add integer to atomic64 variable
14716 * @i: integer value to add
14717 * @v: pointer to type atomic64_t
14718 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
14719 */
14720 static inline void atomic64_add(long i, atomic64_t *v)
14721 {
14722 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
14723 +
14724 +#ifdef CONFIG_PAX_REFCOUNT
14725 + "jno 0f\n"
14726 + LOCK_PREFIX "subq %1,%0\n"
14727 + "int $4\n0:\n"
14728 + _ASM_EXTABLE(0b, 0b)
14729 +#endif
14730 +
14731 + : "=m" (v->counter)
14732 + : "er" (i), "m" (v->counter));
14733 +}
14734 +
14735 +/**
14736 + * atomic64_add_unchecked - add integer to atomic64 variable
14737 + * @i: integer value to add
14738 + * @v: pointer to type atomic64_unchecked_t
14739 + *
14740 + * Atomically adds @i to @v.
14741 + */
14742 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
14743 +{
14744 asm volatile(LOCK_PREFIX "addq %1,%0"
14745 : "=m" (v->counter)
14746 : "er" (i), "m" (v->counter));
14747 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
14748 */
14749 static inline void atomic64_sub(long i, atomic64_t *v)
14750 {
14751 - asm volatile(LOCK_PREFIX "subq %1,%0"
14752 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
14753 +
14754 +#ifdef CONFIG_PAX_REFCOUNT
14755 + "jno 0f\n"
14756 + LOCK_PREFIX "addq %1,%0\n"
14757 + "int $4\n0:\n"
14758 + _ASM_EXTABLE(0b, 0b)
14759 +#endif
14760 +
14761 + : "=m" (v->counter)
14762 + : "er" (i), "m" (v->counter));
14763 +}
14764 +
14765 +/**
14766 + * atomic64_sub_unchecked - subtract the atomic64 variable
14767 + * @i: integer value to subtract
14768 + * @v: pointer to type atomic64_unchecked_t
14769 + *
14770 + * Atomically subtracts @i from @v.
14771 + */
14772 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
14773 +{
14774 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
14775 : "=m" (v->counter)
14776 : "er" (i), "m" (v->counter));
14777 }
14778 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
14779 {
14780 unsigned char c;
14781
14782 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
14783 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
14784 +
14785 +#ifdef CONFIG_PAX_REFCOUNT
14786 + "jno 0f\n"
14787 + LOCK_PREFIX "addq %2,%0\n"
14788 + "int $4\n0:\n"
14789 + _ASM_EXTABLE(0b, 0b)
14790 +#endif
14791 +
14792 + "sete %1\n"
14793 : "=m" (v->counter), "=qm" (c)
14794 : "er" (i), "m" (v->counter) : "memory");
14795 return c;
14796 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
14797 */
14798 static inline void atomic64_inc(atomic64_t *v)
14799 {
14800 + asm volatile(LOCK_PREFIX "incq %0\n"
14801 +
14802 +#ifdef CONFIG_PAX_REFCOUNT
14803 + "jno 0f\n"
14804 + LOCK_PREFIX "decq %0\n"
14805 + "int $4\n0:\n"
14806 + _ASM_EXTABLE(0b, 0b)
14807 +#endif
14808 +
14809 + : "=m" (v->counter)
14810 + : "m" (v->counter));
14811 +}
14812 +
14813 +/**
14814 + * atomic64_inc_unchecked - increment atomic64 variable
14815 + * @v: pointer to type atomic64_unchecked_t
14816 + *
14817 + * Atomically increments @v by 1.
14818 + */
14819 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
14820 +{
14821 asm volatile(LOCK_PREFIX "incq %0"
14822 : "=m" (v->counter)
14823 : "m" (v->counter));
14824 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
14825 */
14826 static inline void atomic64_dec(atomic64_t *v)
14827 {
14828 - asm volatile(LOCK_PREFIX "decq %0"
14829 + asm volatile(LOCK_PREFIX "decq %0\n"
14830 +
14831 +#ifdef CONFIG_PAX_REFCOUNT
14832 + "jno 0f\n"
14833 + LOCK_PREFIX "incq %0\n"
14834 + "int $4\n0:\n"
14835 + _ASM_EXTABLE(0b, 0b)
14836 +#endif
14837 +
14838 + : "=m" (v->counter)
14839 + : "m" (v->counter));
14840 +}
14841 +
14842 +/**
14843 + * atomic64_dec_unchecked - decrement atomic64 variable
14844 + * @v: pointer to type atomic64_t
14845 + *
14846 + * Atomically decrements @v by 1.
14847 + */
14848 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
14849 +{
14850 + asm volatile(LOCK_PREFIX "decq %0\n"
14851 : "=m" (v->counter)
14852 : "m" (v->counter));
14853 }
14854 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
14855 {
14856 unsigned char c;
14857
14858 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
14859 + asm volatile(LOCK_PREFIX "decq %0\n"
14860 +
14861 +#ifdef CONFIG_PAX_REFCOUNT
14862 + "jno 0f\n"
14863 + LOCK_PREFIX "incq %0\n"
14864 + "int $4\n0:\n"
14865 + _ASM_EXTABLE(0b, 0b)
14866 +#endif
14867 +
14868 + "sete %1\n"
14869 : "=m" (v->counter), "=qm" (c)
14870 : "m" (v->counter) : "memory");
14871 return c != 0;
14872 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
14873 {
14874 unsigned char c;
14875
14876 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
14877 + asm volatile(LOCK_PREFIX "incq %0\n"
14878 +
14879 +#ifdef CONFIG_PAX_REFCOUNT
14880 + "jno 0f\n"
14881 + LOCK_PREFIX "decq %0\n"
14882 + "int $4\n0:\n"
14883 + _ASM_EXTABLE(0b, 0b)
14884 +#endif
14885 +
14886 + "sete %1\n"
14887 : "=m" (v->counter), "=qm" (c)
14888 : "m" (v->counter) : "memory");
14889 return c != 0;
14890 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
14891 {
14892 unsigned char c;
14893
14894 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
14895 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
14896 +
14897 +#ifdef CONFIG_PAX_REFCOUNT
14898 + "jno 0f\n"
14899 + LOCK_PREFIX "subq %2,%0\n"
14900 + "int $4\n0:\n"
14901 + _ASM_EXTABLE(0b, 0b)
14902 +#endif
14903 +
14904 + "sets %1\n"
14905 : "=m" (v->counter), "=qm" (c)
14906 : "er" (i), "m" (v->counter) : "memory");
14907 return c;
14908 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
14909 */
14910 static inline long atomic64_add_return(long i, atomic64_t *v)
14911 {
14912 + return i + xadd_check_overflow(&v->counter, i);
14913 +}
14914 +
14915 +/**
14916 + * atomic64_add_return_unchecked - add and return
14917 + * @i: integer value to add
14918 + * @v: pointer to type atomic64_unchecked_t
14919 + *
14920 + * Atomically adds @i to @v and returns @i + @v
14921 + */
14922 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
14923 +{
14924 return i + xadd(&v->counter, i);
14925 }
14926
14927 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
14928 }
14929
14930 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
14931 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
14932 +{
14933 + return atomic64_add_return_unchecked(1, v);
14934 +}
14935 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
14936
14937 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
14938 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
14939 return cmpxchg(&v->counter, old, new);
14940 }
14941
14942 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
14943 +{
14944 + return cmpxchg(&v->counter, old, new);
14945 +}
14946 +
14947 static inline long atomic64_xchg(atomic64_t *v, long new)
14948 {
14949 return xchg(&v->counter, new);
14950 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
14951 */
14952 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
14953 {
14954 - long c, old;
14955 + long c, old, new;
14956 c = atomic64_read(v);
14957 for (;;) {
14958 - if (unlikely(c == (u)))
14959 + if (unlikely(c == u))
14960 break;
14961 - old = atomic64_cmpxchg((v), c, c + (a));
14962 +
14963 + asm volatile("add %2,%0\n"
14964 +
14965 +#ifdef CONFIG_PAX_REFCOUNT
14966 + "jno 0f\n"
14967 + "sub %2,%0\n"
14968 + "int $4\n0:\n"
14969 + _ASM_EXTABLE(0b, 0b)
14970 +#endif
14971 +
14972 + : "=r" (new)
14973 + : "0" (c), "ir" (a));
14974 +
14975 + old = atomic64_cmpxchg(v, c, new);
14976 if (likely(old == c))
14977 break;
14978 c = old;
14979 }
14980 - return c != (u);
14981 + return c != u;
14982 }
14983
14984 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
14985 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
14986 index 6dfd019..28e188d 100644
14987 --- a/arch/x86/include/asm/bitops.h
14988 +++ b/arch/x86/include/asm/bitops.h
14989 @@ -40,7 +40,7 @@
14990 * a mask operation on a byte.
14991 */
14992 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
14993 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
14994 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
14995 #define CONST_MASK(nr) (1 << ((nr) & 7))
14996
14997 /**
14998 @@ -486,7 +486,7 @@ static inline int fls(int x)
14999 * at position 64.
15000 */
15001 #ifdef CONFIG_X86_64
15002 -static __always_inline int fls64(__u64 x)
15003 +static __always_inline long fls64(__u64 x)
15004 {
15005 int bitpos = -1;
15006 /*
15007 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
15008 index 4fa687a..60f2d39 100644
15009 --- a/arch/x86/include/asm/boot.h
15010 +++ b/arch/x86/include/asm/boot.h
15011 @@ -6,10 +6,15 @@
15012 #include <uapi/asm/boot.h>
15013
15014 /* Physical address where kernel should be loaded. */
15015 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
15016 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
15017 + (CONFIG_PHYSICAL_ALIGN - 1)) \
15018 & ~(CONFIG_PHYSICAL_ALIGN - 1))
15019
15020 +#ifndef __ASSEMBLY__
15021 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
15022 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
15023 +#endif
15024 +
15025 /* Minimum kernel alignment, as a power of two */
15026 #ifdef CONFIG_X86_64
15027 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
15028 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
15029 index 48f99f1..d78ebf9 100644
15030 --- a/arch/x86/include/asm/cache.h
15031 +++ b/arch/x86/include/asm/cache.h
15032 @@ -5,12 +5,13 @@
15033
15034 /* L1 cache line size */
15035 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
15036 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
15037 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
15038
15039 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
15040 +#define __read_only __attribute__((__section__(".data..read_only")))
15041
15042 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
15043 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
15044 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
15045
15046 #ifdef CONFIG_X86_VSMP
15047 #ifdef CONFIG_SMP
15048 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
15049 index 9863ee3..4a1f8e1 100644
15050 --- a/arch/x86/include/asm/cacheflush.h
15051 +++ b/arch/x86/include/asm/cacheflush.h
15052 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
15053 unsigned long pg_flags = pg->flags & _PGMT_MASK;
15054
15055 if (pg_flags == _PGMT_DEFAULT)
15056 - return -1;
15057 + return ~0UL;
15058 else if (pg_flags == _PGMT_WC)
15059 return _PAGE_CACHE_WC;
15060 else if (pg_flags == _PGMT_UC_MINUS)
15061 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
15062 index 46fc474..b02b0f9 100644
15063 --- a/arch/x86/include/asm/checksum_32.h
15064 +++ b/arch/x86/include/asm/checksum_32.h
15065 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
15066 int len, __wsum sum,
15067 int *src_err_ptr, int *dst_err_ptr);
15068
15069 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
15070 + int len, __wsum sum,
15071 + int *src_err_ptr, int *dst_err_ptr);
15072 +
15073 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
15074 + int len, __wsum sum,
15075 + int *src_err_ptr, int *dst_err_ptr);
15076 +
15077 /*
15078 * Note: when you get a NULL pointer exception here this means someone
15079 * passed in an incorrect kernel address to one of these functions.
15080 @@ -50,7 +58,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
15081 int *err_ptr)
15082 {
15083 might_sleep();
15084 - return csum_partial_copy_generic((__force void *)src, dst,
15085 + return csum_partial_copy_generic_from_user((__force void *)src, dst,
15086 len, sum, err_ptr, NULL);
15087 }
15088
15089 @@ -178,7 +186,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
15090 {
15091 might_sleep();
15092 if (access_ok(VERIFY_WRITE, dst, len))
15093 - return csum_partial_copy_generic(src, (__force void *)dst,
15094 + return csum_partial_copy_generic_to_user(src, (__force void *)dst,
15095 len, sum, NULL, err_ptr);
15096
15097 if (len)
15098 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
15099 index d47786a..ce1b05d 100644
15100 --- a/arch/x86/include/asm/cmpxchg.h
15101 +++ b/arch/x86/include/asm/cmpxchg.h
15102 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
15103 __compiletime_error("Bad argument size for cmpxchg");
15104 extern void __xadd_wrong_size(void)
15105 __compiletime_error("Bad argument size for xadd");
15106 +extern void __xadd_check_overflow_wrong_size(void)
15107 + __compiletime_error("Bad argument size for xadd_check_overflow");
15108 extern void __add_wrong_size(void)
15109 __compiletime_error("Bad argument size for add");
15110 +extern void __add_check_overflow_wrong_size(void)
15111 + __compiletime_error("Bad argument size for add_check_overflow");
15112
15113 /*
15114 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
15115 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
15116 __ret; \
15117 })
15118
15119 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
15120 + ({ \
15121 + __typeof__ (*(ptr)) __ret = (arg); \
15122 + switch (sizeof(*(ptr))) { \
15123 + case __X86_CASE_L: \
15124 + asm volatile (lock #op "l %0, %1\n" \
15125 + "jno 0f\n" \
15126 + "mov %0,%1\n" \
15127 + "int $4\n0:\n" \
15128 + _ASM_EXTABLE(0b, 0b) \
15129 + : "+r" (__ret), "+m" (*(ptr)) \
15130 + : : "memory", "cc"); \
15131 + break; \
15132 + case __X86_CASE_Q: \
15133 + asm volatile (lock #op "q %q0, %1\n" \
15134 + "jno 0f\n" \
15135 + "mov %0,%1\n" \
15136 + "int $4\n0:\n" \
15137 + _ASM_EXTABLE(0b, 0b) \
15138 + : "+r" (__ret), "+m" (*(ptr)) \
15139 + : : "memory", "cc"); \
15140 + break; \
15141 + default: \
15142 + __ ## op ## _check_overflow_wrong_size(); \
15143 + } \
15144 + __ret; \
15145 + })
15146 +
15147 /*
15148 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
15149 * Since this is generally used to protect other memory information, we
15150 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
15151 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
15152 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
15153
15154 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
15155 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
15156 +
15157 #define __add(ptr, inc, lock) \
15158 ({ \
15159 __typeof__ (*(ptr)) __ret = (inc); \
15160 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
15161 index 59c6c40..5e0b22c 100644
15162 --- a/arch/x86/include/asm/compat.h
15163 +++ b/arch/x86/include/asm/compat.h
15164 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
15165 typedef u32 compat_uint_t;
15166 typedef u32 compat_ulong_t;
15167 typedef u64 __attribute__((aligned(4))) compat_u64;
15168 -typedef u32 compat_uptr_t;
15169 +typedef u32 __user compat_uptr_t;
15170
15171 struct compat_timespec {
15172 compat_time_t tv_sec;
15173 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
15174 index e99ac27..10d834e 100644
15175 --- a/arch/x86/include/asm/cpufeature.h
15176 +++ b/arch/x86/include/asm/cpufeature.h
15177 @@ -203,7 +203,7 @@
15178 #define X86_FEATURE_DECODEASSISTS (8*32+12) /* AMD Decode Assists support */
15179 #define X86_FEATURE_PAUSEFILTER (8*32+13) /* AMD filtered pause intercept */
15180 #define X86_FEATURE_PFTHRESHOLD (8*32+14) /* AMD pause filter threshold */
15181 -
15182 +#define X86_FEATURE_STRONGUDEREF (8*32+31) /* PaX PCID based strong UDEREF */
15183
15184 /* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx), word 9 */
15185 #define X86_FEATURE_FSGSBASE (9*32+ 0) /* {RD/WR}{FS/GS}BASE instructions*/
15186 @@ -211,7 +211,7 @@
15187 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
15188 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
15189 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
15190 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
15191 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
15192 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
15193 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
15194 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
15195 @@ -353,6 +353,7 @@ extern const char * const x86_power_flags[32];
15196 #undef cpu_has_centaur_mcr
15197 #define cpu_has_centaur_mcr 0
15198
15199 +#define cpu_has_pcid boot_cpu_has(X86_FEATURE_PCID)
15200 #endif /* CONFIG_X86_64 */
15201
15202 #if __GNUC__ >= 4
15203 @@ -394,7 +395,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
15204 ".section .discard,\"aw\",@progbits\n"
15205 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
15206 ".previous\n"
15207 - ".section .altinstr_replacement,\"ax\"\n"
15208 + ".section .altinstr_replacement,\"a\"\n"
15209 "3: movb $1,%0\n"
15210 "4:\n"
15211 ".previous\n"
15212 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
15213 index 8bf1c06..b6ae785 100644
15214 --- a/arch/x86/include/asm/desc.h
15215 +++ b/arch/x86/include/asm/desc.h
15216 @@ -4,6 +4,7 @@
15217 #include <asm/desc_defs.h>
15218 #include <asm/ldt.h>
15219 #include <asm/mmu.h>
15220 +#include <asm/pgtable.h>
15221
15222 #include <linux/smp.h>
15223 #include <linux/percpu.h>
15224 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
15225
15226 desc->type = (info->read_exec_only ^ 1) << 1;
15227 desc->type |= info->contents << 2;
15228 + desc->type |= info->seg_not_present ^ 1;
15229
15230 desc->s = 1;
15231 desc->dpl = 0x3;
15232 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
15233 }
15234
15235 extern struct desc_ptr idt_descr;
15236 -extern gate_desc idt_table[];
15237 extern struct desc_ptr nmi_idt_descr;
15238 -extern gate_desc nmi_idt_table[];
15239 -
15240 -struct gdt_page {
15241 - struct desc_struct gdt[GDT_ENTRIES];
15242 -} __attribute__((aligned(PAGE_SIZE)));
15243 -
15244 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
15245 +extern gate_desc idt_table[256];
15246 +extern gate_desc nmi_idt_table[256];
15247
15248 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
15249 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
15250 {
15251 - return per_cpu(gdt_page, cpu).gdt;
15252 + return cpu_gdt_table[cpu];
15253 }
15254
15255 #ifdef CONFIG_X86_64
15256 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
15257 unsigned long base, unsigned dpl, unsigned flags,
15258 unsigned short seg)
15259 {
15260 - gate->a = (seg << 16) | (base & 0xffff);
15261 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
15262 + gate->gate.offset_low = base;
15263 + gate->gate.seg = seg;
15264 + gate->gate.reserved = 0;
15265 + gate->gate.type = type;
15266 + gate->gate.s = 0;
15267 + gate->gate.dpl = dpl;
15268 + gate->gate.p = 1;
15269 + gate->gate.offset_high = base >> 16;
15270 }
15271
15272 #endif
15273 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
15274
15275 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
15276 {
15277 + pax_open_kernel();
15278 memcpy(&idt[entry], gate, sizeof(*gate));
15279 + pax_close_kernel();
15280 }
15281
15282 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
15283 {
15284 + pax_open_kernel();
15285 memcpy(&ldt[entry], desc, 8);
15286 + pax_close_kernel();
15287 }
15288
15289 static inline void
15290 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
15291 default: size = sizeof(*gdt); break;
15292 }
15293
15294 + pax_open_kernel();
15295 memcpy(&gdt[entry], desc, size);
15296 + pax_close_kernel();
15297 }
15298
15299 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
15300 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
15301
15302 static inline void native_load_tr_desc(void)
15303 {
15304 + pax_open_kernel();
15305 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
15306 + pax_close_kernel();
15307 }
15308
15309 static inline void native_load_gdt(const struct desc_ptr *dtr)
15310 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
15311 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
15312 unsigned int i;
15313
15314 + pax_open_kernel();
15315 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
15316 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
15317 + pax_close_kernel();
15318 }
15319
15320 #define _LDT_empty(info) \
15321 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
15322 preempt_enable();
15323 }
15324
15325 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
15326 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
15327 {
15328 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
15329 }
15330 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
15331 }
15332
15333 #ifdef CONFIG_X86_64
15334 -static inline void set_nmi_gate(int gate, void *addr)
15335 +static inline void set_nmi_gate(int gate, const void *addr)
15336 {
15337 gate_desc s;
15338
15339 @@ -320,7 +333,7 @@ static inline void set_nmi_gate(int gate, void *addr)
15340 }
15341 #endif
15342
15343 -static inline void _set_gate(int gate, unsigned type, void *addr,
15344 +static inline void _set_gate(int gate, unsigned type, const void *addr,
15345 unsigned dpl, unsigned ist, unsigned seg)
15346 {
15347 gate_desc s;
15348 @@ -339,7 +352,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
15349 * Pentium F0 0F bugfix can have resulted in the mapped
15350 * IDT being write-protected.
15351 */
15352 -static inline void set_intr_gate(unsigned int n, void *addr)
15353 +static inline void set_intr_gate(unsigned int n, const void *addr)
15354 {
15355 BUG_ON((unsigned)n > 0xFF);
15356 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
15357 @@ -369,19 +382,19 @@ static inline void alloc_intr_gate(unsigned int n, void *addr)
15358 /*
15359 * This routine sets up an interrupt gate at directory privilege level 3.
15360 */
15361 -static inline void set_system_intr_gate(unsigned int n, void *addr)
15362 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
15363 {
15364 BUG_ON((unsigned)n > 0xFF);
15365 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
15366 }
15367
15368 -static inline void set_system_trap_gate(unsigned int n, void *addr)
15369 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
15370 {
15371 BUG_ON((unsigned)n > 0xFF);
15372 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
15373 }
15374
15375 -static inline void set_trap_gate(unsigned int n, void *addr)
15376 +static inline void set_trap_gate(unsigned int n, const void *addr)
15377 {
15378 BUG_ON((unsigned)n > 0xFF);
15379 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
15380 @@ -390,19 +403,31 @@ static inline void set_trap_gate(unsigned int n, void *addr)
15381 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
15382 {
15383 BUG_ON((unsigned)n > 0xFF);
15384 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
15385 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
15386 }
15387
15388 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
15389 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
15390 {
15391 BUG_ON((unsigned)n > 0xFF);
15392 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
15393 }
15394
15395 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
15396 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
15397 {
15398 BUG_ON((unsigned)n > 0xFF);
15399 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
15400 }
15401
15402 +#ifdef CONFIG_X86_32
15403 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
15404 +{
15405 + struct desc_struct d;
15406 +
15407 + if (likely(limit))
15408 + limit = (limit - 1UL) >> PAGE_SHIFT;
15409 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
15410 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
15411 +}
15412 +#endif
15413 +
15414 #endif /* _ASM_X86_DESC_H */
15415 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
15416 index 278441f..b95a174 100644
15417 --- a/arch/x86/include/asm/desc_defs.h
15418 +++ b/arch/x86/include/asm/desc_defs.h
15419 @@ -31,6 +31,12 @@ struct desc_struct {
15420 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
15421 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
15422 };
15423 + struct {
15424 + u16 offset_low;
15425 + u16 seg;
15426 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
15427 + unsigned offset_high: 16;
15428 + } gate;
15429 };
15430 } __attribute__((packed));
15431
15432 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
15433 index ced283a..ffe04cc 100644
15434 --- a/arch/x86/include/asm/div64.h
15435 +++ b/arch/x86/include/asm/div64.h
15436 @@ -39,7 +39,7 @@
15437 __mod; \
15438 })
15439
15440 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
15441 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
15442 {
15443 union {
15444 u64 v64;
15445 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
15446 index 9c999c1..3860cb8 100644
15447 --- a/arch/x86/include/asm/elf.h
15448 +++ b/arch/x86/include/asm/elf.h
15449 @@ -243,7 +243,25 @@ extern int force_personality32;
15450 the loader. We need to make sure that it is out of the way of the program
15451 that it will "exec", and that there is sufficient room for the brk. */
15452
15453 +#ifdef CONFIG_PAX_SEGMEXEC
15454 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
15455 +#else
15456 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
15457 +#endif
15458 +
15459 +#ifdef CONFIG_PAX_ASLR
15460 +#ifdef CONFIG_X86_32
15461 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
15462 +
15463 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
15464 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
15465 +#else
15466 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
15467 +
15468 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
15469 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
15470 +#endif
15471 +#endif
15472
15473 /* This yields a mask that user programs can use to figure out what
15474 instruction set this CPU supports. This could be done in user space,
15475 @@ -296,16 +314,12 @@ do { \
15476
15477 #define ARCH_DLINFO \
15478 do { \
15479 - if (vdso_enabled) \
15480 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
15481 - (unsigned long)current->mm->context.vdso); \
15482 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
15483 } while (0)
15484
15485 #define ARCH_DLINFO_X32 \
15486 do { \
15487 - if (vdso_enabled) \
15488 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
15489 - (unsigned long)current->mm->context.vdso); \
15490 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
15491 } while (0)
15492
15493 #define AT_SYSINFO 32
15494 @@ -320,7 +334,7 @@ else \
15495
15496 #endif /* !CONFIG_X86_32 */
15497
15498 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
15499 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
15500
15501 #define VDSO_ENTRY \
15502 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
15503 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
15504 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
15505 #define compat_arch_setup_additional_pages syscall32_setup_pages
15506
15507 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
15508 -#define arch_randomize_brk arch_randomize_brk
15509 -
15510 /*
15511 * True on X86_32 or when emulating IA32 on X86_64
15512 */
15513 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
15514 index 75ce3f4..882e801 100644
15515 --- a/arch/x86/include/asm/emergency-restart.h
15516 +++ b/arch/x86/include/asm/emergency-restart.h
15517 @@ -13,6 +13,6 @@ enum reboot_type {
15518
15519 extern enum reboot_type reboot_type;
15520
15521 -extern void machine_emergency_restart(void);
15522 +extern void machine_emergency_restart(void) __noreturn;
15523
15524 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
15525 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
15526 index e25cc33..7d3ec01 100644
15527 --- a/arch/x86/include/asm/fpu-internal.h
15528 +++ b/arch/x86/include/asm/fpu-internal.h
15529 @@ -126,8 +126,11 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
15530 #define user_insn(insn, output, input...) \
15531 ({ \
15532 int err; \
15533 + pax_open_userland(); \
15534 asm volatile(ASM_STAC "\n" \
15535 - "1:" #insn "\n\t" \
15536 + "1:" \
15537 + __copyuser_seg \
15538 + #insn "\n\t" \
15539 "2: " ASM_CLAC "\n" \
15540 ".section .fixup,\"ax\"\n" \
15541 "3: movl $-1,%[err]\n" \
15542 @@ -136,6 +139,7 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
15543 _ASM_EXTABLE(1b, 3b) \
15544 : [err] "=r" (err), output \
15545 : "0"(0), input); \
15546 + pax_close_userland(); \
15547 err; \
15548 })
15549
15550 @@ -300,7 +304,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
15551 "emms\n\t" /* clear stack tags */
15552 "fildl %P[addr]", /* set F?P to defined value */
15553 X86_FEATURE_FXSAVE_LEAK,
15554 - [addr] "m" (tsk->thread.fpu.has_fpu));
15555 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
15556
15557 return fpu_restore_checking(&tsk->thread.fpu);
15558 }
15559 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
15560 index be27ba1..04a8801 100644
15561 --- a/arch/x86/include/asm/futex.h
15562 +++ b/arch/x86/include/asm/futex.h
15563 @@ -12,6 +12,7 @@
15564 #include <asm/smap.h>
15565
15566 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
15567 + typecheck(u32 __user *, uaddr); \
15568 asm volatile("\t" ASM_STAC "\n" \
15569 "1:\t" insn "\n" \
15570 "2:\t" ASM_CLAC "\n" \
15571 @@ -20,15 +21,16 @@
15572 "\tjmp\t2b\n" \
15573 "\t.previous\n" \
15574 _ASM_EXTABLE(1b, 3b) \
15575 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
15576 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
15577 : "i" (-EFAULT), "0" (oparg), "1" (0))
15578
15579 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
15580 + typecheck(u32 __user *, uaddr); \
15581 asm volatile("\t" ASM_STAC "\n" \
15582 "1:\tmovl %2, %0\n" \
15583 "\tmovl\t%0, %3\n" \
15584 "\t" insn "\n" \
15585 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
15586 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
15587 "\tjnz\t1b\n" \
15588 "3:\t" ASM_CLAC "\n" \
15589 "\t.section .fixup,\"ax\"\n" \
15590 @@ -38,7 +40,7 @@
15591 _ASM_EXTABLE(1b, 4b) \
15592 _ASM_EXTABLE(2b, 4b) \
15593 : "=&a" (oldval), "=&r" (ret), \
15594 - "+m" (*uaddr), "=&r" (tem) \
15595 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
15596 : "r" (oparg), "i" (-EFAULT), "1" (0))
15597
15598 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15599 @@ -57,12 +59,13 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15600
15601 pagefault_disable();
15602
15603 + pax_open_userland();
15604 switch (op) {
15605 case FUTEX_OP_SET:
15606 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
15607 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
15608 break;
15609 case FUTEX_OP_ADD:
15610 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
15611 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
15612 uaddr, oparg);
15613 break;
15614 case FUTEX_OP_OR:
15615 @@ -77,6 +80,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15616 default:
15617 ret = -ENOSYS;
15618 }
15619 + pax_close_userland();
15620
15621 pagefault_enable();
15622
15623 @@ -115,18 +119,20 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
15624 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
15625 return -EFAULT;
15626
15627 + pax_open_userland();
15628 asm volatile("\t" ASM_STAC "\n"
15629 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
15630 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
15631 "2:\t" ASM_CLAC "\n"
15632 "\t.section .fixup, \"ax\"\n"
15633 "3:\tmov %3, %0\n"
15634 "\tjmp 2b\n"
15635 "\t.previous\n"
15636 _ASM_EXTABLE(1b, 3b)
15637 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
15638 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
15639 : "i" (-EFAULT), "r" (newval), "1" (oldval)
15640 : "memory"
15641 );
15642 + pax_close_userland();
15643
15644 *uval = oldval;
15645 return ret;
15646 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
15647 index 1da97ef..9c2ebff 100644
15648 --- a/arch/x86/include/asm/hw_irq.h
15649 +++ b/arch/x86/include/asm/hw_irq.h
15650 @@ -148,8 +148,8 @@ extern void setup_ioapic_dest(void);
15651 extern void enable_IO_APIC(void);
15652
15653 /* Statistics */
15654 -extern atomic_t irq_err_count;
15655 -extern atomic_t irq_mis_count;
15656 +extern atomic_unchecked_t irq_err_count;
15657 +extern atomic_unchecked_t irq_mis_count;
15658
15659 /* EISA */
15660 extern void eisa_set_level_irq(unsigned int irq);
15661 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
15662 index a203659..9889f1c 100644
15663 --- a/arch/x86/include/asm/i8259.h
15664 +++ b/arch/x86/include/asm/i8259.h
15665 @@ -62,7 +62,7 @@ struct legacy_pic {
15666 void (*init)(int auto_eoi);
15667 int (*irq_pending)(unsigned int irq);
15668 void (*make_irq)(unsigned int irq);
15669 -};
15670 +} __do_const;
15671
15672 extern struct legacy_pic *legacy_pic;
15673 extern struct legacy_pic null_legacy_pic;
15674 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
15675 index d8e8eef..1765f78 100644
15676 --- a/arch/x86/include/asm/io.h
15677 +++ b/arch/x86/include/asm/io.h
15678 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
15679 "m" (*(volatile type __force *)addr) barrier); }
15680
15681 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
15682 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
15683 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
15684 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
15685 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
15686
15687 build_mmio_read(__readb, "b", unsigned char, "=q", )
15688 -build_mmio_read(__readw, "w", unsigned short, "=r", )
15689 -build_mmio_read(__readl, "l", unsigned int, "=r", )
15690 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
15691 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
15692
15693 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
15694 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
15695 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
15696 return ioremap_nocache(offset, size);
15697 }
15698
15699 -extern void iounmap(volatile void __iomem *addr);
15700 +extern void iounmap(const volatile void __iomem *addr);
15701
15702 extern void set_iounmap_nonlazy(void);
15703
15704 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
15705
15706 #include <linux/vmalloc.h>
15707
15708 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
15709 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
15710 +{
15711 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
15712 +}
15713 +
15714 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
15715 +{
15716 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
15717 +}
15718 +
15719 /*
15720 * Convert a virtual cached pointer to an uncached pointer
15721 */
15722 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
15723 index bba3cf8..06bc8da 100644
15724 --- a/arch/x86/include/asm/irqflags.h
15725 +++ b/arch/x86/include/asm/irqflags.h
15726 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
15727 sti; \
15728 sysexit
15729
15730 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
15731 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
15732 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
15733 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
15734 +
15735 #else
15736 #define INTERRUPT_RETURN iret
15737 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
15738 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
15739 index 5a6d287..f815789 100644
15740 --- a/arch/x86/include/asm/kprobes.h
15741 +++ b/arch/x86/include/asm/kprobes.h
15742 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
15743 #define RELATIVEJUMP_SIZE 5
15744 #define RELATIVECALL_OPCODE 0xe8
15745 #define RELATIVE_ADDR_SIZE 4
15746 -#define MAX_STACK_SIZE 64
15747 -#define MIN_STACK_SIZE(ADDR) \
15748 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
15749 - THREAD_SIZE - (unsigned long)(ADDR))) \
15750 - ? (MAX_STACK_SIZE) \
15751 - : (((unsigned long)current_thread_info()) + \
15752 - THREAD_SIZE - (unsigned long)(ADDR)))
15753 +#define MAX_STACK_SIZE 64UL
15754 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
15755
15756 #define flush_insn_slot(p) do { } while (0)
15757
15758 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
15759 index 2d89e39..baee879 100644
15760 --- a/arch/x86/include/asm/local.h
15761 +++ b/arch/x86/include/asm/local.h
15762 @@ -10,33 +10,97 @@ typedef struct {
15763 atomic_long_t a;
15764 } local_t;
15765
15766 +typedef struct {
15767 + atomic_long_unchecked_t a;
15768 +} local_unchecked_t;
15769 +
15770 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
15771
15772 #define local_read(l) atomic_long_read(&(l)->a)
15773 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
15774 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
15775 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
15776
15777 static inline void local_inc(local_t *l)
15778 {
15779 - asm volatile(_ASM_INC "%0"
15780 + asm volatile(_ASM_INC "%0\n"
15781 +
15782 +#ifdef CONFIG_PAX_REFCOUNT
15783 + "jno 0f\n"
15784 + _ASM_DEC "%0\n"
15785 + "int $4\n0:\n"
15786 + _ASM_EXTABLE(0b, 0b)
15787 +#endif
15788 +
15789 + : "+m" (l->a.counter));
15790 +}
15791 +
15792 +static inline void local_inc_unchecked(local_unchecked_t *l)
15793 +{
15794 + asm volatile(_ASM_INC "%0\n"
15795 : "+m" (l->a.counter));
15796 }
15797
15798 static inline void local_dec(local_t *l)
15799 {
15800 - asm volatile(_ASM_DEC "%0"
15801 + asm volatile(_ASM_DEC "%0\n"
15802 +
15803 +#ifdef CONFIG_PAX_REFCOUNT
15804 + "jno 0f\n"
15805 + _ASM_INC "%0\n"
15806 + "int $4\n0:\n"
15807 + _ASM_EXTABLE(0b, 0b)
15808 +#endif
15809 +
15810 + : "+m" (l->a.counter));
15811 +}
15812 +
15813 +static inline void local_dec_unchecked(local_unchecked_t *l)
15814 +{
15815 + asm volatile(_ASM_DEC "%0\n"
15816 : "+m" (l->a.counter));
15817 }
15818
15819 static inline void local_add(long i, local_t *l)
15820 {
15821 - asm volatile(_ASM_ADD "%1,%0"
15822 + asm volatile(_ASM_ADD "%1,%0\n"
15823 +
15824 +#ifdef CONFIG_PAX_REFCOUNT
15825 + "jno 0f\n"
15826 + _ASM_SUB "%1,%0\n"
15827 + "int $4\n0:\n"
15828 + _ASM_EXTABLE(0b, 0b)
15829 +#endif
15830 +
15831 + : "+m" (l->a.counter)
15832 + : "ir" (i));
15833 +}
15834 +
15835 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
15836 +{
15837 + asm volatile(_ASM_ADD "%1,%0\n"
15838 : "+m" (l->a.counter)
15839 : "ir" (i));
15840 }
15841
15842 static inline void local_sub(long i, local_t *l)
15843 {
15844 - asm volatile(_ASM_SUB "%1,%0"
15845 + asm volatile(_ASM_SUB "%1,%0\n"
15846 +
15847 +#ifdef CONFIG_PAX_REFCOUNT
15848 + "jno 0f\n"
15849 + _ASM_ADD "%1,%0\n"
15850 + "int $4\n0:\n"
15851 + _ASM_EXTABLE(0b, 0b)
15852 +#endif
15853 +
15854 + : "+m" (l->a.counter)
15855 + : "ir" (i));
15856 +}
15857 +
15858 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
15859 +{
15860 + asm volatile(_ASM_SUB "%1,%0\n"
15861 : "+m" (l->a.counter)
15862 : "ir" (i));
15863 }
15864 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
15865 {
15866 unsigned char c;
15867
15868 - asm volatile(_ASM_SUB "%2,%0; sete %1"
15869 + asm volatile(_ASM_SUB "%2,%0\n"
15870 +
15871 +#ifdef CONFIG_PAX_REFCOUNT
15872 + "jno 0f\n"
15873 + _ASM_ADD "%2,%0\n"
15874 + "int $4\n0:\n"
15875 + _ASM_EXTABLE(0b, 0b)
15876 +#endif
15877 +
15878 + "sete %1\n"
15879 : "+m" (l->a.counter), "=qm" (c)
15880 : "ir" (i) : "memory");
15881 return c;
15882 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
15883 {
15884 unsigned char c;
15885
15886 - asm volatile(_ASM_DEC "%0; sete %1"
15887 + asm volatile(_ASM_DEC "%0\n"
15888 +
15889 +#ifdef CONFIG_PAX_REFCOUNT
15890 + "jno 0f\n"
15891 + _ASM_INC "%0\n"
15892 + "int $4\n0:\n"
15893 + _ASM_EXTABLE(0b, 0b)
15894 +#endif
15895 +
15896 + "sete %1\n"
15897 : "+m" (l->a.counter), "=qm" (c)
15898 : : "memory");
15899 return c != 0;
15900 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
15901 {
15902 unsigned char c;
15903
15904 - asm volatile(_ASM_INC "%0; sete %1"
15905 + asm volatile(_ASM_INC "%0\n"
15906 +
15907 +#ifdef CONFIG_PAX_REFCOUNT
15908 + "jno 0f\n"
15909 + _ASM_DEC "%0\n"
15910 + "int $4\n0:\n"
15911 + _ASM_EXTABLE(0b, 0b)
15912 +#endif
15913 +
15914 + "sete %1\n"
15915 : "+m" (l->a.counter), "=qm" (c)
15916 : : "memory");
15917 return c != 0;
15918 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
15919 {
15920 unsigned char c;
15921
15922 - asm volatile(_ASM_ADD "%2,%0; sets %1"
15923 + asm volatile(_ASM_ADD "%2,%0\n"
15924 +
15925 +#ifdef CONFIG_PAX_REFCOUNT
15926 + "jno 0f\n"
15927 + _ASM_SUB "%2,%0\n"
15928 + "int $4\n0:\n"
15929 + _ASM_EXTABLE(0b, 0b)
15930 +#endif
15931 +
15932 + "sets %1\n"
15933 : "+m" (l->a.counter), "=qm" (c)
15934 : "ir" (i) : "memory");
15935 return c;
15936 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
15937 static inline long local_add_return(long i, local_t *l)
15938 {
15939 long __i = i;
15940 + asm volatile(_ASM_XADD "%0, %1\n"
15941 +
15942 +#ifdef CONFIG_PAX_REFCOUNT
15943 + "jno 0f\n"
15944 + _ASM_MOV "%0,%1\n"
15945 + "int $4\n0:\n"
15946 + _ASM_EXTABLE(0b, 0b)
15947 +#endif
15948 +
15949 + : "+r" (i), "+m" (l->a.counter)
15950 + : : "memory");
15951 + return i + __i;
15952 +}
15953 +
15954 +/**
15955 + * local_add_return_unchecked - add and return
15956 + * @i: integer value to add
15957 + * @l: pointer to type local_unchecked_t
15958 + *
15959 + * Atomically adds @i to @l and returns @i + @l
15960 + */
15961 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
15962 +{
15963 + long __i = i;
15964 asm volatile(_ASM_XADD "%0, %1;"
15965 : "+r" (i), "+m" (l->a.counter)
15966 : : "memory");
15967 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
15968
15969 #define local_cmpxchg(l, o, n) \
15970 (cmpxchg_local(&((l)->a.counter), (o), (n)))
15971 +#define local_cmpxchg_unchecked(l, o, n) \
15972 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
15973 /* Always has a lock prefix */
15974 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
15975
15976 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
15977 new file mode 100644
15978 index 0000000..2bfd3ba
15979 --- /dev/null
15980 +++ b/arch/x86/include/asm/mman.h
15981 @@ -0,0 +1,15 @@
15982 +#ifndef _X86_MMAN_H
15983 +#define _X86_MMAN_H
15984 +
15985 +#include <uapi/asm/mman.h>
15986 +
15987 +#ifdef __KERNEL__
15988 +#ifndef __ASSEMBLY__
15989 +#ifdef CONFIG_X86_32
15990 +#define arch_mmap_check i386_mmap_check
15991 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
15992 +#endif
15993 +#endif
15994 +#endif
15995 +
15996 +#endif /* X86_MMAN_H */
15997 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
15998 index 5f55e69..e20bfb1 100644
15999 --- a/arch/x86/include/asm/mmu.h
16000 +++ b/arch/x86/include/asm/mmu.h
16001 @@ -9,7 +9,7 @@
16002 * we put the segment information here.
16003 */
16004 typedef struct {
16005 - void *ldt;
16006 + struct desc_struct *ldt;
16007 int size;
16008
16009 #ifdef CONFIG_X86_64
16010 @@ -18,7 +18,19 @@ typedef struct {
16011 #endif
16012
16013 struct mutex lock;
16014 - void *vdso;
16015 + unsigned long vdso;
16016 +
16017 +#ifdef CONFIG_X86_32
16018 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
16019 + unsigned long user_cs_base;
16020 + unsigned long user_cs_limit;
16021 +
16022 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
16023 + cpumask_t cpu_user_cs_mask;
16024 +#endif
16025 +
16026 +#endif
16027 +#endif
16028 } mm_context_t;
16029
16030 #ifdef CONFIG_SMP
16031 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
16032 index cdbf367..4c73c9e 100644
16033 --- a/arch/x86/include/asm/mmu_context.h
16034 +++ b/arch/x86/include/asm/mmu_context.h
16035 @@ -24,6 +24,20 @@ void destroy_context(struct mm_struct *mm);
16036
16037 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
16038 {
16039 +
16040 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16041 + if (!(static_cpu_has(X86_FEATURE_PCID))) {
16042 + unsigned int i;
16043 + pgd_t *pgd;
16044 +
16045 + pax_open_kernel();
16046 + pgd = get_cpu_pgd(smp_processor_id(), kernel);
16047 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
16048 + set_pgd_batched(pgd+i, native_make_pgd(0));
16049 + pax_close_kernel();
16050 + }
16051 +#endif
16052 +
16053 #ifdef CONFIG_SMP
16054 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
16055 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
16056 @@ -34,16 +48,55 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
16057 struct task_struct *tsk)
16058 {
16059 unsigned cpu = smp_processor_id();
16060 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
16061 + int tlbstate = TLBSTATE_OK;
16062 +#endif
16063
16064 if (likely(prev != next)) {
16065 #ifdef CONFIG_SMP
16066 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
16067 + tlbstate = this_cpu_read(cpu_tlbstate.state);
16068 +#endif
16069 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
16070 this_cpu_write(cpu_tlbstate.active_mm, next);
16071 #endif
16072 cpumask_set_cpu(cpu, mm_cpumask(next));
16073
16074 /* Re-load page tables */
16075 +#ifdef CONFIG_PAX_PER_CPU_PGD
16076 + pax_open_kernel();
16077 +
16078 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16079 + if (static_cpu_has(X86_FEATURE_PCID))
16080 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
16081 + else
16082 +#endif
16083 +
16084 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
16085 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
16086 + pax_close_kernel();
16087 + 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));
16088 +
16089 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16090 + if (static_cpu_has(X86_FEATURE_PCID)) {
16091 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
16092 + unsigned long descriptor[2];
16093 + descriptor[0] = PCID_USER;
16094 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
16095 + } else {
16096 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
16097 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
16098 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
16099 + else
16100 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
16101 + }
16102 + } else
16103 +#endif
16104 +
16105 + load_cr3(get_cpu_pgd(cpu, kernel));
16106 +#else
16107 load_cr3(next->pgd);
16108 +#endif
16109
16110 /* stop flush ipis for the previous mm */
16111 cpumask_clear_cpu(cpu, mm_cpumask(prev));
16112 @@ -53,9 +106,63 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
16113 */
16114 if (unlikely(prev->context.ldt != next->context.ldt))
16115 load_LDT_nolock(&next->context);
16116 - }
16117 +
16118 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
16119 + if (!(__supported_pte_mask & _PAGE_NX)) {
16120 + smp_mb__before_clear_bit();
16121 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
16122 + smp_mb__after_clear_bit();
16123 + cpu_set(cpu, next->context.cpu_user_cs_mask);
16124 + }
16125 +#endif
16126 +
16127 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
16128 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
16129 + prev->context.user_cs_limit != next->context.user_cs_limit))
16130 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
16131 #ifdef CONFIG_SMP
16132 + else if (unlikely(tlbstate != TLBSTATE_OK))
16133 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
16134 +#endif
16135 +#endif
16136 +
16137 + }
16138 else {
16139 +
16140 +#ifdef CONFIG_PAX_PER_CPU_PGD
16141 + pax_open_kernel();
16142 +
16143 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16144 + if (static_cpu_has(X86_FEATURE_PCID))
16145 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
16146 + else
16147 +#endif
16148 +
16149 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
16150 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
16151 + pax_close_kernel();
16152 + 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));
16153 +
16154 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16155 + if (static_cpu_has(X86_FEATURE_PCID)) {
16156 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
16157 + unsigned long descriptor[2];
16158 + descriptor[0] = PCID_USER;
16159 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
16160 + } else {
16161 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
16162 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
16163 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
16164 + else
16165 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
16166 + }
16167 + } else
16168 +#endif
16169 +
16170 + load_cr3(get_cpu_pgd(cpu, kernel));
16171 +#endif
16172 +
16173 +#ifdef CONFIG_SMP
16174 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
16175 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
16176
16177 @@ -64,11 +171,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
16178 * tlb flush IPI delivery. We must reload CR3
16179 * to make sure to use no freed page tables.
16180 */
16181 +
16182 +#ifndef CONFIG_PAX_PER_CPU_PGD
16183 load_cr3(next->pgd);
16184 +#endif
16185 +
16186 load_LDT_nolock(&next->context);
16187 +
16188 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
16189 + if (!(__supported_pte_mask & _PAGE_NX))
16190 + cpu_set(cpu, next->context.cpu_user_cs_mask);
16191 +#endif
16192 +
16193 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
16194 +#ifdef CONFIG_PAX_PAGEEXEC
16195 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
16196 +#endif
16197 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
16198 +#endif
16199 +
16200 }
16201 +#endif
16202 }
16203 -#endif
16204 }
16205
16206 #define activate_mm(prev, next) \
16207 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
16208 index e3b7819..b257c64 100644
16209 --- a/arch/x86/include/asm/module.h
16210 +++ b/arch/x86/include/asm/module.h
16211 @@ -5,6 +5,7 @@
16212
16213 #ifdef CONFIG_X86_64
16214 /* X86_64 does not define MODULE_PROC_FAMILY */
16215 +#define MODULE_PROC_FAMILY ""
16216 #elif defined CONFIG_M486
16217 #define MODULE_PROC_FAMILY "486 "
16218 #elif defined CONFIG_M586
16219 @@ -57,8 +58,20 @@
16220 #error unknown processor family
16221 #endif
16222
16223 -#ifdef CONFIG_X86_32
16224 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
16225 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
16226 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
16227 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
16228 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
16229 +#else
16230 +#define MODULE_PAX_KERNEXEC ""
16231 #endif
16232
16233 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16234 +#define MODULE_PAX_UDEREF "UDEREF "
16235 +#else
16236 +#define MODULE_PAX_UDEREF ""
16237 +#endif
16238 +
16239 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
16240 +
16241 #endif /* _ASM_X86_MODULE_H */
16242 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
16243 index 86f9301..b365cda 100644
16244 --- a/arch/x86/include/asm/nmi.h
16245 +++ b/arch/x86/include/asm/nmi.h
16246 @@ -40,11 +40,11 @@ struct nmiaction {
16247 nmi_handler_t handler;
16248 unsigned long flags;
16249 const char *name;
16250 -};
16251 +} __do_const;
16252
16253 #define register_nmi_handler(t, fn, fg, n, init...) \
16254 ({ \
16255 - static struct nmiaction init fn##_na = { \
16256 + static const struct nmiaction init fn##_na = { \
16257 .handler = (fn), \
16258 .name = (n), \
16259 .flags = (fg), \
16260 @@ -52,7 +52,7 @@ struct nmiaction {
16261 __register_nmi_handler((t), &fn##_na); \
16262 })
16263
16264 -int __register_nmi_handler(unsigned int, struct nmiaction *);
16265 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
16266
16267 void unregister_nmi_handler(unsigned int, const char *);
16268
16269 diff --git a/arch/x86/include/asm/page.h b/arch/x86/include/asm/page.h
16270 index c878924..21f4889 100644
16271 --- a/arch/x86/include/asm/page.h
16272 +++ b/arch/x86/include/asm/page.h
16273 @@ -52,6 +52,7 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
16274 __phys_addr_symbol(__phys_reloc_hide((unsigned long)(x)))
16275
16276 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
16277 +#define __early_va(x) ((void *)((unsigned long)(x)+__START_KERNEL_map - phys_base))
16278
16279 #define __boot_va(x) __va(x)
16280 #define __boot_pa(x) __pa(x)
16281 diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
16282 index 0f1ddee..e2fc3d1 100644
16283 --- a/arch/x86/include/asm/page_64.h
16284 +++ b/arch/x86/include/asm/page_64.h
16285 @@ -7,9 +7,9 @@
16286
16287 /* duplicated to the one in bootmem.h */
16288 extern unsigned long max_pfn;
16289 -extern unsigned long phys_base;
16290 +extern const unsigned long phys_base;
16291
16292 -static inline unsigned long __phys_addr_nodebug(unsigned long x)
16293 +static inline unsigned long __intentional_overflow(-1) __phys_addr_nodebug(unsigned long x)
16294 {
16295 unsigned long y = x - __START_KERNEL_map;
16296
16297 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
16298 index cfdc9ee..3f7b5d6 100644
16299 --- a/arch/x86/include/asm/paravirt.h
16300 +++ b/arch/x86/include/asm/paravirt.h
16301 @@ -560,7 +560,7 @@ static inline pmd_t __pmd(pmdval_t val)
16302 return (pmd_t) { ret };
16303 }
16304
16305 -static inline pmdval_t pmd_val(pmd_t pmd)
16306 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
16307 {
16308 pmdval_t ret;
16309
16310 @@ -626,6 +626,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
16311 val);
16312 }
16313
16314 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
16315 +{
16316 + pgdval_t val = native_pgd_val(pgd);
16317 +
16318 + if (sizeof(pgdval_t) > sizeof(long))
16319 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
16320 + val, (u64)val >> 32);
16321 + else
16322 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
16323 + val);
16324 +}
16325 +
16326 static inline void pgd_clear(pgd_t *pgdp)
16327 {
16328 set_pgd(pgdp, __pgd(0));
16329 @@ -710,6 +722,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
16330 pv_mmu_ops.set_fixmap(idx, phys, flags);
16331 }
16332
16333 +#ifdef CONFIG_PAX_KERNEXEC
16334 +static inline unsigned long pax_open_kernel(void)
16335 +{
16336 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
16337 +}
16338 +
16339 +static inline unsigned long pax_close_kernel(void)
16340 +{
16341 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
16342 +}
16343 +#else
16344 +static inline unsigned long pax_open_kernel(void) { return 0; }
16345 +static inline unsigned long pax_close_kernel(void) { return 0; }
16346 +#endif
16347 +
16348 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
16349
16350 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
16351 @@ -926,7 +953,7 @@ extern void default_banner(void);
16352
16353 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
16354 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
16355 -#define PARA_INDIRECT(addr) *%cs:addr
16356 +#define PARA_INDIRECT(addr) *%ss:addr
16357 #endif
16358
16359 #define INTERRUPT_RETURN \
16360 @@ -1001,6 +1028,21 @@ extern void default_banner(void);
16361 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
16362 CLBR_NONE, \
16363 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
16364 +
16365 +#define GET_CR0_INTO_RDI \
16366 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
16367 + mov %rax,%rdi
16368 +
16369 +#define SET_RDI_INTO_CR0 \
16370 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
16371 +
16372 +#define GET_CR3_INTO_RDI \
16373 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
16374 + mov %rax,%rdi
16375 +
16376 +#define SET_RDI_INTO_CR3 \
16377 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
16378 +
16379 #endif /* CONFIG_X86_32 */
16380
16381 #endif /* __ASSEMBLY__ */
16382 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
16383 index 0db1fca..52310cc 100644
16384 --- a/arch/x86/include/asm/paravirt_types.h
16385 +++ b/arch/x86/include/asm/paravirt_types.h
16386 @@ -84,7 +84,7 @@ struct pv_init_ops {
16387 */
16388 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
16389 unsigned long addr, unsigned len);
16390 -};
16391 +} __no_const;
16392
16393
16394 struct pv_lazy_ops {
16395 @@ -98,7 +98,7 @@ struct pv_time_ops {
16396 unsigned long long (*sched_clock)(void);
16397 unsigned long long (*steal_clock)(int cpu);
16398 unsigned long (*get_tsc_khz)(void);
16399 -};
16400 +} __no_const;
16401
16402 struct pv_cpu_ops {
16403 /* hooks for various privileged instructions */
16404 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
16405
16406 void (*start_context_switch)(struct task_struct *prev);
16407 void (*end_context_switch)(struct task_struct *next);
16408 -};
16409 +} __no_const;
16410
16411 struct pv_irq_ops {
16412 /*
16413 @@ -223,7 +223,7 @@ struct pv_apic_ops {
16414 unsigned long start_eip,
16415 unsigned long start_esp);
16416 #endif
16417 -};
16418 +} __no_const;
16419
16420 struct pv_mmu_ops {
16421 unsigned long (*read_cr2)(void);
16422 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
16423 struct paravirt_callee_save make_pud;
16424
16425 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
16426 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
16427 #endif /* PAGETABLE_LEVELS == 4 */
16428 #endif /* PAGETABLE_LEVELS >= 3 */
16429
16430 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
16431 an mfn. We can tell which is which from the index. */
16432 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
16433 phys_addr_t phys, pgprot_t flags);
16434 +
16435 +#ifdef CONFIG_PAX_KERNEXEC
16436 + unsigned long (*pax_open_kernel)(void);
16437 + unsigned long (*pax_close_kernel)(void);
16438 +#endif
16439 +
16440 };
16441
16442 struct arch_spinlock;
16443 @@ -334,7 +341,7 @@ struct pv_lock_ops {
16444 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
16445 int (*spin_trylock)(struct arch_spinlock *lock);
16446 void (*spin_unlock)(struct arch_spinlock *lock);
16447 -};
16448 +} __no_const;
16449
16450 /* This contains all the paravirt structures: we get a convenient
16451 * number for each function using the offset which we use to indicate
16452 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
16453 index b4389a4..7024269 100644
16454 --- a/arch/x86/include/asm/pgalloc.h
16455 +++ b/arch/x86/include/asm/pgalloc.h
16456 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
16457 pmd_t *pmd, pte_t *pte)
16458 {
16459 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
16460 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
16461 +}
16462 +
16463 +static inline void pmd_populate_user(struct mm_struct *mm,
16464 + pmd_t *pmd, pte_t *pte)
16465 +{
16466 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
16467 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
16468 }
16469
16470 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
16471
16472 #ifdef CONFIG_X86_PAE
16473 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
16474 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
16475 +{
16476 + pud_populate(mm, pudp, pmd);
16477 +}
16478 #else /* !CONFIG_X86_PAE */
16479 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
16480 {
16481 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
16482 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
16483 }
16484 +
16485 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
16486 +{
16487 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
16488 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
16489 +}
16490 #endif /* CONFIG_X86_PAE */
16491
16492 #if PAGETABLE_LEVELS > 3
16493 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
16494 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
16495 }
16496
16497 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
16498 +{
16499 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
16500 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
16501 +}
16502 +
16503 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
16504 {
16505 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
16506 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
16507 index f2b489c..4f7e2e5 100644
16508 --- a/arch/x86/include/asm/pgtable-2level.h
16509 +++ b/arch/x86/include/asm/pgtable-2level.h
16510 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
16511
16512 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16513 {
16514 + pax_open_kernel();
16515 *pmdp = pmd;
16516 + pax_close_kernel();
16517 }
16518
16519 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16520 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
16521 index 4cc9f2b..5fd9226 100644
16522 --- a/arch/x86/include/asm/pgtable-3level.h
16523 +++ b/arch/x86/include/asm/pgtable-3level.h
16524 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16525
16526 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16527 {
16528 + pax_open_kernel();
16529 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
16530 + pax_close_kernel();
16531 }
16532
16533 static inline void native_set_pud(pud_t *pudp, pud_t pud)
16534 {
16535 + pax_open_kernel();
16536 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
16537 + pax_close_kernel();
16538 }
16539
16540 /*
16541 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
16542 index 1e67223..92a9585 100644
16543 --- a/arch/x86/include/asm/pgtable.h
16544 +++ b/arch/x86/include/asm/pgtable.h
16545 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
16546
16547 #ifndef __PAGETABLE_PUD_FOLDED
16548 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
16549 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
16550 #define pgd_clear(pgd) native_pgd_clear(pgd)
16551 #endif
16552
16553 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
16554
16555 #define arch_end_context_switch(prev) do {} while(0)
16556
16557 +#define pax_open_kernel() native_pax_open_kernel()
16558 +#define pax_close_kernel() native_pax_close_kernel()
16559 #endif /* CONFIG_PARAVIRT */
16560
16561 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
16562 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
16563 +
16564 +#ifdef CONFIG_PAX_KERNEXEC
16565 +static inline unsigned long native_pax_open_kernel(void)
16566 +{
16567 + unsigned long cr0;
16568 +
16569 + preempt_disable();
16570 + barrier();
16571 + cr0 = read_cr0() ^ X86_CR0_WP;
16572 + BUG_ON(cr0 & X86_CR0_WP);
16573 + write_cr0(cr0);
16574 + return cr0 ^ X86_CR0_WP;
16575 +}
16576 +
16577 +static inline unsigned long native_pax_close_kernel(void)
16578 +{
16579 + unsigned long cr0;
16580 +
16581 + cr0 = read_cr0() ^ X86_CR0_WP;
16582 + BUG_ON(!(cr0 & X86_CR0_WP));
16583 + write_cr0(cr0);
16584 + barrier();
16585 + preempt_enable_no_resched();
16586 + return cr0 ^ X86_CR0_WP;
16587 +}
16588 +#else
16589 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
16590 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
16591 +#endif
16592 +
16593 /*
16594 * The following only work if pte_present() is true.
16595 * Undefined behaviour if not..
16596 */
16597 +static inline int pte_user(pte_t pte)
16598 +{
16599 + return pte_val(pte) & _PAGE_USER;
16600 +}
16601 +
16602 static inline int pte_dirty(pte_t pte)
16603 {
16604 return pte_flags(pte) & _PAGE_DIRTY;
16605 @@ -147,6 +187,11 @@ static inline unsigned long pud_pfn(pud_t pud)
16606 return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
16607 }
16608
16609 +static inline unsigned long pgd_pfn(pgd_t pgd)
16610 +{
16611 + return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT;
16612 +}
16613 +
16614 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
16615
16616 static inline int pmd_large(pmd_t pte)
16617 @@ -200,9 +245,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
16618 return pte_clear_flags(pte, _PAGE_RW);
16619 }
16620
16621 +static inline pte_t pte_mkread(pte_t pte)
16622 +{
16623 + return __pte(pte_val(pte) | _PAGE_USER);
16624 +}
16625 +
16626 static inline pte_t pte_mkexec(pte_t pte)
16627 {
16628 - return pte_clear_flags(pte, _PAGE_NX);
16629 +#ifdef CONFIG_X86_PAE
16630 + if (__supported_pte_mask & _PAGE_NX)
16631 + return pte_clear_flags(pte, _PAGE_NX);
16632 + else
16633 +#endif
16634 + return pte_set_flags(pte, _PAGE_USER);
16635 +}
16636 +
16637 +static inline pte_t pte_exprotect(pte_t pte)
16638 +{
16639 +#ifdef CONFIG_X86_PAE
16640 + if (__supported_pte_mask & _PAGE_NX)
16641 + return pte_set_flags(pte, _PAGE_NX);
16642 + else
16643 +#endif
16644 + return pte_clear_flags(pte, _PAGE_USER);
16645 }
16646
16647 static inline pte_t pte_mkdirty(pte_t pte)
16648 @@ -394,6 +459,16 @@ pte_t *populate_extra_pte(unsigned long vaddr);
16649 #endif
16650
16651 #ifndef __ASSEMBLY__
16652 +
16653 +#ifdef CONFIG_PAX_PER_CPU_PGD
16654 +extern pgd_t cpu_pgd[NR_CPUS][2][PTRS_PER_PGD];
16655 +enum cpu_pgd_type {kernel = 0, user = 1};
16656 +static inline pgd_t *get_cpu_pgd(unsigned int cpu, enum cpu_pgd_type type)
16657 +{
16658 + return cpu_pgd[cpu][type];
16659 +}
16660 +#endif
16661 +
16662 #include <linux/mm_types.h>
16663 #include <linux/log2.h>
16664
16665 @@ -529,7 +604,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
16666 * Currently stuck as a macro due to indirect forward reference to
16667 * linux/mmzone.h's __section_mem_map_addr() definition:
16668 */
16669 -#define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
16670 +#define pud_page(pud) pfn_to_page((pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT)
16671
16672 /* Find an entry in the second-level page table.. */
16673 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
16674 @@ -569,7 +644,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
16675 * Currently stuck as a macro due to indirect forward reference to
16676 * linux/mmzone.h's __section_mem_map_addr() definition:
16677 */
16678 -#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
16679 +#define pgd_page(pgd) pfn_to_page((pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT)
16680
16681 /* to find an entry in a page-table-directory. */
16682 static inline unsigned long pud_index(unsigned long address)
16683 @@ -584,7 +659,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
16684
16685 static inline int pgd_bad(pgd_t pgd)
16686 {
16687 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
16688 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
16689 }
16690
16691 static inline int pgd_none(pgd_t pgd)
16692 @@ -607,7 +682,12 @@ static inline int pgd_none(pgd_t pgd)
16693 * pgd_offset() returns a (pgd_t *)
16694 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
16695 */
16696 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
16697 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
16698 +
16699 +#ifdef CONFIG_PAX_PER_CPU_PGD
16700 +#define pgd_offset_cpu(cpu, type, address) (get_cpu_pgd(cpu, type) + pgd_index(address))
16701 +#endif
16702 +
16703 /*
16704 * a shortcut which implies the use of the kernel's pgd, instead
16705 * of a process's
16706 @@ -618,6 +698,23 @@ static inline int pgd_none(pgd_t pgd)
16707 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
16708 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
16709
16710 +#ifdef CONFIG_X86_32
16711 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
16712 +#else
16713 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
16714 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
16715 +
16716 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16717 +#ifdef __ASSEMBLY__
16718 +#define pax_user_shadow_base pax_user_shadow_base(%rip)
16719 +#else
16720 +extern unsigned long pax_user_shadow_base;
16721 +extern pgdval_t clone_pgd_mask;
16722 +#endif
16723 +#endif
16724 +
16725 +#endif
16726 +
16727 #ifndef __ASSEMBLY__
16728
16729 extern int direct_gbpages;
16730 @@ -784,11 +881,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
16731 * dst and src can be on the same page, but the range must not overlap,
16732 * and must not cross a page boundary.
16733 */
16734 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
16735 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
16736 {
16737 - memcpy(dst, src, count * sizeof(pgd_t));
16738 + pax_open_kernel();
16739 + while (count--)
16740 + *dst++ = *src++;
16741 + pax_close_kernel();
16742 }
16743
16744 +#ifdef CONFIG_PAX_PER_CPU_PGD
16745 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
16746 +#endif
16747 +
16748 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16749 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
16750 +#else
16751 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
16752 +#endif
16753 +
16754 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
16755 static inline int page_level_shift(enum pg_level level)
16756 {
16757 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
16758 index 9ee3221..b979c6b 100644
16759 --- a/arch/x86/include/asm/pgtable_32.h
16760 +++ b/arch/x86/include/asm/pgtable_32.h
16761 @@ -25,9 +25,6 @@
16762 struct mm_struct;
16763 struct vm_area_struct;
16764
16765 -extern pgd_t swapper_pg_dir[1024];
16766 -extern pgd_t initial_page_table[1024];
16767 -
16768 static inline void pgtable_cache_init(void) { }
16769 static inline void check_pgt_cache(void) { }
16770 void paging_init(void);
16771 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
16772 # include <asm/pgtable-2level.h>
16773 #endif
16774
16775 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
16776 +extern pgd_t initial_page_table[PTRS_PER_PGD];
16777 +#ifdef CONFIG_X86_PAE
16778 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
16779 +#endif
16780 +
16781 #if defined(CONFIG_HIGHPTE)
16782 #define pte_offset_map(dir, address) \
16783 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
16784 @@ -62,12 +65,17 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
16785 /* Clear a kernel PTE and flush it from the TLB */
16786 #define kpte_clear_flush(ptep, vaddr) \
16787 do { \
16788 + pax_open_kernel(); \
16789 pte_clear(&init_mm, (vaddr), (ptep)); \
16790 + pax_close_kernel(); \
16791 __flush_tlb_one((vaddr)); \
16792 } while (0)
16793
16794 #endif /* !__ASSEMBLY__ */
16795
16796 +#define HAVE_ARCH_UNMAPPED_AREA
16797 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
16798 +
16799 /*
16800 * kern_addr_valid() is (1) for FLATMEM and (0) for
16801 * SPARSEMEM and DISCONTIGMEM
16802 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
16803 index ed5903b..c7fe163 100644
16804 --- a/arch/x86/include/asm/pgtable_32_types.h
16805 +++ b/arch/x86/include/asm/pgtable_32_types.h
16806 @@ -8,7 +8,7 @@
16807 */
16808 #ifdef CONFIG_X86_PAE
16809 # include <asm/pgtable-3level_types.h>
16810 -# define PMD_SIZE (1UL << PMD_SHIFT)
16811 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
16812 # define PMD_MASK (~(PMD_SIZE - 1))
16813 #else
16814 # include <asm/pgtable-2level_types.h>
16815 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
16816 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
16817 #endif
16818
16819 +#ifdef CONFIG_PAX_KERNEXEC
16820 +#ifndef __ASSEMBLY__
16821 +extern unsigned char MODULES_EXEC_VADDR[];
16822 +extern unsigned char MODULES_EXEC_END[];
16823 +#endif
16824 +#include <asm/boot.h>
16825 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
16826 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
16827 +#else
16828 +#define ktla_ktva(addr) (addr)
16829 +#define ktva_ktla(addr) (addr)
16830 +#endif
16831 +
16832 #define MODULES_VADDR VMALLOC_START
16833 #define MODULES_END VMALLOC_END
16834 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
16835 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
16836 index e22c1db..23a625a 100644
16837 --- a/arch/x86/include/asm/pgtable_64.h
16838 +++ b/arch/x86/include/asm/pgtable_64.h
16839 @@ -16,10 +16,14 @@
16840
16841 extern pud_t level3_kernel_pgt[512];
16842 extern pud_t level3_ident_pgt[512];
16843 +extern pud_t level3_vmalloc_start_pgt[512];
16844 +extern pud_t level3_vmalloc_end_pgt[512];
16845 +extern pud_t level3_vmemmap_pgt[512];
16846 +extern pud_t level2_vmemmap_pgt[512];
16847 extern pmd_t level2_kernel_pgt[512];
16848 extern pmd_t level2_fixmap_pgt[512];
16849 -extern pmd_t level2_ident_pgt[512];
16850 -extern pgd_t init_level4_pgt[];
16851 +extern pmd_t level2_ident_pgt[512*2];
16852 +extern pgd_t init_level4_pgt[512];
16853
16854 #define swapper_pg_dir init_level4_pgt
16855
16856 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16857
16858 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16859 {
16860 + pax_open_kernel();
16861 *pmdp = pmd;
16862 + pax_close_kernel();
16863 }
16864
16865 static inline void native_pmd_clear(pmd_t *pmd)
16866 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
16867
16868 static inline void native_set_pud(pud_t *pudp, pud_t pud)
16869 {
16870 + pax_open_kernel();
16871 *pudp = pud;
16872 + pax_close_kernel();
16873 }
16874
16875 static inline void native_pud_clear(pud_t *pud)
16876 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
16877
16878 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
16879 {
16880 + pax_open_kernel();
16881 + *pgdp = pgd;
16882 + pax_close_kernel();
16883 +}
16884 +
16885 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
16886 +{
16887 *pgdp = pgd;
16888 }
16889
16890 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
16891 index 2d88344..4679fc3 100644
16892 --- a/arch/x86/include/asm/pgtable_64_types.h
16893 +++ b/arch/x86/include/asm/pgtable_64_types.h
16894 @@ -61,6 +61,11 @@ typedef struct { pteval_t pte; } pte_t;
16895 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
16896 #define MODULES_END _AC(0xffffffffff000000, UL)
16897 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
16898 +#define MODULES_EXEC_VADDR MODULES_VADDR
16899 +#define MODULES_EXEC_END MODULES_END
16900 +
16901 +#define ktla_ktva(addr) (addr)
16902 +#define ktva_ktla(addr) (addr)
16903
16904 #define EARLY_DYNAMIC_PAGE_TABLES 64
16905
16906 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
16907 index e642300..0ef8f31 100644
16908 --- a/arch/x86/include/asm/pgtable_types.h
16909 +++ b/arch/x86/include/asm/pgtable_types.h
16910 @@ -16,13 +16,12 @@
16911 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
16912 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
16913 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
16914 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
16915 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
16916 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
16917 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
16918 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
16919 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
16920 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
16921 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
16922 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
16923 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
16924 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
16925
16926 /* If _PAGE_BIT_PRESENT is clear, we use these: */
16927 @@ -40,7 +39,6 @@
16928 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
16929 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
16930 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
16931 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
16932 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
16933 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
16934 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
16935 @@ -57,8 +55,10 @@
16936
16937 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
16938 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
16939 -#else
16940 +#elif defined(CONFIG_KMEMCHECK)
16941 #define _PAGE_NX (_AT(pteval_t, 0))
16942 +#else
16943 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
16944 #endif
16945
16946 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
16947 @@ -116,6 +116,9 @@
16948 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
16949 _PAGE_ACCESSED)
16950
16951 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
16952 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
16953 +
16954 #define __PAGE_KERNEL_EXEC \
16955 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
16956 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
16957 @@ -126,7 +129,7 @@
16958 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
16959 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
16960 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
16961 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
16962 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
16963 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
16964 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
16965 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
16966 @@ -188,8 +191,8 @@
16967 * bits are combined, this will alow user to access the high address mapped
16968 * VDSO in the presence of CONFIG_COMPAT_VDSO
16969 */
16970 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
16971 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
16972 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
16973 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
16974 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
16975 #endif
16976
16977 @@ -227,7 +230,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
16978 {
16979 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
16980 }
16981 +#endif
16982
16983 +#if PAGETABLE_LEVELS == 3
16984 +#include <asm-generic/pgtable-nopud.h>
16985 +#endif
16986 +
16987 +#if PAGETABLE_LEVELS == 2
16988 +#include <asm-generic/pgtable-nopmd.h>
16989 +#endif
16990 +
16991 +#ifndef __ASSEMBLY__
16992 #if PAGETABLE_LEVELS > 3
16993 typedef struct { pudval_t pud; } pud_t;
16994
16995 @@ -241,8 +254,6 @@ static inline pudval_t native_pud_val(pud_t pud)
16996 return pud.pud;
16997 }
16998 #else
16999 -#include <asm-generic/pgtable-nopud.h>
17000 -
17001 static inline pudval_t native_pud_val(pud_t pud)
17002 {
17003 return native_pgd_val(pud.pgd);
17004 @@ -262,8 +273,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
17005 return pmd.pmd;
17006 }
17007 #else
17008 -#include <asm-generic/pgtable-nopmd.h>
17009 -
17010 static inline pmdval_t native_pmd_val(pmd_t pmd)
17011 {
17012 return native_pgd_val(pmd.pud.pgd);
17013 @@ -303,7 +312,6 @@ typedef struct page *pgtable_t;
17014
17015 extern pteval_t __supported_pte_mask;
17016 extern void set_nx(void);
17017 -extern int nx_enabled;
17018
17019 #define pgprot_writecombine pgprot_writecombine
17020 extern pgprot_t pgprot_writecombine(pgprot_t prot);
17021 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
17022 index 22224b3..b3a2f90 100644
17023 --- a/arch/x86/include/asm/processor.h
17024 +++ b/arch/x86/include/asm/processor.h
17025 @@ -198,9 +198,21 @@ static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
17026 : "memory");
17027 }
17028
17029 +/* invpcid (%rdx),%rax */
17030 +#define __ASM_INVPCID ".byte 0x66,0x0f,0x38,0x82,0x02"
17031 +
17032 +#define INVPCID_SINGLE_ADDRESS 0UL
17033 +#define INVPCID_SINGLE_CONTEXT 1UL
17034 +#define INVPCID_ALL_GLOBAL 2UL
17035 +#define INVPCID_ALL_MONGLOBAL 3UL
17036 +
17037 +#define PCID_KERNEL 0UL
17038 +#define PCID_USER 1UL
17039 +#define PCID_NOFLUSH (1UL << 63)
17040 +
17041 static inline void load_cr3(pgd_t *pgdir)
17042 {
17043 - write_cr3(__pa(pgdir));
17044 + write_cr3(__pa(pgdir) | PCID_KERNEL);
17045 }
17046
17047 #ifdef CONFIG_X86_32
17048 @@ -282,7 +294,7 @@ struct tss_struct {
17049
17050 } ____cacheline_aligned;
17051
17052 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
17053 +extern struct tss_struct init_tss[NR_CPUS];
17054
17055 /*
17056 * Save the original ist values for checking stack pointers during debugging
17057 @@ -452,6 +464,7 @@ struct thread_struct {
17058 unsigned short ds;
17059 unsigned short fsindex;
17060 unsigned short gsindex;
17061 + unsigned short ss;
17062 #endif
17063 #ifdef CONFIG_X86_32
17064 unsigned long ip;
17065 @@ -552,29 +565,8 @@ static inline void load_sp0(struct tss_struct *tss,
17066 extern unsigned long mmu_cr4_features;
17067 extern u32 *trampoline_cr4_features;
17068
17069 -static inline void set_in_cr4(unsigned long mask)
17070 -{
17071 - unsigned long cr4;
17072 -
17073 - mmu_cr4_features |= mask;
17074 - if (trampoline_cr4_features)
17075 - *trampoline_cr4_features = mmu_cr4_features;
17076 - cr4 = read_cr4();
17077 - cr4 |= mask;
17078 - write_cr4(cr4);
17079 -}
17080 -
17081 -static inline void clear_in_cr4(unsigned long mask)
17082 -{
17083 - unsigned long cr4;
17084 -
17085 - mmu_cr4_features &= ~mask;
17086 - if (trampoline_cr4_features)
17087 - *trampoline_cr4_features = mmu_cr4_features;
17088 - cr4 = read_cr4();
17089 - cr4 &= ~mask;
17090 - write_cr4(cr4);
17091 -}
17092 +extern void set_in_cr4(unsigned long mask);
17093 +extern void clear_in_cr4(unsigned long mask);
17094
17095 typedef struct {
17096 unsigned long seg;
17097 @@ -823,11 +815,18 @@ static inline void spin_lock_prefetch(const void *x)
17098 */
17099 #define TASK_SIZE PAGE_OFFSET
17100 #define TASK_SIZE_MAX TASK_SIZE
17101 +
17102 +#ifdef CONFIG_PAX_SEGMEXEC
17103 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
17104 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
17105 +#else
17106 #define STACK_TOP TASK_SIZE
17107 -#define STACK_TOP_MAX STACK_TOP
17108 +#endif
17109 +
17110 +#define STACK_TOP_MAX TASK_SIZE
17111
17112 #define INIT_THREAD { \
17113 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
17114 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
17115 .vm86_info = NULL, \
17116 .sysenter_cs = __KERNEL_CS, \
17117 .io_bitmap_ptr = NULL, \
17118 @@ -841,7 +840,7 @@ static inline void spin_lock_prefetch(const void *x)
17119 */
17120 #define INIT_TSS { \
17121 .x86_tss = { \
17122 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
17123 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
17124 .ss0 = __KERNEL_DS, \
17125 .ss1 = __KERNEL_CS, \
17126 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
17127 @@ -852,11 +851,7 @@ static inline void spin_lock_prefetch(const void *x)
17128 extern unsigned long thread_saved_pc(struct task_struct *tsk);
17129
17130 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
17131 -#define KSTK_TOP(info) \
17132 -({ \
17133 - unsigned long *__ptr = (unsigned long *)(info); \
17134 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
17135 -})
17136 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
17137
17138 /*
17139 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
17140 @@ -871,7 +866,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
17141 #define task_pt_regs(task) \
17142 ({ \
17143 struct pt_regs *__regs__; \
17144 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
17145 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
17146 __regs__ - 1; \
17147 })
17148
17149 @@ -881,13 +876,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
17150 /*
17151 * User space process size. 47bits minus one guard page.
17152 */
17153 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
17154 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
17155
17156 /* This decides where the kernel will search for a free chunk of vm
17157 * space during mmap's.
17158 */
17159 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
17160 - 0xc0000000 : 0xFFFFe000)
17161 + 0xc0000000 : 0xFFFFf000)
17162
17163 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
17164 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
17165 @@ -898,11 +893,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
17166 #define STACK_TOP_MAX TASK_SIZE_MAX
17167
17168 #define INIT_THREAD { \
17169 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
17170 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
17171 }
17172
17173 #define INIT_TSS { \
17174 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
17175 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
17176 }
17177
17178 /*
17179 @@ -930,6 +925,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
17180 */
17181 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
17182
17183 +#ifdef CONFIG_PAX_SEGMEXEC
17184 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
17185 +#endif
17186 +
17187 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
17188
17189 /* Get/set a process' ability to use the timestamp counter instruction */
17190 @@ -942,7 +941,8 @@ extern int set_tsc_mode(unsigned int val);
17191 extern u16 amd_get_nb_id(int cpu);
17192
17193 struct aperfmperf {
17194 - u64 aperf, mperf;
17195 + u64 aperf __intentional_overflow(0);
17196 + u64 mperf __intentional_overflow(0);
17197 };
17198
17199 static inline void get_aperfmperf(struct aperfmperf *am)
17200 @@ -970,7 +970,7 @@ unsigned long calc_aperfmperf_ratio(struct aperfmperf *old,
17201 return ratio;
17202 }
17203
17204 -extern unsigned long arch_align_stack(unsigned long sp);
17205 +#define arch_align_stack(x) ((x) & ~0xfUL)
17206 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
17207
17208 void default_idle(void);
17209 @@ -980,6 +980,6 @@ bool xen_set_default_idle(void);
17210 #define xen_set_default_idle 0
17211 #endif
17212
17213 -void stop_this_cpu(void *dummy);
17214 +void stop_this_cpu(void *dummy) __noreturn;
17215
17216 #endif /* _ASM_X86_PROCESSOR_H */
17217 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
17218 index 942a086..6c26446 100644
17219 --- a/arch/x86/include/asm/ptrace.h
17220 +++ b/arch/x86/include/asm/ptrace.h
17221 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
17222 }
17223
17224 /*
17225 - * user_mode_vm(regs) determines whether a register set came from user mode.
17226 + * user_mode(regs) determines whether a register set came from user mode.
17227 * This is true if V8086 mode was enabled OR if the register set was from
17228 * protected mode with RPL-3 CS value. This tricky test checks that with
17229 * one comparison. Many places in the kernel can bypass this full check
17230 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
17231 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
17232 + * be used.
17233 */
17234 -static inline int user_mode(struct pt_regs *regs)
17235 +static inline int user_mode_novm(struct pt_regs *regs)
17236 {
17237 #ifdef CONFIG_X86_32
17238 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
17239 #else
17240 - return !!(regs->cs & 3);
17241 + return !!(regs->cs & SEGMENT_RPL_MASK);
17242 #endif
17243 }
17244
17245 -static inline int user_mode_vm(struct pt_regs *regs)
17246 +static inline int user_mode(struct pt_regs *regs)
17247 {
17248 #ifdef CONFIG_X86_32
17249 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
17250 USER_RPL;
17251 #else
17252 - return user_mode(regs);
17253 + return user_mode_novm(regs);
17254 #endif
17255 }
17256
17257 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
17258 #ifdef CONFIG_X86_64
17259 static inline bool user_64bit_mode(struct pt_regs *regs)
17260 {
17261 + unsigned long cs = regs->cs & 0xffff;
17262 #ifndef CONFIG_PARAVIRT
17263 /*
17264 * On non-paravirt systems, this is the only long mode CPL 3
17265 * selector. We do not allow long mode selectors in the LDT.
17266 */
17267 - return regs->cs == __USER_CS;
17268 + return cs == __USER_CS;
17269 #else
17270 /* Headers are too twisted for this to go in paravirt.h. */
17271 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
17272 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
17273 #endif
17274 }
17275
17276 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
17277 * Traps from the kernel do not save sp and ss.
17278 * Use the helper function to retrieve sp.
17279 */
17280 - if (offset == offsetof(struct pt_regs, sp) &&
17281 - regs->cs == __KERNEL_CS)
17282 - return kernel_stack_pointer(regs);
17283 + if (offset == offsetof(struct pt_regs, sp)) {
17284 + unsigned long cs = regs->cs & 0xffff;
17285 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
17286 + return kernel_stack_pointer(regs);
17287 + }
17288 #endif
17289 return *(unsigned long *)((unsigned long)regs + offset);
17290 }
17291 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
17292 index 9c6b890..5305f53 100644
17293 --- a/arch/x86/include/asm/realmode.h
17294 +++ b/arch/x86/include/asm/realmode.h
17295 @@ -22,16 +22,14 @@ struct real_mode_header {
17296 #endif
17297 /* APM/BIOS reboot */
17298 u32 machine_real_restart_asm;
17299 -#ifdef CONFIG_X86_64
17300 u32 machine_real_restart_seg;
17301 -#endif
17302 };
17303
17304 /* This must match data at trampoline_32/64.S */
17305 struct trampoline_header {
17306 #ifdef CONFIG_X86_32
17307 u32 start;
17308 - u16 gdt_pad;
17309 + u16 boot_cs;
17310 u16 gdt_limit;
17311 u32 gdt_base;
17312 #else
17313 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
17314 index a82c4f1..ac45053 100644
17315 --- a/arch/x86/include/asm/reboot.h
17316 +++ b/arch/x86/include/asm/reboot.h
17317 @@ -6,13 +6,13 @@
17318 struct pt_regs;
17319
17320 struct machine_ops {
17321 - void (*restart)(char *cmd);
17322 - void (*halt)(void);
17323 - void (*power_off)(void);
17324 + void (* __noreturn restart)(char *cmd);
17325 + void (* __noreturn halt)(void);
17326 + void (* __noreturn power_off)(void);
17327 void (*shutdown)(void);
17328 void (*crash_shutdown)(struct pt_regs *);
17329 - void (*emergency_restart)(void);
17330 -};
17331 + void (* __noreturn emergency_restart)(void);
17332 +} __no_const;
17333
17334 extern struct machine_ops machine_ops;
17335
17336 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
17337 index cad82c9..2e5c5c1 100644
17338 --- a/arch/x86/include/asm/rwsem.h
17339 +++ b/arch/x86/include/asm/rwsem.h
17340 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
17341 {
17342 asm volatile("# beginning down_read\n\t"
17343 LOCK_PREFIX _ASM_INC "(%1)\n\t"
17344 +
17345 +#ifdef CONFIG_PAX_REFCOUNT
17346 + "jno 0f\n"
17347 + LOCK_PREFIX _ASM_DEC "(%1)\n"
17348 + "int $4\n0:\n"
17349 + _ASM_EXTABLE(0b, 0b)
17350 +#endif
17351 +
17352 /* adds 0x00000001 */
17353 " jns 1f\n"
17354 " call call_rwsem_down_read_failed\n"
17355 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
17356 "1:\n\t"
17357 " mov %1,%2\n\t"
17358 " add %3,%2\n\t"
17359 +
17360 +#ifdef CONFIG_PAX_REFCOUNT
17361 + "jno 0f\n"
17362 + "sub %3,%2\n"
17363 + "int $4\n0:\n"
17364 + _ASM_EXTABLE(0b, 0b)
17365 +#endif
17366 +
17367 " jle 2f\n\t"
17368 LOCK_PREFIX " cmpxchg %2,%0\n\t"
17369 " jnz 1b\n\t"
17370 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
17371 long tmp;
17372 asm volatile("# beginning down_write\n\t"
17373 LOCK_PREFIX " xadd %1,(%2)\n\t"
17374 +
17375 +#ifdef CONFIG_PAX_REFCOUNT
17376 + "jno 0f\n"
17377 + "mov %1,(%2)\n"
17378 + "int $4\n0:\n"
17379 + _ASM_EXTABLE(0b, 0b)
17380 +#endif
17381 +
17382 /* adds 0xffff0001, returns the old value */
17383 " test " __ASM_SEL(%w1,%k1) "," __ASM_SEL(%w1,%k1) "\n\t"
17384 /* was the active mask 0 before? */
17385 @@ -155,6 +179,14 @@ static inline void __up_read(struct rw_semaphore *sem)
17386 long tmp;
17387 asm volatile("# beginning __up_read\n\t"
17388 LOCK_PREFIX " xadd %1,(%2)\n\t"
17389 +
17390 +#ifdef CONFIG_PAX_REFCOUNT
17391 + "jno 0f\n"
17392 + "mov %1,(%2)\n"
17393 + "int $4\n0:\n"
17394 + _ASM_EXTABLE(0b, 0b)
17395 +#endif
17396 +
17397 /* subtracts 1, returns the old value */
17398 " jns 1f\n\t"
17399 " call call_rwsem_wake\n" /* expects old value in %edx */
17400 @@ -173,6 +205,14 @@ static inline void __up_write(struct rw_semaphore *sem)
17401 long tmp;
17402 asm volatile("# beginning __up_write\n\t"
17403 LOCK_PREFIX " xadd %1,(%2)\n\t"
17404 +
17405 +#ifdef CONFIG_PAX_REFCOUNT
17406 + "jno 0f\n"
17407 + "mov %1,(%2)\n"
17408 + "int $4\n0:\n"
17409 + _ASM_EXTABLE(0b, 0b)
17410 +#endif
17411 +
17412 /* subtracts 0xffff0001, returns the old value */
17413 " jns 1f\n\t"
17414 " call call_rwsem_wake\n" /* expects old value in %edx */
17415 @@ -190,6 +230,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17416 {
17417 asm volatile("# beginning __downgrade_write\n\t"
17418 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
17419 +
17420 +#ifdef CONFIG_PAX_REFCOUNT
17421 + "jno 0f\n"
17422 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
17423 + "int $4\n0:\n"
17424 + _ASM_EXTABLE(0b, 0b)
17425 +#endif
17426 +
17427 /*
17428 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
17429 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
17430 @@ -208,7 +256,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17431 */
17432 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
17433 {
17434 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
17435 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
17436 +
17437 +#ifdef CONFIG_PAX_REFCOUNT
17438 + "jno 0f\n"
17439 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
17440 + "int $4\n0:\n"
17441 + _ASM_EXTABLE(0b, 0b)
17442 +#endif
17443 +
17444 : "+m" (sem->count)
17445 : "er" (delta));
17446 }
17447 @@ -218,7 +274,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
17448 */
17449 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
17450 {
17451 - return delta + xadd(&sem->count, delta);
17452 + return delta + xadd_check_overflow(&sem->count, delta);
17453 }
17454
17455 #endif /* __KERNEL__ */
17456 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
17457 index c48a950..bc40804 100644
17458 --- a/arch/x86/include/asm/segment.h
17459 +++ b/arch/x86/include/asm/segment.h
17460 @@ -64,10 +64,15 @@
17461 * 26 - ESPFIX small SS
17462 * 27 - per-cpu [ offset to per-cpu data area ]
17463 * 28 - stack_canary-20 [ for stack protector ]
17464 - * 29 - unused
17465 - * 30 - unused
17466 + * 29 - PCI BIOS CS
17467 + * 30 - PCI BIOS DS
17468 * 31 - TSS for double fault handler
17469 */
17470 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
17471 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
17472 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
17473 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
17474 +
17475 #define GDT_ENTRY_TLS_MIN 6
17476 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
17477
17478 @@ -79,6 +84,8 @@
17479
17480 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
17481
17482 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
17483 +
17484 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
17485
17486 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
17487 @@ -104,6 +111,12 @@
17488 #define __KERNEL_STACK_CANARY 0
17489 #endif
17490
17491 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
17492 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
17493 +
17494 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
17495 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
17496 +
17497 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
17498
17499 /*
17500 @@ -141,7 +154,7 @@
17501 */
17502
17503 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
17504 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
17505 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
17506
17507
17508 #else
17509 @@ -165,6 +178,8 @@
17510 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
17511 #define __USER32_DS __USER_DS
17512
17513 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
17514 +
17515 #define GDT_ENTRY_TSS 8 /* needs two entries */
17516 #define GDT_ENTRY_LDT 10 /* needs two entries */
17517 #define GDT_ENTRY_TLS_MIN 12
17518 @@ -173,6 +188,8 @@
17519 #define GDT_ENTRY_PER_CPU 15 /* Abused to load per CPU data from limit */
17520 #define __PER_CPU_SEG (GDT_ENTRY_PER_CPU * 8 + 3)
17521
17522 +#define GDT_ENTRY_UDEREF_KERNEL_DS 16
17523 +
17524 /* TLS indexes for 64bit - hardcoded in arch_prctl */
17525 #define FS_TLS 0
17526 #define GS_TLS 1
17527 @@ -180,12 +197,14 @@
17528 #define GS_TLS_SEL ((GDT_ENTRY_TLS_MIN+GS_TLS)*8 + 3)
17529 #define FS_TLS_SEL ((GDT_ENTRY_TLS_MIN+FS_TLS)*8 + 3)
17530
17531 -#define GDT_ENTRIES 16
17532 +#define GDT_ENTRIES 17
17533
17534 #endif
17535
17536 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
17537 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
17538 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
17539 +#define __UDEREF_KERNEL_DS (GDT_ENTRY_UDEREF_KERNEL_DS*8)
17540 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
17541 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
17542 #ifndef CONFIG_PARAVIRT
17543 @@ -265,7 +284,7 @@ static inline unsigned long get_limit(unsigned long segment)
17544 {
17545 unsigned long __limit;
17546 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
17547 - return __limit + 1;
17548 + return __limit;
17549 }
17550
17551 #endif /* !__ASSEMBLY__ */
17552 diff --git a/arch/x86/include/asm/smap.h b/arch/x86/include/asm/smap.h
17553 index 8d3120f..352b440 100644
17554 --- a/arch/x86/include/asm/smap.h
17555 +++ b/arch/x86/include/asm/smap.h
17556 @@ -25,11 +25,40 @@
17557
17558 #include <asm/alternative-asm.h>
17559
17560 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17561 +#define ASM_PAX_OPEN_USERLAND \
17562 + 661: jmp 663f; \
17563 + .pushsection .altinstr_replacement, "a" ; \
17564 + 662: pushq %rax; nop; \
17565 + .popsection ; \
17566 + .pushsection .altinstructions, "a" ; \
17567 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
17568 + .popsection ; \
17569 + call __pax_open_userland; \
17570 + popq %rax; \
17571 + 663:
17572 +
17573 +#define ASM_PAX_CLOSE_USERLAND \
17574 + 661: jmp 663f; \
17575 + .pushsection .altinstr_replacement, "a" ; \
17576 + 662: pushq %rax; nop; \
17577 + .popsection; \
17578 + .pushsection .altinstructions, "a" ; \
17579 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
17580 + .popsection; \
17581 + call __pax_close_userland; \
17582 + popq %rax; \
17583 + 663:
17584 +#else
17585 +#define ASM_PAX_OPEN_USERLAND
17586 +#define ASM_PAX_CLOSE_USERLAND
17587 +#endif
17588 +
17589 #ifdef CONFIG_X86_SMAP
17590
17591 #define ASM_CLAC \
17592 661: ASM_NOP3 ; \
17593 - .pushsection .altinstr_replacement, "ax" ; \
17594 + .pushsection .altinstr_replacement, "a" ; \
17595 662: __ASM_CLAC ; \
17596 .popsection ; \
17597 .pushsection .altinstructions, "a" ; \
17598 @@ -38,7 +67,7 @@
17599
17600 #define ASM_STAC \
17601 661: ASM_NOP3 ; \
17602 - .pushsection .altinstr_replacement, "ax" ; \
17603 + .pushsection .altinstr_replacement, "a" ; \
17604 662: __ASM_STAC ; \
17605 .popsection ; \
17606 .pushsection .altinstructions, "a" ; \
17607 @@ -56,6 +85,37 @@
17608
17609 #include <asm/alternative.h>
17610
17611 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
17612 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
17613 +
17614 +extern void __pax_open_userland(void);
17615 +static __always_inline unsigned long pax_open_userland(void)
17616 +{
17617 +
17618 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17619 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[open]", X86_FEATURE_STRONGUDEREF)
17620 + :
17621 + : [open] "i" (__pax_open_userland)
17622 + : "memory", "rax");
17623 +#endif
17624 +
17625 + return 0;
17626 +}
17627 +
17628 +extern void __pax_close_userland(void);
17629 +static __always_inline unsigned long pax_close_userland(void)
17630 +{
17631 +
17632 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17633 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[close]", X86_FEATURE_STRONGUDEREF)
17634 + :
17635 + : [close] "i" (__pax_close_userland)
17636 + : "memory", "rax");
17637 +#endif
17638 +
17639 + return 0;
17640 +}
17641 +
17642 #ifdef CONFIG_X86_SMAP
17643
17644 static __always_inline void clac(void)
17645 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
17646 index b073aae..39f9bdd 100644
17647 --- a/arch/x86/include/asm/smp.h
17648 +++ b/arch/x86/include/asm/smp.h
17649 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
17650 /* cpus sharing the last level cache: */
17651 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
17652 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
17653 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
17654 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
17655
17656 static inline struct cpumask *cpu_sibling_mask(int cpu)
17657 {
17658 @@ -79,7 +79,7 @@ struct smp_ops {
17659
17660 void (*send_call_func_ipi)(const struct cpumask *mask);
17661 void (*send_call_func_single_ipi)(int cpu);
17662 -};
17663 +} __no_const;
17664
17665 /* Globals due to paravirt */
17666 extern void set_cpu_sibling_map(int cpu);
17667 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus __cpuinitdata;
17668 extern int safe_smp_processor_id(void);
17669
17670 #elif defined(CONFIG_X86_64_SMP)
17671 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
17672 -
17673 -#define stack_smp_processor_id() \
17674 -({ \
17675 - struct thread_info *ti; \
17676 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
17677 - ti->cpu; \
17678 -})
17679 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
17680 +#define stack_smp_processor_id() raw_smp_processor_id()
17681 #define safe_smp_processor_id() smp_processor_id()
17682
17683 #endif
17684 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
17685 index 33692ea..350a534 100644
17686 --- a/arch/x86/include/asm/spinlock.h
17687 +++ b/arch/x86/include/asm/spinlock.h
17688 @@ -172,6 +172,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
17689 static inline void arch_read_lock(arch_rwlock_t *rw)
17690 {
17691 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
17692 +
17693 +#ifdef CONFIG_PAX_REFCOUNT
17694 + "jno 0f\n"
17695 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
17696 + "int $4\n0:\n"
17697 + _ASM_EXTABLE(0b, 0b)
17698 +#endif
17699 +
17700 "jns 1f\n"
17701 "call __read_lock_failed\n\t"
17702 "1:\n"
17703 @@ -181,6 +189,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
17704 static inline void arch_write_lock(arch_rwlock_t *rw)
17705 {
17706 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
17707 +
17708 +#ifdef CONFIG_PAX_REFCOUNT
17709 + "jno 0f\n"
17710 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
17711 + "int $4\n0:\n"
17712 + _ASM_EXTABLE(0b, 0b)
17713 +#endif
17714 +
17715 "jz 1f\n"
17716 "call __write_lock_failed\n\t"
17717 "1:\n"
17718 @@ -210,13 +226,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
17719
17720 static inline void arch_read_unlock(arch_rwlock_t *rw)
17721 {
17722 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
17723 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
17724 +
17725 +#ifdef CONFIG_PAX_REFCOUNT
17726 + "jno 0f\n"
17727 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
17728 + "int $4\n0:\n"
17729 + _ASM_EXTABLE(0b, 0b)
17730 +#endif
17731 +
17732 :"+m" (rw->lock) : : "memory");
17733 }
17734
17735 static inline void arch_write_unlock(arch_rwlock_t *rw)
17736 {
17737 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
17738 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
17739 +
17740 +#ifdef CONFIG_PAX_REFCOUNT
17741 + "jno 0f\n"
17742 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
17743 + "int $4\n0:\n"
17744 + _ASM_EXTABLE(0b, 0b)
17745 +#endif
17746 +
17747 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
17748 }
17749
17750 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
17751 index 6a99859..03cb807 100644
17752 --- a/arch/x86/include/asm/stackprotector.h
17753 +++ b/arch/x86/include/asm/stackprotector.h
17754 @@ -47,7 +47,7 @@
17755 * head_32 for boot CPU and setup_per_cpu_areas() for others.
17756 */
17757 #define GDT_STACK_CANARY_INIT \
17758 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
17759 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
17760
17761 /*
17762 * Initialize the stackprotector canary value.
17763 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
17764
17765 static inline void load_stack_canary_segment(void)
17766 {
17767 -#ifdef CONFIG_X86_32
17768 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
17769 asm volatile ("mov %0, %%gs" : : "r" (0));
17770 #endif
17771 }
17772 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
17773 index 70bbe39..4ae2bd4 100644
17774 --- a/arch/x86/include/asm/stacktrace.h
17775 +++ b/arch/x86/include/asm/stacktrace.h
17776 @@ -11,28 +11,20 @@
17777
17778 extern int kstack_depth_to_print;
17779
17780 -struct thread_info;
17781 +struct task_struct;
17782 struct stacktrace_ops;
17783
17784 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
17785 - unsigned long *stack,
17786 - unsigned long bp,
17787 - const struct stacktrace_ops *ops,
17788 - void *data,
17789 - unsigned long *end,
17790 - int *graph);
17791 +typedef unsigned long walk_stack_t(struct task_struct *task,
17792 + void *stack_start,
17793 + unsigned long *stack,
17794 + unsigned long bp,
17795 + const struct stacktrace_ops *ops,
17796 + void *data,
17797 + unsigned long *end,
17798 + int *graph);
17799
17800 -extern unsigned long
17801 -print_context_stack(struct thread_info *tinfo,
17802 - unsigned long *stack, unsigned long bp,
17803 - const struct stacktrace_ops *ops, void *data,
17804 - unsigned long *end, int *graph);
17805 -
17806 -extern unsigned long
17807 -print_context_stack_bp(struct thread_info *tinfo,
17808 - unsigned long *stack, unsigned long bp,
17809 - const struct stacktrace_ops *ops, void *data,
17810 - unsigned long *end, int *graph);
17811 +extern walk_stack_t print_context_stack;
17812 +extern walk_stack_t print_context_stack_bp;
17813
17814 /* Generic stack tracer with callbacks */
17815
17816 @@ -40,7 +32,7 @@ struct stacktrace_ops {
17817 void (*address)(void *data, unsigned long address, int reliable);
17818 /* On negative return stop dumping */
17819 int (*stack)(void *data, char *name);
17820 - walk_stack_t walk_stack;
17821 + walk_stack_t *walk_stack;
17822 };
17823
17824 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
17825 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
17826 index 4ec45b3..a4f0a8a 100644
17827 --- a/arch/x86/include/asm/switch_to.h
17828 +++ b/arch/x86/include/asm/switch_to.h
17829 @@ -108,7 +108,7 @@ do { \
17830 "call __switch_to\n\t" \
17831 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
17832 __switch_canary \
17833 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
17834 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
17835 "movq %%rax,%%rdi\n\t" \
17836 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
17837 "jnz ret_from_fork\n\t" \
17838 @@ -119,7 +119,7 @@ do { \
17839 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
17840 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
17841 [_tif_fork] "i" (_TIF_FORK), \
17842 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
17843 + [thread_info] "m" (current_tinfo), \
17844 [current_task] "m" (current_task) \
17845 __switch_canary_iparam \
17846 : "memory", "cc" __EXTRA_CLOBBER)
17847 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
17848 index a1df6e8..e002940 100644
17849 --- a/arch/x86/include/asm/thread_info.h
17850 +++ b/arch/x86/include/asm/thread_info.h
17851 @@ -10,6 +10,7 @@
17852 #include <linux/compiler.h>
17853 #include <asm/page.h>
17854 #include <asm/types.h>
17855 +#include <asm/percpu.h>
17856
17857 /*
17858 * low level task data that entry.S needs immediate access to
17859 @@ -23,7 +24,6 @@ struct exec_domain;
17860 #include <linux/atomic.h>
17861
17862 struct thread_info {
17863 - struct task_struct *task; /* main task structure */
17864 struct exec_domain *exec_domain; /* execution domain */
17865 __u32 flags; /* low level flags */
17866 __u32 status; /* thread synchronous flags */
17867 @@ -33,19 +33,13 @@ struct thread_info {
17868 mm_segment_t addr_limit;
17869 struct restart_block restart_block;
17870 void __user *sysenter_return;
17871 -#ifdef CONFIG_X86_32
17872 - unsigned long previous_esp; /* ESP of the previous stack in
17873 - case of nested (IRQ) stacks
17874 - */
17875 - __u8 supervisor_stack[0];
17876 -#endif
17877 + unsigned long lowest_stack;
17878 unsigned int sig_on_uaccess_error:1;
17879 unsigned int uaccess_err:1; /* uaccess failed */
17880 };
17881
17882 -#define INIT_THREAD_INFO(tsk) \
17883 +#define INIT_THREAD_INFO \
17884 { \
17885 - .task = &tsk, \
17886 .exec_domain = &default_exec_domain, \
17887 .flags = 0, \
17888 .cpu = 0, \
17889 @@ -56,7 +50,7 @@ struct thread_info {
17890 }, \
17891 }
17892
17893 -#define init_thread_info (init_thread_union.thread_info)
17894 +#define init_thread_info (init_thread_union.stack)
17895 #define init_stack (init_thread_union.stack)
17896
17897 #else /* !__ASSEMBLY__ */
17898 @@ -97,6 +91,7 @@ struct thread_info {
17899 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
17900 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
17901 #define TIF_X32 30 /* 32-bit native x86-64 binary */
17902 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
17903
17904 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
17905 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
17906 @@ -121,17 +116,18 @@ struct thread_info {
17907 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
17908 #define _TIF_ADDR32 (1 << TIF_ADDR32)
17909 #define _TIF_X32 (1 << TIF_X32)
17910 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
17911
17912 /* work to do in syscall_trace_enter() */
17913 #define _TIF_WORK_SYSCALL_ENTRY \
17914 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
17915 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
17916 - _TIF_NOHZ)
17917 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
17918
17919 /* work to do in syscall_trace_leave() */
17920 #define _TIF_WORK_SYSCALL_EXIT \
17921 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
17922 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
17923 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
17924
17925 /* work to do on interrupt/exception return */
17926 #define _TIF_WORK_MASK \
17927 @@ -142,7 +138,7 @@ struct thread_info {
17928 /* work to do on any return to user space */
17929 #define _TIF_ALLWORK_MASK \
17930 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
17931 - _TIF_NOHZ)
17932 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
17933
17934 /* Only used for 64 bit */
17935 #define _TIF_DO_NOTIFY_MASK \
17936 @@ -158,45 +154,40 @@ struct thread_info {
17937
17938 #define PREEMPT_ACTIVE 0x10000000
17939
17940 -#ifdef CONFIG_X86_32
17941 -
17942 -#define STACK_WARN (THREAD_SIZE/8)
17943 -/*
17944 - * macros/functions for gaining access to the thread information structure
17945 - *
17946 - * preempt_count needs to be 1 initially, until the scheduler is functional.
17947 - */
17948 -#ifndef __ASSEMBLY__
17949 -
17950 -
17951 -/* how to get the current stack pointer from C */
17952 -register unsigned long current_stack_pointer asm("esp") __used;
17953 -
17954 -/* how to get the thread information struct from C */
17955 -static inline struct thread_info *current_thread_info(void)
17956 -{
17957 - return (struct thread_info *)
17958 - (current_stack_pointer & ~(THREAD_SIZE - 1));
17959 -}
17960 -
17961 -#else /* !__ASSEMBLY__ */
17962 -
17963 +#ifdef __ASSEMBLY__
17964 /* how to get the thread information struct from ASM */
17965 #define GET_THREAD_INFO(reg) \
17966 - movl $-THREAD_SIZE, reg; \
17967 - andl %esp, reg
17968 + mov PER_CPU_VAR(current_tinfo), reg
17969
17970 /* use this one if reg already contains %esp */
17971 -#define GET_THREAD_INFO_WITH_ESP(reg) \
17972 - andl $-THREAD_SIZE, reg
17973 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
17974 +#else
17975 +/* how to get the thread information struct from C */
17976 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
17977 +
17978 +static __always_inline struct thread_info *current_thread_info(void)
17979 +{
17980 + return this_cpu_read_stable(current_tinfo);
17981 +}
17982 +#endif
17983 +
17984 +#ifdef CONFIG_X86_32
17985 +
17986 +#define STACK_WARN (THREAD_SIZE/8)
17987 +/*
17988 + * macros/functions for gaining access to the thread information structure
17989 + *
17990 + * preempt_count needs to be 1 initially, until the scheduler is functional.
17991 + */
17992 +#ifndef __ASSEMBLY__
17993 +
17994 +/* how to get the current stack pointer from C */
17995 +register unsigned long current_stack_pointer asm("esp") __used;
17996
17997 #endif
17998
17999 #else /* X86_32 */
18000
18001 -#include <asm/percpu.h>
18002 -#define KERNEL_STACK_OFFSET (5*8)
18003 -
18004 /*
18005 * macros/functions for gaining access to the thread information structure
18006 * preempt_count needs to be 1 initially, until the scheduler is functional.
18007 @@ -204,27 +195,8 @@ static inline struct thread_info *current_thread_info(void)
18008 #ifndef __ASSEMBLY__
18009 DECLARE_PER_CPU(unsigned long, kernel_stack);
18010
18011 -static inline struct thread_info *current_thread_info(void)
18012 -{
18013 - struct thread_info *ti;
18014 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
18015 - KERNEL_STACK_OFFSET - THREAD_SIZE);
18016 - return ti;
18017 -}
18018 -
18019 -#else /* !__ASSEMBLY__ */
18020 -
18021 -/* how to get the thread information struct from ASM */
18022 -#define GET_THREAD_INFO(reg) \
18023 - movq PER_CPU_VAR(kernel_stack),reg ; \
18024 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
18025 -
18026 -/*
18027 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
18028 - * a certain register (to be used in assembler memory operands).
18029 - */
18030 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
18031 -
18032 +/* how to get the current stack pointer from C */
18033 +register unsigned long current_stack_pointer asm("rsp") __used;
18034 #endif
18035
18036 #endif /* !X86_32 */
18037 @@ -283,5 +255,12 @@ static inline bool is_ia32_task(void)
18038 extern void arch_task_cache_init(void);
18039 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
18040 extern void arch_release_task_struct(struct task_struct *tsk);
18041 +
18042 +#define __HAVE_THREAD_FUNCTIONS
18043 +#define task_thread_info(task) (&(task)->tinfo)
18044 +#define task_stack_page(task) ((task)->stack)
18045 +#define setup_thread_stack(p, org) do {} while (0)
18046 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
18047 +
18048 #endif
18049 #endif /* _ASM_X86_THREAD_INFO_H */
18050 diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
18051 index 50a7fc0..45844c0 100644
18052 --- a/arch/x86/include/asm/tlbflush.h
18053 +++ b/arch/x86/include/asm/tlbflush.h
18054 @@ -17,18 +17,44 @@
18055
18056 static inline void __native_flush_tlb(void)
18057 {
18058 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
18059 + unsigned long descriptor[2];
18060 +
18061 + descriptor[0] = PCID_KERNEL;
18062 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_MONGLOBAL) : "memory");
18063 + return;
18064 + }
18065 +
18066 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18067 + if (static_cpu_has(X86_FEATURE_PCID)) {
18068 + unsigned int cpu = raw_get_cpu();
18069 +
18070 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
18071 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
18072 + raw_put_cpu_no_resched();
18073 + return;
18074 + }
18075 +#endif
18076 +
18077 native_write_cr3(native_read_cr3());
18078 }
18079
18080 static inline void __native_flush_tlb_global_irq_disabled(void)
18081 {
18082 - unsigned long cr4;
18083 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
18084 + unsigned long descriptor[2];
18085
18086 - cr4 = native_read_cr4();
18087 - /* clear PGE */
18088 - native_write_cr4(cr4 & ~X86_CR4_PGE);
18089 - /* write old PGE again and flush TLBs */
18090 - native_write_cr4(cr4);
18091 + descriptor[0] = PCID_KERNEL;
18092 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_GLOBAL) : "memory");
18093 + } else {
18094 + unsigned long cr4;
18095 +
18096 + cr4 = native_read_cr4();
18097 + /* clear PGE */
18098 + native_write_cr4(cr4 & ~X86_CR4_PGE);
18099 + /* write old PGE again and flush TLBs */
18100 + native_write_cr4(cr4);
18101 + }
18102 }
18103
18104 static inline void __native_flush_tlb_global(void)
18105 @@ -49,6 +75,42 @@ static inline void __native_flush_tlb_global(void)
18106
18107 static inline void __native_flush_tlb_single(unsigned long addr)
18108 {
18109 +
18110 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
18111 + unsigned long descriptor[2];
18112 +
18113 + descriptor[0] = PCID_KERNEL;
18114 + descriptor[1] = addr;
18115 +
18116 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18117 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) || addr >= TASK_SIZE_MAX) {
18118 + if (addr < TASK_SIZE_MAX)
18119 + descriptor[1] += pax_user_shadow_base;
18120 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
18121 + }
18122 +
18123 + descriptor[0] = PCID_USER;
18124 + descriptor[1] = addr;
18125 +#endif
18126 +
18127 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
18128 + return;
18129 + }
18130 +
18131 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18132 + if (static_cpu_has(X86_FEATURE_PCID)) {
18133 + unsigned int cpu = raw_get_cpu();
18134 +
18135 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
18136 + asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
18137 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
18138 + raw_put_cpu_no_resched();
18139 +
18140 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) && addr < TASK_SIZE_MAX)
18141 + addr += pax_user_shadow_base;
18142 + }
18143 +#endif
18144 +
18145 asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
18146 }
18147
18148 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
18149 index 5ee2687..74590b9 100644
18150 --- a/arch/x86/include/asm/uaccess.h
18151 +++ b/arch/x86/include/asm/uaccess.h
18152 @@ -7,6 +7,7 @@
18153 #include <linux/compiler.h>
18154 #include <linux/thread_info.h>
18155 #include <linux/string.h>
18156 +#include <linux/sched.h>
18157 #include <asm/asm.h>
18158 #include <asm/page.h>
18159 #include <asm/smap.h>
18160 @@ -29,7 +30,12 @@
18161
18162 #define get_ds() (KERNEL_DS)
18163 #define get_fs() (current_thread_info()->addr_limit)
18164 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
18165 +void __set_fs(mm_segment_t x);
18166 +void set_fs(mm_segment_t x);
18167 +#else
18168 #define set_fs(x) (current_thread_info()->addr_limit = (x))
18169 +#endif
18170
18171 #define segment_eq(a, b) ((a).seg == (b).seg)
18172
18173 @@ -77,8 +83,33 @@
18174 * checks that the pointer is in the user space range - after calling
18175 * this function, memory access functions may still return -EFAULT.
18176 */
18177 -#define access_ok(type, addr, size) \
18178 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
18179 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
18180 +#define access_ok(type, addr, size) \
18181 +({ \
18182 + long __size = size; \
18183 + unsigned long __addr = (unsigned long)addr; \
18184 + unsigned long __addr_ao = __addr & PAGE_MASK; \
18185 + unsigned long __end_ao = __addr + __size - 1; \
18186 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
18187 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
18188 + while(__addr_ao <= __end_ao) { \
18189 + char __c_ao; \
18190 + __addr_ao += PAGE_SIZE; \
18191 + if (__size > PAGE_SIZE) \
18192 + cond_resched(); \
18193 + if (__get_user(__c_ao, (char __user *)__addr)) \
18194 + break; \
18195 + if (type != VERIFY_WRITE) { \
18196 + __addr = __addr_ao; \
18197 + continue; \
18198 + } \
18199 + if (__put_user(__c_ao, (char __user *)__addr)) \
18200 + break; \
18201 + __addr = __addr_ao; \
18202 + } \
18203 + } \
18204 + __ret_ao; \
18205 +})
18206
18207 /*
18208 * The exception table consists of pairs of addresses relative to the
18209 @@ -165,10 +196,12 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
18210 register __inttype(*(ptr)) __val_gu asm("%edx"); \
18211 __chk_user_ptr(ptr); \
18212 might_fault(); \
18213 + pax_open_userland(); \
18214 asm volatile("call __get_user_%P3" \
18215 : "=a" (__ret_gu), "=r" (__val_gu) \
18216 : "0" (ptr), "i" (sizeof(*(ptr)))); \
18217 (x) = (__typeof__(*(ptr))) __val_gu; \
18218 + pax_close_userland(); \
18219 __ret_gu; \
18220 })
18221
18222 @@ -176,13 +209,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
18223 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
18224 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
18225
18226 -
18227 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
18228 +#define __copyuser_seg "gs;"
18229 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
18230 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
18231 +#else
18232 +#define __copyuser_seg
18233 +#define __COPYUSER_SET_ES
18234 +#define __COPYUSER_RESTORE_ES
18235 +#endif
18236
18237 #ifdef CONFIG_X86_32
18238 #define __put_user_asm_u64(x, addr, err, errret) \
18239 asm volatile(ASM_STAC "\n" \
18240 - "1: movl %%eax,0(%2)\n" \
18241 - "2: movl %%edx,4(%2)\n" \
18242 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
18243 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
18244 "3: " ASM_CLAC "\n" \
18245 ".section .fixup,\"ax\"\n" \
18246 "4: movl %3,%0\n" \
18247 @@ -195,8 +236,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
18248
18249 #define __put_user_asm_ex_u64(x, addr) \
18250 asm volatile(ASM_STAC "\n" \
18251 - "1: movl %%eax,0(%1)\n" \
18252 - "2: movl %%edx,4(%1)\n" \
18253 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
18254 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
18255 "3: " ASM_CLAC "\n" \
18256 _ASM_EXTABLE_EX(1b, 2b) \
18257 _ASM_EXTABLE_EX(2b, 3b) \
18258 @@ -246,7 +287,8 @@ extern void __put_user_8(void);
18259 __typeof__(*(ptr)) __pu_val; \
18260 __chk_user_ptr(ptr); \
18261 might_fault(); \
18262 - __pu_val = x; \
18263 + __pu_val = (x); \
18264 + pax_open_userland(); \
18265 switch (sizeof(*(ptr))) { \
18266 case 1: \
18267 __put_user_x(1, __pu_val, ptr, __ret_pu); \
18268 @@ -264,6 +306,7 @@ extern void __put_user_8(void);
18269 __put_user_x(X, __pu_val, ptr, __ret_pu); \
18270 break; \
18271 } \
18272 + pax_close_userland(); \
18273 __ret_pu; \
18274 })
18275
18276 @@ -344,8 +387,10 @@ do { \
18277 } while (0)
18278
18279 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
18280 +do { \
18281 + pax_open_userland(); \
18282 asm volatile(ASM_STAC "\n" \
18283 - "1: mov"itype" %2,%"rtype"1\n" \
18284 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
18285 "2: " ASM_CLAC "\n" \
18286 ".section .fixup,\"ax\"\n" \
18287 "3: mov %3,%0\n" \
18288 @@ -353,8 +398,10 @@ do { \
18289 " jmp 2b\n" \
18290 ".previous\n" \
18291 _ASM_EXTABLE(1b, 3b) \
18292 - : "=r" (err), ltype(x) \
18293 - : "m" (__m(addr)), "i" (errret), "0" (err))
18294 + : "=r" (err), ltype (x) \
18295 + : "m" (__m(addr)), "i" (errret), "0" (err)); \
18296 + pax_close_userland(); \
18297 +} while (0)
18298
18299 #define __get_user_size_ex(x, ptr, size) \
18300 do { \
18301 @@ -378,7 +425,7 @@ do { \
18302 } while (0)
18303
18304 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
18305 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
18306 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
18307 "2:\n" \
18308 _ASM_EXTABLE_EX(1b, 2b) \
18309 : ltype(x) : "m" (__m(addr)))
18310 @@ -395,13 +442,24 @@ do { \
18311 int __gu_err; \
18312 unsigned long __gu_val; \
18313 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
18314 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
18315 + (x) = (__typeof__(*(ptr)))__gu_val; \
18316 __gu_err; \
18317 })
18318
18319 /* FIXME: this hack is definitely wrong -AK */
18320 struct __large_struct { unsigned long buf[100]; };
18321 -#define __m(x) (*(struct __large_struct __user *)(x))
18322 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18323 +#define ____m(x) \
18324 +({ \
18325 + unsigned long ____x = (unsigned long)(x); \
18326 + if (____x < pax_user_shadow_base) \
18327 + ____x += pax_user_shadow_base; \
18328 + (typeof(x))____x; \
18329 +})
18330 +#else
18331 +#define ____m(x) (x)
18332 +#endif
18333 +#define __m(x) (*(struct __large_struct __user *)____m(x))
18334
18335 /*
18336 * Tell gcc we read from memory instead of writing: this is because
18337 @@ -409,8 +467,10 @@ struct __large_struct { unsigned long buf[100]; };
18338 * aliasing issues.
18339 */
18340 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
18341 +do { \
18342 + pax_open_userland(); \
18343 asm volatile(ASM_STAC "\n" \
18344 - "1: mov"itype" %"rtype"1,%2\n" \
18345 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
18346 "2: " ASM_CLAC "\n" \
18347 ".section .fixup,\"ax\"\n" \
18348 "3: mov %3,%0\n" \
18349 @@ -418,10 +478,12 @@ struct __large_struct { unsigned long buf[100]; };
18350 ".previous\n" \
18351 _ASM_EXTABLE(1b, 3b) \
18352 : "=r"(err) \
18353 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
18354 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err));\
18355 + pax_close_userland(); \
18356 +} while (0)
18357
18358 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
18359 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
18360 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
18361 "2:\n" \
18362 _ASM_EXTABLE_EX(1b, 2b) \
18363 : : ltype(x), "m" (__m(addr)))
18364 @@ -431,11 +493,13 @@ struct __large_struct { unsigned long buf[100]; };
18365 */
18366 #define uaccess_try do { \
18367 current_thread_info()->uaccess_err = 0; \
18368 + pax_open_userland(); \
18369 stac(); \
18370 barrier();
18371
18372 #define uaccess_catch(err) \
18373 clac(); \
18374 + pax_close_userland(); \
18375 (err) |= (current_thread_info()->uaccess_err ? -EFAULT : 0); \
18376 } while (0)
18377
18378 @@ -460,8 +524,12 @@ struct __large_struct { unsigned long buf[100]; };
18379 * On error, the variable @x is set to zero.
18380 */
18381
18382 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18383 +#define __get_user(x, ptr) get_user((x), (ptr))
18384 +#else
18385 #define __get_user(x, ptr) \
18386 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
18387 +#endif
18388
18389 /**
18390 * __put_user: - Write a simple value into user space, with less checking.
18391 @@ -483,8 +551,12 @@ struct __large_struct { unsigned long buf[100]; };
18392 * Returns zero on success, or -EFAULT on error.
18393 */
18394
18395 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18396 +#define __put_user(x, ptr) put_user((x), (ptr))
18397 +#else
18398 #define __put_user(x, ptr) \
18399 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
18400 +#endif
18401
18402 #define __get_user_unaligned __get_user
18403 #define __put_user_unaligned __put_user
18404 @@ -502,7 +574,7 @@ struct __large_struct { unsigned long buf[100]; };
18405 #define get_user_ex(x, ptr) do { \
18406 unsigned long __gue_val; \
18407 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
18408 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
18409 + (x) = (__typeof__(*(ptr)))__gue_val; \
18410 } while (0)
18411
18412 #define put_user_try uaccess_try
18413 @@ -519,8 +591,8 @@ strncpy_from_user(char *dst, const char __user *src, long count);
18414 extern __must_check long strlen_user(const char __user *str);
18415 extern __must_check long strnlen_user(const char __user *str, long n);
18416
18417 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
18418 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
18419 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
18420 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
18421
18422 /*
18423 * movsl can be slow when source and dest are not both 8-byte aligned
18424 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
18425 index 7f760a9..04b1c65 100644
18426 --- a/arch/x86/include/asm/uaccess_32.h
18427 +++ b/arch/x86/include/asm/uaccess_32.h
18428 @@ -11,15 +11,15 @@
18429 #include <asm/page.h>
18430
18431 unsigned long __must_check __copy_to_user_ll
18432 - (void __user *to, const void *from, unsigned long n);
18433 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
18434 unsigned long __must_check __copy_from_user_ll
18435 - (void *to, const void __user *from, unsigned long n);
18436 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18437 unsigned long __must_check __copy_from_user_ll_nozero
18438 - (void *to, const void __user *from, unsigned long n);
18439 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18440 unsigned long __must_check __copy_from_user_ll_nocache
18441 - (void *to, const void __user *from, unsigned long n);
18442 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18443 unsigned long __must_check __copy_from_user_ll_nocache_nozero
18444 - (void *to, const void __user *from, unsigned long n);
18445 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18446
18447 /**
18448 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
18449 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
18450 static __always_inline unsigned long __must_check
18451 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
18452 {
18453 + if ((long)n < 0)
18454 + return n;
18455 +
18456 + check_object_size(from, n, true);
18457 +
18458 if (__builtin_constant_p(n)) {
18459 unsigned long ret;
18460
18461 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
18462 __copy_to_user(void __user *to, const void *from, unsigned long n)
18463 {
18464 might_fault();
18465 +
18466 return __copy_to_user_inatomic(to, from, n);
18467 }
18468
18469 static __always_inline unsigned long
18470 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
18471 {
18472 + if ((long)n < 0)
18473 + return n;
18474 +
18475 /* Avoid zeroing the tail if the copy fails..
18476 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
18477 * but as the zeroing behaviour is only significant when n is not
18478 @@ -137,6 +146,12 @@ static __always_inline unsigned long
18479 __copy_from_user(void *to, const void __user *from, unsigned long n)
18480 {
18481 might_fault();
18482 +
18483 + if ((long)n < 0)
18484 + return n;
18485 +
18486 + check_object_size(to, n, false);
18487 +
18488 if (__builtin_constant_p(n)) {
18489 unsigned long ret;
18490
18491 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
18492 const void __user *from, unsigned long n)
18493 {
18494 might_fault();
18495 +
18496 + if ((long)n < 0)
18497 + return n;
18498 +
18499 if (__builtin_constant_p(n)) {
18500 unsigned long ret;
18501
18502 @@ -181,15 +200,19 @@ static __always_inline unsigned long
18503 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
18504 unsigned long n)
18505 {
18506 - return __copy_from_user_ll_nocache_nozero(to, from, n);
18507 + if ((long)n < 0)
18508 + return n;
18509 +
18510 + return __copy_from_user_ll_nocache_nozero(to, from, n);
18511 }
18512
18513 -unsigned long __must_check copy_to_user(void __user *to,
18514 - const void *from, unsigned long n);
18515 -unsigned long __must_check _copy_from_user(void *to,
18516 - const void __user *from,
18517 - unsigned long n);
18518 -
18519 +extern void copy_to_user_overflow(void)
18520 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18521 + __compiletime_error("copy_to_user() buffer size is not provably correct")
18522 +#else
18523 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
18524 +#endif
18525 +;
18526
18527 extern void copy_from_user_overflow(void)
18528 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18529 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
18530 #endif
18531 ;
18532
18533 -static inline unsigned long __must_check copy_from_user(void *to,
18534 - const void __user *from,
18535 - unsigned long n)
18536 +/**
18537 + * copy_to_user: - Copy a block of data into user space.
18538 + * @to: Destination address, in user space.
18539 + * @from: Source address, in kernel space.
18540 + * @n: Number of bytes to copy.
18541 + *
18542 + * Context: User context only. This function may sleep.
18543 + *
18544 + * Copy data from kernel space to user space.
18545 + *
18546 + * Returns number of bytes that could not be copied.
18547 + * On success, this will be zero.
18548 + */
18549 +static inline unsigned long __must_check
18550 +copy_to_user(void __user *to, const void *from, unsigned long n)
18551 {
18552 - int sz = __compiletime_object_size(to);
18553 + size_t sz = __compiletime_object_size(from);
18554
18555 - if (likely(sz == -1 || sz >= n))
18556 - n = _copy_from_user(to, from, n);
18557 - else
18558 + if (unlikely(sz != (size_t)-1 && sz < n))
18559 + copy_to_user_overflow();
18560 + else if (access_ok(VERIFY_WRITE, to, n))
18561 + n = __copy_to_user(to, from, n);
18562 + return n;
18563 +}
18564 +
18565 +/**
18566 + * copy_from_user: - Copy a block of data from user space.
18567 + * @to: Destination address, in kernel space.
18568 + * @from: Source address, in user space.
18569 + * @n: Number of bytes to copy.
18570 + *
18571 + * Context: User context only. This function may sleep.
18572 + *
18573 + * Copy data from user space to kernel space.
18574 + *
18575 + * Returns number of bytes that could not be copied.
18576 + * On success, this will be zero.
18577 + *
18578 + * If some data could not be copied, this function will pad the copied
18579 + * data to the requested size using zero bytes.
18580 + */
18581 +static inline unsigned long __must_check
18582 +copy_from_user(void *to, const void __user *from, unsigned long n)
18583 +{
18584 + size_t sz = __compiletime_object_size(to);
18585 +
18586 + check_object_size(to, n, false);
18587 +
18588 + if (unlikely(sz != (size_t)-1 && sz < n))
18589 copy_from_user_overflow();
18590 -
18591 + else if (access_ok(VERIFY_READ, from, n))
18592 + n = __copy_from_user(to, from, n);
18593 + else if ((long)n > 0)
18594 + memset(to, 0, n);
18595 return n;
18596 }
18597
18598 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
18599 index 142810c..1dbe82f 100644
18600 --- a/arch/x86/include/asm/uaccess_64.h
18601 +++ b/arch/x86/include/asm/uaccess_64.h
18602 @@ -10,6 +10,9 @@
18603 #include <asm/alternative.h>
18604 #include <asm/cpufeature.h>
18605 #include <asm/page.h>
18606 +#include <asm/pgtable.h>
18607 +
18608 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
18609
18610 /*
18611 * Copy To/From Userspace
18612 @@ -17,13 +20,13 @@
18613
18614 /* Handles exceptions in both to and from, but doesn't do access_ok */
18615 __must_check unsigned long
18616 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
18617 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
18618 __must_check unsigned long
18619 -copy_user_generic_string(void *to, const void *from, unsigned len);
18620 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
18621 __must_check unsigned long
18622 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
18623 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
18624
18625 -static __always_inline __must_check unsigned long
18626 +static __always_inline __must_check __size_overflow(3) unsigned long
18627 copy_user_generic(void *to, const void *from, unsigned len)
18628 {
18629 unsigned ret;
18630 @@ -41,142 +44,204 @@ copy_user_generic(void *to, const void *from, unsigned len)
18631 ASM_OUTPUT2("=a" (ret), "=D" (to), "=S" (from),
18632 "=d" (len)),
18633 "1" (to), "2" (from), "3" (len)
18634 - : "memory", "rcx", "r8", "r9", "r10", "r11");
18635 + : "memory", "rcx", "r8", "r9", "r11");
18636 return ret;
18637 }
18638
18639 +static __always_inline __must_check unsigned long
18640 +__copy_to_user(void __user *to, const void *from, unsigned long len);
18641 +static __always_inline __must_check unsigned long
18642 +__copy_from_user(void *to, const void __user *from, unsigned long len);
18643 __must_check unsigned long
18644 -_copy_to_user(void __user *to, const void *from, unsigned len);
18645 -__must_check unsigned long
18646 -_copy_from_user(void *to, const void __user *from, unsigned len);
18647 -__must_check unsigned long
18648 -copy_in_user(void __user *to, const void __user *from, unsigned len);
18649 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
18650 +
18651 +extern void copy_to_user_overflow(void)
18652 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18653 + __compiletime_error("copy_to_user() buffer size is not provably correct")
18654 +#else
18655 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
18656 +#endif
18657 +;
18658 +
18659 +extern void copy_from_user_overflow(void)
18660 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18661 + __compiletime_error("copy_from_user() buffer size is not provably correct")
18662 +#else
18663 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
18664 +#endif
18665 +;
18666
18667 static inline unsigned long __must_check copy_from_user(void *to,
18668 const void __user *from,
18669 unsigned long n)
18670 {
18671 - int sz = __compiletime_object_size(to);
18672 -
18673 might_fault();
18674 - if (likely(sz == -1 || sz >= n))
18675 - n = _copy_from_user(to, from, n);
18676 -#ifdef CONFIG_DEBUG_VM
18677 - else
18678 - WARN(1, "Buffer overflow detected!\n");
18679 -#endif
18680 +
18681 + check_object_size(to, n, false);
18682 +
18683 + if (access_ok(VERIFY_READ, from, n))
18684 + n = __copy_from_user(to, from, n);
18685 + else if (n < INT_MAX)
18686 + memset(to, 0, n);
18687 return n;
18688 }
18689
18690 static __always_inline __must_check
18691 -int copy_to_user(void __user *dst, const void *src, unsigned size)
18692 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
18693 {
18694 might_fault();
18695
18696 - return _copy_to_user(dst, src, size);
18697 + if (access_ok(VERIFY_WRITE, dst, size))
18698 + size = __copy_to_user(dst, src, size);
18699 + return size;
18700 }
18701
18702 static __always_inline __must_check
18703 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
18704 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
18705 {
18706 - int ret = 0;
18707 + size_t sz = __compiletime_object_size(dst);
18708 + unsigned ret = 0;
18709
18710 might_fault();
18711 +
18712 + if (size > INT_MAX)
18713 + return size;
18714 +
18715 + check_object_size(dst, size, false);
18716 +
18717 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18718 + if (!__access_ok(VERIFY_READ, src, size))
18719 + return size;
18720 +#endif
18721 +
18722 + if (unlikely(sz != (size_t)-1 && sz < size)) {
18723 + copy_from_user_overflow();
18724 + return size;
18725 + }
18726 +
18727 if (!__builtin_constant_p(size))
18728 - return copy_user_generic(dst, (__force void *)src, size);
18729 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18730 switch (size) {
18731 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
18732 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
18733 ret, "b", "b", "=q", 1);
18734 return ret;
18735 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
18736 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
18737 ret, "w", "w", "=r", 2);
18738 return ret;
18739 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
18740 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
18741 ret, "l", "k", "=r", 4);
18742 return ret;
18743 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
18744 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18745 ret, "q", "", "=r", 8);
18746 return ret;
18747 case 10:
18748 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
18749 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18750 ret, "q", "", "=r", 10);
18751 if (unlikely(ret))
18752 return ret;
18753 __get_user_asm(*(u16 *)(8 + (char *)dst),
18754 - (u16 __user *)(8 + (char __user *)src),
18755 + (const u16 __user *)(8 + (const char __user *)src),
18756 ret, "w", "w", "=r", 2);
18757 return ret;
18758 case 16:
18759 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
18760 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18761 ret, "q", "", "=r", 16);
18762 if (unlikely(ret))
18763 return ret;
18764 __get_user_asm(*(u64 *)(8 + (char *)dst),
18765 - (u64 __user *)(8 + (char __user *)src),
18766 + (const u64 __user *)(8 + (const char __user *)src),
18767 ret, "q", "", "=r", 8);
18768 return ret;
18769 default:
18770 - return copy_user_generic(dst, (__force void *)src, size);
18771 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18772 }
18773 }
18774
18775 static __always_inline __must_check
18776 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
18777 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
18778 {
18779 - int ret = 0;
18780 + size_t sz = __compiletime_object_size(src);
18781 + unsigned ret = 0;
18782
18783 might_fault();
18784 +
18785 + if (size > INT_MAX)
18786 + return size;
18787 +
18788 + check_object_size(src, size, true);
18789 +
18790 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18791 + if (!__access_ok(VERIFY_WRITE, dst, size))
18792 + return size;
18793 +#endif
18794 +
18795 + if (unlikely(sz != (size_t)-1 && sz < size)) {
18796 + copy_to_user_overflow();
18797 + return size;
18798 + }
18799 +
18800 if (!__builtin_constant_p(size))
18801 - return copy_user_generic((__force void *)dst, src, size);
18802 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18803 switch (size) {
18804 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
18805 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
18806 ret, "b", "b", "iq", 1);
18807 return ret;
18808 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
18809 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
18810 ret, "w", "w", "ir", 2);
18811 return ret;
18812 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
18813 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
18814 ret, "l", "k", "ir", 4);
18815 return ret;
18816 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
18817 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18818 ret, "q", "", "er", 8);
18819 return ret;
18820 case 10:
18821 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
18822 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18823 ret, "q", "", "er", 10);
18824 if (unlikely(ret))
18825 return ret;
18826 asm("":::"memory");
18827 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
18828 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
18829 ret, "w", "w", "ir", 2);
18830 return ret;
18831 case 16:
18832 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
18833 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18834 ret, "q", "", "er", 16);
18835 if (unlikely(ret))
18836 return ret;
18837 asm("":::"memory");
18838 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
18839 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
18840 ret, "q", "", "er", 8);
18841 return ret;
18842 default:
18843 - return copy_user_generic((__force void *)dst, src, size);
18844 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18845 }
18846 }
18847
18848 static __always_inline __must_check
18849 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18850 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
18851 {
18852 - int ret = 0;
18853 + unsigned ret = 0;
18854
18855 might_fault();
18856 +
18857 + if (size > INT_MAX)
18858 + return size;
18859 +
18860 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18861 + if (!__access_ok(VERIFY_READ, src, size))
18862 + return size;
18863 + if (!__access_ok(VERIFY_WRITE, dst, size))
18864 + return size;
18865 +#endif
18866 +
18867 if (!__builtin_constant_p(size))
18868 - return copy_user_generic((__force void *)dst,
18869 - (__force void *)src, size);
18870 + return copy_user_generic((__force_kernel void *)____m(dst),
18871 + (__force_kernel const void *)____m(src), size);
18872 switch (size) {
18873 case 1: {
18874 u8 tmp;
18875 - __get_user_asm(tmp, (u8 __user *)src,
18876 + __get_user_asm(tmp, (const u8 __user *)src,
18877 ret, "b", "b", "=q", 1);
18878 if (likely(!ret))
18879 __put_user_asm(tmp, (u8 __user *)dst,
18880 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18881 }
18882 case 2: {
18883 u16 tmp;
18884 - __get_user_asm(tmp, (u16 __user *)src,
18885 + __get_user_asm(tmp, (const u16 __user *)src,
18886 ret, "w", "w", "=r", 2);
18887 if (likely(!ret))
18888 __put_user_asm(tmp, (u16 __user *)dst,
18889 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18890
18891 case 4: {
18892 u32 tmp;
18893 - __get_user_asm(tmp, (u32 __user *)src,
18894 + __get_user_asm(tmp, (const u32 __user *)src,
18895 ret, "l", "k", "=r", 4);
18896 if (likely(!ret))
18897 __put_user_asm(tmp, (u32 __user *)dst,
18898 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18899 }
18900 case 8: {
18901 u64 tmp;
18902 - __get_user_asm(tmp, (u64 __user *)src,
18903 + __get_user_asm(tmp, (const u64 __user *)src,
18904 ret, "q", "", "=r", 8);
18905 if (likely(!ret))
18906 __put_user_asm(tmp, (u64 __user *)dst,
18907 @@ -212,41 +277,72 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18908 return ret;
18909 }
18910 default:
18911 - return copy_user_generic((__force void *)dst,
18912 - (__force void *)src, size);
18913 + return copy_user_generic((__force_kernel void *)____m(dst),
18914 + (__force_kernel const void *)____m(src), size);
18915 }
18916 }
18917
18918 -static __must_check __always_inline int
18919 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
18920 +static __must_check __always_inline unsigned long
18921 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
18922 {
18923 - return copy_user_generic(dst, (__force const void *)src, size);
18924 + if (size > INT_MAX)
18925 + return size;
18926 +
18927 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18928 + if (!__access_ok(VERIFY_READ, src, size))
18929 + return size;
18930 +#endif
18931 +
18932 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18933 }
18934
18935 -static __must_check __always_inline int
18936 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
18937 +static __must_check __always_inline unsigned long
18938 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
18939 {
18940 - return copy_user_generic((__force void *)dst, src, size);
18941 + if (size > INT_MAX)
18942 + return size;
18943 +
18944 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18945 + if (!__access_ok(VERIFY_WRITE, dst, size))
18946 + return size;
18947 +#endif
18948 +
18949 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18950 }
18951
18952 -extern long __copy_user_nocache(void *dst, const void __user *src,
18953 - unsigned size, int zerorest);
18954 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
18955 + unsigned long size, int zerorest) __size_overflow(3);
18956
18957 -static inline int
18958 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
18959 +static inline unsigned long __copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
18960 {
18961 might_sleep();
18962 +
18963 + if (size > INT_MAX)
18964 + return size;
18965 +
18966 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18967 + if (!__access_ok(VERIFY_READ, src, size))
18968 + return size;
18969 +#endif
18970 +
18971 return __copy_user_nocache(dst, src, size, 1);
18972 }
18973
18974 -static inline int
18975 -__copy_from_user_inatomic_nocache(void *dst, const void __user *src,
18976 - unsigned size)
18977 +static inline unsigned long __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
18978 + unsigned long size)
18979 {
18980 + if (size > INT_MAX)
18981 + return size;
18982 +
18983 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18984 + if (!__access_ok(VERIFY_READ, src, size))
18985 + return size;
18986 +#endif
18987 +
18988 return __copy_user_nocache(dst, src, size, 0);
18989 }
18990
18991 -unsigned long
18992 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
18993 +extern unsigned long
18994 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
18995
18996 #endif /* _ASM_X86_UACCESS_64_H */
18997 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
18998 index 5b238981..77fdd78 100644
18999 --- a/arch/x86/include/asm/word-at-a-time.h
19000 +++ b/arch/x86/include/asm/word-at-a-time.h
19001 @@ -11,7 +11,7 @@
19002 * and shift, for example.
19003 */
19004 struct word_at_a_time {
19005 - const unsigned long one_bits, high_bits;
19006 + unsigned long one_bits, high_bits;
19007 };
19008
19009 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
19010 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
19011 index d8d9922..bf6cecb 100644
19012 --- a/arch/x86/include/asm/x86_init.h
19013 +++ b/arch/x86/include/asm/x86_init.h
19014 @@ -129,7 +129,7 @@ struct x86_init_ops {
19015 struct x86_init_timers timers;
19016 struct x86_init_iommu iommu;
19017 struct x86_init_pci pci;
19018 -};
19019 +} __no_const;
19020
19021 /**
19022 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
19023 @@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
19024 void (*setup_percpu_clockev)(void);
19025 void (*early_percpu_clock_init)(void);
19026 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
19027 -};
19028 +} __no_const;
19029
19030 /**
19031 * struct x86_platform_ops - platform specific runtime functions
19032 @@ -166,7 +166,7 @@ struct x86_platform_ops {
19033 void (*save_sched_clock_state)(void);
19034 void (*restore_sched_clock_state)(void);
19035 void (*apic_post_init)(void);
19036 -};
19037 +} __no_const;
19038
19039 struct pci_dev;
19040 struct msi_msg;
19041 @@ -180,7 +180,7 @@ struct x86_msi_ops {
19042 void (*teardown_msi_irqs)(struct pci_dev *dev);
19043 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
19044 int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
19045 -};
19046 +} __no_const;
19047
19048 struct IO_APIC_route_entry;
19049 struct io_apic_irq_attr;
19050 @@ -201,7 +201,7 @@ struct x86_io_apic_ops {
19051 unsigned int destination, int vector,
19052 struct io_apic_irq_attr *attr);
19053 void (*eoi_ioapic_pin)(int apic, int pin, int vector);
19054 -};
19055 +} __no_const;
19056
19057 extern struct x86_init_ops x86_init;
19058 extern struct x86_cpuinit_ops x86_cpuinit;
19059 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
19060 index 0415cda..3b22adc 100644
19061 --- a/arch/x86/include/asm/xsave.h
19062 +++ b/arch/x86/include/asm/xsave.h
19063 @@ -70,8 +70,11 @@ static inline int xsave_user(struct xsave_struct __user *buf)
19064 if (unlikely(err))
19065 return -EFAULT;
19066
19067 + pax_open_userland();
19068 __asm__ __volatile__(ASM_STAC "\n"
19069 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
19070 + "1:"
19071 + __copyuser_seg
19072 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
19073 "2: " ASM_CLAC "\n"
19074 ".section .fixup,\"ax\"\n"
19075 "3: movl $-1,%[err]\n"
19076 @@ -81,18 +84,22 @@ static inline int xsave_user(struct xsave_struct __user *buf)
19077 : [err] "=r" (err)
19078 : "D" (buf), "a" (-1), "d" (-1), "0" (0)
19079 : "memory");
19080 + pax_close_userland();
19081 return err;
19082 }
19083
19084 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
19085 {
19086 int err;
19087 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
19088 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
19089 u32 lmask = mask;
19090 u32 hmask = mask >> 32;
19091
19092 + pax_open_userland();
19093 __asm__ __volatile__(ASM_STAC "\n"
19094 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
19095 + "1:"
19096 + __copyuser_seg
19097 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
19098 "2: " ASM_CLAC "\n"
19099 ".section .fixup,\"ax\"\n"
19100 "3: movl $-1,%[err]\n"
19101 @@ -102,6 +109,7 @@ static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
19102 : [err] "=r" (err)
19103 : "D" (xstate), "a" (lmask), "d" (hmask), "0" (0)
19104 : "memory"); /* memory required? */
19105 + pax_close_userland();
19106 return err;
19107 }
19108
19109 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
19110 index bbae024..e1528f9 100644
19111 --- a/arch/x86/include/uapi/asm/e820.h
19112 +++ b/arch/x86/include/uapi/asm/e820.h
19113 @@ -63,7 +63,7 @@ struct e820map {
19114 #define ISA_START_ADDRESS 0xa0000
19115 #define ISA_END_ADDRESS 0x100000
19116
19117 -#define BIOS_BEGIN 0x000a0000
19118 +#define BIOS_BEGIN 0x000c0000
19119 #define BIOS_END 0x00100000
19120
19121 #define BIOS_ROM_BASE 0xffe00000
19122 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
19123 index 7bd3bd3..5dac791 100644
19124 --- a/arch/x86/kernel/Makefile
19125 +++ b/arch/x86/kernel/Makefile
19126 @@ -22,7 +22,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
19127 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
19128 obj-$(CONFIG_IRQ_WORK) += irq_work.o
19129 obj-y += probe_roms.o
19130 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
19131 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
19132 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
19133 obj-y += syscall_$(BITS).o
19134 obj-$(CONFIG_X86_64) += vsyscall_64.o
19135 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
19136 index 230c8ea..f915130 100644
19137 --- a/arch/x86/kernel/acpi/boot.c
19138 +++ b/arch/x86/kernel/acpi/boot.c
19139 @@ -1361,7 +1361,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
19140 * If your system is blacklisted here, but you find that acpi=force
19141 * works for you, please contact linux-acpi@vger.kernel.org
19142 */
19143 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
19144 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
19145 /*
19146 * Boxes that need ACPI disabled
19147 */
19148 @@ -1436,7 +1436,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
19149 };
19150
19151 /* second table for DMI checks that should run after early-quirks */
19152 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
19153 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
19154 /*
19155 * HP laptops which use a DSDT reporting as HP/SB400/10000,
19156 * which includes some code which overrides all temperature
19157 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
19158 index ec94e11..7fbbec0 100644
19159 --- a/arch/x86/kernel/acpi/sleep.c
19160 +++ b/arch/x86/kernel/acpi/sleep.c
19161 @@ -88,8 +88,12 @@ int acpi_suspend_lowlevel(void)
19162 #else /* CONFIG_64BIT */
19163 #ifdef CONFIG_SMP
19164 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
19165 +
19166 + pax_open_kernel();
19167 early_gdt_descr.address =
19168 (unsigned long)get_cpu_gdt_table(smp_processor_id());
19169 + pax_close_kernel();
19170 +
19171 initial_gs = per_cpu_offset(smp_processor_id());
19172 #endif
19173 initial_code = (unsigned long)wakeup_long64;
19174 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
19175 index d1daa66..59fecba 100644
19176 --- a/arch/x86/kernel/acpi/wakeup_32.S
19177 +++ b/arch/x86/kernel/acpi/wakeup_32.S
19178 @@ -29,13 +29,11 @@ wakeup_pmode_return:
19179 # and restore the stack ... but you need gdt for this to work
19180 movl saved_context_esp, %esp
19181
19182 - movl %cs:saved_magic, %eax
19183 - cmpl $0x12345678, %eax
19184 + cmpl $0x12345678, saved_magic
19185 jne bogus_magic
19186
19187 # jump to place where we left off
19188 - movl saved_eip, %eax
19189 - jmp *%eax
19190 + jmp *(saved_eip)
19191
19192 bogus_magic:
19193 jmp bogus_magic
19194 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
19195 index c15cf9a..0e63558 100644
19196 --- a/arch/x86/kernel/alternative.c
19197 +++ b/arch/x86/kernel/alternative.c
19198 @@ -268,6 +268,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
19199 */
19200 for (a = start; a < end; a++) {
19201 instr = (u8 *)&a->instr_offset + a->instr_offset;
19202 +
19203 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
19204 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19205 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
19206 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19207 +#endif
19208 +
19209 replacement = (u8 *)&a->repl_offset + a->repl_offset;
19210 BUG_ON(a->replacementlen > a->instrlen);
19211 BUG_ON(a->instrlen > sizeof(insnbuf));
19212 @@ -299,10 +306,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
19213 for (poff = start; poff < end; poff++) {
19214 u8 *ptr = (u8 *)poff + *poff;
19215
19216 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
19217 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19218 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
19219 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19220 +#endif
19221 +
19222 if (!*poff || ptr < text || ptr >= text_end)
19223 continue;
19224 /* turn DS segment override prefix into lock prefix */
19225 - if (*ptr == 0x3e)
19226 + if (*ktla_ktva(ptr) == 0x3e)
19227 text_poke(ptr, ((unsigned char []){0xf0}), 1);
19228 }
19229 mutex_unlock(&text_mutex);
19230 @@ -317,10 +330,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
19231 for (poff = start; poff < end; poff++) {
19232 u8 *ptr = (u8 *)poff + *poff;
19233
19234 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
19235 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19236 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
19237 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19238 +#endif
19239 +
19240 if (!*poff || ptr < text || ptr >= text_end)
19241 continue;
19242 /* turn lock prefix into DS segment override prefix */
19243 - if (*ptr == 0xf0)
19244 + if (*ktla_ktva(ptr) == 0xf0)
19245 text_poke(ptr, ((unsigned char []){0x3E}), 1);
19246 }
19247 mutex_unlock(&text_mutex);
19248 @@ -468,7 +487,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
19249
19250 BUG_ON(p->len > MAX_PATCH_LEN);
19251 /* prep the buffer with the original instructions */
19252 - memcpy(insnbuf, p->instr, p->len);
19253 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
19254 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
19255 (unsigned long)p->instr, p->len);
19256
19257 @@ -515,7 +534,7 @@ void __init alternative_instructions(void)
19258 if (!uniproc_patched || num_possible_cpus() == 1)
19259 free_init_pages("SMP alternatives",
19260 (unsigned long)__smp_locks,
19261 - (unsigned long)__smp_locks_end);
19262 + PAGE_ALIGN((unsigned long)__smp_locks_end));
19263 #endif
19264
19265 apply_paravirt(__parainstructions, __parainstructions_end);
19266 @@ -535,13 +554,17 @@ void __init alternative_instructions(void)
19267 * instructions. And on the local CPU you need to be protected again NMI or MCE
19268 * handlers seeing an inconsistent instruction while you patch.
19269 */
19270 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
19271 +void *__kprobes text_poke_early(void *addr, const void *opcode,
19272 size_t len)
19273 {
19274 unsigned long flags;
19275 local_irq_save(flags);
19276 - memcpy(addr, opcode, len);
19277 +
19278 + pax_open_kernel();
19279 + memcpy(ktla_ktva(addr), opcode, len);
19280 sync_core();
19281 + pax_close_kernel();
19282 +
19283 local_irq_restore(flags);
19284 /* Could also do a CLFLUSH here to speed up CPU recovery; but
19285 that causes hangs on some VIA CPUs. */
19286 @@ -563,36 +586,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
19287 */
19288 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
19289 {
19290 - unsigned long flags;
19291 - char *vaddr;
19292 + unsigned char *vaddr = ktla_ktva(addr);
19293 struct page *pages[2];
19294 - int i;
19295 + size_t i;
19296
19297 if (!core_kernel_text((unsigned long)addr)) {
19298 - pages[0] = vmalloc_to_page(addr);
19299 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
19300 + pages[0] = vmalloc_to_page(vaddr);
19301 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
19302 } else {
19303 - pages[0] = virt_to_page(addr);
19304 + pages[0] = virt_to_page(vaddr);
19305 WARN_ON(!PageReserved(pages[0]));
19306 - pages[1] = virt_to_page(addr + PAGE_SIZE);
19307 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
19308 }
19309 BUG_ON(!pages[0]);
19310 - local_irq_save(flags);
19311 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
19312 - if (pages[1])
19313 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
19314 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
19315 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
19316 - clear_fixmap(FIX_TEXT_POKE0);
19317 - if (pages[1])
19318 - clear_fixmap(FIX_TEXT_POKE1);
19319 - local_flush_tlb();
19320 - sync_core();
19321 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
19322 - that causes hangs on some VIA CPUs. */
19323 + text_poke_early(addr, opcode, len);
19324 for (i = 0; i < len; i++)
19325 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
19326 - local_irq_restore(flags);
19327 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
19328 return addr;
19329 }
19330
19331 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
19332 index 904611b..004dde6 100644
19333 --- a/arch/x86/kernel/apic/apic.c
19334 +++ b/arch/x86/kernel/apic/apic.c
19335 @@ -189,7 +189,7 @@ int first_system_vector = 0xfe;
19336 /*
19337 * Debug level, exported for io_apic.c
19338 */
19339 -unsigned int apic_verbosity;
19340 +int apic_verbosity;
19341
19342 int pic_mode;
19343
19344 @@ -1955,7 +1955,7 @@ void smp_error_interrupt(struct pt_regs *regs)
19345 apic_write(APIC_ESR, 0);
19346 v1 = apic_read(APIC_ESR);
19347 ack_APIC_irq();
19348 - atomic_inc(&irq_err_count);
19349 + atomic_inc_unchecked(&irq_err_count);
19350
19351 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
19352 smp_processor_id(), v0 , v1);
19353 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
19354 index 00c77cf..2dc6a2d 100644
19355 --- a/arch/x86/kernel/apic/apic_flat_64.c
19356 +++ b/arch/x86/kernel/apic/apic_flat_64.c
19357 @@ -157,7 +157,7 @@ static int flat_probe(void)
19358 return 1;
19359 }
19360
19361 -static struct apic apic_flat = {
19362 +static struct apic apic_flat __read_only = {
19363 .name = "flat",
19364 .probe = flat_probe,
19365 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
19366 @@ -271,7 +271,7 @@ static int physflat_probe(void)
19367 return 0;
19368 }
19369
19370 -static struct apic apic_physflat = {
19371 +static struct apic apic_physflat __read_only = {
19372
19373 .name = "physical flat",
19374 .probe = physflat_probe,
19375 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
19376 index e145f28..2752888 100644
19377 --- a/arch/x86/kernel/apic/apic_noop.c
19378 +++ b/arch/x86/kernel/apic/apic_noop.c
19379 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
19380 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
19381 }
19382
19383 -struct apic apic_noop = {
19384 +struct apic apic_noop __read_only = {
19385 .name = "noop",
19386 .probe = noop_probe,
19387 .acpi_madt_oem_check = NULL,
19388 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
19389 index d50e364..543bee3 100644
19390 --- a/arch/x86/kernel/apic/bigsmp_32.c
19391 +++ b/arch/x86/kernel/apic/bigsmp_32.c
19392 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
19393 return dmi_bigsmp;
19394 }
19395
19396 -static struct apic apic_bigsmp = {
19397 +static struct apic apic_bigsmp __read_only = {
19398
19399 .name = "bigsmp",
19400 .probe = probe_bigsmp,
19401 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
19402 index 0874799..a7a7892 100644
19403 --- a/arch/x86/kernel/apic/es7000_32.c
19404 +++ b/arch/x86/kernel/apic/es7000_32.c
19405 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
19406 return ret && es7000_apic_is_cluster();
19407 }
19408
19409 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
19410 -static struct apic __refdata apic_es7000_cluster = {
19411 +static struct apic apic_es7000_cluster __read_only = {
19412
19413 .name = "es7000",
19414 .probe = probe_es7000,
19415 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
19416 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
19417 };
19418
19419 -static struct apic __refdata apic_es7000 = {
19420 +static struct apic apic_es7000 __read_only = {
19421
19422 .name = "es7000",
19423 .probe = probe_es7000,
19424 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
19425 index 9ed796c..e930fe4 100644
19426 --- a/arch/x86/kernel/apic/io_apic.c
19427 +++ b/arch/x86/kernel/apic/io_apic.c
19428 @@ -1060,7 +1060,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
19429 }
19430 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
19431
19432 -void lock_vector_lock(void)
19433 +void lock_vector_lock(void) __acquires(vector_lock)
19434 {
19435 /* Used to the online set of cpus does not change
19436 * during assign_irq_vector.
19437 @@ -1068,7 +1068,7 @@ void lock_vector_lock(void)
19438 raw_spin_lock(&vector_lock);
19439 }
19440
19441 -void unlock_vector_lock(void)
19442 +void unlock_vector_lock(void) __releases(vector_lock)
19443 {
19444 raw_spin_unlock(&vector_lock);
19445 }
19446 @@ -2362,7 +2362,7 @@ static void ack_apic_edge(struct irq_data *data)
19447 ack_APIC_irq();
19448 }
19449
19450 -atomic_t irq_mis_count;
19451 +atomic_unchecked_t irq_mis_count;
19452
19453 #ifdef CONFIG_GENERIC_PENDING_IRQ
19454 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
19455 @@ -2503,7 +2503,7 @@ static void ack_apic_level(struct irq_data *data)
19456 * at the cpu.
19457 */
19458 if (!(v & (1 << (i & 0x1f)))) {
19459 - atomic_inc(&irq_mis_count);
19460 + atomic_inc_unchecked(&irq_mis_count);
19461
19462 eoi_ioapic_irq(irq, cfg);
19463 }
19464 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
19465 index d661ee9..791fd33 100644
19466 --- a/arch/x86/kernel/apic/numaq_32.c
19467 +++ b/arch/x86/kernel/apic/numaq_32.c
19468 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
19469 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
19470 }
19471
19472 -/* Use __refdata to keep false positive warning calm. */
19473 -static struct apic __refdata apic_numaq = {
19474 +static struct apic apic_numaq __read_only = {
19475
19476 .name = "NUMAQ",
19477 .probe = probe_numaq,
19478 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
19479 index eb35ef9..f184a21 100644
19480 --- a/arch/x86/kernel/apic/probe_32.c
19481 +++ b/arch/x86/kernel/apic/probe_32.c
19482 @@ -72,7 +72,7 @@ static int probe_default(void)
19483 return 1;
19484 }
19485
19486 -static struct apic apic_default = {
19487 +static struct apic apic_default __read_only = {
19488
19489 .name = "default",
19490 .probe = probe_default,
19491 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
19492 index 77c95c0..434f8a4 100644
19493 --- a/arch/x86/kernel/apic/summit_32.c
19494 +++ b/arch/x86/kernel/apic/summit_32.c
19495 @@ -486,7 +486,7 @@ void setup_summit(void)
19496 }
19497 #endif
19498
19499 -static struct apic apic_summit = {
19500 +static struct apic apic_summit __read_only = {
19501
19502 .name = "summit",
19503 .probe = probe_summit,
19504 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
19505 index c88baa4..757aee1 100644
19506 --- a/arch/x86/kernel/apic/x2apic_cluster.c
19507 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
19508 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
19509 return notifier_from_errno(err);
19510 }
19511
19512 -static struct notifier_block __refdata x2apic_cpu_notifier = {
19513 +static struct notifier_block x2apic_cpu_notifier = {
19514 .notifier_call = update_clusterinfo,
19515 };
19516
19517 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
19518 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
19519 }
19520
19521 -static struct apic apic_x2apic_cluster = {
19522 +static struct apic apic_x2apic_cluster __read_only = {
19523
19524 .name = "cluster x2apic",
19525 .probe = x2apic_cluster_probe,
19526 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
19527 index 562a76d..a003c0f 100644
19528 --- a/arch/x86/kernel/apic/x2apic_phys.c
19529 +++ b/arch/x86/kernel/apic/x2apic_phys.c
19530 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
19531 return apic == &apic_x2apic_phys;
19532 }
19533
19534 -static struct apic apic_x2apic_phys = {
19535 +static struct apic apic_x2apic_phys __read_only = {
19536
19537 .name = "physical x2apic",
19538 .probe = x2apic_phys_probe,
19539 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
19540 index 794f6eb..67e1db2 100644
19541 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
19542 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
19543 @@ -342,7 +342,7 @@ static int uv_probe(void)
19544 return apic == &apic_x2apic_uv_x;
19545 }
19546
19547 -static struct apic __refdata apic_x2apic_uv_x = {
19548 +static struct apic apic_x2apic_uv_x __read_only = {
19549
19550 .name = "UV large system",
19551 .probe = uv_probe,
19552 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
19553 index 53a4e27..038760a 100644
19554 --- a/arch/x86/kernel/apm_32.c
19555 +++ b/arch/x86/kernel/apm_32.c
19556 @@ -433,7 +433,7 @@ static DEFINE_MUTEX(apm_mutex);
19557 * This is for buggy BIOS's that refer to (real mode) segment 0x40
19558 * even though they are called in protected mode.
19559 */
19560 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
19561 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
19562 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
19563
19564 static const char driver_version[] = "1.16ac"; /* no spaces */
19565 @@ -611,7 +611,10 @@ static long __apm_bios_call(void *_call)
19566 BUG_ON(cpu != 0);
19567 gdt = get_cpu_gdt_table(cpu);
19568 save_desc_40 = gdt[0x40 / 8];
19569 +
19570 + pax_open_kernel();
19571 gdt[0x40 / 8] = bad_bios_desc;
19572 + pax_close_kernel();
19573
19574 apm_irq_save(flags);
19575 APM_DO_SAVE_SEGS;
19576 @@ -620,7 +623,11 @@ static long __apm_bios_call(void *_call)
19577 &call->esi);
19578 APM_DO_RESTORE_SEGS;
19579 apm_irq_restore(flags);
19580 +
19581 + pax_open_kernel();
19582 gdt[0x40 / 8] = save_desc_40;
19583 + pax_close_kernel();
19584 +
19585 put_cpu();
19586
19587 return call->eax & 0xff;
19588 @@ -687,7 +694,10 @@ static long __apm_bios_call_simple(void *_call)
19589 BUG_ON(cpu != 0);
19590 gdt = get_cpu_gdt_table(cpu);
19591 save_desc_40 = gdt[0x40 / 8];
19592 +
19593 + pax_open_kernel();
19594 gdt[0x40 / 8] = bad_bios_desc;
19595 + pax_close_kernel();
19596
19597 apm_irq_save(flags);
19598 APM_DO_SAVE_SEGS;
19599 @@ -695,7 +705,11 @@ static long __apm_bios_call_simple(void *_call)
19600 &call->eax);
19601 APM_DO_RESTORE_SEGS;
19602 apm_irq_restore(flags);
19603 +
19604 + pax_open_kernel();
19605 gdt[0x40 / 8] = save_desc_40;
19606 + pax_close_kernel();
19607 +
19608 put_cpu();
19609 return error;
19610 }
19611 @@ -2362,12 +2376,15 @@ static int __init apm_init(void)
19612 * code to that CPU.
19613 */
19614 gdt = get_cpu_gdt_table(0);
19615 +
19616 + pax_open_kernel();
19617 set_desc_base(&gdt[APM_CS >> 3],
19618 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
19619 set_desc_base(&gdt[APM_CS_16 >> 3],
19620 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
19621 set_desc_base(&gdt[APM_DS >> 3],
19622 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
19623 + pax_close_kernel();
19624
19625 proc_create("apm", 0, NULL, &apm_file_ops);
19626
19627 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
19628 index 2861082..6d4718e 100644
19629 --- a/arch/x86/kernel/asm-offsets.c
19630 +++ b/arch/x86/kernel/asm-offsets.c
19631 @@ -33,6 +33,8 @@ void common(void) {
19632 OFFSET(TI_status, thread_info, status);
19633 OFFSET(TI_addr_limit, thread_info, addr_limit);
19634 OFFSET(TI_preempt_count, thread_info, preempt_count);
19635 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
19636 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
19637
19638 BLANK();
19639 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
19640 @@ -53,8 +55,26 @@ void common(void) {
19641 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
19642 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
19643 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
19644 +
19645 +#ifdef CONFIG_PAX_KERNEXEC
19646 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
19647 #endif
19648
19649 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19650 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
19651 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
19652 +#ifdef CONFIG_X86_64
19653 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
19654 +#endif
19655 +#endif
19656 +
19657 +#endif
19658 +
19659 + BLANK();
19660 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
19661 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
19662 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
19663 +
19664 #ifdef CONFIG_XEN
19665 BLANK();
19666 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
19667 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
19668 index e7c798b..2b2019b 100644
19669 --- a/arch/x86/kernel/asm-offsets_64.c
19670 +++ b/arch/x86/kernel/asm-offsets_64.c
19671 @@ -77,6 +77,7 @@ int main(void)
19672 BLANK();
19673 #undef ENTRY
19674
19675 + DEFINE(TSS_size, sizeof(struct tss_struct));
19676 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
19677 BLANK();
19678
19679 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
19680 index b0684e4..22ccfd7 100644
19681 --- a/arch/x86/kernel/cpu/Makefile
19682 +++ b/arch/x86/kernel/cpu/Makefile
19683 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
19684 CFLAGS_REMOVE_perf_event.o = -pg
19685 endif
19686
19687 -# Make sure load_percpu_segment has no stackprotector
19688 -nostackp := $(call cc-option, -fno-stack-protector)
19689 -CFLAGS_common.o := $(nostackp)
19690 -
19691 obj-y := intel_cacheinfo.o scattered.o topology.o
19692 obj-y += proc.o capflags.o powerflags.o common.o
19693 obj-y += rdrand.o
19694 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
19695 index 5013a48..0782c53 100644
19696 --- a/arch/x86/kernel/cpu/amd.c
19697 +++ b/arch/x86/kernel/cpu/amd.c
19698 @@ -744,7 +744,7 @@ static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c,
19699 unsigned int size)
19700 {
19701 /* AMD errata T13 (order #21922) */
19702 - if ((c->x86 == 6)) {
19703 + if (c->x86 == 6) {
19704 /* Duron Rev A0 */
19705 if (c->x86_model == 3 && c->x86_mask == 0)
19706 size = 64;
19707 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
19708 index 22018f7..df77e23 100644
19709 --- a/arch/x86/kernel/cpu/common.c
19710 +++ b/arch/x86/kernel/cpu/common.c
19711 @@ -88,60 +88,6 @@ static const struct cpu_dev __cpuinitconst default_cpu = {
19712
19713 static const struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
19714
19715 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
19716 -#ifdef CONFIG_X86_64
19717 - /*
19718 - * We need valid kernel segments for data and code in long mode too
19719 - * IRET will check the segment types kkeil 2000/10/28
19720 - * Also sysret mandates a special GDT layout
19721 - *
19722 - * TLS descriptors are currently at a different place compared to i386.
19723 - * Hopefully nobody expects them at a fixed place (Wine?)
19724 - */
19725 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
19726 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
19727 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
19728 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
19729 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
19730 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
19731 -#else
19732 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
19733 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19734 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
19735 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
19736 - /*
19737 - * Segments used for calling PnP BIOS have byte granularity.
19738 - * They code segments and data segments have fixed 64k limits,
19739 - * the transfer segment sizes are set at run time.
19740 - */
19741 - /* 32-bit code */
19742 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
19743 - /* 16-bit code */
19744 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
19745 - /* 16-bit data */
19746 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
19747 - /* 16-bit data */
19748 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
19749 - /* 16-bit data */
19750 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
19751 - /*
19752 - * The APM segments have byte granularity and their bases
19753 - * are set at run time. All have 64k limits.
19754 - */
19755 - /* 32-bit code */
19756 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
19757 - /* 16-bit code */
19758 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
19759 - /* data */
19760 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
19761 -
19762 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19763 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19764 - GDT_STACK_CANARY_INIT
19765 -#endif
19766 -} };
19767 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
19768 -
19769 static int __init x86_xsave_setup(char *s)
19770 {
19771 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
19772 @@ -288,6 +234,57 @@ static __always_inline void setup_smap(struct cpuinfo_x86 *c)
19773 set_in_cr4(X86_CR4_SMAP);
19774 }
19775
19776 +#ifdef CONFIG_X86_64
19777 +static __init int setup_disable_pcid(char *arg)
19778 +{
19779 + setup_clear_cpu_cap(X86_FEATURE_PCID);
19780 +
19781 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19782 + if (clone_pgd_mask != ~(pgdval_t)0UL)
19783 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
19784 +#endif
19785 +
19786 + return 1;
19787 +}
19788 +__setup("nopcid", setup_disable_pcid);
19789 +
19790 +static void setup_pcid(struct cpuinfo_x86 *c)
19791 +{
19792 + if (!cpu_has(c, X86_FEATURE_PCID)) {
19793 +
19794 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19795 + if (clone_pgd_mask != ~(pgdval_t)0UL) {
19796 + pax_open_kernel();
19797 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
19798 + pax_close_kernel();
19799 + printk("PAX: slow and weak UDEREF enabled\n");
19800 + } else
19801 + printk("PAX: UDEREF disabled\n");
19802 +#endif
19803 +
19804 + return;
19805 + }
19806 +
19807 + printk("PAX: PCID detected\n");
19808 + set_in_cr4(X86_CR4_PCIDE);
19809 +
19810 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19811 + pax_open_kernel();
19812 + clone_pgd_mask = ~(pgdval_t)0UL;
19813 + pax_close_kernel();
19814 + if (pax_user_shadow_base)
19815 + printk("PAX: weak UDEREF enabled\n");
19816 + else {
19817 + set_cpu_cap(c, X86_FEATURE_STRONGUDEREF);
19818 + printk("PAX: strong UDEREF enabled\n");
19819 + }
19820 +#endif
19821 +
19822 + if (cpu_has(c, X86_FEATURE_INVPCID))
19823 + printk("PAX: INVPCID detected\n");
19824 +}
19825 +#endif
19826 +
19827 /*
19828 * Some CPU features depend on higher CPUID levels, which may not always
19829 * be available due to CPUID level capping or broken virtualization
19830 @@ -386,7 +383,7 @@ void switch_to_new_gdt(int cpu)
19831 {
19832 struct desc_ptr gdt_descr;
19833
19834 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
19835 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
19836 gdt_descr.size = GDT_SIZE - 1;
19837 load_gdt(&gdt_descr);
19838 /* Reload the per-cpu base */
19839 @@ -874,6 +871,10 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
19840 setup_smep(c);
19841 setup_smap(c);
19842
19843 +#ifdef CONFIG_X86_64
19844 + setup_pcid(c);
19845 +#endif
19846 +
19847 /*
19848 * The vendor-specific functions might have changed features.
19849 * Now we do "generic changes."
19850 @@ -882,6 +883,10 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
19851 /* Filter out anything that depends on CPUID levels we don't have */
19852 filter_cpuid_features(c, true);
19853
19854 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
19855 + setup_clear_cpu_cap(X86_FEATURE_SEP);
19856 +#endif
19857 +
19858 /* If the model name is still unset, do table lookup. */
19859 if (!c->x86_model_id[0]) {
19860 const char *p;
19861 @@ -1069,10 +1074,12 @@ static __init int setup_disablecpuid(char *arg)
19862 }
19863 __setup("clearcpuid=", setup_disablecpuid);
19864
19865 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
19866 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
19867 +
19868 #ifdef CONFIG_X86_64
19869 struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
19870 -struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1,
19871 - (unsigned long) nmi_idt_table };
19872 +struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) nmi_idt_table };
19873
19874 DEFINE_PER_CPU_FIRST(union irq_stack_union,
19875 irq_stack_union) __aligned(PAGE_SIZE);
19876 @@ -1086,7 +1093,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
19877 EXPORT_PER_CPU_SYMBOL(current_task);
19878
19879 DEFINE_PER_CPU(unsigned long, kernel_stack) =
19880 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
19881 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
19882 EXPORT_PER_CPU_SYMBOL(kernel_stack);
19883
19884 DEFINE_PER_CPU(char *, irq_stack_ptr) =
19885 @@ -1231,7 +1238,7 @@ void __cpuinit cpu_init(void)
19886 load_ucode_ap();
19887
19888 cpu = stack_smp_processor_id();
19889 - t = &per_cpu(init_tss, cpu);
19890 + t = init_tss + cpu;
19891 oist = &per_cpu(orig_ist, cpu);
19892
19893 #ifdef CONFIG_NUMA
19894 @@ -1257,7 +1264,7 @@ void __cpuinit cpu_init(void)
19895 switch_to_new_gdt(cpu);
19896 loadsegment(fs, 0);
19897
19898 - load_idt((const struct desc_ptr *)&idt_descr);
19899 + load_idt(&idt_descr);
19900
19901 memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
19902 syscall_init();
19903 @@ -1266,7 +1273,6 @@ void __cpuinit cpu_init(void)
19904 wrmsrl(MSR_KERNEL_GS_BASE, 0);
19905 barrier();
19906
19907 - x86_configure_nx();
19908 enable_x2apic();
19909
19910 /*
19911 @@ -1318,7 +1324,7 @@ void __cpuinit cpu_init(void)
19912 {
19913 int cpu = smp_processor_id();
19914 struct task_struct *curr = current;
19915 - struct tss_struct *t = &per_cpu(init_tss, cpu);
19916 + struct tss_struct *t = init_tss + cpu;
19917 struct thread_struct *thread = &curr->thread;
19918
19919 show_ucode_info_early();
19920 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
19921 index 7c6f7d5..8cac382 100644
19922 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
19923 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
19924 @@ -1017,6 +1017,22 @@ static struct attribute *default_attrs[] = {
19925 };
19926
19927 #ifdef CONFIG_AMD_NB
19928 +static struct attribute *default_attrs_amd_nb[] = {
19929 + &type.attr,
19930 + &level.attr,
19931 + &coherency_line_size.attr,
19932 + &physical_line_partition.attr,
19933 + &ways_of_associativity.attr,
19934 + &number_of_sets.attr,
19935 + &size.attr,
19936 + &shared_cpu_map.attr,
19937 + &shared_cpu_list.attr,
19938 + NULL,
19939 + NULL,
19940 + NULL,
19941 + NULL
19942 +};
19943 +
19944 static struct attribute ** __cpuinit amd_l3_attrs(void)
19945 {
19946 static struct attribute **attrs;
19947 @@ -1027,18 +1043,7 @@ static struct attribute ** __cpuinit amd_l3_attrs(void)
19948
19949 n = ARRAY_SIZE(default_attrs);
19950
19951 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
19952 - n += 2;
19953 -
19954 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
19955 - n += 1;
19956 -
19957 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
19958 - if (attrs == NULL)
19959 - return attrs = default_attrs;
19960 -
19961 - for (n = 0; default_attrs[n]; n++)
19962 - attrs[n] = default_attrs[n];
19963 + attrs = default_attrs_amd_nb;
19964
19965 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
19966 attrs[n++] = &cache_disable_0.attr;
19967 @@ -1089,6 +1094,13 @@ static struct kobj_type ktype_cache = {
19968 .default_attrs = default_attrs,
19969 };
19970
19971 +#ifdef CONFIG_AMD_NB
19972 +static struct kobj_type ktype_cache_amd_nb = {
19973 + .sysfs_ops = &sysfs_ops,
19974 + .default_attrs = default_attrs_amd_nb,
19975 +};
19976 +#endif
19977 +
19978 static struct kobj_type ktype_percpu_entry = {
19979 .sysfs_ops = &sysfs_ops,
19980 };
19981 @@ -1154,20 +1166,26 @@ static int __cpuinit cache_add_dev(struct device *dev)
19982 return retval;
19983 }
19984
19985 +#ifdef CONFIG_AMD_NB
19986 + amd_l3_attrs();
19987 +#endif
19988 +
19989 for (i = 0; i < num_cache_leaves; i++) {
19990 + struct kobj_type *ktype;
19991 +
19992 this_object = INDEX_KOBJECT_PTR(cpu, i);
19993 this_object->cpu = cpu;
19994 this_object->index = i;
19995
19996 this_leaf = CPUID4_INFO_IDX(cpu, i);
19997
19998 - ktype_cache.default_attrs = default_attrs;
19999 + ktype = &ktype_cache;
20000 #ifdef CONFIG_AMD_NB
20001 if (this_leaf->base.nb)
20002 - ktype_cache.default_attrs = amd_l3_attrs();
20003 + ktype = &ktype_cache_amd_nb;
20004 #endif
20005 retval = kobject_init_and_add(&(this_object->kobj),
20006 - &ktype_cache,
20007 + ktype,
20008 per_cpu(ici_cache_kobject, cpu),
20009 "index%1lu", i);
20010 if (unlikely(retval)) {
20011 @@ -1222,7 +1240,7 @@ static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb,
20012 return NOTIFY_OK;
20013 }
20014
20015 -static struct notifier_block __cpuinitdata cacheinfo_cpu_notifier = {
20016 +static struct notifier_block cacheinfo_cpu_notifier = {
20017 .notifier_call = cacheinfo_cpu_callback,
20018 };
20019
20020 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
20021 index 9239504..b2471ce 100644
20022 --- a/arch/x86/kernel/cpu/mcheck/mce.c
20023 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
20024 @@ -45,6 +45,7 @@
20025 #include <asm/processor.h>
20026 #include <asm/mce.h>
20027 #include <asm/msr.h>
20028 +#include <asm/local.h>
20029
20030 #include "mce-internal.h"
20031
20032 @@ -246,7 +247,7 @@ static void print_mce(struct mce *m)
20033 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
20034 m->cs, m->ip);
20035
20036 - if (m->cs == __KERNEL_CS)
20037 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
20038 print_symbol("{%s}", m->ip);
20039 pr_cont("\n");
20040 }
20041 @@ -279,10 +280,10 @@ static void print_mce(struct mce *m)
20042
20043 #define PANIC_TIMEOUT 5 /* 5 seconds */
20044
20045 -static atomic_t mce_paniced;
20046 +static atomic_unchecked_t mce_paniced;
20047
20048 static int fake_panic;
20049 -static atomic_t mce_fake_paniced;
20050 +static atomic_unchecked_t mce_fake_paniced;
20051
20052 /* Panic in progress. Enable interrupts and wait for final IPI */
20053 static void wait_for_panic(void)
20054 @@ -306,7 +307,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
20055 /*
20056 * Make sure only one CPU runs in machine check panic
20057 */
20058 - if (atomic_inc_return(&mce_paniced) > 1)
20059 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
20060 wait_for_panic();
20061 barrier();
20062
20063 @@ -314,7 +315,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
20064 console_verbose();
20065 } else {
20066 /* Don't log too much for fake panic */
20067 - if (atomic_inc_return(&mce_fake_paniced) > 1)
20068 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
20069 return;
20070 }
20071 /* First print corrected ones that are still unlogged */
20072 @@ -353,7 +354,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
20073 if (!fake_panic) {
20074 if (panic_timeout == 0)
20075 panic_timeout = mca_cfg.panic_timeout;
20076 - panic(msg);
20077 + panic("%s", msg);
20078 } else
20079 pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg);
20080 }
20081 @@ -683,7 +684,7 @@ static int mce_timed_out(u64 *t)
20082 * might have been modified by someone else.
20083 */
20084 rmb();
20085 - if (atomic_read(&mce_paniced))
20086 + if (atomic_read_unchecked(&mce_paniced))
20087 wait_for_panic();
20088 if (!mca_cfg.monarch_timeout)
20089 goto out;
20090 @@ -1654,7 +1655,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
20091 }
20092
20093 /* Call the installed machine check handler for this CPU setup. */
20094 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
20095 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
20096 unexpected_machine_check;
20097
20098 /*
20099 @@ -1677,7 +1678,9 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
20100 return;
20101 }
20102
20103 + pax_open_kernel();
20104 machine_check_vector = do_machine_check;
20105 + pax_close_kernel();
20106
20107 __mcheck_cpu_init_generic();
20108 __mcheck_cpu_init_vendor(c);
20109 @@ -1691,7 +1694,7 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
20110 */
20111
20112 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
20113 -static int mce_chrdev_open_count; /* #times opened */
20114 +static local_t mce_chrdev_open_count; /* #times opened */
20115 static int mce_chrdev_open_exclu; /* already open exclusive? */
20116
20117 static int mce_chrdev_open(struct inode *inode, struct file *file)
20118 @@ -1699,7 +1702,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
20119 spin_lock(&mce_chrdev_state_lock);
20120
20121 if (mce_chrdev_open_exclu ||
20122 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
20123 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
20124 spin_unlock(&mce_chrdev_state_lock);
20125
20126 return -EBUSY;
20127 @@ -1707,7 +1710,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
20128
20129 if (file->f_flags & O_EXCL)
20130 mce_chrdev_open_exclu = 1;
20131 - mce_chrdev_open_count++;
20132 + local_inc(&mce_chrdev_open_count);
20133
20134 spin_unlock(&mce_chrdev_state_lock);
20135
20136 @@ -1718,7 +1721,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
20137 {
20138 spin_lock(&mce_chrdev_state_lock);
20139
20140 - mce_chrdev_open_count--;
20141 + local_dec(&mce_chrdev_open_count);
20142 mce_chrdev_open_exclu = 0;
20143
20144 spin_unlock(&mce_chrdev_state_lock);
20145 @@ -2364,7 +2367,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
20146 return NOTIFY_OK;
20147 }
20148
20149 -static struct notifier_block mce_cpu_notifier __cpuinitdata = {
20150 +static struct notifier_block mce_cpu_notifier = {
20151 .notifier_call = mce_cpu_callback,
20152 };
20153
20154 @@ -2374,7 +2377,7 @@ static __init void mce_init_banks(void)
20155
20156 for (i = 0; i < mca_cfg.banks; i++) {
20157 struct mce_bank *b = &mce_banks[i];
20158 - struct device_attribute *a = &b->attr;
20159 + device_attribute_no_const *a = &b->attr;
20160
20161 sysfs_attr_init(&a->attr);
20162 a->attr.name = b->attrname;
20163 @@ -2442,7 +2445,7 @@ struct dentry *mce_get_debugfs_dir(void)
20164 static void mce_reset(void)
20165 {
20166 cpu_missing = 0;
20167 - atomic_set(&mce_fake_paniced, 0);
20168 + atomic_set_unchecked(&mce_fake_paniced, 0);
20169 atomic_set(&mce_executing, 0);
20170 atomic_set(&mce_callin, 0);
20171 atomic_set(&global_nwo, 0);
20172 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
20173 index 1c044b1..37a2a43 100644
20174 --- a/arch/x86/kernel/cpu/mcheck/p5.c
20175 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
20176 @@ -11,6 +11,7 @@
20177 #include <asm/processor.h>
20178 #include <asm/mce.h>
20179 #include <asm/msr.h>
20180 +#include <asm/pgtable.h>
20181
20182 /* By default disabled */
20183 int mce_p5_enabled __read_mostly;
20184 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
20185 if (!cpu_has(c, X86_FEATURE_MCE))
20186 return;
20187
20188 + pax_open_kernel();
20189 machine_check_vector = pentium_machine_check;
20190 + pax_close_kernel();
20191 /* Make sure the vector pointer is visible before we enable MCEs: */
20192 wmb();
20193
20194 diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
20195 index 47a1870..8c019a7 100644
20196 --- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
20197 +++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
20198 @@ -288,7 +288,7 @@ thermal_throttle_cpu_callback(struct notifier_block *nfb,
20199 return notifier_from_errno(err);
20200 }
20201
20202 -static struct notifier_block thermal_throttle_cpu_notifier __cpuinitdata =
20203 +static struct notifier_block thermal_throttle_cpu_notifier =
20204 {
20205 .notifier_call = thermal_throttle_cpu_callback,
20206 };
20207 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
20208 index e9a701a..35317d6 100644
20209 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
20210 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
20211 @@ -10,6 +10,7 @@
20212 #include <asm/processor.h>
20213 #include <asm/mce.h>
20214 #include <asm/msr.h>
20215 +#include <asm/pgtable.h>
20216
20217 /* Machine check handler for WinChip C6: */
20218 static void winchip_machine_check(struct pt_regs *regs, long error_code)
20219 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
20220 {
20221 u32 lo, hi;
20222
20223 + pax_open_kernel();
20224 machine_check_vector = winchip_machine_check;
20225 + pax_close_kernel();
20226 /* Make sure the vector pointer is visible before we enable MCEs: */
20227 wmb();
20228
20229 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
20230 index ca22b73..9987afe 100644
20231 --- a/arch/x86/kernel/cpu/mtrr/main.c
20232 +++ b/arch/x86/kernel/cpu/mtrr/main.c
20233 @@ -62,7 +62,7 @@ static DEFINE_MUTEX(mtrr_mutex);
20234 u64 size_or_mask, size_and_mask;
20235 static bool mtrr_aps_delayed_init;
20236
20237 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
20238 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
20239
20240 const struct mtrr_ops *mtrr_if;
20241
20242 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
20243 index df5e41f..816c719 100644
20244 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
20245 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
20246 @@ -25,7 +25,7 @@ struct mtrr_ops {
20247 int (*validate_add_page)(unsigned long base, unsigned long size,
20248 unsigned int type);
20249 int (*have_wrcomb)(void);
20250 -};
20251 +} __do_const;
20252
20253 extern int generic_get_free_region(unsigned long base, unsigned long size,
20254 int replace_reg);
20255 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
20256 index 1025f3c..824f677 100644
20257 --- a/arch/x86/kernel/cpu/perf_event.c
20258 +++ b/arch/x86/kernel/cpu/perf_event.c
20259 @@ -1311,7 +1311,7 @@ static void __init pmu_check_apic(void)
20260 pr_info("no hardware sampling interrupt available.\n");
20261 }
20262
20263 -static struct attribute_group x86_pmu_format_group = {
20264 +static attribute_group_no_const x86_pmu_format_group = {
20265 .name = "format",
20266 .attrs = NULL,
20267 };
20268 @@ -1410,7 +1410,7 @@ static struct attribute *events_attr[] = {
20269 NULL,
20270 };
20271
20272 -static struct attribute_group x86_pmu_events_group = {
20273 +static attribute_group_no_const x86_pmu_events_group = {
20274 .name = "events",
20275 .attrs = events_attr,
20276 };
20277 @@ -1920,7 +1920,7 @@ static unsigned long get_segment_base(unsigned int segment)
20278 if (idx > GDT_ENTRIES)
20279 return 0;
20280
20281 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
20282 + desc = get_cpu_gdt_table(smp_processor_id());
20283 }
20284
20285 return get_desc_base(desc + idx);
20286 @@ -2010,7 +2010,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
20287 break;
20288
20289 perf_callchain_store(entry, frame.return_address);
20290 - fp = frame.next_frame;
20291 + fp = (const void __force_user *)frame.next_frame;
20292 }
20293 }
20294
20295 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
20296 index a9e2207..d70c83a 100644
20297 --- a/arch/x86/kernel/cpu/perf_event_intel.c
20298 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
20299 @@ -2022,10 +2022,10 @@ __init int intel_pmu_init(void)
20300 * v2 and above have a perf capabilities MSR
20301 */
20302 if (version > 1) {
20303 - u64 capabilities;
20304 + u64 capabilities = x86_pmu.intel_cap.capabilities;
20305
20306 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
20307 - x86_pmu.intel_cap.capabilities = capabilities;
20308 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
20309 + x86_pmu.intel_cap.capabilities = capabilities;
20310 }
20311
20312 intel_ds_init();
20313 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20314 index 8aac56b..588fb13 100644
20315 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20316 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20317 @@ -3093,7 +3093,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
20318 static int __init uncore_type_init(struct intel_uncore_type *type)
20319 {
20320 struct intel_uncore_pmu *pmus;
20321 - struct attribute_group *attr_group;
20322 + attribute_group_no_const *attr_group;
20323 struct attribute **attrs;
20324 int i, j;
20325
20326 @@ -3518,7 +3518,7 @@ static int
20327 return NOTIFY_OK;
20328 }
20329
20330 -static struct notifier_block uncore_cpu_nb __cpuinitdata = {
20331 +static struct notifier_block uncore_cpu_nb = {
20332 .notifier_call = uncore_cpu_notifier,
20333 /*
20334 * to migrate uncore events, our notifier should be executed
20335 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20336 index f952891..4722ad4 100644
20337 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20338 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20339 @@ -488,7 +488,7 @@ struct intel_uncore_box {
20340 struct uncore_event_desc {
20341 struct kobj_attribute attr;
20342 const char *config;
20343 -};
20344 +} __do_const;
20345
20346 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
20347 { \
20348 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
20349 index 1e4dbcf..b9a34c2 100644
20350 --- a/arch/x86/kernel/cpuid.c
20351 +++ b/arch/x86/kernel/cpuid.c
20352 @@ -171,7 +171,7 @@ static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb,
20353 return notifier_from_errno(err);
20354 }
20355
20356 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
20357 +static struct notifier_block cpuid_class_cpu_notifier =
20358 {
20359 .notifier_call = cpuid_class_cpu_callback,
20360 };
20361 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
20362 index 74467fe..18793d5 100644
20363 --- a/arch/x86/kernel/crash.c
20364 +++ b/arch/x86/kernel/crash.c
20365 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
20366 {
20367 #ifdef CONFIG_X86_32
20368 struct pt_regs fixed_regs;
20369 -#endif
20370
20371 -#ifdef CONFIG_X86_32
20372 - if (!user_mode_vm(regs)) {
20373 + if (!user_mode(regs)) {
20374 crash_fixup_ss_esp(&fixed_regs, regs);
20375 regs = &fixed_regs;
20376 }
20377 diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
20378 index afa64ad..dce67dd 100644
20379 --- a/arch/x86/kernel/crash_dump_64.c
20380 +++ b/arch/x86/kernel/crash_dump_64.c
20381 @@ -36,7 +36,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
20382 return -ENOMEM;
20383
20384 if (userbuf) {
20385 - if (copy_to_user(buf, vaddr + offset, csize)) {
20386 + if (copy_to_user((char __force_user *)buf, vaddr + offset, csize)) {
20387 iounmap(vaddr);
20388 return -EFAULT;
20389 }
20390 diff --git a/arch/x86/kernel/doublefault_32.c b/arch/x86/kernel/doublefault_32.c
20391 index 155a13f..1672b9b 100644
20392 --- a/arch/x86/kernel/doublefault_32.c
20393 +++ b/arch/x86/kernel/doublefault_32.c
20394 @@ -11,7 +11,7 @@
20395
20396 #define DOUBLEFAULT_STACKSIZE (1024)
20397 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
20398 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
20399 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
20400
20401 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
20402
20403 @@ -21,7 +21,7 @@ static void doublefault_fn(void)
20404 unsigned long gdt, tss;
20405
20406 native_store_gdt(&gdt_desc);
20407 - gdt = gdt_desc.address;
20408 + gdt = (unsigned long)gdt_desc.address;
20409
20410 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
20411
20412 @@ -58,10 +58,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
20413 /* 0x2 bit is always set */
20414 .flags = X86_EFLAGS_SF | 0x2,
20415 .sp = STACK_START,
20416 - .es = __USER_DS,
20417 + .es = __KERNEL_DS,
20418 .cs = __KERNEL_CS,
20419 .ss = __KERNEL_DS,
20420 - .ds = __USER_DS,
20421 + .ds = __KERNEL_DS,
20422 .fs = __KERNEL_PERCPU,
20423
20424 .__cr3 = __pa_nodebug(swapper_pg_dir),
20425 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
20426 index deb6421..76bbc12 100644
20427 --- a/arch/x86/kernel/dumpstack.c
20428 +++ b/arch/x86/kernel/dumpstack.c
20429 @@ -2,6 +2,9 @@
20430 * Copyright (C) 1991, 1992 Linus Torvalds
20431 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
20432 */
20433 +#ifdef CONFIG_GRKERNSEC_HIDESYM
20434 +#define __INCLUDED_BY_HIDESYM 1
20435 +#endif
20436 #include <linux/kallsyms.h>
20437 #include <linux/kprobes.h>
20438 #include <linux/uaccess.h>
20439 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
20440 static void
20441 print_ftrace_graph_addr(unsigned long addr, void *data,
20442 const struct stacktrace_ops *ops,
20443 - struct thread_info *tinfo, int *graph)
20444 + struct task_struct *task, int *graph)
20445 {
20446 - struct task_struct *task;
20447 unsigned long ret_addr;
20448 int index;
20449
20450 if (addr != (unsigned long)return_to_handler)
20451 return;
20452
20453 - task = tinfo->task;
20454 index = task->curr_ret_stack;
20455
20456 if (!task->ret_stack || index < *graph)
20457 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
20458 static inline void
20459 print_ftrace_graph_addr(unsigned long addr, void *data,
20460 const struct stacktrace_ops *ops,
20461 - struct thread_info *tinfo, int *graph)
20462 + struct task_struct *task, int *graph)
20463 { }
20464 #endif
20465
20466 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
20467 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
20468 */
20469
20470 -static inline int valid_stack_ptr(struct thread_info *tinfo,
20471 - void *p, unsigned int size, void *end)
20472 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
20473 {
20474 - void *t = tinfo;
20475 if (end) {
20476 if (p < end && p >= (end-THREAD_SIZE))
20477 return 1;
20478 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
20479 }
20480
20481 unsigned long
20482 -print_context_stack(struct thread_info *tinfo,
20483 +print_context_stack(struct task_struct *task, void *stack_start,
20484 unsigned long *stack, unsigned long bp,
20485 const struct stacktrace_ops *ops, void *data,
20486 unsigned long *end, int *graph)
20487 {
20488 struct stack_frame *frame = (struct stack_frame *)bp;
20489
20490 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
20491 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
20492 unsigned long addr;
20493
20494 addr = *stack;
20495 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
20496 } else {
20497 ops->address(data, addr, 0);
20498 }
20499 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
20500 + print_ftrace_graph_addr(addr, data, ops, task, graph);
20501 }
20502 stack++;
20503 }
20504 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
20505 EXPORT_SYMBOL_GPL(print_context_stack);
20506
20507 unsigned long
20508 -print_context_stack_bp(struct thread_info *tinfo,
20509 +print_context_stack_bp(struct task_struct *task, void *stack_start,
20510 unsigned long *stack, unsigned long bp,
20511 const struct stacktrace_ops *ops, void *data,
20512 unsigned long *end, int *graph)
20513 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
20514 struct stack_frame *frame = (struct stack_frame *)bp;
20515 unsigned long *ret_addr = &frame->return_address;
20516
20517 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
20518 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
20519 unsigned long addr = *ret_addr;
20520
20521 if (!__kernel_text_address(addr))
20522 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
20523 ops->address(data, addr, 1);
20524 frame = frame->next_frame;
20525 ret_addr = &frame->return_address;
20526 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
20527 + print_ftrace_graph_addr(addr, data, ops, task, graph);
20528 }
20529
20530 return (unsigned long)frame;
20531 @@ -150,7 +149,7 @@ static int print_trace_stack(void *data, char *name)
20532 static void print_trace_address(void *data, unsigned long addr, int reliable)
20533 {
20534 touch_nmi_watchdog();
20535 - printk(data);
20536 + printk("%s", (char *)data);
20537 printk_address(addr, reliable);
20538 }
20539
20540 @@ -219,6 +218,8 @@ unsigned __kprobes long oops_begin(void)
20541 }
20542 EXPORT_SYMBOL_GPL(oops_begin);
20543
20544 +extern void gr_handle_kernel_exploit(void);
20545 +
20546 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
20547 {
20548 if (regs && kexec_should_crash(current))
20549 @@ -240,7 +241,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
20550 panic("Fatal exception in interrupt");
20551 if (panic_on_oops)
20552 panic("Fatal exception");
20553 - do_exit(signr);
20554 +
20555 + gr_handle_kernel_exploit();
20556 +
20557 + do_group_exit(signr);
20558 }
20559
20560 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
20561 @@ -268,7 +272,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
20562 print_modules();
20563 show_regs(regs);
20564 #ifdef CONFIG_X86_32
20565 - if (user_mode_vm(regs)) {
20566 + if (user_mode(regs)) {
20567 sp = regs->sp;
20568 ss = regs->ss & 0xffff;
20569 } else {
20570 @@ -296,7 +300,7 @@ void die(const char *str, struct pt_regs *regs, long err)
20571 unsigned long flags = oops_begin();
20572 int sig = SIGSEGV;
20573
20574 - if (!user_mode_vm(regs))
20575 + if (!user_mode(regs))
20576 report_bug(regs->ip, regs);
20577
20578 if (__die(str, regs, err))
20579 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
20580 index f2a1770..540657f 100644
20581 --- a/arch/x86/kernel/dumpstack_32.c
20582 +++ b/arch/x86/kernel/dumpstack_32.c
20583 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20584 bp = stack_frame(task, regs);
20585
20586 for (;;) {
20587 - struct thread_info *context;
20588 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
20589
20590 - context = (struct thread_info *)
20591 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
20592 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
20593 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
20594
20595 - stack = (unsigned long *)context->previous_esp;
20596 - if (!stack)
20597 + if (stack_start == task_stack_page(task))
20598 break;
20599 + stack = *(unsigned long **)stack_start;
20600 if (ops->stack(data, "IRQ") < 0)
20601 break;
20602 touch_nmi_watchdog();
20603 @@ -87,27 +85,28 @@ void show_regs(struct pt_regs *regs)
20604 int i;
20605
20606 show_regs_print_info(KERN_EMERG);
20607 - __show_regs(regs, !user_mode_vm(regs));
20608 + __show_regs(regs, !user_mode(regs));
20609
20610 /*
20611 * When in-kernel, we also print out the stack and code at the
20612 * time of the fault..
20613 */
20614 - if (!user_mode_vm(regs)) {
20615 + if (!user_mode(regs)) {
20616 unsigned int code_prologue = code_bytes * 43 / 64;
20617 unsigned int code_len = code_bytes;
20618 unsigned char c;
20619 u8 *ip;
20620 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
20621
20622 pr_emerg("Stack:\n");
20623 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
20624
20625 pr_emerg("Code:");
20626
20627 - ip = (u8 *)regs->ip - code_prologue;
20628 + ip = (u8 *)regs->ip - code_prologue + cs_base;
20629 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
20630 /* try starting at IP */
20631 - ip = (u8 *)regs->ip;
20632 + ip = (u8 *)regs->ip + cs_base;
20633 code_len = code_len - code_prologue + 1;
20634 }
20635 for (i = 0; i < code_len; i++, ip++) {
20636 @@ -116,7 +115,7 @@ void show_regs(struct pt_regs *regs)
20637 pr_cont(" Bad EIP value.");
20638 break;
20639 }
20640 - if (ip == (u8 *)regs->ip)
20641 + if (ip == (u8 *)regs->ip + cs_base)
20642 pr_cont(" <%02x>", c);
20643 else
20644 pr_cont(" %02x", c);
20645 @@ -129,6 +128,7 @@ int is_valid_bugaddr(unsigned long ip)
20646 {
20647 unsigned short ud2;
20648
20649 + ip = ktla_ktva(ip);
20650 if (ip < PAGE_OFFSET)
20651 return 0;
20652 if (probe_kernel_address((unsigned short *)ip, ud2))
20653 @@ -136,3 +136,15 @@ int is_valid_bugaddr(unsigned long ip)
20654
20655 return ud2 == 0x0b0f;
20656 }
20657 +
20658 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20659 +void pax_check_alloca(unsigned long size)
20660 +{
20661 + unsigned long sp = (unsigned long)&sp, stack_left;
20662 +
20663 + /* all kernel stacks are of the same size */
20664 + stack_left = sp & (THREAD_SIZE - 1);
20665 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20666 +}
20667 +EXPORT_SYMBOL(pax_check_alloca);
20668 +#endif
20669 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
20670 index addb207..99635fa 100644
20671 --- a/arch/x86/kernel/dumpstack_64.c
20672 +++ b/arch/x86/kernel/dumpstack_64.c
20673 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20674 unsigned long *irq_stack_end =
20675 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
20676 unsigned used = 0;
20677 - struct thread_info *tinfo;
20678 int graph = 0;
20679 unsigned long dummy;
20680 + void *stack_start;
20681
20682 if (!task)
20683 task = current;
20684 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20685 * current stack address. If the stacks consist of nested
20686 * exceptions
20687 */
20688 - tinfo = task_thread_info(task);
20689 for (;;) {
20690 char *id;
20691 unsigned long *estack_end;
20692 +
20693 estack_end = in_exception_stack(cpu, (unsigned long)stack,
20694 &used, &id);
20695
20696 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20697 if (ops->stack(data, id) < 0)
20698 break;
20699
20700 - bp = ops->walk_stack(tinfo, stack, bp, ops,
20701 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
20702 data, estack_end, &graph);
20703 ops->stack(data, "<EOE>");
20704 /*
20705 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20706 * second-to-last pointer (index -2 to end) in the
20707 * exception stack:
20708 */
20709 + if ((u16)estack_end[-1] != __KERNEL_DS)
20710 + goto out;
20711 stack = (unsigned long *) estack_end[-2];
20712 continue;
20713 }
20714 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20715 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
20716 if (ops->stack(data, "IRQ") < 0)
20717 break;
20718 - bp = ops->walk_stack(tinfo, stack, bp,
20719 + bp = ops->walk_stack(task, irq_stack, stack, bp,
20720 ops, data, irq_stack_end, &graph);
20721 /*
20722 * We link to the next stack (which would be
20723 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20724 /*
20725 * This handles the process stack:
20726 */
20727 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
20728 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
20729 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
20730 +out:
20731 put_cpu();
20732 }
20733 EXPORT_SYMBOL(dump_trace);
20734 @@ -300,3 +304,50 @@ int is_valid_bugaddr(unsigned long ip)
20735
20736 return ud2 == 0x0b0f;
20737 }
20738 +
20739 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20740 +void pax_check_alloca(unsigned long size)
20741 +{
20742 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
20743 + unsigned cpu, used;
20744 + char *id;
20745 +
20746 + /* check the process stack first */
20747 + stack_start = (unsigned long)task_stack_page(current);
20748 + stack_end = stack_start + THREAD_SIZE;
20749 + if (likely(stack_start <= sp && sp < stack_end)) {
20750 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
20751 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20752 + return;
20753 + }
20754 +
20755 + cpu = get_cpu();
20756 +
20757 + /* check the irq stacks */
20758 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
20759 + stack_start = stack_end - IRQ_STACK_SIZE;
20760 + if (stack_start <= sp && sp < stack_end) {
20761 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
20762 + put_cpu();
20763 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20764 + return;
20765 + }
20766 +
20767 + /* check the exception stacks */
20768 + used = 0;
20769 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
20770 + stack_start = stack_end - EXCEPTION_STKSZ;
20771 + if (stack_end && stack_start <= sp && sp < stack_end) {
20772 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
20773 + put_cpu();
20774 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20775 + return;
20776 + }
20777 +
20778 + put_cpu();
20779 +
20780 + /* unknown stack */
20781 + BUG();
20782 +}
20783 +EXPORT_SYMBOL(pax_check_alloca);
20784 +#endif
20785 diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
20786 index d32abea..74daf4f 100644
20787 --- a/arch/x86/kernel/e820.c
20788 +++ b/arch/x86/kernel/e820.c
20789 @@ -800,8 +800,8 @@ unsigned long __init e820_end_of_low_ram_pfn(void)
20790
20791 static void early_panic(char *msg)
20792 {
20793 - early_printk(msg);
20794 - panic(msg);
20795 + early_printk("%s", msg);
20796 + panic("%s", msg);
20797 }
20798
20799 static int userdef __initdata;
20800 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
20801 index d15f575..d692043 100644
20802 --- a/arch/x86/kernel/early_printk.c
20803 +++ b/arch/x86/kernel/early_printk.c
20804 @@ -7,6 +7,7 @@
20805 #include <linux/pci_regs.h>
20806 #include <linux/pci_ids.h>
20807 #include <linux/errno.h>
20808 +#include <linux/sched.h>
20809 #include <asm/io.h>
20810 #include <asm/processor.h>
20811 #include <asm/fcntl.h>
20812 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
20813 index 8f3e2de..6b71e39 100644
20814 --- a/arch/x86/kernel/entry_32.S
20815 +++ b/arch/x86/kernel/entry_32.S
20816 @@ -177,13 +177,153 @@
20817 /*CFI_REL_OFFSET gs, PT_GS*/
20818 .endm
20819 .macro SET_KERNEL_GS reg
20820 +
20821 +#ifdef CONFIG_CC_STACKPROTECTOR
20822 movl $(__KERNEL_STACK_CANARY), \reg
20823 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20824 + movl $(__USER_DS), \reg
20825 +#else
20826 + xorl \reg, \reg
20827 +#endif
20828 +
20829 movl \reg, %gs
20830 .endm
20831
20832 #endif /* CONFIG_X86_32_LAZY_GS */
20833
20834 -.macro SAVE_ALL
20835 +.macro pax_enter_kernel
20836 +#ifdef CONFIG_PAX_KERNEXEC
20837 + call pax_enter_kernel
20838 +#endif
20839 +.endm
20840 +
20841 +.macro pax_exit_kernel
20842 +#ifdef CONFIG_PAX_KERNEXEC
20843 + call pax_exit_kernel
20844 +#endif
20845 +.endm
20846 +
20847 +#ifdef CONFIG_PAX_KERNEXEC
20848 +ENTRY(pax_enter_kernel)
20849 +#ifdef CONFIG_PARAVIRT
20850 + pushl %eax
20851 + pushl %ecx
20852 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
20853 + mov %eax, %esi
20854 +#else
20855 + mov %cr0, %esi
20856 +#endif
20857 + bts $16, %esi
20858 + jnc 1f
20859 + mov %cs, %esi
20860 + cmp $__KERNEL_CS, %esi
20861 + jz 3f
20862 + ljmp $__KERNEL_CS, $3f
20863 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
20864 +2:
20865 +#ifdef CONFIG_PARAVIRT
20866 + mov %esi, %eax
20867 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
20868 +#else
20869 + mov %esi, %cr0
20870 +#endif
20871 +3:
20872 +#ifdef CONFIG_PARAVIRT
20873 + popl %ecx
20874 + popl %eax
20875 +#endif
20876 + ret
20877 +ENDPROC(pax_enter_kernel)
20878 +
20879 +ENTRY(pax_exit_kernel)
20880 +#ifdef CONFIG_PARAVIRT
20881 + pushl %eax
20882 + pushl %ecx
20883 +#endif
20884 + mov %cs, %esi
20885 + cmp $__KERNEXEC_KERNEL_CS, %esi
20886 + jnz 2f
20887 +#ifdef CONFIG_PARAVIRT
20888 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
20889 + mov %eax, %esi
20890 +#else
20891 + mov %cr0, %esi
20892 +#endif
20893 + btr $16, %esi
20894 + ljmp $__KERNEL_CS, $1f
20895 +1:
20896 +#ifdef CONFIG_PARAVIRT
20897 + mov %esi, %eax
20898 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
20899 +#else
20900 + mov %esi, %cr0
20901 +#endif
20902 +2:
20903 +#ifdef CONFIG_PARAVIRT
20904 + popl %ecx
20905 + popl %eax
20906 +#endif
20907 + ret
20908 +ENDPROC(pax_exit_kernel)
20909 +#endif
20910 +
20911 + .macro pax_erase_kstack
20912 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20913 + call pax_erase_kstack
20914 +#endif
20915 + .endm
20916 +
20917 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20918 +/*
20919 + * ebp: thread_info
20920 + */
20921 +ENTRY(pax_erase_kstack)
20922 + pushl %edi
20923 + pushl %ecx
20924 + pushl %eax
20925 +
20926 + mov TI_lowest_stack(%ebp), %edi
20927 + mov $-0xBEEF, %eax
20928 + std
20929 +
20930 +1: mov %edi, %ecx
20931 + and $THREAD_SIZE_asm - 1, %ecx
20932 + shr $2, %ecx
20933 + repne scasl
20934 + jecxz 2f
20935 +
20936 + cmp $2*16, %ecx
20937 + jc 2f
20938 +
20939 + mov $2*16, %ecx
20940 + repe scasl
20941 + jecxz 2f
20942 + jne 1b
20943 +
20944 +2: cld
20945 + mov %esp, %ecx
20946 + sub %edi, %ecx
20947 +
20948 + cmp $THREAD_SIZE_asm, %ecx
20949 + jb 3f
20950 + ud2
20951 +3:
20952 +
20953 + shr $2, %ecx
20954 + rep stosl
20955 +
20956 + mov TI_task_thread_sp0(%ebp), %edi
20957 + sub $128, %edi
20958 + mov %edi, TI_lowest_stack(%ebp)
20959 +
20960 + popl %eax
20961 + popl %ecx
20962 + popl %edi
20963 + ret
20964 +ENDPROC(pax_erase_kstack)
20965 +#endif
20966 +
20967 +.macro __SAVE_ALL _DS
20968 cld
20969 PUSH_GS
20970 pushl_cfi %fs
20971 @@ -206,7 +346,7 @@
20972 CFI_REL_OFFSET ecx, 0
20973 pushl_cfi %ebx
20974 CFI_REL_OFFSET ebx, 0
20975 - movl $(__USER_DS), %edx
20976 + movl $\_DS, %edx
20977 movl %edx, %ds
20978 movl %edx, %es
20979 movl $(__KERNEL_PERCPU), %edx
20980 @@ -214,6 +354,15 @@
20981 SET_KERNEL_GS %edx
20982 .endm
20983
20984 +.macro SAVE_ALL
20985 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
20986 + __SAVE_ALL __KERNEL_DS
20987 + pax_enter_kernel
20988 +#else
20989 + __SAVE_ALL __USER_DS
20990 +#endif
20991 +.endm
20992 +
20993 .macro RESTORE_INT_REGS
20994 popl_cfi %ebx
20995 CFI_RESTORE ebx
20996 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
20997 popfl_cfi
20998 jmp syscall_exit
20999 CFI_ENDPROC
21000 -END(ret_from_fork)
21001 +ENDPROC(ret_from_fork)
21002
21003 ENTRY(ret_from_kernel_thread)
21004 CFI_STARTPROC
21005 @@ -344,7 +493,15 @@ ret_from_intr:
21006 andl $SEGMENT_RPL_MASK, %eax
21007 #endif
21008 cmpl $USER_RPL, %eax
21009 +
21010 +#ifdef CONFIG_PAX_KERNEXEC
21011 + jae resume_userspace
21012 +
21013 + pax_exit_kernel
21014 + jmp resume_kernel
21015 +#else
21016 jb resume_kernel # not returning to v8086 or userspace
21017 +#endif
21018
21019 ENTRY(resume_userspace)
21020 LOCKDEP_SYS_EXIT
21021 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
21022 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
21023 # int/exception return?
21024 jne work_pending
21025 - jmp restore_all
21026 -END(ret_from_exception)
21027 + jmp restore_all_pax
21028 +ENDPROC(ret_from_exception)
21029
21030 #ifdef CONFIG_PREEMPT
21031 ENTRY(resume_kernel)
21032 @@ -372,7 +529,7 @@ need_resched:
21033 jz restore_all
21034 call preempt_schedule_irq
21035 jmp need_resched
21036 -END(resume_kernel)
21037 +ENDPROC(resume_kernel)
21038 #endif
21039 CFI_ENDPROC
21040 /*
21041 @@ -406,30 +563,45 @@ sysenter_past_esp:
21042 /*CFI_REL_OFFSET cs, 0*/
21043 /*
21044 * Push current_thread_info()->sysenter_return to the stack.
21045 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
21046 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
21047 */
21048 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
21049 + pushl_cfi $0
21050 CFI_REL_OFFSET eip, 0
21051
21052 pushl_cfi %eax
21053 SAVE_ALL
21054 + GET_THREAD_INFO(%ebp)
21055 + movl TI_sysenter_return(%ebp),%ebp
21056 + movl %ebp,PT_EIP(%esp)
21057 ENABLE_INTERRUPTS(CLBR_NONE)
21058
21059 /*
21060 * Load the potential sixth argument from user stack.
21061 * Careful about security.
21062 */
21063 + movl PT_OLDESP(%esp),%ebp
21064 +
21065 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21066 + mov PT_OLDSS(%esp),%ds
21067 +1: movl %ds:(%ebp),%ebp
21068 + push %ss
21069 + pop %ds
21070 +#else
21071 cmpl $__PAGE_OFFSET-3,%ebp
21072 jae syscall_fault
21073 ASM_STAC
21074 1: movl (%ebp),%ebp
21075 ASM_CLAC
21076 +#endif
21077 +
21078 movl %ebp,PT_EBP(%esp)
21079 _ASM_EXTABLE(1b,syscall_fault)
21080
21081 GET_THREAD_INFO(%ebp)
21082
21083 +#ifdef CONFIG_PAX_RANDKSTACK
21084 + pax_erase_kstack
21085 +#endif
21086 +
21087 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
21088 jnz sysenter_audit
21089 sysenter_do_call:
21090 @@ -444,12 +616,24 @@ sysenter_do_call:
21091 testl $_TIF_ALLWORK_MASK, %ecx
21092 jne sysexit_audit
21093 sysenter_exit:
21094 +
21095 +#ifdef CONFIG_PAX_RANDKSTACK
21096 + pushl_cfi %eax
21097 + movl %esp, %eax
21098 + call pax_randomize_kstack
21099 + popl_cfi %eax
21100 +#endif
21101 +
21102 + pax_erase_kstack
21103 +
21104 /* if something modifies registers it must also disable sysexit */
21105 movl PT_EIP(%esp), %edx
21106 movl PT_OLDESP(%esp), %ecx
21107 xorl %ebp,%ebp
21108 TRACE_IRQS_ON
21109 1: mov PT_FS(%esp), %fs
21110 +2: mov PT_DS(%esp), %ds
21111 +3: mov PT_ES(%esp), %es
21112 PTGS_TO_GS
21113 ENABLE_INTERRUPTS_SYSEXIT
21114
21115 @@ -466,6 +650,9 @@ sysenter_audit:
21116 movl %eax,%edx /* 2nd arg: syscall number */
21117 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
21118 call __audit_syscall_entry
21119 +
21120 + pax_erase_kstack
21121 +
21122 pushl_cfi %ebx
21123 movl PT_EAX(%esp),%eax /* reload syscall number */
21124 jmp sysenter_do_call
21125 @@ -491,10 +678,16 @@ sysexit_audit:
21126
21127 CFI_ENDPROC
21128 .pushsection .fixup,"ax"
21129 -2: movl $0,PT_FS(%esp)
21130 +4: movl $0,PT_FS(%esp)
21131 + jmp 1b
21132 +5: movl $0,PT_DS(%esp)
21133 + jmp 1b
21134 +6: movl $0,PT_ES(%esp)
21135 jmp 1b
21136 .popsection
21137 - _ASM_EXTABLE(1b,2b)
21138 + _ASM_EXTABLE(1b,4b)
21139 + _ASM_EXTABLE(2b,5b)
21140 + _ASM_EXTABLE(3b,6b)
21141 PTGS_TO_GS_EX
21142 ENDPROC(ia32_sysenter_target)
21143
21144 @@ -509,6 +702,11 @@ ENTRY(system_call)
21145 pushl_cfi %eax # save orig_eax
21146 SAVE_ALL
21147 GET_THREAD_INFO(%ebp)
21148 +
21149 +#ifdef CONFIG_PAX_RANDKSTACK
21150 + pax_erase_kstack
21151 +#endif
21152 +
21153 # system call tracing in operation / emulation
21154 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
21155 jnz syscall_trace_entry
21156 @@ -527,6 +725,15 @@ syscall_exit:
21157 testl $_TIF_ALLWORK_MASK, %ecx # current->work
21158 jne syscall_exit_work
21159
21160 +restore_all_pax:
21161 +
21162 +#ifdef CONFIG_PAX_RANDKSTACK
21163 + movl %esp, %eax
21164 + call pax_randomize_kstack
21165 +#endif
21166 +
21167 + pax_erase_kstack
21168 +
21169 restore_all:
21170 TRACE_IRQS_IRET
21171 restore_all_notrace:
21172 @@ -583,14 +790,34 @@ ldt_ss:
21173 * compensating for the offset by changing to the ESPFIX segment with
21174 * a base address that matches for the difference.
21175 */
21176 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
21177 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
21178 mov %esp, %edx /* load kernel esp */
21179 mov PT_OLDESP(%esp), %eax /* load userspace esp */
21180 mov %dx, %ax /* eax: new kernel esp */
21181 sub %eax, %edx /* offset (low word is 0) */
21182 +#ifdef CONFIG_SMP
21183 + movl PER_CPU_VAR(cpu_number), %ebx
21184 + shll $PAGE_SHIFT_asm, %ebx
21185 + addl $cpu_gdt_table, %ebx
21186 +#else
21187 + movl $cpu_gdt_table, %ebx
21188 +#endif
21189 shr $16, %edx
21190 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
21191 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
21192 +
21193 +#ifdef CONFIG_PAX_KERNEXEC
21194 + mov %cr0, %esi
21195 + btr $16, %esi
21196 + mov %esi, %cr0
21197 +#endif
21198 +
21199 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
21200 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
21201 +
21202 +#ifdef CONFIG_PAX_KERNEXEC
21203 + bts $16, %esi
21204 + mov %esi, %cr0
21205 +#endif
21206 +
21207 pushl_cfi $__ESPFIX_SS
21208 pushl_cfi %eax /* new kernel esp */
21209 /* Disable interrupts, but do not irqtrace this section: we
21210 @@ -619,20 +846,18 @@ work_resched:
21211 movl TI_flags(%ebp), %ecx
21212 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
21213 # than syscall tracing?
21214 - jz restore_all
21215 + jz restore_all_pax
21216 testb $_TIF_NEED_RESCHED, %cl
21217 jnz work_resched
21218
21219 work_notifysig: # deal with pending signals and
21220 # notify-resume requests
21221 + movl %esp, %eax
21222 #ifdef CONFIG_VM86
21223 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
21224 - movl %esp, %eax
21225 jne work_notifysig_v86 # returning to kernel-space or
21226 # vm86-space
21227 1:
21228 -#else
21229 - movl %esp, %eax
21230 #endif
21231 TRACE_IRQS_ON
21232 ENABLE_INTERRUPTS(CLBR_NONE)
21233 @@ -653,7 +878,7 @@ work_notifysig_v86:
21234 movl %eax, %esp
21235 jmp 1b
21236 #endif
21237 -END(work_pending)
21238 +ENDPROC(work_pending)
21239
21240 # perform syscall exit tracing
21241 ALIGN
21242 @@ -661,11 +886,14 @@ syscall_trace_entry:
21243 movl $-ENOSYS,PT_EAX(%esp)
21244 movl %esp, %eax
21245 call syscall_trace_enter
21246 +
21247 + pax_erase_kstack
21248 +
21249 /* What it returned is what we'll actually use. */
21250 cmpl $(NR_syscalls), %eax
21251 jnae syscall_call
21252 jmp syscall_exit
21253 -END(syscall_trace_entry)
21254 +ENDPROC(syscall_trace_entry)
21255
21256 # perform syscall exit tracing
21257 ALIGN
21258 @@ -678,21 +906,25 @@ syscall_exit_work:
21259 movl %esp, %eax
21260 call syscall_trace_leave
21261 jmp resume_userspace
21262 -END(syscall_exit_work)
21263 +ENDPROC(syscall_exit_work)
21264 CFI_ENDPROC
21265
21266 RING0_INT_FRAME # can't unwind into user space anyway
21267 syscall_fault:
21268 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21269 + push %ss
21270 + pop %ds
21271 +#endif
21272 ASM_CLAC
21273 GET_THREAD_INFO(%ebp)
21274 movl $-EFAULT,PT_EAX(%esp)
21275 jmp resume_userspace
21276 -END(syscall_fault)
21277 +ENDPROC(syscall_fault)
21278
21279 syscall_badsys:
21280 movl $-ENOSYS,PT_EAX(%esp)
21281 jmp resume_userspace
21282 -END(syscall_badsys)
21283 +ENDPROC(syscall_badsys)
21284 CFI_ENDPROC
21285 /*
21286 * End of kprobes section
21287 @@ -708,8 +940,15 @@ END(syscall_badsys)
21288 * normal stack and adjusts ESP with the matching offset.
21289 */
21290 /* fixup the stack */
21291 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
21292 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
21293 +#ifdef CONFIG_SMP
21294 + movl PER_CPU_VAR(cpu_number), %ebx
21295 + shll $PAGE_SHIFT_asm, %ebx
21296 + addl $cpu_gdt_table, %ebx
21297 +#else
21298 + movl $cpu_gdt_table, %ebx
21299 +#endif
21300 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
21301 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
21302 shl $16, %eax
21303 addl %esp, %eax /* the adjusted stack pointer */
21304 pushl_cfi $__KERNEL_DS
21305 @@ -762,7 +1001,7 @@ vector=vector+1
21306 .endr
21307 2: jmp common_interrupt
21308 .endr
21309 -END(irq_entries_start)
21310 +ENDPROC(irq_entries_start)
21311
21312 .previous
21313 END(interrupt)
21314 @@ -813,7 +1052,7 @@ ENTRY(coprocessor_error)
21315 pushl_cfi $do_coprocessor_error
21316 jmp error_code
21317 CFI_ENDPROC
21318 -END(coprocessor_error)
21319 +ENDPROC(coprocessor_error)
21320
21321 ENTRY(simd_coprocessor_error)
21322 RING0_INT_FRAME
21323 @@ -826,7 +1065,7 @@ ENTRY(simd_coprocessor_error)
21324 .section .altinstructions,"a"
21325 altinstruction_entry 661b, 663f, X86_FEATURE_XMM, 662b-661b, 664f-663f
21326 .previous
21327 -.section .altinstr_replacement,"ax"
21328 +.section .altinstr_replacement,"a"
21329 663: pushl $do_simd_coprocessor_error
21330 664:
21331 .previous
21332 @@ -835,7 +1074,7 @@ ENTRY(simd_coprocessor_error)
21333 #endif
21334 jmp error_code
21335 CFI_ENDPROC
21336 -END(simd_coprocessor_error)
21337 +ENDPROC(simd_coprocessor_error)
21338
21339 ENTRY(device_not_available)
21340 RING0_INT_FRAME
21341 @@ -844,18 +1083,18 @@ ENTRY(device_not_available)
21342 pushl_cfi $do_device_not_available
21343 jmp error_code
21344 CFI_ENDPROC
21345 -END(device_not_available)
21346 +ENDPROC(device_not_available)
21347
21348 #ifdef CONFIG_PARAVIRT
21349 ENTRY(native_iret)
21350 iret
21351 _ASM_EXTABLE(native_iret, iret_exc)
21352 -END(native_iret)
21353 +ENDPROC(native_iret)
21354
21355 ENTRY(native_irq_enable_sysexit)
21356 sti
21357 sysexit
21358 -END(native_irq_enable_sysexit)
21359 +ENDPROC(native_irq_enable_sysexit)
21360 #endif
21361
21362 ENTRY(overflow)
21363 @@ -865,7 +1104,7 @@ ENTRY(overflow)
21364 pushl_cfi $do_overflow
21365 jmp error_code
21366 CFI_ENDPROC
21367 -END(overflow)
21368 +ENDPROC(overflow)
21369
21370 ENTRY(bounds)
21371 RING0_INT_FRAME
21372 @@ -874,7 +1113,7 @@ ENTRY(bounds)
21373 pushl_cfi $do_bounds
21374 jmp error_code
21375 CFI_ENDPROC
21376 -END(bounds)
21377 +ENDPROC(bounds)
21378
21379 ENTRY(invalid_op)
21380 RING0_INT_FRAME
21381 @@ -883,7 +1122,7 @@ ENTRY(invalid_op)
21382 pushl_cfi $do_invalid_op
21383 jmp error_code
21384 CFI_ENDPROC
21385 -END(invalid_op)
21386 +ENDPROC(invalid_op)
21387
21388 ENTRY(coprocessor_segment_overrun)
21389 RING0_INT_FRAME
21390 @@ -892,7 +1131,7 @@ ENTRY(coprocessor_segment_overrun)
21391 pushl_cfi $do_coprocessor_segment_overrun
21392 jmp error_code
21393 CFI_ENDPROC
21394 -END(coprocessor_segment_overrun)
21395 +ENDPROC(coprocessor_segment_overrun)
21396
21397 ENTRY(invalid_TSS)
21398 RING0_EC_FRAME
21399 @@ -900,7 +1139,7 @@ ENTRY(invalid_TSS)
21400 pushl_cfi $do_invalid_TSS
21401 jmp error_code
21402 CFI_ENDPROC
21403 -END(invalid_TSS)
21404 +ENDPROC(invalid_TSS)
21405
21406 ENTRY(segment_not_present)
21407 RING0_EC_FRAME
21408 @@ -908,7 +1147,7 @@ ENTRY(segment_not_present)
21409 pushl_cfi $do_segment_not_present
21410 jmp error_code
21411 CFI_ENDPROC
21412 -END(segment_not_present)
21413 +ENDPROC(segment_not_present)
21414
21415 ENTRY(stack_segment)
21416 RING0_EC_FRAME
21417 @@ -916,7 +1155,7 @@ ENTRY(stack_segment)
21418 pushl_cfi $do_stack_segment
21419 jmp error_code
21420 CFI_ENDPROC
21421 -END(stack_segment)
21422 +ENDPROC(stack_segment)
21423
21424 ENTRY(alignment_check)
21425 RING0_EC_FRAME
21426 @@ -924,7 +1163,7 @@ ENTRY(alignment_check)
21427 pushl_cfi $do_alignment_check
21428 jmp error_code
21429 CFI_ENDPROC
21430 -END(alignment_check)
21431 +ENDPROC(alignment_check)
21432
21433 ENTRY(divide_error)
21434 RING0_INT_FRAME
21435 @@ -933,7 +1172,7 @@ ENTRY(divide_error)
21436 pushl_cfi $do_divide_error
21437 jmp error_code
21438 CFI_ENDPROC
21439 -END(divide_error)
21440 +ENDPROC(divide_error)
21441
21442 #ifdef CONFIG_X86_MCE
21443 ENTRY(machine_check)
21444 @@ -943,7 +1182,7 @@ ENTRY(machine_check)
21445 pushl_cfi machine_check_vector
21446 jmp error_code
21447 CFI_ENDPROC
21448 -END(machine_check)
21449 +ENDPROC(machine_check)
21450 #endif
21451
21452 ENTRY(spurious_interrupt_bug)
21453 @@ -953,7 +1192,7 @@ ENTRY(spurious_interrupt_bug)
21454 pushl_cfi $do_spurious_interrupt_bug
21455 jmp error_code
21456 CFI_ENDPROC
21457 -END(spurious_interrupt_bug)
21458 +ENDPROC(spurious_interrupt_bug)
21459 /*
21460 * End of kprobes section
21461 */
21462 @@ -1063,7 +1302,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
21463
21464 ENTRY(mcount)
21465 ret
21466 -END(mcount)
21467 +ENDPROC(mcount)
21468
21469 ENTRY(ftrace_caller)
21470 cmpl $0, function_trace_stop
21471 @@ -1096,7 +1335,7 @@ ftrace_graph_call:
21472 .globl ftrace_stub
21473 ftrace_stub:
21474 ret
21475 -END(ftrace_caller)
21476 +ENDPROC(ftrace_caller)
21477
21478 ENTRY(ftrace_regs_caller)
21479 pushf /* push flags before compare (in cs location) */
21480 @@ -1197,7 +1436,7 @@ trace:
21481 popl %ecx
21482 popl %eax
21483 jmp ftrace_stub
21484 -END(mcount)
21485 +ENDPROC(mcount)
21486 #endif /* CONFIG_DYNAMIC_FTRACE */
21487 #endif /* CONFIG_FUNCTION_TRACER */
21488
21489 @@ -1215,7 +1454,7 @@ ENTRY(ftrace_graph_caller)
21490 popl %ecx
21491 popl %eax
21492 ret
21493 -END(ftrace_graph_caller)
21494 +ENDPROC(ftrace_graph_caller)
21495
21496 .globl return_to_handler
21497 return_to_handler:
21498 @@ -1271,15 +1510,18 @@ error_code:
21499 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
21500 REG_TO_PTGS %ecx
21501 SET_KERNEL_GS %ecx
21502 - movl $(__USER_DS), %ecx
21503 + movl $(__KERNEL_DS), %ecx
21504 movl %ecx, %ds
21505 movl %ecx, %es
21506 +
21507 + pax_enter_kernel
21508 +
21509 TRACE_IRQS_OFF
21510 movl %esp,%eax # pt_regs pointer
21511 call *%edi
21512 jmp ret_from_exception
21513 CFI_ENDPROC
21514 -END(page_fault)
21515 +ENDPROC(page_fault)
21516
21517 /*
21518 * Debug traps and NMI can happen at the one SYSENTER instruction
21519 @@ -1322,7 +1564,7 @@ debug_stack_correct:
21520 call do_debug
21521 jmp ret_from_exception
21522 CFI_ENDPROC
21523 -END(debug)
21524 +ENDPROC(debug)
21525
21526 /*
21527 * NMI is doubly nasty. It can happen _while_ we're handling
21528 @@ -1360,6 +1602,9 @@ nmi_stack_correct:
21529 xorl %edx,%edx # zero error code
21530 movl %esp,%eax # pt_regs pointer
21531 call do_nmi
21532 +
21533 + pax_exit_kernel
21534 +
21535 jmp restore_all_notrace
21536 CFI_ENDPROC
21537
21538 @@ -1396,12 +1641,15 @@ nmi_espfix_stack:
21539 FIXUP_ESPFIX_STACK # %eax == %esp
21540 xorl %edx,%edx # zero error code
21541 call do_nmi
21542 +
21543 + pax_exit_kernel
21544 +
21545 RESTORE_REGS
21546 lss 12+4(%esp), %esp # back to espfix stack
21547 CFI_ADJUST_CFA_OFFSET -24
21548 jmp irq_return
21549 CFI_ENDPROC
21550 -END(nmi)
21551 +ENDPROC(nmi)
21552
21553 ENTRY(int3)
21554 RING0_INT_FRAME
21555 @@ -1414,14 +1662,14 @@ ENTRY(int3)
21556 call do_int3
21557 jmp ret_from_exception
21558 CFI_ENDPROC
21559 -END(int3)
21560 +ENDPROC(int3)
21561
21562 ENTRY(general_protection)
21563 RING0_EC_FRAME
21564 pushl_cfi $do_general_protection
21565 jmp error_code
21566 CFI_ENDPROC
21567 -END(general_protection)
21568 +ENDPROC(general_protection)
21569
21570 #ifdef CONFIG_KVM_GUEST
21571 ENTRY(async_page_fault)
21572 @@ -1430,7 +1678,7 @@ ENTRY(async_page_fault)
21573 pushl_cfi $do_async_page_fault
21574 jmp error_code
21575 CFI_ENDPROC
21576 -END(async_page_fault)
21577 +ENDPROC(async_page_fault)
21578 #endif
21579
21580 /*
21581 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
21582 index 7272089..0b74104 100644
21583 --- a/arch/x86/kernel/entry_64.S
21584 +++ b/arch/x86/kernel/entry_64.S
21585 @@ -59,6 +59,8 @@
21586 #include <asm/context_tracking.h>
21587 #include <asm/smap.h>
21588 #include <linux/err.h>
21589 +#include <asm/pgtable.h>
21590 +#include <asm/alternative-asm.h>
21591
21592 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
21593 #include <linux/elf-em.h>
21594 @@ -80,8 +82,9 @@
21595 #ifdef CONFIG_DYNAMIC_FTRACE
21596
21597 ENTRY(function_hook)
21598 + pax_force_retaddr
21599 retq
21600 -END(function_hook)
21601 +ENDPROC(function_hook)
21602
21603 /* skip is set if stack has been adjusted */
21604 .macro ftrace_caller_setup skip=0
21605 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
21606 #endif
21607
21608 GLOBAL(ftrace_stub)
21609 + pax_force_retaddr
21610 retq
21611 -END(ftrace_caller)
21612 +ENDPROC(ftrace_caller)
21613
21614 ENTRY(ftrace_regs_caller)
21615 /* Save the current flags before compare (in SS location)*/
21616 @@ -191,7 +195,7 @@ ftrace_restore_flags:
21617 popfq
21618 jmp ftrace_stub
21619
21620 -END(ftrace_regs_caller)
21621 +ENDPROC(ftrace_regs_caller)
21622
21623
21624 #else /* ! CONFIG_DYNAMIC_FTRACE */
21625 @@ -212,6 +216,7 @@ ENTRY(function_hook)
21626 #endif
21627
21628 GLOBAL(ftrace_stub)
21629 + pax_force_retaddr
21630 retq
21631
21632 trace:
21633 @@ -225,12 +230,13 @@ trace:
21634 #endif
21635 subq $MCOUNT_INSN_SIZE, %rdi
21636
21637 + pax_force_fptr ftrace_trace_function
21638 call *ftrace_trace_function
21639
21640 MCOUNT_RESTORE_FRAME
21641
21642 jmp ftrace_stub
21643 -END(function_hook)
21644 +ENDPROC(function_hook)
21645 #endif /* CONFIG_DYNAMIC_FTRACE */
21646 #endif /* CONFIG_FUNCTION_TRACER */
21647
21648 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
21649
21650 MCOUNT_RESTORE_FRAME
21651
21652 + pax_force_retaddr
21653 retq
21654 -END(ftrace_graph_caller)
21655 +ENDPROC(ftrace_graph_caller)
21656
21657 GLOBAL(return_to_handler)
21658 subq $24, %rsp
21659 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
21660 movq 8(%rsp), %rdx
21661 movq (%rsp), %rax
21662 addq $24, %rsp
21663 + pax_force_fptr %rdi
21664 jmp *%rdi
21665 +ENDPROC(return_to_handler)
21666 #endif
21667
21668
21669 @@ -284,6 +293,430 @@ ENTRY(native_usergs_sysret64)
21670 ENDPROC(native_usergs_sysret64)
21671 #endif /* CONFIG_PARAVIRT */
21672
21673 + .macro ljmpq sel, off
21674 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
21675 + .byte 0x48; ljmp *1234f(%rip)
21676 + .pushsection .rodata
21677 + .align 16
21678 + 1234: .quad \off; .word \sel
21679 + .popsection
21680 +#else
21681 + pushq $\sel
21682 + pushq $\off
21683 + lretq
21684 +#endif
21685 + .endm
21686 +
21687 + .macro pax_enter_kernel
21688 + pax_set_fptr_mask
21689 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21690 + call pax_enter_kernel
21691 +#endif
21692 + .endm
21693 +
21694 + .macro pax_exit_kernel
21695 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21696 + call pax_exit_kernel
21697 +#endif
21698 +
21699 + .endm
21700 +
21701 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21702 +ENTRY(pax_enter_kernel)
21703 + pushq %rdi
21704 +
21705 +#ifdef CONFIG_PARAVIRT
21706 + PV_SAVE_REGS(CLBR_RDI)
21707 +#endif
21708 +
21709 +#ifdef CONFIG_PAX_KERNEXEC
21710 + GET_CR0_INTO_RDI
21711 + bts $16,%rdi
21712 + jnc 3f
21713 + mov %cs,%edi
21714 + cmp $__KERNEL_CS,%edi
21715 + jnz 2f
21716 +1:
21717 +#endif
21718 +
21719 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21720 + 661: jmp 111f
21721 + .pushsection .altinstr_replacement, "a"
21722 + 662: ASM_NOP2
21723 + .popsection
21724 + .pushsection .altinstructions, "a"
21725 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21726 + .popsection
21727 + GET_CR3_INTO_RDI
21728 + cmp $0,%dil
21729 + jnz 112f
21730 + mov $__KERNEL_DS,%edi
21731 + mov %edi,%ss
21732 + jmp 111f
21733 +112: cmp $1,%dil
21734 + jz 113f
21735 + ud2
21736 +113: sub $4097,%rdi
21737 + bts $63,%rdi
21738 + SET_RDI_INTO_CR3
21739 + mov $__UDEREF_KERNEL_DS,%edi
21740 + mov %edi,%ss
21741 +111:
21742 +#endif
21743 +
21744 +#ifdef CONFIG_PARAVIRT
21745 + PV_RESTORE_REGS(CLBR_RDI)
21746 +#endif
21747 +
21748 + popq %rdi
21749 + pax_force_retaddr
21750 + retq
21751 +
21752 +#ifdef CONFIG_PAX_KERNEXEC
21753 +2: ljmpq __KERNEL_CS,1b
21754 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
21755 +4: SET_RDI_INTO_CR0
21756 + jmp 1b
21757 +#endif
21758 +ENDPROC(pax_enter_kernel)
21759 +
21760 +ENTRY(pax_exit_kernel)
21761 + pushq %rdi
21762 +
21763 +#ifdef CONFIG_PARAVIRT
21764 + PV_SAVE_REGS(CLBR_RDI)
21765 +#endif
21766 +
21767 +#ifdef CONFIG_PAX_KERNEXEC
21768 + mov %cs,%rdi
21769 + cmp $__KERNEXEC_KERNEL_CS,%edi
21770 + jz 2f
21771 + GET_CR0_INTO_RDI
21772 + bts $16,%rdi
21773 + jnc 4f
21774 +1:
21775 +#endif
21776 +
21777 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21778 + 661: jmp 111f
21779 + .pushsection .altinstr_replacement, "a"
21780 + 662: ASM_NOP2
21781 + .popsection
21782 + .pushsection .altinstructions, "a"
21783 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21784 + .popsection
21785 + mov %ss,%edi
21786 + cmp $__UDEREF_KERNEL_DS,%edi
21787 + jnz 111f
21788 + GET_CR3_INTO_RDI
21789 + cmp $0,%dil
21790 + jz 112f
21791 + ud2
21792 +112: add $4097,%rdi
21793 + bts $63,%rdi
21794 + SET_RDI_INTO_CR3
21795 + mov $__KERNEL_DS,%edi
21796 + mov %edi,%ss
21797 +111:
21798 +#endif
21799 +
21800 +#ifdef CONFIG_PARAVIRT
21801 + PV_RESTORE_REGS(CLBR_RDI);
21802 +#endif
21803 +
21804 + popq %rdi
21805 + pax_force_retaddr
21806 + retq
21807 +
21808 +#ifdef CONFIG_PAX_KERNEXEC
21809 +2: GET_CR0_INTO_RDI
21810 + btr $16,%rdi
21811 + jnc 4f
21812 + ljmpq __KERNEL_CS,3f
21813 +3: SET_RDI_INTO_CR0
21814 + jmp 1b
21815 +4: ud2
21816 + jmp 4b
21817 +#endif
21818 +ENDPROC(pax_exit_kernel)
21819 +#endif
21820 +
21821 + .macro pax_enter_kernel_user
21822 + pax_set_fptr_mask
21823 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21824 + call pax_enter_kernel_user
21825 +#endif
21826 + .endm
21827 +
21828 + .macro pax_exit_kernel_user
21829 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21830 + call pax_exit_kernel_user
21831 +#endif
21832 +#ifdef CONFIG_PAX_RANDKSTACK
21833 + pushq %rax
21834 + pushq %r11
21835 + call pax_randomize_kstack
21836 + popq %r11
21837 + popq %rax
21838 +#endif
21839 + .endm
21840 +
21841 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21842 +ENTRY(pax_enter_kernel_user)
21843 + pushq %rdi
21844 + pushq %rbx
21845 +
21846 +#ifdef CONFIG_PARAVIRT
21847 + PV_SAVE_REGS(CLBR_RDI)
21848 +#endif
21849 +
21850 + 661: jmp 111f
21851 + .pushsection .altinstr_replacement, "a"
21852 + 662: ASM_NOP2
21853 + .popsection
21854 + .pushsection .altinstructions, "a"
21855 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21856 + .popsection
21857 + GET_CR3_INTO_RDI
21858 + cmp $1,%dil
21859 + jnz 4f
21860 + sub $4097,%rdi
21861 + bts $63,%rdi
21862 + SET_RDI_INTO_CR3
21863 + jmp 3f
21864 +111:
21865 +
21866 + GET_CR3_INTO_RDI
21867 + mov %rdi,%rbx
21868 + add $__START_KERNEL_map,%rbx
21869 + sub phys_base(%rip),%rbx
21870 +
21871 +#ifdef CONFIG_PARAVIRT
21872 + cmpl $0, pv_info+PARAVIRT_enabled
21873 + jz 1f
21874 + pushq %rdi
21875 + i = 0
21876 + .rept USER_PGD_PTRS
21877 + mov i*8(%rbx),%rsi
21878 + mov $0,%sil
21879 + lea i*8(%rbx),%rdi
21880 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
21881 + i = i + 1
21882 + .endr
21883 + popq %rdi
21884 + jmp 2f
21885 +1:
21886 +#endif
21887 +
21888 + i = 0
21889 + .rept USER_PGD_PTRS
21890 + movb $0,i*8(%rbx)
21891 + i = i + 1
21892 + .endr
21893 +
21894 +2: SET_RDI_INTO_CR3
21895 +
21896 +#ifdef CONFIG_PAX_KERNEXEC
21897 + GET_CR0_INTO_RDI
21898 + bts $16,%rdi
21899 + SET_RDI_INTO_CR0
21900 +#endif
21901 +
21902 +3:
21903 +
21904 +#ifdef CONFIG_PARAVIRT
21905 + PV_RESTORE_REGS(CLBR_RDI)
21906 +#endif
21907 +
21908 + popq %rbx
21909 + popq %rdi
21910 + pax_force_retaddr
21911 + retq
21912 +4: ud2
21913 +ENDPROC(pax_enter_kernel_user)
21914 +
21915 +ENTRY(pax_exit_kernel_user)
21916 + pushq %rdi
21917 + pushq %rbx
21918 +
21919 +#ifdef CONFIG_PARAVIRT
21920 + PV_SAVE_REGS(CLBR_RDI)
21921 +#endif
21922 +
21923 + GET_CR3_INTO_RDI
21924 + 661: jmp 1f
21925 + .pushsection .altinstr_replacement, "a"
21926 + 662: ASM_NOP2
21927 + .popsection
21928 + .pushsection .altinstructions, "a"
21929 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21930 + .popsection
21931 + cmp $0,%dil
21932 + jnz 3f
21933 + add $4097,%rdi
21934 + bts $63,%rdi
21935 + SET_RDI_INTO_CR3
21936 + jmp 2f
21937 +1:
21938 +
21939 + mov %rdi,%rbx
21940 +
21941 +#ifdef CONFIG_PAX_KERNEXEC
21942 + GET_CR0_INTO_RDI
21943 + btr $16,%rdi
21944 + jnc 3f
21945 + SET_RDI_INTO_CR0
21946 +#endif
21947 +
21948 + add $__START_KERNEL_map,%rbx
21949 + sub phys_base(%rip),%rbx
21950 +
21951 +#ifdef CONFIG_PARAVIRT
21952 + cmpl $0, pv_info+PARAVIRT_enabled
21953 + jz 1f
21954 + i = 0
21955 + .rept USER_PGD_PTRS
21956 + mov i*8(%rbx),%rsi
21957 + mov $0x67,%sil
21958 + lea i*8(%rbx),%rdi
21959 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
21960 + i = i + 1
21961 + .endr
21962 + jmp 2f
21963 +1:
21964 +#endif
21965 +
21966 + i = 0
21967 + .rept USER_PGD_PTRS
21968 + movb $0x67,i*8(%rbx)
21969 + i = i + 1
21970 + .endr
21971 +2:
21972 +
21973 +#ifdef CONFIG_PARAVIRT
21974 + PV_RESTORE_REGS(CLBR_RDI)
21975 +#endif
21976 +
21977 + popq %rbx
21978 + popq %rdi
21979 + pax_force_retaddr
21980 + retq
21981 +3: ud2
21982 +ENDPROC(pax_exit_kernel_user)
21983 +#endif
21984 +
21985 + .macro pax_enter_kernel_nmi
21986 + pax_set_fptr_mask
21987 +
21988 +#ifdef CONFIG_PAX_KERNEXEC
21989 + GET_CR0_INTO_RDI
21990 + bts $16,%rdi
21991 + jc 110f
21992 + SET_RDI_INTO_CR0
21993 + or $2,%ebx
21994 +110:
21995 +#endif
21996 +
21997 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21998 + 661: jmp 111f
21999 + .pushsection .altinstr_replacement, "a"
22000 + 662: ASM_NOP2
22001 + .popsection
22002 + .pushsection .altinstructions, "a"
22003 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
22004 + .popsection
22005 + GET_CR3_INTO_RDI
22006 + cmp $0,%dil
22007 + jz 111f
22008 + sub $4097,%rdi
22009 + or $4,%ebx
22010 + bts $63,%rdi
22011 + SET_RDI_INTO_CR3
22012 + mov $__UDEREF_KERNEL_DS,%edi
22013 + mov %edi,%ss
22014 +111:
22015 +#endif
22016 + .endm
22017 +
22018 + .macro pax_exit_kernel_nmi
22019 +#ifdef CONFIG_PAX_KERNEXEC
22020 + btr $1,%ebx
22021 + jnc 110f
22022 + GET_CR0_INTO_RDI
22023 + btr $16,%rdi
22024 + SET_RDI_INTO_CR0
22025 +110:
22026 +#endif
22027 +
22028 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22029 + btr $2,%ebx
22030 + jnc 111f
22031 + GET_CR3_INTO_RDI
22032 + add $4097,%rdi
22033 + bts $63,%rdi
22034 + SET_RDI_INTO_CR3
22035 + mov $__KERNEL_DS,%edi
22036 + mov %edi,%ss
22037 +111:
22038 +#endif
22039 + .endm
22040 +
22041 + .macro pax_erase_kstack
22042 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
22043 + call pax_erase_kstack
22044 +#endif
22045 + .endm
22046 +
22047 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
22048 +ENTRY(pax_erase_kstack)
22049 + pushq %rdi
22050 + pushq %rcx
22051 + pushq %rax
22052 + pushq %r11
22053 +
22054 + GET_THREAD_INFO(%r11)
22055 + mov TI_lowest_stack(%r11), %rdi
22056 + mov $-0xBEEF, %rax
22057 + std
22058 +
22059 +1: mov %edi, %ecx
22060 + and $THREAD_SIZE_asm - 1, %ecx
22061 + shr $3, %ecx
22062 + repne scasq
22063 + jecxz 2f
22064 +
22065 + cmp $2*8, %ecx
22066 + jc 2f
22067 +
22068 + mov $2*8, %ecx
22069 + repe scasq
22070 + jecxz 2f
22071 + jne 1b
22072 +
22073 +2: cld
22074 + mov %esp, %ecx
22075 + sub %edi, %ecx
22076 +
22077 + cmp $THREAD_SIZE_asm, %rcx
22078 + jb 3f
22079 + ud2
22080 +3:
22081 +
22082 + shr $3, %ecx
22083 + rep stosq
22084 +
22085 + mov TI_task_thread_sp0(%r11), %rdi
22086 + sub $256, %rdi
22087 + mov %rdi, TI_lowest_stack(%r11)
22088 +
22089 + popq %r11
22090 + popq %rax
22091 + popq %rcx
22092 + popq %rdi
22093 + pax_force_retaddr
22094 + ret
22095 +ENDPROC(pax_erase_kstack)
22096 +#endif
22097
22098 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
22099 #ifdef CONFIG_TRACE_IRQFLAGS
22100 @@ -375,8 +808,8 @@ ENDPROC(native_usergs_sysret64)
22101 .endm
22102
22103 .macro UNFAKE_STACK_FRAME
22104 - addq $8*6, %rsp
22105 - CFI_ADJUST_CFA_OFFSET -(6*8)
22106 + addq $8*6 + ARG_SKIP, %rsp
22107 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
22108 .endm
22109
22110 /*
22111 @@ -463,7 +896,7 @@ ENDPROC(native_usergs_sysret64)
22112 movq %rsp, %rsi
22113
22114 leaq -RBP(%rsp),%rdi /* arg1 for handler */
22115 - testl $3, CS-RBP(%rsi)
22116 + testb $3, CS-RBP(%rsi)
22117 je 1f
22118 SWAPGS
22119 /*
22120 @@ -498,9 +931,10 @@ ENTRY(save_rest)
22121 movq_cfi r15, R15+16
22122 movq %r11, 8(%rsp) /* return address */
22123 FIXUP_TOP_OF_STACK %r11, 16
22124 + pax_force_retaddr
22125 ret
22126 CFI_ENDPROC
22127 -END(save_rest)
22128 +ENDPROC(save_rest)
22129
22130 /* save complete stack frame */
22131 .pushsection .kprobes.text, "ax"
22132 @@ -529,9 +963,10 @@ ENTRY(save_paranoid)
22133 js 1f /* negative -> in kernel */
22134 SWAPGS
22135 xorl %ebx,%ebx
22136 -1: ret
22137 +1: pax_force_retaddr_bts
22138 + ret
22139 CFI_ENDPROC
22140 -END(save_paranoid)
22141 +ENDPROC(save_paranoid)
22142 .popsection
22143
22144 /*
22145 @@ -553,7 +988,7 @@ ENTRY(ret_from_fork)
22146
22147 RESTORE_REST
22148
22149 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
22150 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
22151 jz 1f
22152
22153 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
22154 @@ -571,7 +1006,7 @@ ENTRY(ret_from_fork)
22155 RESTORE_REST
22156 jmp int_ret_from_sys_call
22157 CFI_ENDPROC
22158 -END(ret_from_fork)
22159 +ENDPROC(ret_from_fork)
22160
22161 /*
22162 * System call entry. Up to 6 arguments in registers are supported.
22163 @@ -608,7 +1043,7 @@ END(ret_from_fork)
22164 ENTRY(system_call)
22165 CFI_STARTPROC simple
22166 CFI_SIGNAL_FRAME
22167 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
22168 + CFI_DEF_CFA rsp,0
22169 CFI_REGISTER rip,rcx
22170 /*CFI_REGISTER rflags,r11*/
22171 SWAPGS_UNSAFE_STACK
22172 @@ -621,16 +1056,23 @@ GLOBAL(system_call_after_swapgs)
22173
22174 movq %rsp,PER_CPU_VAR(old_rsp)
22175 movq PER_CPU_VAR(kernel_stack),%rsp
22176 + SAVE_ARGS 8*6,0
22177 + pax_enter_kernel_user
22178 +
22179 +#ifdef CONFIG_PAX_RANDKSTACK
22180 + pax_erase_kstack
22181 +#endif
22182 +
22183 /*
22184 * No need to follow this irqs off/on section - it's straight
22185 * and short:
22186 */
22187 ENABLE_INTERRUPTS(CLBR_NONE)
22188 - SAVE_ARGS 8,0
22189 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
22190 movq %rcx,RIP-ARGOFFSET(%rsp)
22191 CFI_REL_OFFSET rip,RIP-ARGOFFSET
22192 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
22193 + GET_THREAD_INFO(%rcx)
22194 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
22195 jnz tracesys
22196 system_call_fastpath:
22197 #if __SYSCALL_MASK == ~0
22198 @@ -640,7 +1082,7 @@ system_call_fastpath:
22199 cmpl $__NR_syscall_max,%eax
22200 #endif
22201 ja badsys
22202 - movq %r10,%rcx
22203 + movq R10-ARGOFFSET(%rsp),%rcx
22204 call *sys_call_table(,%rax,8) # XXX: rip relative
22205 movq %rax,RAX-ARGOFFSET(%rsp)
22206 /*
22207 @@ -654,10 +1096,13 @@ sysret_check:
22208 LOCKDEP_SYS_EXIT
22209 DISABLE_INTERRUPTS(CLBR_NONE)
22210 TRACE_IRQS_OFF
22211 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
22212 + GET_THREAD_INFO(%rcx)
22213 + movl TI_flags(%rcx),%edx
22214 andl %edi,%edx
22215 jnz sysret_careful
22216 CFI_REMEMBER_STATE
22217 + pax_exit_kernel_user
22218 + pax_erase_kstack
22219 /*
22220 * sysretq will re-enable interrupts:
22221 */
22222 @@ -709,14 +1154,18 @@ badsys:
22223 * jump back to the normal fast path.
22224 */
22225 auditsys:
22226 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
22227 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
22228 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
22229 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
22230 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
22231 movq %rax,%rsi /* 2nd arg: syscall number */
22232 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
22233 call __audit_syscall_entry
22234 +
22235 + pax_erase_kstack
22236 +
22237 LOAD_ARGS 0 /* reload call-clobbered registers */
22238 + pax_set_fptr_mask
22239 jmp system_call_fastpath
22240
22241 /*
22242 @@ -737,7 +1186,7 @@ sysret_audit:
22243 /* Do syscall tracing */
22244 tracesys:
22245 #ifdef CONFIG_AUDITSYSCALL
22246 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
22247 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
22248 jz auditsys
22249 #endif
22250 SAVE_REST
22251 @@ -745,12 +1194,16 @@ tracesys:
22252 FIXUP_TOP_OF_STACK %rdi
22253 movq %rsp,%rdi
22254 call syscall_trace_enter
22255 +
22256 + pax_erase_kstack
22257 +
22258 /*
22259 * Reload arg registers from stack in case ptrace changed them.
22260 * We don't reload %rax because syscall_trace_enter() returned
22261 * the value it wants us to use in the table lookup.
22262 */
22263 LOAD_ARGS ARGOFFSET, 1
22264 + pax_set_fptr_mask
22265 RESTORE_REST
22266 #if __SYSCALL_MASK == ~0
22267 cmpq $__NR_syscall_max,%rax
22268 @@ -759,7 +1212,7 @@ tracesys:
22269 cmpl $__NR_syscall_max,%eax
22270 #endif
22271 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
22272 - movq %r10,%rcx /* fixup for C */
22273 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
22274 call *sys_call_table(,%rax,8)
22275 movq %rax,RAX-ARGOFFSET(%rsp)
22276 /* Use IRET because user could have changed frame */
22277 @@ -780,7 +1233,9 @@ GLOBAL(int_with_check)
22278 andl %edi,%edx
22279 jnz int_careful
22280 andl $~TS_COMPAT,TI_status(%rcx)
22281 - jmp retint_swapgs
22282 + pax_exit_kernel_user
22283 + pax_erase_kstack
22284 + jmp retint_swapgs_pax
22285
22286 /* Either reschedule or signal or syscall exit tracking needed. */
22287 /* First do a reschedule test. */
22288 @@ -826,7 +1281,7 @@ int_restore_rest:
22289 TRACE_IRQS_OFF
22290 jmp int_with_check
22291 CFI_ENDPROC
22292 -END(system_call)
22293 +ENDPROC(system_call)
22294
22295 .macro FORK_LIKE func
22296 ENTRY(stub_\func)
22297 @@ -839,9 +1294,10 @@ ENTRY(stub_\func)
22298 DEFAULT_FRAME 0 8 /* offset 8: return address */
22299 call sys_\func
22300 RESTORE_TOP_OF_STACK %r11, 8
22301 + pax_force_retaddr
22302 ret $REST_SKIP /* pop extended registers */
22303 CFI_ENDPROC
22304 -END(stub_\func)
22305 +ENDPROC(stub_\func)
22306 .endm
22307
22308 .macro FIXED_FRAME label,func
22309 @@ -851,9 +1307,10 @@ ENTRY(\label)
22310 FIXUP_TOP_OF_STACK %r11, 8-ARGOFFSET
22311 call \func
22312 RESTORE_TOP_OF_STACK %r11, 8-ARGOFFSET
22313 + pax_force_retaddr
22314 ret
22315 CFI_ENDPROC
22316 -END(\label)
22317 +ENDPROC(\label)
22318 .endm
22319
22320 FORK_LIKE clone
22321 @@ -870,9 +1327,10 @@ ENTRY(ptregscall_common)
22322 movq_cfi_restore R12+8, r12
22323 movq_cfi_restore RBP+8, rbp
22324 movq_cfi_restore RBX+8, rbx
22325 + pax_force_retaddr
22326 ret $REST_SKIP /* pop extended registers */
22327 CFI_ENDPROC
22328 -END(ptregscall_common)
22329 +ENDPROC(ptregscall_common)
22330
22331 ENTRY(stub_execve)
22332 CFI_STARTPROC
22333 @@ -885,7 +1343,7 @@ ENTRY(stub_execve)
22334 RESTORE_REST
22335 jmp int_ret_from_sys_call
22336 CFI_ENDPROC
22337 -END(stub_execve)
22338 +ENDPROC(stub_execve)
22339
22340 /*
22341 * sigreturn is special because it needs to restore all registers on return.
22342 @@ -902,7 +1360,7 @@ ENTRY(stub_rt_sigreturn)
22343 RESTORE_REST
22344 jmp int_ret_from_sys_call
22345 CFI_ENDPROC
22346 -END(stub_rt_sigreturn)
22347 +ENDPROC(stub_rt_sigreturn)
22348
22349 #ifdef CONFIG_X86_X32_ABI
22350 ENTRY(stub_x32_rt_sigreturn)
22351 @@ -916,7 +1374,7 @@ ENTRY(stub_x32_rt_sigreturn)
22352 RESTORE_REST
22353 jmp int_ret_from_sys_call
22354 CFI_ENDPROC
22355 -END(stub_x32_rt_sigreturn)
22356 +ENDPROC(stub_x32_rt_sigreturn)
22357
22358 ENTRY(stub_x32_execve)
22359 CFI_STARTPROC
22360 @@ -930,7 +1388,7 @@ ENTRY(stub_x32_execve)
22361 RESTORE_REST
22362 jmp int_ret_from_sys_call
22363 CFI_ENDPROC
22364 -END(stub_x32_execve)
22365 +ENDPROC(stub_x32_execve)
22366
22367 #endif
22368
22369 @@ -967,7 +1425,7 @@ vector=vector+1
22370 2: jmp common_interrupt
22371 .endr
22372 CFI_ENDPROC
22373 -END(irq_entries_start)
22374 +ENDPROC(irq_entries_start)
22375
22376 .previous
22377 END(interrupt)
22378 @@ -987,6 +1445,16 @@ END(interrupt)
22379 subq $ORIG_RAX-RBP, %rsp
22380 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
22381 SAVE_ARGS_IRQ
22382 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22383 + testb $3, CS(%rdi)
22384 + jnz 1f
22385 + pax_enter_kernel
22386 + jmp 2f
22387 +1: pax_enter_kernel_user
22388 +2:
22389 +#else
22390 + pax_enter_kernel
22391 +#endif
22392 call \func
22393 .endm
22394
22395 @@ -1019,7 +1487,7 @@ ret_from_intr:
22396
22397 exit_intr:
22398 GET_THREAD_INFO(%rcx)
22399 - testl $3,CS-ARGOFFSET(%rsp)
22400 + testb $3,CS-ARGOFFSET(%rsp)
22401 je retint_kernel
22402
22403 /* Interrupt came from user space */
22404 @@ -1041,12 +1509,16 @@ retint_swapgs: /* return to user-space */
22405 * The iretq could re-enable interrupts:
22406 */
22407 DISABLE_INTERRUPTS(CLBR_ANY)
22408 + pax_exit_kernel_user
22409 +retint_swapgs_pax:
22410 TRACE_IRQS_IRETQ
22411 SWAPGS
22412 jmp restore_args
22413
22414 retint_restore_args: /* return to kernel space */
22415 DISABLE_INTERRUPTS(CLBR_ANY)
22416 + pax_exit_kernel
22417 + pax_force_retaddr (RIP-ARGOFFSET)
22418 /*
22419 * The iretq could re-enable interrupts:
22420 */
22421 @@ -1129,7 +1601,7 @@ ENTRY(retint_kernel)
22422 #endif
22423
22424 CFI_ENDPROC
22425 -END(common_interrupt)
22426 +ENDPROC(common_interrupt)
22427 /*
22428 * End of kprobes section
22429 */
22430 @@ -1147,7 +1619,7 @@ ENTRY(\sym)
22431 interrupt \do_sym
22432 jmp ret_from_intr
22433 CFI_ENDPROC
22434 -END(\sym)
22435 +ENDPROC(\sym)
22436 .endm
22437
22438 #ifdef CONFIG_SMP
22439 @@ -1208,12 +1680,22 @@ ENTRY(\sym)
22440 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22441 call error_entry
22442 DEFAULT_FRAME 0
22443 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22444 + testb $3, CS(%rsp)
22445 + jnz 1f
22446 + pax_enter_kernel
22447 + jmp 2f
22448 +1: pax_enter_kernel_user
22449 +2:
22450 +#else
22451 + pax_enter_kernel
22452 +#endif
22453 movq %rsp,%rdi /* pt_regs pointer */
22454 xorl %esi,%esi /* no error code */
22455 call \do_sym
22456 jmp error_exit /* %ebx: no swapgs flag */
22457 CFI_ENDPROC
22458 -END(\sym)
22459 +ENDPROC(\sym)
22460 .endm
22461
22462 .macro paranoidzeroentry sym do_sym
22463 @@ -1226,15 +1708,25 @@ ENTRY(\sym)
22464 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22465 call save_paranoid
22466 TRACE_IRQS_OFF
22467 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22468 + testb $3, CS(%rsp)
22469 + jnz 1f
22470 + pax_enter_kernel
22471 + jmp 2f
22472 +1: pax_enter_kernel_user
22473 +2:
22474 +#else
22475 + pax_enter_kernel
22476 +#endif
22477 movq %rsp,%rdi /* pt_regs pointer */
22478 xorl %esi,%esi /* no error code */
22479 call \do_sym
22480 jmp paranoid_exit /* %ebx: no swapgs flag */
22481 CFI_ENDPROC
22482 -END(\sym)
22483 +ENDPROC(\sym)
22484 .endm
22485
22486 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
22487 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
22488 .macro paranoidzeroentry_ist sym do_sym ist
22489 ENTRY(\sym)
22490 INTR_FRAME
22491 @@ -1245,14 +1737,30 @@ ENTRY(\sym)
22492 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22493 call save_paranoid
22494 TRACE_IRQS_OFF_DEBUG
22495 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22496 + testb $3, CS(%rsp)
22497 + jnz 1f
22498 + pax_enter_kernel
22499 + jmp 2f
22500 +1: pax_enter_kernel_user
22501 +2:
22502 +#else
22503 + pax_enter_kernel
22504 +#endif
22505 movq %rsp,%rdi /* pt_regs pointer */
22506 xorl %esi,%esi /* no error code */
22507 +#ifdef CONFIG_SMP
22508 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
22509 + lea init_tss(%r12), %r12
22510 +#else
22511 + lea init_tss(%rip), %r12
22512 +#endif
22513 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
22514 call \do_sym
22515 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
22516 jmp paranoid_exit /* %ebx: no swapgs flag */
22517 CFI_ENDPROC
22518 -END(\sym)
22519 +ENDPROC(\sym)
22520 .endm
22521
22522 .macro errorentry sym do_sym
22523 @@ -1264,13 +1772,23 @@ ENTRY(\sym)
22524 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22525 call error_entry
22526 DEFAULT_FRAME 0
22527 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22528 + testb $3, CS(%rsp)
22529 + jnz 1f
22530 + pax_enter_kernel
22531 + jmp 2f
22532 +1: pax_enter_kernel_user
22533 +2:
22534 +#else
22535 + pax_enter_kernel
22536 +#endif
22537 movq %rsp,%rdi /* pt_regs pointer */
22538 movq ORIG_RAX(%rsp),%rsi /* get error code */
22539 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
22540 call \do_sym
22541 jmp error_exit /* %ebx: no swapgs flag */
22542 CFI_ENDPROC
22543 -END(\sym)
22544 +ENDPROC(\sym)
22545 .endm
22546
22547 /* error code is on the stack already */
22548 @@ -1284,13 +1802,23 @@ ENTRY(\sym)
22549 call save_paranoid
22550 DEFAULT_FRAME 0
22551 TRACE_IRQS_OFF
22552 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22553 + testb $3, CS(%rsp)
22554 + jnz 1f
22555 + pax_enter_kernel
22556 + jmp 2f
22557 +1: pax_enter_kernel_user
22558 +2:
22559 +#else
22560 + pax_enter_kernel
22561 +#endif
22562 movq %rsp,%rdi /* pt_regs pointer */
22563 movq ORIG_RAX(%rsp),%rsi /* get error code */
22564 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
22565 call \do_sym
22566 jmp paranoid_exit /* %ebx: no swapgs flag */
22567 CFI_ENDPROC
22568 -END(\sym)
22569 +ENDPROC(\sym)
22570 .endm
22571
22572 zeroentry divide_error do_divide_error
22573 @@ -1320,9 +1848,10 @@ gs_change:
22574 2: mfence /* workaround */
22575 SWAPGS
22576 popfq_cfi
22577 + pax_force_retaddr
22578 ret
22579 CFI_ENDPROC
22580 -END(native_load_gs_index)
22581 +ENDPROC(native_load_gs_index)
22582
22583 _ASM_EXTABLE(gs_change,bad_gs)
22584 .section .fixup,"ax"
22585 @@ -1350,9 +1879,10 @@ ENTRY(call_softirq)
22586 CFI_DEF_CFA_REGISTER rsp
22587 CFI_ADJUST_CFA_OFFSET -8
22588 decl PER_CPU_VAR(irq_count)
22589 + pax_force_retaddr
22590 ret
22591 CFI_ENDPROC
22592 -END(call_softirq)
22593 +ENDPROC(call_softirq)
22594
22595 #ifdef CONFIG_XEN
22596 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
22597 @@ -1390,7 +1920,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
22598 decl PER_CPU_VAR(irq_count)
22599 jmp error_exit
22600 CFI_ENDPROC
22601 -END(xen_do_hypervisor_callback)
22602 +ENDPROC(xen_do_hypervisor_callback)
22603
22604 /*
22605 * Hypervisor uses this for application faults while it executes.
22606 @@ -1449,7 +1979,7 @@ ENTRY(xen_failsafe_callback)
22607 SAVE_ALL
22608 jmp error_exit
22609 CFI_ENDPROC
22610 -END(xen_failsafe_callback)
22611 +ENDPROC(xen_failsafe_callback)
22612
22613 apicinterrupt HYPERVISOR_CALLBACK_VECTOR \
22614 xen_hvm_callback_vector xen_evtchn_do_upcall
22615 @@ -1501,18 +2031,33 @@ ENTRY(paranoid_exit)
22616 DEFAULT_FRAME
22617 DISABLE_INTERRUPTS(CLBR_NONE)
22618 TRACE_IRQS_OFF_DEBUG
22619 - testl %ebx,%ebx /* swapgs needed? */
22620 + testl $1,%ebx /* swapgs needed? */
22621 jnz paranoid_restore
22622 - testl $3,CS(%rsp)
22623 + testb $3,CS(%rsp)
22624 jnz paranoid_userspace
22625 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22626 + pax_exit_kernel
22627 + TRACE_IRQS_IRETQ 0
22628 + SWAPGS_UNSAFE_STACK
22629 + RESTORE_ALL 8
22630 + pax_force_retaddr_bts
22631 + jmp irq_return
22632 +#endif
22633 paranoid_swapgs:
22634 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22635 + pax_exit_kernel_user
22636 +#else
22637 + pax_exit_kernel
22638 +#endif
22639 TRACE_IRQS_IRETQ 0
22640 SWAPGS_UNSAFE_STACK
22641 RESTORE_ALL 8
22642 jmp irq_return
22643 paranoid_restore:
22644 + pax_exit_kernel
22645 TRACE_IRQS_IRETQ_DEBUG 0
22646 RESTORE_ALL 8
22647 + pax_force_retaddr_bts
22648 jmp irq_return
22649 paranoid_userspace:
22650 GET_THREAD_INFO(%rcx)
22651 @@ -1541,7 +2086,7 @@ paranoid_schedule:
22652 TRACE_IRQS_OFF
22653 jmp paranoid_userspace
22654 CFI_ENDPROC
22655 -END(paranoid_exit)
22656 +ENDPROC(paranoid_exit)
22657
22658 /*
22659 * Exception entry point. This expects an error code/orig_rax on the stack.
22660 @@ -1568,12 +2113,13 @@ ENTRY(error_entry)
22661 movq_cfi r14, R14+8
22662 movq_cfi r15, R15+8
22663 xorl %ebx,%ebx
22664 - testl $3,CS+8(%rsp)
22665 + testb $3,CS+8(%rsp)
22666 je error_kernelspace
22667 error_swapgs:
22668 SWAPGS
22669 error_sti:
22670 TRACE_IRQS_OFF
22671 + pax_force_retaddr_bts
22672 ret
22673
22674 /*
22675 @@ -1600,7 +2146,7 @@ bstep_iret:
22676 movq %rcx,RIP+8(%rsp)
22677 jmp error_swapgs
22678 CFI_ENDPROC
22679 -END(error_entry)
22680 +ENDPROC(error_entry)
22681
22682
22683 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
22684 @@ -1611,7 +2157,7 @@ ENTRY(error_exit)
22685 DISABLE_INTERRUPTS(CLBR_NONE)
22686 TRACE_IRQS_OFF
22687 GET_THREAD_INFO(%rcx)
22688 - testl %eax,%eax
22689 + testl $1,%eax
22690 jne retint_kernel
22691 LOCKDEP_SYS_EXIT_IRQ
22692 movl TI_flags(%rcx),%edx
22693 @@ -1620,7 +2166,7 @@ ENTRY(error_exit)
22694 jnz retint_careful
22695 jmp retint_swapgs
22696 CFI_ENDPROC
22697 -END(error_exit)
22698 +ENDPROC(error_exit)
22699
22700 /*
22701 * Test if a given stack is an NMI stack or not.
22702 @@ -1678,9 +2224,11 @@ ENTRY(nmi)
22703 * If %cs was not the kernel segment, then the NMI triggered in user
22704 * space, which means it is definitely not nested.
22705 */
22706 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
22707 + je 1f
22708 cmpl $__KERNEL_CS, 16(%rsp)
22709 jne first_nmi
22710 -
22711 +1:
22712 /*
22713 * Check the special variable on the stack to see if NMIs are
22714 * executing.
22715 @@ -1714,8 +2262,7 @@ nested_nmi:
22716
22717 1:
22718 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
22719 - leaq -1*8(%rsp), %rdx
22720 - movq %rdx, %rsp
22721 + subq $8, %rsp
22722 CFI_ADJUST_CFA_OFFSET 1*8
22723 leaq -10*8(%rsp), %rdx
22724 pushq_cfi $__KERNEL_DS
22725 @@ -1733,6 +2280,7 @@ nested_nmi_out:
22726 CFI_RESTORE rdx
22727
22728 /* No need to check faults here */
22729 +# pax_force_retaddr_bts
22730 INTERRUPT_RETURN
22731
22732 CFI_RESTORE_STATE
22733 @@ -1849,6 +2397,8 @@ end_repeat_nmi:
22734 */
22735 movq %cr2, %r12
22736
22737 + pax_enter_kernel_nmi
22738 +
22739 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
22740 movq %rsp,%rdi
22741 movq $-1,%rsi
22742 @@ -1861,26 +2411,31 @@ end_repeat_nmi:
22743 movq %r12, %cr2
22744 1:
22745
22746 - testl %ebx,%ebx /* swapgs needed? */
22747 + testl $1,%ebx /* swapgs needed? */
22748 jnz nmi_restore
22749 nmi_swapgs:
22750 SWAPGS_UNSAFE_STACK
22751 nmi_restore:
22752 + pax_exit_kernel_nmi
22753 /* Pop the extra iret frame at once */
22754 RESTORE_ALL 6*8
22755 + testb $3, 8(%rsp)
22756 + jnz 1f
22757 + pax_force_retaddr_bts
22758 +1:
22759
22760 /* Clear the NMI executing stack variable */
22761 movq $0, 5*8(%rsp)
22762 jmp irq_return
22763 CFI_ENDPROC
22764 -END(nmi)
22765 +ENDPROC(nmi)
22766
22767 ENTRY(ignore_sysret)
22768 CFI_STARTPROC
22769 mov $-ENOSYS,%eax
22770 sysret
22771 CFI_ENDPROC
22772 -END(ignore_sysret)
22773 +ENDPROC(ignore_sysret)
22774
22775 /*
22776 * End of kprobes section
22777 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
22778 index 42a392a..fbbd930 100644
22779 --- a/arch/x86/kernel/ftrace.c
22780 +++ b/arch/x86/kernel/ftrace.c
22781 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
22782 {
22783 unsigned char replaced[MCOUNT_INSN_SIZE];
22784
22785 + ip = ktla_ktva(ip);
22786 +
22787 /*
22788 * Note: Due to modules and __init, code can
22789 * disappear and change, we need to protect against faulting
22790 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
22791 unsigned char old[MCOUNT_INSN_SIZE], *new;
22792 int ret;
22793
22794 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
22795 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
22796 new = ftrace_call_replace(ip, (unsigned long)func);
22797
22798 /* See comment above by declaration of modifying_ftrace_code */
22799 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
22800 /* Also update the regs callback function */
22801 if (!ret) {
22802 ip = (unsigned long)(&ftrace_regs_call);
22803 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
22804 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
22805 new = ftrace_call_replace(ip, (unsigned long)func);
22806 ret = ftrace_modify_code(ip, old, new);
22807 }
22808 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
22809 * kernel identity mapping to modify code.
22810 */
22811 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
22812 - ip = (unsigned long)__va(__pa_symbol(ip));
22813 + ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
22814
22815 return probe_kernel_write((void *)ip, val, size);
22816 }
22817 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
22818 unsigned char replaced[MCOUNT_INSN_SIZE];
22819 unsigned char brk = BREAKPOINT_INSTRUCTION;
22820
22821 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
22822 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
22823 return -EFAULT;
22824
22825 /* Make sure it is what we expect it to be */
22826 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
22827 return ret;
22828
22829 fail_update:
22830 - probe_kernel_write((void *)ip, &old_code[0], 1);
22831 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
22832 goto out;
22833 }
22834
22835 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
22836 {
22837 unsigned char code[MCOUNT_INSN_SIZE];
22838
22839 + ip = ktla_ktva(ip);
22840 +
22841 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
22842 return -EFAULT;
22843
22844 diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
22845 index 55b6761..a6456fc 100644
22846 --- a/arch/x86/kernel/head64.c
22847 +++ b/arch/x86/kernel/head64.c
22848 @@ -67,12 +67,12 @@ again:
22849 pgd = *pgd_p;
22850
22851 /*
22852 - * The use of __START_KERNEL_map rather than __PAGE_OFFSET here is
22853 - * critical -- __PAGE_OFFSET would point us back into the dynamic
22854 + * The use of __early_va rather than __va here is critical:
22855 + * __va would point us back into the dynamic
22856 * range and we might end up looping forever...
22857 */
22858 if (pgd)
22859 - pud_p = (pudval_t *)((pgd & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
22860 + pud_p = (pudval_t *)(__early_va(pgd & PTE_PFN_MASK));
22861 else {
22862 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
22863 reset_early_page_tables();
22864 @@ -82,13 +82,13 @@ again:
22865 pud_p = (pudval_t *)early_dynamic_pgts[next_early_pgt++];
22866 for (i = 0; i < PTRS_PER_PUD; i++)
22867 pud_p[i] = 0;
22868 - *pgd_p = (pgdval_t)pud_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
22869 + *pgd_p = (pgdval_t)__pa(pud_p) + _KERNPG_TABLE;
22870 }
22871 pud_p += pud_index(address);
22872 pud = *pud_p;
22873
22874 if (pud)
22875 - pmd_p = (pmdval_t *)((pud & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
22876 + pmd_p = (pmdval_t *)(__early_va(pud & PTE_PFN_MASK));
22877 else {
22878 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
22879 reset_early_page_tables();
22880 @@ -98,7 +98,7 @@ again:
22881 pmd_p = (pmdval_t *)early_dynamic_pgts[next_early_pgt++];
22882 for (i = 0; i < PTRS_PER_PMD; i++)
22883 pmd_p[i] = 0;
22884 - *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
22885 + *pud_p = (pudval_t)__pa(pmd_p) + _KERNPG_TABLE;
22886 }
22887 pmd = (physaddr & PMD_MASK) + early_pmd_flags;
22888 pmd_p[pmd_index(address)] = pmd;
22889 @@ -175,7 +175,6 @@ void __init x86_64_start_kernel(char * real_mode_data)
22890 if (console_loglevel == 10)
22891 early_printk("Kernel alive\n");
22892
22893 - clear_page(init_level4_pgt);
22894 /* set init_level4_pgt kernel high mapping*/
22895 init_level4_pgt[511] = early_level4_pgt[511];
22896
22897 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
22898 index 73afd11..0ef46f2 100644
22899 --- a/arch/x86/kernel/head_32.S
22900 +++ b/arch/x86/kernel/head_32.S
22901 @@ -26,6 +26,12 @@
22902 /* Physical address */
22903 #define pa(X) ((X) - __PAGE_OFFSET)
22904
22905 +#ifdef CONFIG_PAX_KERNEXEC
22906 +#define ta(X) (X)
22907 +#else
22908 +#define ta(X) ((X) - __PAGE_OFFSET)
22909 +#endif
22910 +
22911 /*
22912 * References to members of the new_cpu_data structure.
22913 */
22914 @@ -55,11 +61,7 @@
22915 * and small than max_low_pfn, otherwise will waste some page table entries
22916 */
22917
22918 -#if PTRS_PER_PMD > 1
22919 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
22920 -#else
22921 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
22922 -#endif
22923 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
22924
22925 /* Number of possible pages in the lowmem region */
22926 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
22927 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
22928 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
22929
22930 /*
22931 + * Real beginning of normal "text" segment
22932 + */
22933 +ENTRY(stext)
22934 +ENTRY(_stext)
22935 +
22936 +/*
22937 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
22938 * %esi points to the real-mode code as a 32-bit pointer.
22939 * CS and DS must be 4 GB flat segments, but we don't depend on
22940 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
22941 * can.
22942 */
22943 __HEAD
22944 +
22945 +#ifdef CONFIG_PAX_KERNEXEC
22946 + jmp startup_32
22947 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
22948 +.fill PAGE_SIZE-5,1,0xcc
22949 +#endif
22950 +
22951 ENTRY(startup_32)
22952 movl pa(stack_start),%ecx
22953
22954 @@ -106,6 +121,59 @@ ENTRY(startup_32)
22955 2:
22956 leal -__PAGE_OFFSET(%ecx),%esp
22957
22958 +#ifdef CONFIG_SMP
22959 + movl $pa(cpu_gdt_table),%edi
22960 + movl $__per_cpu_load,%eax
22961 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
22962 + rorl $16,%eax
22963 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
22964 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
22965 + movl $__per_cpu_end - 1,%eax
22966 + subl $__per_cpu_start,%eax
22967 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
22968 +#endif
22969 +
22970 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22971 + movl $NR_CPUS,%ecx
22972 + movl $pa(cpu_gdt_table),%edi
22973 +1:
22974 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
22975 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
22976 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
22977 + addl $PAGE_SIZE_asm,%edi
22978 + loop 1b
22979 +#endif
22980 +
22981 +#ifdef CONFIG_PAX_KERNEXEC
22982 + movl $pa(boot_gdt),%edi
22983 + movl $__LOAD_PHYSICAL_ADDR,%eax
22984 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
22985 + rorl $16,%eax
22986 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
22987 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
22988 + rorl $16,%eax
22989 +
22990 + ljmp $(__BOOT_CS),$1f
22991 +1:
22992 +
22993 + movl $NR_CPUS,%ecx
22994 + movl $pa(cpu_gdt_table),%edi
22995 + addl $__PAGE_OFFSET,%eax
22996 +1:
22997 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
22998 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
22999 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
23000 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
23001 + rorl $16,%eax
23002 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
23003 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
23004 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
23005 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
23006 + rorl $16,%eax
23007 + addl $PAGE_SIZE_asm,%edi
23008 + loop 1b
23009 +#endif
23010 +
23011 /*
23012 * Clear BSS first so that there are no surprises...
23013 */
23014 @@ -201,8 +269,11 @@ ENTRY(startup_32)
23015 movl %eax, pa(max_pfn_mapped)
23016
23017 /* Do early initialization of the fixmap area */
23018 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
23019 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
23020 +#ifdef CONFIG_COMPAT_VDSO
23021 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
23022 +#else
23023 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
23024 +#endif
23025 #else /* Not PAE */
23026
23027 page_pde_offset = (__PAGE_OFFSET >> 20);
23028 @@ -232,8 +303,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
23029 movl %eax, pa(max_pfn_mapped)
23030
23031 /* Do early initialization of the fixmap area */
23032 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
23033 - movl %eax,pa(initial_page_table+0xffc)
23034 +#ifdef CONFIG_COMPAT_VDSO
23035 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
23036 +#else
23037 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
23038 +#endif
23039 #endif
23040
23041 #ifdef CONFIG_PARAVIRT
23042 @@ -247,9 +321,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
23043 cmpl $num_subarch_entries, %eax
23044 jae bad_subarch
23045
23046 - movl pa(subarch_entries)(,%eax,4), %eax
23047 - subl $__PAGE_OFFSET, %eax
23048 - jmp *%eax
23049 + jmp *pa(subarch_entries)(,%eax,4)
23050
23051 bad_subarch:
23052 WEAK(lguest_entry)
23053 @@ -261,10 +333,10 @@ WEAK(xen_entry)
23054 __INITDATA
23055
23056 subarch_entries:
23057 - .long default_entry /* normal x86/PC */
23058 - .long lguest_entry /* lguest hypervisor */
23059 - .long xen_entry /* Xen hypervisor */
23060 - .long default_entry /* Moorestown MID */
23061 + .long ta(default_entry) /* normal x86/PC */
23062 + .long ta(lguest_entry) /* lguest hypervisor */
23063 + .long ta(xen_entry) /* Xen hypervisor */
23064 + .long ta(default_entry) /* Moorestown MID */
23065 num_subarch_entries = (. - subarch_entries) / 4
23066 .previous
23067 #else
23068 @@ -355,6 +427,7 @@ default_entry:
23069 movl pa(mmu_cr4_features),%eax
23070 movl %eax,%cr4
23071
23072 +#ifdef CONFIG_X86_PAE
23073 testb $X86_CR4_PAE, %al # check if PAE is enabled
23074 jz enable_paging
23075
23076 @@ -383,6 +456,9 @@ default_entry:
23077 /* Make changes effective */
23078 wrmsr
23079
23080 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
23081 +#endif
23082 +
23083 enable_paging:
23084
23085 /*
23086 @@ -451,14 +527,20 @@ is486:
23087 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
23088 movl %eax,%ss # after changing gdt.
23089
23090 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
23091 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
23092 movl %eax,%ds
23093 movl %eax,%es
23094
23095 movl $(__KERNEL_PERCPU), %eax
23096 movl %eax,%fs # set this cpu's percpu
23097
23098 +#ifdef CONFIG_CC_STACKPROTECTOR
23099 movl $(__KERNEL_STACK_CANARY),%eax
23100 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
23101 + movl $(__USER_DS),%eax
23102 +#else
23103 + xorl %eax,%eax
23104 +#endif
23105 movl %eax,%gs
23106
23107 xorl %eax,%eax # Clear LDT
23108 @@ -534,8 +616,11 @@ setup_once:
23109 * relocation. Manually set base address in stack canary
23110 * segment descriptor.
23111 */
23112 - movl $gdt_page,%eax
23113 + movl $cpu_gdt_table,%eax
23114 movl $stack_canary,%ecx
23115 +#ifdef CONFIG_SMP
23116 + addl $__per_cpu_load,%ecx
23117 +#endif
23118 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
23119 shrl $16, %ecx
23120 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
23121 @@ -566,7 +651,7 @@ ENDPROC(early_idt_handlers)
23122 /* This is global to keep gas from relaxing the jumps */
23123 ENTRY(early_idt_handler)
23124 cld
23125 - cmpl $2,%ss:early_recursion_flag
23126 + cmpl $1,%ss:early_recursion_flag
23127 je hlt_loop
23128 incl %ss:early_recursion_flag
23129
23130 @@ -604,8 +689,8 @@ ENTRY(early_idt_handler)
23131 pushl (20+6*4)(%esp) /* trapno */
23132 pushl $fault_msg
23133 call printk
23134 -#endif
23135 call dump_stack
23136 +#endif
23137 hlt_loop:
23138 hlt
23139 jmp hlt_loop
23140 @@ -624,8 +709,11 @@ ENDPROC(early_idt_handler)
23141 /* This is the default interrupt "handler" :-) */
23142 ALIGN
23143 ignore_int:
23144 - cld
23145 #ifdef CONFIG_PRINTK
23146 + cmpl $2,%ss:early_recursion_flag
23147 + je hlt_loop
23148 + incl %ss:early_recursion_flag
23149 + cld
23150 pushl %eax
23151 pushl %ecx
23152 pushl %edx
23153 @@ -634,9 +722,6 @@ ignore_int:
23154 movl $(__KERNEL_DS),%eax
23155 movl %eax,%ds
23156 movl %eax,%es
23157 - cmpl $2,early_recursion_flag
23158 - je hlt_loop
23159 - incl early_recursion_flag
23160 pushl 16(%esp)
23161 pushl 24(%esp)
23162 pushl 32(%esp)
23163 @@ -670,29 +755,43 @@ ENTRY(setup_once_ref)
23164 /*
23165 * BSS section
23166 */
23167 -__PAGE_ALIGNED_BSS
23168 - .align PAGE_SIZE
23169 #ifdef CONFIG_X86_PAE
23170 +.section .initial_pg_pmd,"a",@progbits
23171 initial_pg_pmd:
23172 .fill 1024*KPMDS,4,0
23173 #else
23174 +.section .initial_page_table,"a",@progbits
23175 ENTRY(initial_page_table)
23176 .fill 1024,4,0
23177 #endif
23178 +.section .initial_pg_fixmap,"a",@progbits
23179 initial_pg_fixmap:
23180 .fill 1024,4,0
23181 +.section .empty_zero_page,"a",@progbits
23182 ENTRY(empty_zero_page)
23183 .fill 4096,1,0
23184 +.section .swapper_pg_dir,"a",@progbits
23185 ENTRY(swapper_pg_dir)
23186 +#ifdef CONFIG_X86_PAE
23187 + .fill 4,8,0
23188 +#else
23189 .fill 1024,4,0
23190 +#endif
23191 +
23192 +/*
23193 + * The IDT has to be page-aligned to simplify the Pentium
23194 + * F0 0F bug workaround.. We have a special link segment
23195 + * for this.
23196 + */
23197 +.section .idt,"a",@progbits
23198 +ENTRY(idt_table)
23199 + .fill 256,8,0
23200
23201 /*
23202 * This starts the data section.
23203 */
23204 #ifdef CONFIG_X86_PAE
23205 -__PAGE_ALIGNED_DATA
23206 - /* Page-aligned for the benefit of paravirt? */
23207 - .align PAGE_SIZE
23208 +.section .initial_page_table,"a",@progbits
23209 ENTRY(initial_page_table)
23210 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
23211 # if KPMDS == 3
23212 @@ -711,12 +810,20 @@ ENTRY(initial_page_table)
23213 # error "Kernel PMDs should be 1, 2 or 3"
23214 # endif
23215 .align PAGE_SIZE /* needs to be page-sized too */
23216 +
23217 +#ifdef CONFIG_PAX_PER_CPU_PGD
23218 +ENTRY(cpu_pgd)
23219 + .rept 2*NR_CPUS
23220 + .fill 4,8,0
23221 + .endr
23222 +#endif
23223 +
23224 #endif
23225
23226 .data
23227 .balign 4
23228 ENTRY(stack_start)
23229 - .long init_thread_union+THREAD_SIZE
23230 + .long init_thread_union+THREAD_SIZE-8
23231
23232 __INITRODATA
23233 int_msg:
23234 @@ -744,7 +851,7 @@ fault_msg:
23235 * segment size, and 32-bit linear address value:
23236 */
23237
23238 - .data
23239 +.section .rodata,"a",@progbits
23240 .globl boot_gdt_descr
23241 .globl idt_descr
23242
23243 @@ -753,7 +860,7 @@ fault_msg:
23244 .word 0 # 32 bit align gdt_desc.address
23245 boot_gdt_descr:
23246 .word __BOOT_DS+7
23247 - .long boot_gdt - __PAGE_OFFSET
23248 + .long pa(boot_gdt)
23249
23250 .word 0 # 32-bit align idt_desc.address
23251 idt_descr:
23252 @@ -764,7 +871,7 @@ idt_descr:
23253 .word 0 # 32 bit align gdt_desc.address
23254 ENTRY(early_gdt_descr)
23255 .word GDT_ENTRIES*8-1
23256 - .long gdt_page /* Overwritten for secondary CPUs */
23257 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
23258
23259 /*
23260 * The boot_gdt must mirror the equivalent in setup.S and is
23261 @@ -773,5 +880,65 @@ ENTRY(early_gdt_descr)
23262 .align L1_CACHE_BYTES
23263 ENTRY(boot_gdt)
23264 .fill GDT_ENTRY_BOOT_CS,8,0
23265 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
23266 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
23267 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
23268 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
23269 +
23270 + .align PAGE_SIZE_asm
23271 +ENTRY(cpu_gdt_table)
23272 + .rept NR_CPUS
23273 + .quad 0x0000000000000000 /* NULL descriptor */
23274 + .quad 0x0000000000000000 /* 0x0b reserved */
23275 + .quad 0x0000000000000000 /* 0x13 reserved */
23276 + .quad 0x0000000000000000 /* 0x1b reserved */
23277 +
23278 +#ifdef CONFIG_PAX_KERNEXEC
23279 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
23280 +#else
23281 + .quad 0x0000000000000000 /* 0x20 unused */
23282 +#endif
23283 +
23284 + .quad 0x0000000000000000 /* 0x28 unused */
23285 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
23286 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
23287 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
23288 + .quad 0x0000000000000000 /* 0x4b reserved */
23289 + .quad 0x0000000000000000 /* 0x53 reserved */
23290 + .quad 0x0000000000000000 /* 0x5b reserved */
23291 +
23292 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
23293 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
23294 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
23295 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
23296 +
23297 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
23298 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
23299 +
23300 + /*
23301 + * Segments used for calling PnP BIOS have byte granularity.
23302 + * The code segments and data segments have fixed 64k limits,
23303 + * the transfer segment sizes are set at run time.
23304 + */
23305 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
23306 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
23307 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
23308 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
23309 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
23310 +
23311 + /*
23312 + * The APM segments have byte granularity and their bases
23313 + * are set at run time. All have 64k limits.
23314 + */
23315 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
23316 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
23317 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
23318 +
23319 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
23320 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
23321 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
23322 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
23323 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
23324 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
23325 +
23326 + /* Be sure this is zeroed to avoid false validations in Xen */
23327 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
23328 + .endr
23329 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
23330 index a836860..1b5c665 100644
23331 --- a/arch/x86/kernel/head_64.S
23332 +++ b/arch/x86/kernel/head_64.S
23333 @@ -20,6 +20,8 @@
23334 #include <asm/processor-flags.h>
23335 #include <asm/percpu.h>
23336 #include <asm/nops.h>
23337 +#include <asm/cpufeature.h>
23338 +#include <asm/alternative-asm.h>
23339
23340 #ifdef CONFIG_PARAVIRT
23341 #include <asm/asm-offsets.h>
23342 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
23343 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
23344 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
23345 L3_START_KERNEL = pud_index(__START_KERNEL_map)
23346 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
23347 +L3_VMALLOC_START = pud_index(VMALLOC_START)
23348 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
23349 +L3_VMALLOC_END = pud_index(VMALLOC_END)
23350 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
23351 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
23352
23353 .text
23354 __HEAD
23355 @@ -89,11 +97,23 @@ startup_64:
23356 * Fixup the physical addresses in the page table
23357 */
23358 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
23359 + addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
23360 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
23361 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
23362 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
23363 + addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
23364
23365 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
23366 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
23367 + addq %rbp, level3_ident_pgt + (0*8)(%rip)
23368 +#ifndef CONFIG_XEN
23369 + addq %rbp, level3_ident_pgt + (1*8)(%rip)
23370 +#endif
23371
23372 - addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
23373 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
23374 +
23375 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
23376 + addq %rbp, level3_kernel_pgt + ((L3_START_KERNEL+1)*8)(%rip)
23377 +
23378 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
23379
23380 /*
23381 * Set up the identity mapping for the switchover. These
23382 @@ -177,8 +197,8 @@ ENTRY(secondary_startup_64)
23383 movq $(init_level4_pgt - __START_KERNEL_map), %rax
23384 1:
23385
23386 - /* Enable PAE mode and PGE */
23387 - movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
23388 + /* Enable PAE mode and PSE/PGE */
23389 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
23390 movq %rcx, %cr4
23391
23392 /* Setup early boot stage 4 level pagetables. */
23393 @@ -199,10 +219,18 @@ ENTRY(secondary_startup_64)
23394 movl $MSR_EFER, %ecx
23395 rdmsr
23396 btsl $_EFER_SCE, %eax /* Enable System Call */
23397 - btl $20,%edi /* No Execute supported? */
23398 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
23399 jnc 1f
23400 btsl $_EFER_NX, %eax
23401 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
23402 + leaq init_level4_pgt(%rip), %rdi
23403 +#ifndef CONFIG_EFI
23404 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
23405 +#endif
23406 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
23407 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
23408 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
23409 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
23410 1: wrmsr /* Make changes effective */
23411
23412 /* Setup cr0 */
23413 @@ -282,6 +310,7 @@ ENTRY(secondary_startup_64)
23414 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
23415 * address given in m16:64.
23416 */
23417 + pax_set_fptr_mask
23418 movq initial_code(%rip),%rax
23419 pushq $0 # fake return address to stop unwinder
23420 pushq $__KERNEL_CS # set correct cs
23421 @@ -388,7 +417,7 @@ ENTRY(early_idt_handler)
23422 call dump_stack
23423 #ifdef CONFIG_KALLSYMS
23424 leaq early_idt_ripmsg(%rip),%rdi
23425 - movq 40(%rsp),%rsi # %rip again
23426 + movq 88(%rsp),%rsi # %rip again
23427 call __print_symbol
23428 #endif
23429 #endif /* EARLY_PRINTK */
23430 @@ -416,6 +445,7 @@ ENDPROC(early_idt_handler)
23431 early_recursion_flag:
23432 .long 0
23433
23434 + .section .rodata,"a",@progbits
23435 #ifdef CONFIG_EARLY_PRINTK
23436 early_idt_msg:
23437 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
23438 @@ -443,29 +473,52 @@ NEXT_PAGE(early_level4_pgt)
23439 NEXT_PAGE(early_dynamic_pgts)
23440 .fill 512*EARLY_DYNAMIC_PAGE_TABLES,8,0
23441
23442 - .data
23443 + .section .rodata,"a",@progbits
23444
23445 -#ifndef CONFIG_XEN
23446 NEXT_PAGE(init_level4_pgt)
23447 - .fill 512,8,0
23448 -#else
23449 -NEXT_PAGE(init_level4_pgt)
23450 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23451 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
23452 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23453 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
23454 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
23455 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
23456 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
23457 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
23458 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
23459 .org init_level4_pgt + L4_START_KERNEL*8, 0
23460 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
23461 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
23462
23463 +#ifdef CONFIG_PAX_PER_CPU_PGD
23464 +NEXT_PAGE(cpu_pgd)
23465 + .rept 2*NR_CPUS
23466 + .fill 512,8,0
23467 + .endr
23468 +#endif
23469 +
23470 NEXT_PAGE(level3_ident_pgt)
23471 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23472 +#ifdef CONFIG_XEN
23473 .fill 511, 8, 0
23474 +#else
23475 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
23476 + .fill 510,8,0
23477 +#endif
23478 +
23479 +NEXT_PAGE(level3_vmalloc_start_pgt)
23480 + .fill 512,8,0
23481 +
23482 +NEXT_PAGE(level3_vmalloc_end_pgt)
23483 + .fill 512,8,0
23484 +
23485 +NEXT_PAGE(level3_vmemmap_pgt)
23486 + .fill L3_VMEMMAP_START,8,0
23487 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
23488 +
23489 NEXT_PAGE(level2_ident_pgt)
23490 - /* Since I easily can, map the first 1G.
23491 + /* Since I easily can, map the first 2G.
23492 * Don't set NX because code runs from these pages.
23493 */
23494 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
23495 -#endif
23496 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
23497
23498 NEXT_PAGE(level3_kernel_pgt)
23499 .fill L3_START_KERNEL,8,0
23500 @@ -473,6 +526,9 @@ NEXT_PAGE(level3_kernel_pgt)
23501 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
23502 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
23503
23504 +NEXT_PAGE(level2_vmemmap_pgt)
23505 + .fill 512,8,0
23506 +
23507 NEXT_PAGE(level2_kernel_pgt)
23508 /*
23509 * 512 MB kernel mapping. We spend a full page on this pagetable
23510 @@ -488,39 +544,70 @@ NEXT_PAGE(level2_kernel_pgt)
23511 KERNEL_IMAGE_SIZE/PMD_SIZE)
23512
23513 NEXT_PAGE(level2_fixmap_pgt)
23514 - .fill 506,8,0
23515 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
23516 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
23517 - .fill 5,8,0
23518 + .fill 507,8,0
23519 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
23520 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
23521 + .fill 4,8,0
23522
23523 -NEXT_PAGE(level1_fixmap_pgt)
23524 +NEXT_PAGE(level1_vsyscall_pgt)
23525 .fill 512,8,0
23526
23527 #undef PMDS
23528
23529 - .data
23530 + .align PAGE_SIZE
23531 +ENTRY(cpu_gdt_table)
23532 + .rept NR_CPUS
23533 + .quad 0x0000000000000000 /* NULL descriptor */
23534 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
23535 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
23536 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
23537 + .quad 0x00cffb000000ffff /* __USER32_CS */
23538 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
23539 + .quad 0x00affb000000ffff /* __USER_CS */
23540 +
23541 +#ifdef CONFIG_PAX_KERNEXEC
23542 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
23543 +#else
23544 + .quad 0x0 /* unused */
23545 +#endif
23546 +
23547 + .quad 0,0 /* TSS */
23548 + .quad 0,0 /* LDT */
23549 + .quad 0,0,0 /* three TLS descriptors */
23550 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
23551 + /* asm/segment.h:GDT_ENTRIES must match this */
23552 +
23553 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23554 + .quad 0x00cf93000000ffff /* __UDEREF_KERNEL_DS */
23555 +#else
23556 + .quad 0x0 /* unused */
23557 +#endif
23558 +
23559 + /* zero the remaining page */
23560 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
23561 + .endr
23562 +
23563 .align 16
23564 .globl early_gdt_descr
23565 early_gdt_descr:
23566 .word GDT_ENTRIES*8-1
23567 early_gdt_descr_base:
23568 - .quad INIT_PER_CPU_VAR(gdt_page)
23569 + .quad cpu_gdt_table
23570
23571 ENTRY(phys_base)
23572 /* This must match the first entry in level2_kernel_pgt */
23573 .quad 0x0000000000000000
23574
23575 #include "../../x86/xen/xen-head.S"
23576 -
23577 - .section .bss, "aw", @nobits
23578 +
23579 + .section .rodata,"a",@progbits
23580 +NEXT_PAGE(empty_zero_page)
23581 + .skip PAGE_SIZE
23582 +
23583 .align PAGE_SIZE
23584 ENTRY(idt_table)
23585 - .skip IDT_ENTRIES * 16
23586 + .fill 512,8,0
23587
23588 .align L1_CACHE_BYTES
23589 ENTRY(nmi_idt_table)
23590 - .skip IDT_ENTRIES * 16
23591 -
23592 - __PAGE_ALIGNED_BSS
23593 -NEXT_PAGE(empty_zero_page)
23594 - .skip PAGE_SIZE
23595 + .fill 512,8,0
23596 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
23597 index 0fa6912..b37438b 100644
23598 --- a/arch/x86/kernel/i386_ksyms_32.c
23599 +++ b/arch/x86/kernel/i386_ksyms_32.c
23600 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
23601 EXPORT_SYMBOL(cmpxchg8b_emu);
23602 #endif
23603
23604 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
23605 +
23606 /* Networking helper routines. */
23607 EXPORT_SYMBOL(csum_partial_copy_generic);
23608 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
23609 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
23610
23611 EXPORT_SYMBOL(__get_user_1);
23612 EXPORT_SYMBOL(__get_user_2);
23613 @@ -37,3 +41,11 @@ EXPORT_SYMBOL(strstr);
23614
23615 EXPORT_SYMBOL(csum_partial);
23616 EXPORT_SYMBOL(empty_zero_page);
23617 +
23618 +#ifdef CONFIG_PAX_KERNEXEC
23619 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
23620 +#endif
23621 +
23622 +#ifdef CONFIG_PAX_PER_CPU_PGD
23623 +EXPORT_SYMBOL(cpu_pgd);
23624 +#endif
23625 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
23626 index f7ea30d..6318acc 100644
23627 --- a/arch/x86/kernel/i387.c
23628 +++ b/arch/x86/kernel/i387.c
23629 @@ -51,7 +51,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
23630 static inline bool interrupted_user_mode(void)
23631 {
23632 struct pt_regs *regs = get_irq_regs();
23633 - return regs && user_mode_vm(regs);
23634 + return regs && user_mode(regs);
23635 }
23636
23637 /*
23638 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
23639 index 9a5c460..84868423 100644
23640 --- a/arch/x86/kernel/i8259.c
23641 +++ b/arch/x86/kernel/i8259.c
23642 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
23643 static void make_8259A_irq(unsigned int irq)
23644 {
23645 disable_irq_nosync(irq);
23646 - io_apic_irqs &= ~(1<<irq);
23647 + io_apic_irqs &= ~(1UL<<irq);
23648 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
23649 i8259A_chip.name);
23650 enable_irq(irq);
23651 @@ -209,7 +209,7 @@ spurious_8259A_irq:
23652 "spurious 8259A interrupt: IRQ%d.\n", irq);
23653 spurious_irq_mask |= irqmask;
23654 }
23655 - atomic_inc(&irq_err_count);
23656 + atomic_inc_unchecked(&irq_err_count);
23657 /*
23658 * Theoretically we do not have to handle this IRQ,
23659 * but in Linux this does not cause problems and is
23660 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
23661 /* (slave's support for AEOI in flat mode is to be investigated) */
23662 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
23663
23664 + pax_open_kernel();
23665 if (auto_eoi)
23666 /*
23667 * In AEOI mode we just have to mask the interrupt
23668 * when acking.
23669 */
23670 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
23671 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
23672 else
23673 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
23674 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
23675 + pax_close_kernel();
23676
23677 udelay(100); /* wait for 8259A to initialize */
23678
23679 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
23680 index a979b5b..1d6db75 100644
23681 --- a/arch/x86/kernel/io_delay.c
23682 +++ b/arch/x86/kernel/io_delay.c
23683 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
23684 * Quirk table for systems that misbehave (lock up, etc.) if port
23685 * 0x80 is used:
23686 */
23687 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
23688 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
23689 {
23690 .callback = dmi_io_delay_0xed_port,
23691 .ident = "Compaq Presario V6000",
23692 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
23693 index 4ddaf66..6292f4e 100644
23694 --- a/arch/x86/kernel/ioport.c
23695 +++ b/arch/x86/kernel/ioport.c
23696 @@ -6,6 +6,7 @@
23697 #include <linux/sched.h>
23698 #include <linux/kernel.h>
23699 #include <linux/capability.h>
23700 +#include <linux/security.h>
23701 #include <linux/errno.h>
23702 #include <linux/types.h>
23703 #include <linux/ioport.h>
23704 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
23705
23706 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
23707 return -EINVAL;
23708 +#ifdef CONFIG_GRKERNSEC_IO
23709 + if (turn_on && grsec_disable_privio) {
23710 + gr_handle_ioperm();
23711 + return -EPERM;
23712 + }
23713 +#endif
23714 if (turn_on && !capable(CAP_SYS_RAWIO))
23715 return -EPERM;
23716
23717 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
23718 * because the ->io_bitmap_max value must match the bitmap
23719 * contents:
23720 */
23721 - tss = &per_cpu(init_tss, get_cpu());
23722 + tss = init_tss + get_cpu();
23723
23724 if (turn_on)
23725 bitmap_clear(t->io_bitmap_ptr, from, num);
23726 @@ -103,6 +110,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
23727 return -EINVAL;
23728 /* Trying to gain more privileges? */
23729 if (level > old) {
23730 +#ifdef CONFIG_GRKERNSEC_IO
23731 + if (grsec_disable_privio) {
23732 + gr_handle_iopl();
23733 + return -EPERM;
23734 + }
23735 +#endif
23736 if (!capable(CAP_SYS_RAWIO))
23737 return -EPERM;
23738 }
23739 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
23740 index ac0631d..ff7cb62 100644
23741 --- a/arch/x86/kernel/irq.c
23742 +++ b/arch/x86/kernel/irq.c
23743 @@ -18,7 +18,7 @@
23744 #include <asm/mce.h>
23745 #include <asm/hw_irq.h>
23746
23747 -atomic_t irq_err_count;
23748 +atomic_unchecked_t irq_err_count;
23749
23750 /* Function pointer for generic interrupt vector handling */
23751 void (*x86_platform_ipi_callback)(void) = NULL;
23752 @@ -122,9 +122,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
23753 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
23754 seq_printf(p, " Machine check polls\n");
23755 #endif
23756 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
23757 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
23758 #if defined(CONFIG_X86_IO_APIC)
23759 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
23760 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
23761 #endif
23762 return 0;
23763 }
23764 @@ -164,7 +164,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
23765
23766 u64 arch_irq_stat(void)
23767 {
23768 - u64 sum = atomic_read(&irq_err_count);
23769 + u64 sum = atomic_read_unchecked(&irq_err_count);
23770 return sum;
23771 }
23772
23773 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
23774 index 344faf8..355f60d 100644
23775 --- a/arch/x86/kernel/irq_32.c
23776 +++ b/arch/x86/kernel/irq_32.c
23777 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
23778 __asm__ __volatile__("andl %%esp,%0" :
23779 "=r" (sp) : "0" (THREAD_SIZE - 1));
23780
23781 - return sp < (sizeof(struct thread_info) + STACK_WARN);
23782 + return sp < STACK_WARN;
23783 }
23784
23785 static void print_stack_overflow(void)
23786 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
23787 * per-CPU IRQ handling contexts (thread information and stack)
23788 */
23789 union irq_ctx {
23790 - struct thread_info tinfo;
23791 - u32 stack[THREAD_SIZE/sizeof(u32)];
23792 + unsigned long previous_esp;
23793 + u32 stack[THREAD_SIZE/sizeof(u32)];
23794 } __attribute__((aligned(THREAD_SIZE)));
23795
23796 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
23797 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
23798 static inline int
23799 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23800 {
23801 - union irq_ctx *curctx, *irqctx;
23802 + union irq_ctx *irqctx;
23803 u32 *isp, arg1, arg2;
23804
23805 - curctx = (union irq_ctx *) current_thread_info();
23806 irqctx = __this_cpu_read(hardirq_ctx);
23807
23808 /*
23809 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23810 * handler) we can't do that and just have to keep using the
23811 * current stack (which is the irq stack already after all)
23812 */
23813 - if (unlikely(curctx == irqctx))
23814 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
23815 return 0;
23816
23817 /* build the stack frame on the IRQ stack */
23818 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
23819 - irqctx->tinfo.task = curctx->tinfo.task;
23820 - irqctx->tinfo.previous_esp = current_stack_pointer;
23821 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
23822 + irqctx->previous_esp = current_stack_pointer;
23823
23824 - /* Copy the preempt_count so that the [soft]irq checks work. */
23825 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
23826 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23827 + __set_fs(MAKE_MM_SEG(0));
23828 +#endif
23829
23830 if (unlikely(overflow))
23831 call_on_stack(print_stack_overflow, isp);
23832 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23833 : "0" (irq), "1" (desc), "2" (isp),
23834 "D" (desc->handle_irq)
23835 : "memory", "cc", "ecx");
23836 +
23837 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23838 + __set_fs(current_thread_info()->addr_limit);
23839 +#endif
23840 +
23841 return 1;
23842 }
23843
23844 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23845 */
23846 void __cpuinit irq_ctx_init(int cpu)
23847 {
23848 - union irq_ctx *irqctx;
23849 -
23850 if (per_cpu(hardirq_ctx, cpu))
23851 return;
23852
23853 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
23854 - THREADINFO_GFP,
23855 - THREAD_SIZE_ORDER));
23856 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
23857 - irqctx->tinfo.cpu = cpu;
23858 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
23859 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
23860 -
23861 - per_cpu(hardirq_ctx, cpu) = irqctx;
23862 -
23863 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
23864 - THREADINFO_GFP,
23865 - THREAD_SIZE_ORDER));
23866 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
23867 - irqctx->tinfo.cpu = cpu;
23868 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
23869 -
23870 - per_cpu(softirq_ctx, cpu) = irqctx;
23871 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
23872 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
23873 +
23874 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
23875 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
23876
23877 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
23878 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
23879 @@ -152,7 +141,6 @@ void __cpuinit irq_ctx_init(int cpu)
23880 asmlinkage void do_softirq(void)
23881 {
23882 unsigned long flags;
23883 - struct thread_info *curctx;
23884 union irq_ctx *irqctx;
23885 u32 *isp;
23886
23887 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
23888 local_irq_save(flags);
23889
23890 if (local_softirq_pending()) {
23891 - curctx = current_thread_info();
23892 irqctx = __this_cpu_read(softirq_ctx);
23893 - irqctx->tinfo.task = curctx->task;
23894 - irqctx->tinfo.previous_esp = current_stack_pointer;
23895 + irqctx->previous_esp = current_stack_pointer;
23896
23897 /* build the stack frame on the softirq stack */
23898 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
23899 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
23900 +
23901 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23902 + __set_fs(MAKE_MM_SEG(0));
23903 +#endif
23904
23905 call_on_stack(__do_softirq, isp);
23906 +
23907 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23908 + __set_fs(current_thread_info()->addr_limit);
23909 +#endif
23910 +
23911 /*
23912 * Shouldn't happen, we returned above if in_interrupt():
23913 */
23914 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
23915 if (unlikely(!desc))
23916 return false;
23917
23918 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
23919 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
23920 if (unlikely(overflow))
23921 print_stack_overflow();
23922 desc->handle_irq(irq, desc);
23923 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
23924 index d04d3ec..ea4b374 100644
23925 --- a/arch/x86/kernel/irq_64.c
23926 +++ b/arch/x86/kernel/irq_64.c
23927 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
23928 u64 estack_top, estack_bottom;
23929 u64 curbase = (u64)task_stack_page(current);
23930
23931 - if (user_mode_vm(regs))
23932 + if (user_mode(regs))
23933 return;
23934
23935 if (regs->sp >= curbase + sizeof(struct thread_info) +
23936 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
23937 index dc1404b..bbc43e7 100644
23938 --- a/arch/x86/kernel/kdebugfs.c
23939 +++ b/arch/x86/kernel/kdebugfs.c
23940 @@ -27,7 +27,7 @@ struct setup_data_node {
23941 u32 len;
23942 };
23943
23944 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
23945 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
23946 size_t count, loff_t *ppos)
23947 {
23948 struct setup_data_node *node = file->private_data;
23949 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
23950 index 836f832..a8bda67 100644
23951 --- a/arch/x86/kernel/kgdb.c
23952 +++ b/arch/x86/kernel/kgdb.c
23953 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
23954 #ifdef CONFIG_X86_32
23955 switch (regno) {
23956 case GDB_SS:
23957 - if (!user_mode_vm(regs))
23958 + if (!user_mode(regs))
23959 *(unsigned long *)mem = __KERNEL_DS;
23960 break;
23961 case GDB_SP:
23962 - if (!user_mode_vm(regs))
23963 + if (!user_mode(regs))
23964 *(unsigned long *)mem = kernel_stack_pointer(regs);
23965 break;
23966 case GDB_GS:
23967 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
23968 bp->attr.bp_addr = breakinfo[breakno].addr;
23969 bp->attr.bp_len = breakinfo[breakno].len;
23970 bp->attr.bp_type = breakinfo[breakno].type;
23971 - info->address = breakinfo[breakno].addr;
23972 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
23973 + info->address = ktla_ktva(breakinfo[breakno].addr);
23974 + else
23975 + info->address = breakinfo[breakno].addr;
23976 info->len = breakinfo[breakno].len;
23977 info->type = breakinfo[breakno].type;
23978 val = arch_install_hw_breakpoint(bp);
23979 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
23980 case 'k':
23981 /* clear the trace bit */
23982 linux_regs->flags &= ~X86_EFLAGS_TF;
23983 - atomic_set(&kgdb_cpu_doing_single_step, -1);
23984 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
23985
23986 /* set the trace bit if we're stepping */
23987 if (remcomInBuffer[0] == 's') {
23988 linux_regs->flags |= X86_EFLAGS_TF;
23989 - atomic_set(&kgdb_cpu_doing_single_step,
23990 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
23991 raw_smp_processor_id());
23992 }
23993
23994 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
23995
23996 switch (cmd) {
23997 case DIE_DEBUG:
23998 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
23999 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
24000 if (user_mode(regs))
24001 return single_step_cont(regs, args);
24002 break;
24003 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
24004 #endif /* CONFIG_DEBUG_RODATA */
24005
24006 bpt->type = BP_BREAKPOINT;
24007 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
24008 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
24009 BREAK_INSTR_SIZE);
24010 if (err)
24011 return err;
24012 - err = probe_kernel_write((char *)bpt->bpt_addr,
24013 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
24014 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
24015 #ifdef CONFIG_DEBUG_RODATA
24016 if (!err)
24017 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
24018 return -EBUSY;
24019 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
24020 BREAK_INSTR_SIZE);
24021 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
24022 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
24023 if (err)
24024 return err;
24025 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
24026 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
24027 if (mutex_is_locked(&text_mutex))
24028 goto knl_write;
24029 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
24030 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
24031 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
24032 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
24033 goto knl_write;
24034 return err;
24035 knl_write:
24036 #endif /* CONFIG_DEBUG_RODATA */
24037 - return probe_kernel_write((char *)bpt->bpt_addr,
24038 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
24039 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
24040 }
24041
24042 diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
24043 index 211bce4..6e2580a 100644
24044 --- a/arch/x86/kernel/kprobes/core.c
24045 +++ b/arch/x86/kernel/kprobes/core.c
24046 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
24047 s32 raddr;
24048 } __packed *insn;
24049
24050 - insn = (struct __arch_relative_insn *)from;
24051 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
24052 +
24053 + pax_open_kernel();
24054 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
24055 insn->op = op;
24056 + pax_close_kernel();
24057 }
24058
24059 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
24060 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
24061 kprobe_opcode_t opcode;
24062 kprobe_opcode_t *orig_opcodes = opcodes;
24063
24064 - if (search_exception_tables((unsigned long)opcodes))
24065 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
24066 return 0; /* Page fault may occur on this address. */
24067
24068 retry:
24069 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
24070 * for the first byte, we can recover the original instruction
24071 * from it and kp->opcode.
24072 */
24073 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
24074 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
24075 buf[0] = kp->opcode;
24076 - return (unsigned long)buf;
24077 + return ktva_ktla((unsigned long)buf);
24078 }
24079
24080 /*
24081 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
24082 /* Another subsystem puts a breakpoint, failed to recover */
24083 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
24084 return 0;
24085 + pax_open_kernel();
24086 memcpy(dest, insn.kaddr, insn.length);
24087 + pax_close_kernel();
24088
24089 #ifdef CONFIG_X86_64
24090 if (insn_rip_relative(&insn)) {
24091 @@ -359,7 +364,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
24092 return 0;
24093 }
24094 disp = (u8 *) dest + insn_offset_displacement(&insn);
24095 + pax_open_kernel();
24096 *(s32 *) disp = (s32) newdisp;
24097 + pax_close_kernel();
24098 }
24099 #endif
24100 return insn.length;
24101 @@ -498,7 +505,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
24102 * nor set current_kprobe, because it doesn't use single
24103 * stepping.
24104 */
24105 - regs->ip = (unsigned long)p->ainsn.insn;
24106 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
24107 preempt_enable_no_resched();
24108 return;
24109 }
24110 @@ -515,9 +522,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
24111 regs->flags &= ~X86_EFLAGS_IF;
24112 /* single step inline if the instruction is an int3 */
24113 if (p->opcode == BREAKPOINT_INSTRUCTION)
24114 - regs->ip = (unsigned long)p->addr;
24115 + regs->ip = ktla_ktva((unsigned long)p->addr);
24116 else
24117 - regs->ip = (unsigned long)p->ainsn.insn;
24118 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
24119 }
24120
24121 /*
24122 @@ -596,7 +603,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
24123 setup_singlestep(p, regs, kcb, 0);
24124 return 1;
24125 }
24126 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
24127 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
24128 /*
24129 * The breakpoint instruction was removed right
24130 * after we hit it. Another cpu has removed
24131 @@ -642,6 +649,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
24132 " movq %rax, 152(%rsp)\n"
24133 RESTORE_REGS_STRING
24134 " popfq\n"
24135 +#ifdef KERNEXEC_PLUGIN
24136 + " btsq $63,(%rsp)\n"
24137 +#endif
24138 #else
24139 " pushf\n"
24140 SAVE_REGS_STRING
24141 @@ -779,7 +789,7 @@ static void __kprobes
24142 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
24143 {
24144 unsigned long *tos = stack_addr(regs);
24145 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
24146 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
24147 unsigned long orig_ip = (unsigned long)p->addr;
24148 kprobe_opcode_t *insn = p->ainsn.insn;
24149
24150 @@ -961,7 +971,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
24151 struct die_args *args = data;
24152 int ret = NOTIFY_DONE;
24153
24154 - if (args->regs && user_mode_vm(args->regs))
24155 + if (args->regs && user_mode(args->regs))
24156 return ret;
24157
24158 switch (val) {
24159 diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
24160 index 76dc6f0..66bdfc3 100644
24161 --- a/arch/x86/kernel/kprobes/opt.c
24162 +++ b/arch/x86/kernel/kprobes/opt.c
24163 @@ -79,6 +79,7 @@ found:
24164 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
24165 static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
24166 {
24167 + pax_open_kernel();
24168 #ifdef CONFIG_X86_64
24169 *addr++ = 0x48;
24170 *addr++ = 0xbf;
24171 @@ -86,6 +87,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long v
24172 *addr++ = 0xb8;
24173 #endif
24174 *(unsigned long *)addr = val;
24175 + pax_close_kernel();
24176 }
24177
24178 static void __used __kprobes kprobes_optinsn_template_holder(void)
24179 @@ -338,7 +340,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
24180 * Verify if the address gap is in 2GB range, because this uses
24181 * a relative jump.
24182 */
24183 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
24184 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
24185 if (abs(rel) > 0x7fffffff)
24186 return -ERANGE;
24187
24188 @@ -353,16 +355,18 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
24189 op->optinsn.size = ret;
24190
24191 /* Copy arch-dep-instance from template */
24192 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
24193 + pax_open_kernel();
24194 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
24195 + pax_close_kernel();
24196
24197 /* Set probe information */
24198 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
24199
24200 /* Set probe function call */
24201 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
24202 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
24203
24204 /* Set returning jmp instruction at the tail of out-of-line buffer */
24205 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
24206 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
24207 (u8 *)op->kp.addr + op->optinsn.size);
24208
24209 flush_icache_range((unsigned long) buf,
24210 @@ -385,7 +389,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
24211 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
24212
24213 /* Backup instructions which will be replaced by jump address */
24214 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
24215 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
24216 RELATIVE_ADDR_SIZE);
24217
24218 insn_buf[0] = RELATIVEJUMP_OPCODE;
24219 @@ -483,7 +487,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
24220 /* This kprobe is really able to run optimized path. */
24221 op = container_of(p, struct optimized_kprobe, kp);
24222 /* Detour through copied instructions */
24223 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
24224 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
24225 if (!reenter)
24226 reset_current_kprobe();
24227 preempt_enable_no_resched();
24228 diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
24229 index cd6d9a5..16245a4 100644
24230 --- a/arch/x86/kernel/kvm.c
24231 +++ b/arch/x86/kernel/kvm.c
24232 @@ -455,7 +455,7 @@ static int __cpuinit kvm_cpu_notify(struct notifier_block *self,
24233 return NOTIFY_OK;
24234 }
24235
24236 -static struct notifier_block __cpuinitdata kvm_cpu_notifier = {
24237 +static struct notifier_block kvm_cpu_notifier = {
24238 .notifier_call = kvm_cpu_notify,
24239 };
24240 #endif
24241 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
24242 index ebc9873..1b9724b 100644
24243 --- a/arch/x86/kernel/ldt.c
24244 +++ b/arch/x86/kernel/ldt.c
24245 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
24246 if (reload) {
24247 #ifdef CONFIG_SMP
24248 preempt_disable();
24249 - load_LDT(pc);
24250 + load_LDT_nolock(pc);
24251 if (!cpumask_equal(mm_cpumask(current->mm),
24252 cpumask_of(smp_processor_id())))
24253 smp_call_function(flush_ldt, current->mm, 1);
24254 preempt_enable();
24255 #else
24256 - load_LDT(pc);
24257 + load_LDT_nolock(pc);
24258 #endif
24259 }
24260 if (oldsize) {
24261 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
24262 return err;
24263
24264 for (i = 0; i < old->size; i++)
24265 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
24266 + write_ldt_entry(new->ldt, i, old->ldt + i);
24267 return 0;
24268 }
24269
24270 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
24271 retval = copy_ldt(&mm->context, &old_mm->context);
24272 mutex_unlock(&old_mm->context.lock);
24273 }
24274 +
24275 + if (tsk == current) {
24276 + mm->context.vdso = 0;
24277 +
24278 +#ifdef CONFIG_X86_32
24279 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
24280 + mm->context.user_cs_base = 0UL;
24281 + mm->context.user_cs_limit = ~0UL;
24282 +
24283 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
24284 + cpus_clear(mm->context.cpu_user_cs_mask);
24285 +#endif
24286 +
24287 +#endif
24288 +#endif
24289 +
24290 + }
24291 +
24292 return retval;
24293 }
24294
24295 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
24296 }
24297 }
24298
24299 +#ifdef CONFIG_PAX_SEGMEXEC
24300 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
24301 + error = -EINVAL;
24302 + goto out_unlock;
24303 + }
24304 +#endif
24305 +
24306 fill_ldt(&ldt, &ldt_info);
24307 if (oldmode)
24308 ldt.avl = 0;
24309 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
24310 index 5b19e4d..6476a76 100644
24311 --- a/arch/x86/kernel/machine_kexec_32.c
24312 +++ b/arch/x86/kernel/machine_kexec_32.c
24313 @@ -26,7 +26,7 @@
24314 #include <asm/cacheflush.h>
24315 #include <asm/debugreg.h>
24316
24317 -static void set_idt(void *newidt, __u16 limit)
24318 +static void set_idt(struct desc_struct *newidt, __u16 limit)
24319 {
24320 struct desc_ptr curidt;
24321
24322 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
24323 }
24324
24325
24326 -static void set_gdt(void *newgdt, __u16 limit)
24327 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
24328 {
24329 struct desc_ptr curgdt;
24330
24331 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
24332 }
24333
24334 control_page = page_address(image->control_code_page);
24335 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
24336 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
24337
24338 relocate_kernel_ptr = control_page;
24339 page_list[PA_CONTROL_PAGE] = __pa(control_page);
24340 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
24341 index 22db92b..d546bec 100644
24342 --- a/arch/x86/kernel/microcode_core.c
24343 +++ b/arch/x86/kernel/microcode_core.c
24344 @@ -513,7 +513,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
24345 return NOTIFY_OK;
24346 }
24347
24348 -static struct notifier_block __refdata mc_cpu_notifier = {
24349 +static struct notifier_block mc_cpu_notifier = {
24350 .notifier_call = mc_cpu_callback,
24351 };
24352
24353 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
24354 index 5fb2ceb..3ae90bb 100644
24355 --- a/arch/x86/kernel/microcode_intel.c
24356 +++ b/arch/x86/kernel/microcode_intel.c
24357 @@ -293,13 +293,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
24358
24359 static int get_ucode_user(void *to, const void *from, size_t n)
24360 {
24361 - return copy_from_user(to, from, n);
24362 + return copy_from_user(to, (const void __force_user *)from, n);
24363 }
24364
24365 static enum ucode_state
24366 request_microcode_user(int cpu, const void __user *buf, size_t size)
24367 {
24368 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
24369 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
24370 }
24371
24372 static void microcode_fini_cpu(int cpu)
24373 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
24374 index 216a4d7..228255a 100644
24375 --- a/arch/x86/kernel/module.c
24376 +++ b/arch/x86/kernel/module.c
24377 @@ -43,15 +43,60 @@ do { \
24378 } while (0)
24379 #endif
24380
24381 -void *module_alloc(unsigned long size)
24382 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
24383 {
24384 - if (PAGE_ALIGN(size) > MODULES_LEN)
24385 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
24386 return NULL;
24387 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
24388 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
24389 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
24390 -1, __builtin_return_address(0));
24391 }
24392
24393 +void *module_alloc(unsigned long size)
24394 +{
24395 +
24396 +#ifdef CONFIG_PAX_KERNEXEC
24397 + return __module_alloc(size, PAGE_KERNEL);
24398 +#else
24399 + return __module_alloc(size, PAGE_KERNEL_EXEC);
24400 +#endif
24401 +
24402 +}
24403 +
24404 +#ifdef CONFIG_PAX_KERNEXEC
24405 +#ifdef CONFIG_X86_32
24406 +void *module_alloc_exec(unsigned long size)
24407 +{
24408 + struct vm_struct *area;
24409 +
24410 + if (size == 0)
24411 + return NULL;
24412 +
24413 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
24414 + return area ? area->addr : NULL;
24415 +}
24416 +EXPORT_SYMBOL(module_alloc_exec);
24417 +
24418 +void module_free_exec(struct module *mod, void *module_region)
24419 +{
24420 + vunmap(module_region);
24421 +}
24422 +EXPORT_SYMBOL(module_free_exec);
24423 +#else
24424 +void module_free_exec(struct module *mod, void *module_region)
24425 +{
24426 + module_free(mod, module_region);
24427 +}
24428 +EXPORT_SYMBOL(module_free_exec);
24429 +
24430 +void *module_alloc_exec(unsigned long size)
24431 +{
24432 + return __module_alloc(size, PAGE_KERNEL_RX);
24433 +}
24434 +EXPORT_SYMBOL(module_alloc_exec);
24435 +#endif
24436 +#endif
24437 +
24438 #ifdef CONFIG_X86_32
24439 int apply_relocate(Elf32_Shdr *sechdrs,
24440 const char *strtab,
24441 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
24442 unsigned int i;
24443 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
24444 Elf32_Sym *sym;
24445 - uint32_t *location;
24446 + uint32_t *plocation, location;
24447
24448 DEBUGP("Applying relocate section %u to %u\n",
24449 relsec, sechdrs[relsec].sh_info);
24450 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
24451 /* This is where to make the change */
24452 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
24453 - + rel[i].r_offset;
24454 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
24455 + location = (uint32_t)plocation;
24456 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
24457 + plocation = ktla_ktva((void *)plocation);
24458 /* This is the symbol it is referring to. Note that all
24459 undefined symbols have been resolved. */
24460 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
24461 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
24462 switch (ELF32_R_TYPE(rel[i].r_info)) {
24463 case R_386_32:
24464 /* We add the value into the location given */
24465 - *location += sym->st_value;
24466 + pax_open_kernel();
24467 + *plocation += sym->st_value;
24468 + pax_close_kernel();
24469 break;
24470 case R_386_PC32:
24471 /* Add the value, subtract its position */
24472 - *location += sym->st_value - (uint32_t)location;
24473 + pax_open_kernel();
24474 + *plocation += sym->st_value - location;
24475 + pax_close_kernel();
24476 break;
24477 default:
24478 pr_err("%s: Unknown relocation: %u\n",
24479 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
24480 case R_X86_64_NONE:
24481 break;
24482 case R_X86_64_64:
24483 + pax_open_kernel();
24484 *(u64 *)loc = val;
24485 + pax_close_kernel();
24486 break;
24487 case R_X86_64_32:
24488 + pax_open_kernel();
24489 *(u32 *)loc = val;
24490 + pax_close_kernel();
24491 if (val != *(u32 *)loc)
24492 goto overflow;
24493 break;
24494 case R_X86_64_32S:
24495 + pax_open_kernel();
24496 *(s32 *)loc = val;
24497 + pax_close_kernel();
24498 if ((s64)val != *(s32 *)loc)
24499 goto overflow;
24500 break;
24501 case R_X86_64_PC32:
24502 val -= (u64)loc;
24503 + pax_open_kernel();
24504 *(u32 *)loc = val;
24505 + pax_close_kernel();
24506 +
24507 #if 0
24508 if ((s64)val != *(s32 *)loc)
24509 goto overflow;
24510 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
24511 index ce13049..e2e9c3c 100644
24512 --- a/arch/x86/kernel/msr.c
24513 +++ b/arch/x86/kernel/msr.c
24514 @@ -233,7 +233,7 @@ static int __cpuinit msr_class_cpu_callback(struct notifier_block *nfb,
24515 return notifier_from_errno(err);
24516 }
24517
24518 -static struct notifier_block __refdata msr_class_cpu_notifier = {
24519 +static struct notifier_block msr_class_cpu_notifier = {
24520 .notifier_call = msr_class_cpu_callback,
24521 };
24522
24523 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
24524 index 6030805..2d33f21 100644
24525 --- a/arch/x86/kernel/nmi.c
24526 +++ b/arch/x86/kernel/nmi.c
24527 @@ -105,7 +105,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
24528 return handled;
24529 }
24530
24531 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
24532 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
24533 {
24534 struct nmi_desc *desc = nmi_to_desc(type);
24535 unsigned long flags;
24536 @@ -129,9 +129,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
24537 * event confuses some handlers (kdump uses this flag)
24538 */
24539 if (action->flags & NMI_FLAG_FIRST)
24540 - list_add_rcu(&action->list, &desc->head);
24541 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
24542 else
24543 - list_add_tail_rcu(&action->list, &desc->head);
24544 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
24545
24546 spin_unlock_irqrestore(&desc->lock, flags);
24547 return 0;
24548 @@ -154,7 +154,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
24549 if (!strcmp(n->name, name)) {
24550 WARN(in_nmi(),
24551 "Trying to free NMI (%s) from NMI context!\n", n->name);
24552 - list_del_rcu(&n->list);
24553 + pax_list_del_rcu((struct list_head *)&n->list);
24554 break;
24555 }
24556 }
24557 @@ -479,6 +479,17 @@ static inline void nmi_nesting_postprocess(void)
24558 dotraplinkage notrace __kprobes void
24559 do_nmi(struct pt_regs *regs, long error_code)
24560 {
24561 +
24562 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24563 + if (!user_mode(regs)) {
24564 + unsigned long cs = regs->cs & 0xFFFF;
24565 + unsigned long ip = ktva_ktla(regs->ip);
24566 +
24567 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
24568 + regs->ip = ip;
24569 + }
24570 +#endif
24571 +
24572 nmi_nesting_preprocess(regs);
24573
24574 nmi_enter();
24575 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
24576 index 6d9582e..f746287 100644
24577 --- a/arch/x86/kernel/nmi_selftest.c
24578 +++ b/arch/x86/kernel/nmi_selftest.c
24579 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
24580 {
24581 /* trap all the unknown NMIs we may generate */
24582 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
24583 - __initdata);
24584 + __initconst);
24585 }
24586
24587 static void __init cleanup_nmi_testsuite(void)
24588 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
24589 unsigned long timeout;
24590
24591 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
24592 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
24593 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
24594 nmi_fail = FAILURE;
24595 return;
24596 }
24597 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
24598 index 676b8c7..870ba04 100644
24599 --- a/arch/x86/kernel/paravirt-spinlocks.c
24600 +++ b/arch/x86/kernel/paravirt-spinlocks.c
24601 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
24602 arch_spin_lock(lock);
24603 }
24604
24605 -struct pv_lock_ops pv_lock_ops = {
24606 +struct pv_lock_ops pv_lock_ops __read_only = {
24607 #ifdef CONFIG_SMP
24608 .spin_is_locked = __ticket_spin_is_locked,
24609 .spin_is_contended = __ticket_spin_is_contended,
24610 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
24611 index cd6de64..27c6af0 100644
24612 --- a/arch/x86/kernel/paravirt.c
24613 +++ b/arch/x86/kernel/paravirt.c
24614 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
24615 {
24616 return x;
24617 }
24618 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
24619 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
24620 +#endif
24621
24622 void __init default_banner(void)
24623 {
24624 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
24625 if (opfunc == NULL)
24626 /* If there's no function, patch it with a ud2a (BUG) */
24627 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
24628 - else if (opfunc == _paravirt_nop)
24629 + else if (opfunc == (void *)_paravirt_nop)
24630 /* If the operation is a nop, then nop the callsite */
24631 ret = paravirt_patch_nop();
24632
24633 /* identity functions just return their single argument */
24634 - else if (opfunc == _paravirt_ident_32)
24635 + else if (opfunc == (void *)_paravirt_ident_32)
24636 ret = paravirt_patch_ident_32(insnbuf, len);
24637 - else if (opfunc == _paravirt_ident_64)
24638 + else if (opfunc == (void *)_paravirt_ident_64)
24639 ret = paravirt_patch_ident_64(insnbuf, len);
24640 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
24641 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
24642 + ret = paravirt_patch_ident_64(insnbuf, len);
24643 +#endif
24644
24645 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
24646 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
24647 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
24648 if (insn_len > len || start == NULL)
24649 insn_len = len;
24650 else
24651 - memcpy(insnbuf, start, insn_len);
24652 + memcpy(insnbuf, ktla_ktva(start), insn_len);
24653
24654 return insn_len;
24655 }
24656 @@ -304,7 +311,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
24657 return this_cpu_read(paravirt_lazy_mode);
24658 }
24659
24660 -struct pv_info pv_info = {
24661 +struct pv_info pv_info __read_only = {
24662 .name = "bare hardware",
24663 .paravirt_enabled = 0,
24664 .kernel_rpl = 0,
24665 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
24666 #endif
24667 };
24668
24669 -struct pv_init_ops pv_init_ops = {
24670 +struct pv_init_ops pv_init_ops __read_only = {
24671 .patch = native_patch,
24672 };
24673
24674 -struct pv_time_ops pv_time_ops = {
24675 +struct pv_time_ops pv_time_ops __read_only = {
24676 .sched_clock = native_sched_clock,
24677 .steal_clock = native_steal_clock,
24678 };
24679
24680 -struct pv_irq_ops pv_irq_ops = {
24681 +struct pv_irq_ops pv_irq_ops __read_only = {
24682 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
24683 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
24684 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
24685 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
24686 #endif
24687 };
24688
24689 -struct pv_cpu_ops pv_cpu_ops = {
24690 +struct pv_cpu_ops pv_cpu_ops __read_only = {
24691 .cpuid = native_cpuid,
24692 .get_debugreg = native_get_debugreg,
24693 .set_debugreg = native_set_debugreg,
24694 @@ -394,21 +401,26 @@ struct pv_cpu_ops pv_cpu_ops = {
24695 .end_context_switch = paravirt_nop,
24696 };
24697
24698 -struct pv_apic_ops pv_apic_ops = {
24699 +struct pv_apic_ops pv_apic_ops __read_only= {
24700 #ifdef CONFIG_X86_LOCAL_APIC
24701 .startup_ipi_hook = paravirt_nop,
24702 #endif
24703 };
24704
24705 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
24706 +#ifdef CONFIG_X86_32
24707 +#ifdef CONFIG_X86_PAE
24708 +/* 64-bit pagetable entries */
24709 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
24710 +#else
24711 /* 32-bit pagetable entries */
24712 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
24713 +#endif
24714 #else
24715 /* 64-bit pagetable entries */
24716 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
24717 #endif
24718
24719 -struct pv_mmu_ops pv_mmu_ops = {
24720 +struct pv_mmu_ops pv_mmu_ops __read_only = {
24721
24722 .read_cr2 = native_read_cr2,
24723 .write_cr2 = native_write_cr2,
24724 @@ -458,6 +470,7 @@ struct pv_mmu_ops pv_mmu_ops = {
24725 .make_pud = PTE_IDENT,
24726
24727 .set_pgd = native_set_pgd,
24728 + .set_pgd_batched = native_set_pgd_batched,
24729 #endif
24730 #endif /* PAGETABLE_LEVELS >= 3 */
24731
24732 @@ -478,6 +491,12 @@ struct pv_mmu_ops pv_mmu_ops = {
24733 },
24734
24735 .set_fixmap = native_set_fixmap,
24736 +
24737 +#ifdef CONFIG_PAX_KERNEXEC
24738 + .pax_open_kernel = native_pax_open_kernel,
24739 + .pax_close_kernel = native_pax_close_kernel,
24740 +#endif
24741 +
24742 };
24743
24744 EXPORT_SYMBOL_GPL(pv_time_ops);
24745 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
24746 index 299d493..2ccb0ee 100644
24747 --- a/arch/x86/kernel/pci-calgary_64.c
24748 +++ b/arch/x86/kernel/pci-calgary_64.c
24749 @@ -1339,7 +1339,7 @@ static void __init get_tce_space_from_tar(void)
24750 tce_space = be64_to_cpu(readq(target));
24751 tce_space = tce_space & TAR_SW_BITS;
24752
24753 - tce_space = tce_space & (~specified_table_size);
24754 + tce_space = tce_space & (~(unsigned long)specified_table_size);
24755 info->tce_space = (u64 *)__va(tce_space);
24756 }
24757 }
24758 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
24759 index 35ccf75..7a15747 100644
24760 --- a/arch/x86/kernel/pci-iommu_table.c
24761 +++ b/arch/x86/kernel/pci-iommu_table.c
24762 @@ -2,7 +2,7 @@
24763 #include <asm/iommu_table.h>
24764 #include <linux/string.h>
24765 #include <linux/kallsyms.h>
24766 -
24767 +#include <linux/sched.h>
24768
24769 #define DEBUG 1
24770
24771 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
24772 index 6c483ba..d10ce2f 100644
24773 --- a/arch/x86/kernel/pci-swiotlb.c
24774 +++ b/arch/x86/kernel/pci-swiotlb.c
24775 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
24776 void *vaddr, dma_addr_t dma_addr,
24777 struct dma_attrs *attrs)
24778 {
24779 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
24780 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
24781 }
24782
24783 static struct dma_map_ops swiotlb_dma_ops = {
24784 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
24785 index 81a5f5e..20f8b58 100644
24786 --- a/arch/x86/kernel/process.c
24787 +++ b/arch/x86/kernel/process.c
24788 @@ -36,7 +36,8 @@
24789 * section. Since TSS's are completely CPU-local, we want them
24790 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
24791 */
24792 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
24793 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
24794 +EXPORT_SYMBOL(init_tss);
24795
24796 #ifdef CONFIG_X86_64
24797 static DEFINE_PER_CPU(unsigned char, is_idle);
24798 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
24799 task_xstate_cachep =
24800 kmem_cache_create("task_xstate", xstate_size,
24801 __alignof__(union thread_xstate),
24802 - SLAB_PANIC | SLAB_NOTRACK, NULL);
24803 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
24804 }
24805
24806 /*
24807 @@ -105,7 +106,7 @@ void exit_thread(void)
24808 unsigned long *bp = t->io_bitmap_ptr;
24809
24810 if (bp) {
24811 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
24812 + struct tss_struct *tss = init_tss + get_cpu();
24813
24814 t->io_bitmap_ptr = NULL;
24815 clear_thread_flag(TIF_IO_BITMAP);
24816 @@ -125,6 +126,9 @@ void flush_thread(void)
24817 {
24818 struct task_struct *tsk = current;
24819
24820 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
24821 + loadsegment(gs, 0);
24822 +#endif
24823 flush_ptrace_hw_breakpoint(tsk);
24824 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
24825 drop_init_fpu(tsk);
24826 @@ -271,7 +275,7 @@ static void __exit_idle(void)
24827 void exit_idle(void)
24828 {
24829 /* idle loop has pid 0 */
24830 - if (current->pid)
24831 + if (task_pid_nr(current))
24832 return;
24833 __exit_idle();
24834 }
24835 @@ -327,7 +331,7 @@ bool xen_set_default_idle(void)
24836 return ret;
24837 }
24838 #endif
24839 -void stop_this_cpu(void *dummy)
24840 +__noreturn void stop_this_cpu(void *dummy)
24841 {
24842 local_irq_disable();
24843 /*
24844 @@ -456,16 +460,37 @@ static int __init idle_setup(char *str)
24845 }
24846 early_param("idle", idle_setup);
24847
24848 -unsigned long arch_align_stack(unsigned long sp)
24849 +#ifdef CONFIG_PAX_RANDKSTACK
24850 +void pax_randomize_kstack(struct pt_regs *regs)
24851 {
24852 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
24853 - sp -= get_random_int() % 8192;
24854 - return sp & ~0xf;
24855 -}
24856 + struct thread_struct *thread = &current->thread;
24857 + unsigned long time;
24858
24859 -unsigned long arch_randomize_brk(struct mm_struct *mm)
24860 -{
24861 - unsigned long range_end = mm->brk + 0x02000000;
24862 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
24863 -}
24864 + if (!randomize_va_space)
24865 + return;
24866 +
24867 + if (v8086_mode(regs))
24868 + return;
24869
24870 + rdtscl(time);
24871 +
24872 + /* P4 seems to return a 0 LSB, ignore it */
24873 +#ifdef CONFIG_MPENTIUM4
24874 + time &= 0x3EUL;
24875 + time <<= 2;
24876 +#elif defined(CONFIG_X86_64)
24877 + time &= 0xFUL;
24878 + time <<= 4;
24879 +#else
24880 + time &= 0x1FUL;
24881 + time <<= 3;
24882 +#endif
24883 +
24884 + thread->sp0 ^= time;
24885 + load_sp0(init_tss + smp_processor_id(), thread);
24886 +
24887 +#ifdef CONFIG_X86_64
24888 + this_cpu_write(kernel_stack, thread->sp0);
24889 +#endif
24890 +}
24891 +#endif
24892 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
24893 index 7305f7d..22f73d6 100644
24894 --- a/arch/x86/kernel/process_32.c
24895 +++ b/arch/x86/kernel/process_32.c
24896 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
24897 unsigned long thread_saved_pc(struct task_struct *tsk)
24898 {
24899 return ((unsigned long *)tsk->thread.sp)[3];
24900 +//XXX return tsk->thread.eip;
24901 }
24902
24903 void __show_regs(struct pt_regs *regs, int all)
24904 @@ -74,19 +75,18 @@ void __show_regs(struct pt_regs *regs, int all)
24905 unsigned long sp;
24906 unsigned short ss, gs;
24907
24908 - if (user_mode_vm(regs)) {
24909 + if (user_mode(regs)) {
24910 sp = regs->sp;
24911 ss = regs->ss & 0xffff;
24912 - gs = get_user_gs(regs);
24913 } else {
24914 sp = kernel_stack_pointer(regs);
24915 savesegment(ss, ss);
24916 - savesegment(gs, gs);
24917 }
24918 + gs = get_user_gs(regs);
24919
24920 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
24921 (u16)regs->cs, regs->ip, regs->flags,
24922 - smp_processor_id());
24923 + raw_smp_processor_id());
24924 print_symbol("EIP is at %s\n", regs->ip);
24925
24926 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
24927 @@ -128,20 +128,21 @@ void release_thread(struct task_struct *dead_task)
24928 int copy_thread(unsigned long clone_flags, unsigned long sp,
24929 unsigned long arg, struct task_struct *p)
24930 {
24931 - struct pt_regs *childregs = task_pt_regs(p);
24932 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
24933 struct task_struct *tsk;
24934 int err;
24935
24936 p->thread.sp = (unsigned long) childregs;
24937 p->thread.sp0 = (unsigned long) (childregs+1);
24938 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
24939
24940 if (unlikely(p->flags & PF_KTHREAD)) {
24941 /* kernel thread */
24942 memset(childregs, 0, sizeof(struct pt_regs));
24943 p->thread.ip = (unsigned long) ret_from_kernel_thread;
24944 - task_user_gs(p) = __KERNEL_STACK_CANARY;
24945 - childregs->ds = __USER_DS;
24946 - childregs->es = __USER_DS;
24947 + savesegment(gs, childregs->gs);
24948 + childregs->ds = __KERNEL_DS;
24949 + childregs->es = __KERNEL_DS;
24950 childregs->fs = __KERNEL_PERCPU;
24951 childregs->bx = sp; /* function */
24952 childregs->bp = arg;
24953 @@ -248,7 +249,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24954 struct thread_struct *prev = &prev_p->thread,
24955 *next = &next_p->thread;
24956 int cpu = smp_processor_id();
24957 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
24958 + struct tss_struct *tss = init_tss + cpu;
24959 fpu_switch_t fpu;
24960
24961 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
24962 @@ -272,6 +273,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24963 */
24964 lazy_save_gs(prev->gs);
24965
24966 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24967 + __set_fs(task_thread_info(next_p)->addr_limit);
24968 +#endif
24969 +
24970 /*
24971 * Load the per-thread Thread-Local Storage descriptor.
24972 */
24973 @@ -302,6 +307,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24974 */
24975 arch_end_context_switch(next_p);
24976
24977 + this_cpu_write(current_task, next_p);
24978 + this_cpu_write(current_tinfo, &next_p->tinfo);
24979 +
24980 /*
24981 * Restore %gs if needed (which is common)
24982 */
24983 @@ -310,8 +318,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24984
24985 switch_fpu_finish(next_p, fpu);
24986
24987 - this_cpu_write(current_task, next_p);
24988 -
24989 return prev_p;
24990 }
24991
24992 @@ -341,4 +347,3 @@ unsigned long get_wchan(struct task_struct *p)
24993 } while (count++ < 16);
24994 return 0;
24995 }
24996 -
24997 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
24998 index 355ae06..560fbbe 100644
24999 --- a/arch/x86/kernel/process_64.c
25000 +++ b/arch/x86/kernel/process_64.c
25001 @@ -151,10 +151,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
25002 struct pt_regs *childregs;
25003 struct task_struct *me = current;
25004
25005 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
25006 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
25007 childregs = task_pt_regs(p);
25008 p->thread.sp = (unsigned long) childregs;
25009 p->thread.usersp = me->thread.usersp;
25010 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
25011 set_tsk_thread_flag(p, TIF_FORK);
25012 p->fpu_counter = 0;
25013 p->thread.io_bitmap_ptr = NULL;
25014 @@ -165,6 +166,8 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
25015 p->thread.fs = p->thread.fsindex ? 0 : me->thread.fs;
25016 savesegment(es, p->thread.es);
25017 savesegment(ds, p->thread.ds);
25018 + savesegment(ss, p->thread.ss);
25019 + BUG_ON(p->thread.ss == __UDEREF_KERNEL_DS);
25020 memset(p->thread.ptrace_bps, 0, sizeof(p->thread.ptrace_bps));
25021
25022 if (unlikely(p->flags & PF_KTHREAD)) {
25023 @@ -273,7 +276,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
25024 struct thread_struct *prev = &prev_p->thread;
25025 struct thread_struct *next = &next_p->thread;
25026 int cpu = smp_processor_id();
25027 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
25028 + struct tss_struct *tss = init_tss + cpu;
25029 unsigned fsindex, gsindex;
25030 fpu_switch_t fpu;
25031
25032 @@ -296,6 +299,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
25033 if (unlikely(next->ds | prev->ds))
25034 loadsegment(ds, next->ds);
25035
25036 + savesegment(ss, prev->ss);
25037 + if (unlikely(next->ss != prev->ss))
25038 + loadsegment(ss, next->ss);
25039
25040 /* We must save %fs and %gs before load_TLS() because
25041 * %fs and %gs may be cleared by load_TLS().
25042 @@ -355,10 +361,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
25043 prev->usersp = this_cpu_read(old_rsp);
25044 this_cpu_write(old_rsp, next->usersp);
25045 this_cpu_write(current_task, next_p);
25046 + this_cpu_write(current_tinfo, &next_p->tinfo);
25047
25048 - this_cpu_write(kernel_stack,
25049 - (unsigned long)task_stack_page(next_p) +
25050 - THREAD_SIZE - KERNEL_STACK_OFFSET);
25051 + this_cpu_write(kernel_stack, next->sp0);
25052
25053 /*
25054 * Now maybe reload the debug registers and handle I/O bitmaps
25055 @@ -427,12 +432,11 @@ unsigned long get_wchan(struct task_struct *p)
25056 if (!p || p == current || p->state == TASK_RUNNING)
25057 return 0;
25058 stack = (unsigned long)task_stack_page(p);
25059 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
25060 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
25061 return 0;
25062 fp = *(u64 *)(p->thread.sp);
25063 do {
25064 - if (fp < (unsigned long)stack ||
25065 - fp >= (unsigned long)stack+THREAD_SIZE)
25066 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
25067 return 0;
25068 ip = *(u64 *)(fp+8);
25069 if (!in_sched_functions(ip))
25070 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
25071 index 29a8120..a50b5ee 100644
25072 --- a/arch/x86/kernel/ptrace.c
25073 +++ b/arch/x86/kernel/ptrace.c
25074 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
25075 {
25076 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
25077 unsigned long sp = (unsigned long)&regs->sp;
25078 - struct thread_info *tinfo;
25079
25080 - if (context == (sp & ~(THREAD_SIZE - 1)))
25081 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
25082 return sp;
25083
25084 - tinfo = (struct thread_info *)context;
25085 - if (tinfo->previous_esp)
25086 - return tinfo->previous_esp;
25087 + sp = *(unsigned long *)context;
25088 + if (sp)
25089 + return sp;
25090
25091 return (unsigned long)regs;
25092 }
25093 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
25094 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
25095 {
25096 int i;
25097 - int dr7 = 0;
25098 + unsigned long dr7 = 0;
25099 struct arch_hw_breakpoint *info;
25100
25101 for (i = 0; i < HBP_NUM; i++) {
25102 @@ -856,7 +855,7 @@ long arch_ptrace(struct task_struct *child, long request,
25103 unsigned long addr, unsigned long data)
25104 {
25105 int ret;
25106 - unsigned long __user *datap = (unsigned long __user *)data;
25107 + unsigned long __user *datap = (__force unsigned long __user *)data;
25108
25109 switch (request) {
25110 /* read the word at location addr in the USER area. */
25111 @@ -941,14 +940,14 @@ long arch_ptrace(struct task_struct *child, long request,
25112 if ((int) addr < 0)
25113 return -EIO;
25114 ret = do_get_thread_area(child, addr,
25115 - (struct user_desc __user *)data);
25116 + (__force struct user_desc __user *) data);
25117 break;
25118
25119 case PTRACE_SET_THREAD_AREA:
25120 if ((int) addr < 0)
25121 return -EIO;
25122 ret = do_set_thread_area(child, addr,
25123 - (struct user_desc __user *)data, 0);
25124 + (__force struct user_desc __user *) data, 0);
25125 break;
25126 #endif
25127
25128 @@ -1326,7 +1325,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
25129
25130 #ifdef CONFIG_X86_64
25131
25132 -static struct user_regset x86_64_regsets[] __read_mostly = {
25133 +static user_regset_no_const x86_64_regsets[] __read_only = {
25134 [REGSET_GENERAL] = {
25135 .core_note_type = NT_PRSTATUS,
25136 .n = sizeof(struct user_regs_struct) / sizeof(long),
25137 @@ -1367,7 +1366,7 @@ static const struct user_regset_view user_x86_64_view = {
25138 #endif /* CONFIG_X86_64 */
25139
25140 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
25141 -static struct user_regset x86_32_regsets[] __read_mostly = {
25142 +static user_regset_no_const x86_32_regsets[] __read_only = {
25143 [REGSET_GENERAL] = {
25144 .core_note_type = NT_PRSTATUS,
25145 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
25146 @@ -1420,7 +1419,7 @@ static const struct user_regset_view user_x86_32_view = {
25147 */
25148 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
25149
25150 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
25151 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
25152 {
25153 #ifdef CONFIG_X86_64
25154 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
25155 @@ -1455,7 +1454,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
25156 memset(info, 0, sizeof(*info));
25157 info->si_signo = SIGTRAP;
25158 info->si_code = si_code;
25159 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
25160 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
25161 }
25162
25163 void user_single_step_siginfo(struct task_struct *tsk,
25164 @@ -1484,6 +1483,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
25165 # define IS_IA32 0
25166 #endif
25167
25168 +#ifdef CONFIG_GRKERNSEC_SETXID
25169 +extern void gr_delayed_cred_worker(void);
25170 +#endif
25171 +
25172 /*
25173 * We must return the syscall number to actually look up in the table.
25174 * This can be -1L to skip running any syscall at all.
25175 @@ -1494,6 +1497,11 @@ long syscall_trace_enter(struct pt_regs *regs)
25176
25177 user_exit();
25178
25179 +#ifdef CONFIG_GRKERNSEC_SETXID
25180 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
25181 + gr_delayed_cred_worker();
25182 +#endif
25183 +
25184 /*
25185 * If we stepped into a sysenter/syscall insn, it trapped in
25186 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
25187 @@ -1549,6 +1557,11 @@ void syscall_trace_leave(struct pt_regs *regs)
25188 */
25189 user_exit();
25190
25191 +#ifdef CONFIG_GRKERNSEC_SETXID
25192 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
25193 + gr_delayed_cred_worker();
25194 +#endif
25195 +
25196 audit_syscall_exit(regs);
25197
25198 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
25199 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
25200 index 2cb9470..ff1fd80 100644
25201 --- a/arch/x86/kernel/pvclock.c
25202 +++ b/arch/x86/kernel/pvclock.c
25203 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
25204 return pv_tsc_khz;
25205 }
25206
25207 -static atomic64_t last_value = ATOMIC64_INIT(0);
25208 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
25209
25210 void pvclock_resume(void)
25211 {
25212 - atomic64_set(&last_value, 0);
25213 + atomic64_set_unchecked(&last_value, 0);
25214 }
25215
25216 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
25217 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
25218 * updating at the same time, and one of them could be slightly behind,
25219 * making the assumption that last_value always go forward fail to hold.
25220 */
25221 - last = atomic64_read(&last_value);
25222 + last = atomic64_read_unchecked(&last_value);
25223 do {
25224 if (ret < last)
25225 return last;
25226 - last = atomic64_cmpxchg(&last_value, last, ret);
25227 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
25228 } while (unlikely(last != ret));
25229
25230 return ret;
25231 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
25232 index 76fa1e9..abf09ea 100644
25233 --- a/arch/x86/kernel/reboot.c
25234 +++ b/arch/x86/kernel/reboot.c
25235 @@ -36,7 +36,7 @@ void (*pm_power_off)(void);
25236 EXPORT_SYMBOL(pm_power_off);
25237
25238 static const struct desc_ptr no_idt = {};
25239 -static int reboot_mode;
25240 +static unsigned short reboot_mode;
25241 enum reboot_type reboot_type = BOOT_ACPI;
25242 int reboot_force;
25243
25244 @@ -157,6 +157,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
25245
25246 void __noreturn machine_real_restart(unsigned int type)
25247 {
25248 +
25249 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
25250 + struct desc_struct *gdt;
25251 +#endif
25252 +
25253 local_irq_disable();
25254
25255 /*
25256 @@ -184,7 +189,29 @@ void __noreturn machine_real_restart(unsigned int type)
25257
25258 /* Jump to the identity-mapped low memory code */
25259 #ifdef CONFIG_X86_32
25260 - asm volatile("jmpl *%0" : :
25261 +
25262 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
25263 + gdt = get_cpu_gdt_table(smp_processor_id());
25264 + pax_open_kernel();
25265 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25266 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
25267 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
25268 + loadsegment(ds, __KERNEL_DS);
25269 + loadsegment(es, __KERNEL_DS);
25270 + loadsegment(ss, __KERNEL_DS);
25271 +#endif
25272 +#ifdef CONFIG_PAX_KERNEXEC
25273 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
25274 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
25275 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
25276 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
25277 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
25278 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
25279 +#endif
25280 + pax_close_kernel();
25281 +#endif
25282 +
25283 + asm volatile("ljmpl *%0" : :
25284 "rm" (real_mode_header->machine_real_restart_asm),
25285 "a" (type));
25286 #else
25287 @@ -531,7 +558,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
25288 * try to force a triple fault and then cycle between hitting the keyboard
25289 * controller and doing that
25290 */
25291 -static void native_machine_emergency_restart(void)
25292 +static void __noreturn native_machine_emergency_restart(void)
25293 {
25294 int i;
25295 int attempt = 0;
25296 @@ -654,13 +681,13 @@ void native_machine_shutdown(void)
25297 #endif
25298 }
25299
25300 -static void __machine_emergency_restart(int emergency)
25301 +static void __noreturn __machine_emergency_restart(int emergency)
25302 {
25303 reboot_emergency = emergency;
25304 machine_ops.emergency_restart();
25305 }
25306
25307 -static void native_machine_restart(char *__unused)
25308 +static void __noreturn native_machine_restart(char *__unused)
25309 {
25310 pr_notice("machine restart\n");
25311
25312 @@ -669,7 +696,7 @@ static void native_machine_restart(char *__unused)
25313 __machine_emergency_restart(0);
25314 }
25315
25316 -static void native_machine_halt(void)
25317 +static void __noreturn native_machine_halt(void)
25318 {
25319 /* Stop other cpus and apics */
25320 machine_shutdown();
25321 @@ -679,7 +706,7 @@ static void native_machine_halt(void)
25322 stop_this_cpu(NULL);
25323 }
25324
25325 -static void native_machine_power_off(void)
25326 +static void __noreturn native_machine_power_off(void)
25327 {
25328 if (pm_power_off) {
25329 if (!reboot_force)
25330 @@ -688,9 +715,10 @@ static void native_machine_power_off(void)
25331 }
25332 /* A fallback in case there is no PM info available */
25333 tboot_shutdown(TB_SHUTDOWN_HALT);
25334 + unreachable();
25335 }
25336
25337 -struct machine_ops machine_ops = {
25338 +struct machine_ops machine_ops __read_only = {
25339 .power_off = native_machine_power_off,
25340 .shutdown = native_machine_shutdown,
25341 .emergency_restart = native_machine_emergency_restart,
25342 diff --git a/arch/x86/kernel/reboot_fixups_32.c b/arch/x86/kernel/reboot_fixups_32.c
25343 index c8e41e9..64049ef 100644
25344 --- a/arch/x86/kernel/reboot_fixups_32.c
25345 +++ b/arch/x86/kernel/reboot_fixups_32.c
25346 @@ -57,7 +57,7 @@ struct device_fixup {
25347 unsigned int vendor;
25348 unsigned int device;
25349 void (*reboot_fixup)(struct pci_dev *);
25350 -};
25351 +} __do_const;
25352
25353 /*
25354 * PCI ids solely used for fixups_table go here
25355 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
25356 index f2bb9c9..bed145d7 100644
25357 --- a/arch/x86/kernel/relocate_kernel_64.S
25358 +++ b/arch/x86/kernel/relocate_kernel_64.S
25359 @@ -11,6 +11,7 @@
25360 #include <asm/kexec.h>
25361 #include <asm/processor-flags.h>
25362 #include <asm/pgtable_types.h>
25363 +#include <asm/alternative-asm.h>
25364
25365 /*
25366 * Must be relocatable PIC code callable as a C function
25367 @@ -167,6 +168,7 @@ identity_mapped:
25368 xorq %r14, %r14
25369 xorq %r15, %r15
25370
25371 + pax_force_retaddr 0, 1
25372 ret
25373
25374 1:
25375 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
25376 index 56f7fcf..2cfe4f1 100644
25377 --- a/arch/x86/kernel/setup.c
25378 +++ b/arch/x86/kernel/setup.c
25379 @@ -110,6 +110,7 @@
25380 #include <asm/mce.h>
25381 #include <asm/alternative.h>
25382 #include <asm/prom.h>
25383 +#include <asm/boot.h>
25384
25385 /*
25386 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
25387 @@ -205,12 +206,50 @@ EXPORT_SYMBOL(boot_cpu_data);
25388 #endif
25389
25390
25391 -#if !defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64)
25392 -unsigned long mmu_cr4_features;
25393 +#ifdef CONFIG_X86_64
25394 +unsigned long mmu_cr4_features __read_only = X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE;
25395 +#elif defined(CONFIG_X86_PAE)
25396 +unsigned long mmu_cr4_features __read_only = X86_CR4_PAE;
25397 #else
25398 -unsigned long mmu_cr4_features = X86_CR4_PAE;
25399 +unsigned long mmu_cr4_features __read_only;
25400 #endif
25401
25402 +void set_in_cr4(unsigned long mask)
25403 +{
25404 + unsigned long cr4 = read_cr4();
25405 +
25406 + if ((cr4 & mask) == mask && cr4 == mmu_cr4_features)
25407 + return;
25408 +
25409 + pax_open_kernel();
25410 + mmu_cr4_features |= mask;
25411 + pax_close_kernel();
25412 +
25413 + if (trampoline_cr4_features)
25414 + *trampoline_cr4_features = mmu_cr4_features;
25415 + cr4 |= mask;
25416 + write_cr4(cr4);
25417 +}
25418 +EXPORT_SYMBOL(set_in_cr4);
25419 +
25420 +void clear_in_cr4(unsigned long mask)
25421 +{
25422 + unsigned long cr4 = read_cr4();
25423 +
25424 + if (!(cr4 & mask) && cr4 == mmu_cr4_features)
25425 + return;
25426 +
25427 + pax_open_kernel();
25428 + mmu_cr4_features &= ~mask;
25429 + pax_close_kernel();
25430 +
25431 + if (trampoline_cr4_features)
25432 + *trampoline_cr4_features = mmu_cr4_features;
25433 + cr4 &= ~mask;
25434 + write_cr4(cr4);
25435 +}
25436 +EXPORT_SYMBOL(clear_in_cr4);
25437 +
25438 /* Boot loader ID and version as integers, for the benefit of proc_dointvec */
25439 int bootloader_type, bootloader_version;
25440
25441 @@ -444,7 +483,7 @@ static void __init parse_setup_data(void)
25442
25443 switch (data->type) {
25444 case SETUP_E820_EXT:
25445 - parse_e820_ext(data);
25446 + parse_e820_ext((struct setup_data __force_kernel *)data);
25447 break;
25448 case SETUP_DTB:
25449 add_dtb(pa_data);
25450 @@ -771,7 +810,7 @@ static void __init trim_bios_range(void)
25451 * area (640->1Mb) as ram even though it is not.
25452 * take them out.
25453 */
25454 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
25455 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
25456
25457 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
25458 }
25459 @@ -779,7 +818,7 @@ static void __init trim_bios_range(void)
25460 /* called before trim_bios_range() to spare extra sanitize */
25461 static void __init e820_add_kernel_range(void)
25462 {
25463 - u64 start = __pa_symbol(_text);
25464 + u64 start = __pa_symbol(ktla_ktva(_text));
25465 u64 size = __pa_symbol(_end) - start;
25466
25467 /*
25468 @@ -841,8 +880,12 @@ static void __init trim_low_memory_range(void)
25469
25470 void __init setup_arch(char **cmdline_p)
25471 {
25472 +#ifdef CONFIG_X86_32
25473 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(__bss_stop) - LOAD_PHYSICAL_ADDR);
25474 +#else
25475 memblock_reserve(__pa_symbol(_text),
25476 (unsigned long)__bss_stop - (unsigned long)_text);
25477 +#endif
25478
25479 early_reserve_initrd();
25480
25481 @@ -934,14 +977,14 @@ void __init setup_arch(char **cmdline_p)
25482
25483 if (!boot_params.hdr.root_flags)
25484 root_mountflags &= ~MS_RDONLY;
25485 - init_mm.start_code = (unsigned long) _text;
25486 - init_mm.end_code = (unsigned long) _etext;
25487 + init_mm.start_code = ktla_ktva((unsigned long) _text);
25488 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
25489 init_mm.end_data = (unsigned long) _edata;
25490 init_mm.brk = _brk_end;
25491
25492 - code_resource.start = __pa_symbol(_text);
25493 - code_resource.end = __pa_symbol(_etext)-1;
25494 - data_resource.start = __pa_symbol(_etext);
25495 + code_resource.start = __pa_symbol(ktla_ktva(_text));
25496 + code_resource.end = __pa_symbol(ktla_ktva(_etext))-1;
25497 + data_resource.start = __pa_symbol(_sdata);
25498 data_resource.end = __pa_symbol(_edata)-1;
25499 bss_resource.start = __pa_symbol(__bss_start);
25500 bss_resource.end = __pa_symbol(__bss_stop)-1;
25501 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
25502 index 5cdff03..80fa283 100644
25503 --- a/arch/x86/kernel/setup_percpu.c
25504 +++ b/arch/x86/kernel/setup_percpu.c
25505 @@ -21,19 +21,17 @@
25506 #include <asm/cpu.h>
25507 #include <asm/stackprotector.h>
25508
25509 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
25510 +#ifdef CONFIG_SMP
25511 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
25512 EXPORT_PER_CPU_SYMBOL(cpu_number);
25513 +#endif
25514
25515 -#ifdef CONFIG_X86_64
25516 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
25517 -#else
25518 -#define BOOT_PERCPU_OFFSET 0
25519 -#endif
25520
25521 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
25522 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
25523
25524 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
25525 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
25526 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
25527 };
25528 EXPORT_SYMBOL(__per_cpu_offset);
25529 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
25530 {
25531 #ifdef CONFIG_NEED_MULTIPLE_NODES
25532 pg_data_t *last = NULL;
25533 - unsigned int cpu;
25534 + int cpu;
25535
25536 for_each_possible_cpu(cpu) {
25537 int node = early_cpu_to_node(cpu);
25538 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
25539 {
25540 #ifdef CONFIG_X86_32
25541 struct desc_struct gdt;
25542 + unsigned long base = per_cpu_offset(cpu);
25543
25544 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
25545 - 0x2 | DESCTYPE_S, 0x8);
25546 - gdt.s = 1;
25547 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
25548 + 0x83 | DESCTYPE_S, 0xC);
25549 write_gdt_entry(get_cpu_gdt_table(cpu),
25550 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
25551 #endif
25552 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
25553 /* alrighty, percpu areas up and running */
25554 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
25555 for_each_possible_cpu(cpu) {
25556 +#ifdef CONFIG_CC_STACKPROTECTOR
25557 +#ifdef CONFIG_X86_32
25558 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
25559 +#endif
25560 +#endif
25561 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
25562 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
25563 per_cpu(cpu_number, cpu) = cpu;
25564 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
25565 */
25566 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
25567 #endif
25568 +#ifdef CONFIG_CC_STACKPROTECTOR
25569 +#ifdef CONFIG_X86_32
25570 + if (!cpu)
25571 + per_cpu(stack_canary.canary, cpu) = canary;
25572 +#endif
25573 +#endif
25574 /*
25575 * Up to this point, the boot CPU has been using .init.data
25576 * area. Reload any changed state for the boot CPU.
25577 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
25578 index 6956299..18126ec4 100644
25579 --- a/arch/x86/kernel/signal.c
25580 +++ b/arch/x86/kernel/signal.c
25581 @@ -196,7 +196,7 @@ static unsigned long align_sigframe(unsigned long sp)
25582 * Align the stack pointer according to the i386 ABI,
25583 * i.e. so that on function entry ((sp + 4) & 15) == 0.
25584 */
25585 - sp = ((sp + 4) & -16ul) - 4;
25586 + sp = ((sp - 12) & -16ul) - 4;
25587 #else /* !CONFIG_X86_32 */
25588 sp = round_down(sp, 16) - 8;
25589 #endif
25590 @@ -304,9 +304,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
25591 }
25592
25593 if (current->mm->context.vdso)
25594 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
25595 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
25596 else
25597 - restorer = &frame->retcode;
25598 + restorer = (void __user *)&frame->retcode;
25599 if (ksig->ka.sa.sa_flags & SA_RESTORER)
25600 restorer = ksig->ka.sa.sa_restorer;
25601
25602 @@ -320,7 +320,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
25603 * reasons and because gdb uses it as a signature to notice
25604 * signal handler stack frames.
25605 */
25606 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
25607 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
25608
25609 if (err)
25610 return -EFAULT;
25611 @@ -364,10 +364,13 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
25612 else
25613 put_user_ex(0, &frame->uc.uc_flags);
25614 put_user_ex(0, &frame->uc.uc_link);
25615 - err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
25616 + __save_altstack_ex(&frame->uc.uc_stack, regs->sp);
25617
25618 /* Set up to return from userspace. */
25619 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
25620 + if (current->mm->context.vdso)
25621 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
25622 + else
25623 + restorer = (void __user *)&frame->retcode;
25624 if (ksig->ka.sa.sa_flags & SA_RESTORER)
25625 restorer = ksig->ka.sa.sa_restorer;
25626 put_user_ex(restorer, &frame->pretcode);
25627 @@ -379,7 +382,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
25628 * reasons and because gdb uses it as a signature to notice
25629 * signal handler stack frames.
25630 */
25631 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
25632 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
25633 } put_user_catch(err);
25634
25635 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
25636 @@ -429,7 +432,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
25637 else
25638 put_user_ex(0, &frame->uc.uc_flags);
25639 put_user_ex(0, &frame->uc.uc_link);
25640 - err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
25641 + __save_altstack_ex(&frame->uc.uc_stack, regs->sp);
25642
25643 /* Set up to return from userspace. If provided, use a stub
25644 already in userspace. */
25645 @@ -615,7 +618,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
25646 {
25647 int usig = signr_convert(ksig->sig);
25648 sigset_t *set = sigmask_to_save();
25649 - compat_sigset_t *cset = (compat_sigset_t *) set;
25650 + sigset_t sigcopy;
25651 + compat_sigset_t *cset;
25652 +
25653 + sigcopy = *set;
25654 +
25655 + cset = (compat_sigset_t *) &sigcopy;
25656
25657 /* Set up the stack frame */
25658 if (is_ia32_frame()) {
25659 @@ -626,7 +634,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
25660 } else if (is_x32_frame()) {
25661 return x32_setup_rt_frame(ksig, cset, regs);
25662 } else {
25663 - return __setup_rt_frame(ksig->sig, ksig, set, regs);
25664 + return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
25665 }
25666 }
25667
25668 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
25669 index 48d2b7d..90d328a 100644
25670 --- a/arch/x86/kernel/smp.c
25671 +++ b/arch/x86/kernel/smp.c
25672 @@ -285,7 +285,7 @@ static int __init nonmi_ipi_setup(char *str)
25673
25674 __setup("nonmi_ipi", nonmi_ipi_setup);
25675
25676 -struct smp_ops smp_ops = {
25677 +struct smp_ops smp_ops __read_only = {
25678 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
25679 .smp_prepare_cpus = native_smp_prepare_cpus,
25680 .smp_cpus_done = native_smp_cpus_done,
25681 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
25682 index bfd348e..914f323 100644
25683 --- a/arch/x86/kernel/smpboot.c
25684 +++ b/arch/x86/kernel/smpboot.c
25685 @@ -251,14 +251,18 @@ notrace static void __cpuinit start_secondary(void *unused)
25686
25687 enable_start_cpu0 = 0;
25688
25689 -#ifdef CONFIG_X86_32
25690 - /* switch away from the initial page table */
25691 - load_cr3(swapper_pg_dir);
25692 - __flush_tlb_all();
25693 -#endif
25694 -
25695 /* otherwise gcc will move up smp_processor_id before the cpu_init */
25696 barrier();
25697 +
25698 + /* switch away from the initial page table */
25699 +#ifdef CONFIG_PAX_PER_CPU_PGD
25700 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
25701 + __flush_tlb_all();
25702 +#elif defined(CONFIG_X86_32)
25703 + load_cr3(swapper_pg_dir);
25704 + __flush_tlb_all();
25705 +#endif
25706 +
25707 /*
25708 * Check TSC synchronization with the BP:
25709 */
25710 @@ -748,6 +752,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
25711 idle->thread.sp = (unsigned long) (((struct pt_regs *)
25712 (THREAD_SIZE + task_stack_page(idle))) - 1);
25713 per_cpu(current_task, cpu) = idle;
25714 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
25715
25716 #ifdef CONFIG_X86_32
25717 /* Stack for startup_32 can be just as for start_secondary onwards */
25718 @@ -755,11 +760,13 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
25719 #else
25720 clear_tsk_thread_flag(idle, TIF_FORK);
25721 initial_gs = per_cpu_offset(cpu);
25722 - per_cpu(kernel_stack, cpu) =
25723 - (unsigned long)task_stack_page(idle) -
25724 - KERNEL_STACK_OFFSET + THREAD_SIZE;
25725 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
25726 #endif
25727 +
25728 + pax_open_kernel();
25729 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
25730 + pax_close_kernel();
25731 +
25732 initial_code = (unsigned long)start_secondary;
25733 stack_start = idle->thread.sp;
25734
25735 @@ -908,6 +915,15 @@ int __cpuinit native_cpu_up(unsigned int cpu, struct task_struct *tidle)
25736 /* the FPU context is blank, nobody can own it */
25737 __cpu_disable_lazy_restore(cpu);
25738
25739 +#ifdef CONFIG_PAX_PER_CPU_PGD
25740 + clone_pgd_range(get_cpu_pgd(cpu, kernel) + KERNEL_PGD_BOUNDARY,
25741 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
25742 + KERNEL_PGD_PTRS);
25743 + clone_pgd_range(get_cpu_pgd(cpu, user) + KERNEL_PGD_BOUNDARY,
25744 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
25745 + KERNEL_PGD_PTRS);
25746 +#endif
25747 +
25748 err = do_boot_cpu(apicid, cpu, tidle);
25749 if (err) {
25750 pr_debug("do_boot_cpu failed %d\n", err);
25751 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
25752 index 9b4d51d..5d28b58 100644
25753 --- a/arch/x86/kernel/step.c
25754 +++ b/arch/x86/kernel/step.c
25755 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
25756 struct desc_struct *desc;
25757 unsigned long base;
25758
25759 - seg &= ~7UL;
25760 + seg >>= 3;
25761
25762 mutex_lock(&child->mm->context.lock);
25763 - if (unlikely((seg >> 3) >= child->mm->context.size))
25764 + if (unlikely(seg >= child->mm->context.size))
25765 addr = -1L; /* bogus selector, access would fault */
25766 else {
25767 desc = child->mm->context.ldt + seg;
25768 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
25769 addr += base;
25770 }
25771 mutex_unlock(&child->mm->context.lock);
25772 - }
25773 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
25774 + addr = ktla_ktva(addr);
25775
25776 return addr;
25777 }
25778 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
25779 unsigned char opcode[15];
25780 unsigned long addr = convert_ip_to_linear(child, regs);
25781
25782 + if (addr == -EINVAL)
25783 + return 0;
25784 +
25785 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
25786 for (i = 0; i < copied; i++) {
25787 switch (opcode[i]) {
25788 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
25789 new file mode 100644
25790 index 0000000..5877189
25791 --- /dev/null
25792 +++ b/arch/x86/kernel/sys_i386_32.c
25793 @@ -0,0 +1,189 @@
25794 +/*
25795 + * This file contains various random system calls that
25796 + * have a non-standard calling sequence on the Linux/i386
25797 + * platform.
25798 + */
25799 +
25800 +#include <linux/errno.h>
25801 +#include <linux/sched.h>
25802 +#include <linux/mm.h>
25803 +#include <linux/fs.h>
25804 +#include <linux/smp.h>
25805 +#include <linux/sem.h>
25806 +#include <linux/msg.h>
25807 +#include <linux/shm.h>
25808 +#include <linux/stat.h>
25809 +#include <linux/syscalls.h>
25810 +#include <linux/mman.h>
25811 +#include <linux/file.h>
25812 +#include <linux/utsname.h>
25813 +#include <linux/ipc.h>
25814 +#include <linux/elf.h>
25815 +
25816 +#include <linux/uaccess.h>
25817 +#include <linux/unistd.h>
25818 +
25819 +#include <asm/syscalls.h>
25820 +
25821 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
25822 +{
25823 + unsigned long pax_task_size = TASK_SIZE;
25824 +
25825 +#ifdef CONFIG_PAX_SEGMEXEC
25826 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
25827 + pax_task_size = SEGMEXEC_TASK_SIZE;
25828 +#endif
25829 +
25830 + if (flags & MAP_FIXED)
25831 + if (len > pax_task_size || addr > pax_task_size - len)
25832 + return -EINVAL;
25833 +
25834 + return 0;
25835 +}
25836 +
25837 +/*
25838 + * Align a virtual address to avoid aliasing in the I$ on AMD F15h.
25839 + */
25840 +static unsigned long get_align_mask(void)
25841 +{
25842 + if (va_align.flags < 0 || !(va_align.flags & ALIGN_VA_32))
25843 + return 0;
25844 +
25845 + if (!(current->flags & PF_RANDOMIZE))
25846 + return 0;
25847 +
25848 + return va_align.mask;
25849 +}
25850 +
25851 +unsigned long
25852 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
25853 + unsigned long len, unsigned long pgoff, unsigned long flags)
25854 +{
25855 + struct mm_struct *mm = current->mm;
25856 + struct vm_area_struct *vma;
25857 + unsigned long pax_task_size = TASK_SIZE;
25858 + struct vm_unmapped_area_info info;
25859 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25860 +
25861 +#ifdef CONFIG_PAX_SEGMEXEC
25862 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
25863 + pax_task_size = SEGMEXEC_TASK_SIZE;
25864 +#endif
25865 +
25866 + pax_task_size -= PAGE_SIZE;
25867 +
25868 + if (len > pax_task_size)
25869 + return -ENOMEM;
25870 +
25871 + if (flags & MAP_FIXED)
25872 + return addr;
25873 +
25874 +#ifdef CONFIG_PAX_RANDMMAP
25875 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25876 +#endif
25877 +
25878 + if (addr) {
25879 + addr = PAGE_ALIGN(addr);
25880 + if (pax_task_size - len >= addr) {
25881 + vma = find_vma(mm, addr);
25882 + if (check_heap_stack_gap(vma, addr, len, offset))
25883 + return addr;
25884 + }
25885 + }
25886 +
25887 + info.flags = 0;
25888 + info.length = len;
25889 + info.align_mask = filp ? get_align_mask() : 0;
25890 + info.align_offset = pgoff << PAGE_SHIFT;
25891 + info.threadstack_offset = offset;
25892 +
25893 +#ifdef CONFIG_PAX_PAGEEXEC
25894 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE)) {
25895 + info.low_limit = 0x00110000UL;
25896 + info.high_limit = mm->start_code;
25897 +
25898 +#ifdef CONFIG_PAX_RANDMMAP
25899 + if (mm->pax_flags & MF_PAX_RANDMMAP)
25900 + info.low_limit += mm->delta_mmap & 0x03FFF000UL;
25901 +#endif
25902 +
25903 + if (info.low_limit < info.high_limit) {
25904 + addr = vm_unmapped_area(&info);
25905 + if (!IS_ERR_VALUE(addr))
25906 + return addr;
25907 + }
25908 + } else
25909 +#endif
25910 +
25911 + info.low_limit = mm->mmap_base;
25912 + info.high_limit = pax_task_size;
25913 +
25914 + return vm_unmapped_area(&info);
25915 +}
25916 +
25917 +unsigned long
25918 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25919 + const unsigned long len, const unsigned long pgoff,
25920 + const unsigned long flags)
25921 +{
25922 + struct vm_area_struct *vma;
25923 + struct mm_struct *mm = current->mm;
25924 + unsigned long addr = addr0, pax_task_size = TASK_SIZE;
25925 + struct vm_unmapped_area_info info;
25926 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25927 +
25928 +#ifdef CONFIG_PAX_SEGMEXEC
25929 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
25930 + pax_task_size = SEGMEXEC_TASK_SIZE;
25931 +#endif
25932 +
25933 + pax_task_size -= PAGE_SIZE;
25934 +
25935 + /* requested length too big for entire address space */
25936 + if (len > pax_task_size)
25937 + return -ENOMEM;
25938 +
25939 + if (flags & MAP_FIXED)
25940 + return addr;
25941 +
25942 +#ifdef CONFIG_PAX_PAGEEXEC
25943 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
25944 + goto bottomup;
25945 +#endif
25946 +
25947 +#ifdef CONFIG_PAX_RANDMMAP
25948 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25949 +#endif
25950 +
25951 + /* requesting a specific address */
25952 + if (addr) {
25953 + addr = PAGE_ALIGN(addr);
25954 + if (pax_task_size - len >= addr) {
25955 + vma = find_vma(mm, addr);
25956 + if (check_heap_stack_gap(vma, addr, len, offset))
25957 + return addr;
25958 + }
25959 + }
25960 +
25961 + info.flags = VM_UNMAPPED_AREA_TOPDOWN;
25962 + info.length = len;
25963 + info.low_limit = PAGE_SIZE;
25964 + info.high_limit = mm->mmap_base;
25965 + info.align_mask = filp ? get_align_mask() : 0;
25966 + info.align_offset = pgoff << PAGE_SHIFT;
25967 + info.threadstack_offset = offset;
25968 +
25969 + addr = vm_unmapped_area(&info);
25970 + if (!(addr & ~PAGE_MASK))
25971 + return addr;
25972 + VM_BUG_ON(addr != -ENOMEM);
25973 +
25974 +bottomup:
25975 + /*
25976 + * A failed mmap() very likely causes application failure,
25977 + * so fall back to the bottom-up function here. This scenario
25978 + * can happen with large stack limits and large mmap()
25979 + * allocations.
25980 + */
25981 + return arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
25982 +}
25983 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
25984 index 30277e2..5664a29 100644
25985 --- a/arch/x86/kernel/sys_x86_64.c
25986 +++ b/arch/x86/kernel/sys_x86_64.c
25987 @@ -81,8 +81,8 @@ out:
25988 return error;
25989 }
25990
25991 -static void find_start_end(unsigned long flags, unsigned long *begin,
25992 - unsigned long *end)
25993 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
25994 + unsigned long *begin, unsigned long *end)
25995 {
25996 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
25997 unsigned long new_begin;
25998 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
25999 *begin = new_begin;
26000 }
26001 } else {
26002 - *begin = current->mm->mmap_legacy_base;
26003 + *begin = mm->mmap_legacy_base;
26004 *end = TASK_SIZE;
26005 }
26006 }
26007 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
26008 struct vm_area_struct *vma;
26009 struct vm_unmapped_area_info info;
26010 unsigned long begin, end;
26011 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
26012
26013 if (flags & MAP_FIXED)
26014 return addr;
26015
26016 - find_start_end(flags, &begin, &end);
26017 + find_start_end(mm, flags, &begin, &end);
26018
26019 if (len > end)
26020 return -ENOMEM;
26021
26022 +#ifdef CONFIG_PAX_RANDMMAP
26023 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
26024 +#endif
26025 +
26026 if (addr) {
26027 addr = PAGE_ALIGN(addr);
26028 vma = find_vma(mm, addr);
26029 - if (end - len >= addr &&
26030 - (!vma || addr + len <= vma->vm_start))
26031 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
26032 return addr;
26033 }
26034
26035 @@ -137,6 +141,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
26036 info.high_limit = end;
26037 info.align_mask = filp ? get_align_mask() : 0;
26038 info.align_offset = pgoff << PAGE_SHIFT;
26039 + info.threadstack_offset = offset;
26040 return vm_unmapped_area(&info);
26041 }
26042
26043 @@ -149,6 +154,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
26044 struct mm_struct *mm = current->mm;
26045 unsigned long addr = addr0;
26046 struct vm_unmapped_area_info info;
26047 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
26048
26049 /* requested length too big for entire address space */
26050 if (len > TASK_SIZE)
26051 @@ -161,12 +167,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
26052 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
26053 goto bottomup;
26054
26055 +#ifdef CONFIG_PAX_RANDMMAP
26056 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
26057 +#endif
26058 +
26059 /* requesting a specific address */
26060 if (addr) {
26061 addr = PAGE_ALIGN(addr);
26062 vma = find_vma(mm, addr);
26063 - if (TASK_SIZE - len >= addr &&
26064 - (!vma || addr + len <= vma->vm_start))
26065 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
26066 return addr;
26067 }
26068
26069 @@ -176,6 +185,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
26070 info.high_limit = mm->mmap_base;
26071 info.align_mask = filp ? get_align_mask() : 0;
26072 info.align_offset = pgoff << PAGE_SHIFT;
26073 + info.threadstack_offset = offset;
26074 addr = vm_unmapped_area(&info);
26075 if (!(addr & ~PAGE_MASK))
26076 return addr;
26077 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
26078 index f84fe00..f41d9f1 100644
26079 --- a/arch/x86/kernel/tboot.c
26080 +++ b/arch/x86/kernel/tboot.c
26081 @@ -220,7 +220,7 @@ static int tboot_setup_sleep(void)
26082
26083 void tboot_shutdown(u32 shutdown_type)
26084 {
26085 - void (*shutdown)(void);
26086 + void (* __noreturn shutdown)(void);
26087
26088 if (!tboot_enabled())
26089 return;
26090 @@ -242,7 +242,7 @@ void tboot_shutdown(u32 shutdown_type)
26091
26092 switch_to_tboot_pt();
26093
26094 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
26095 + shutdown = (void *)tboot->shutdown_entry;
26096 shutdown();
26097
26098 /* should not reach here */
26099 @@ -300,7 +300,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
26100 return 0;
26101 }
26102
26103 -static atomic_t ap_wfs_count;
26104 +static atomic_unchecked_t ap_wfs_count;
26105
26106 static int tboot_wait_for_aps(int num_aps)
26107 {
26108 @@ -324,16 +324,16 @@ static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb,
26109 {
26110 switch (action) {
26111 case CPU_DYING:
26112 - atomic_inc(&ap_wfs_count);
26113 + atomic_inc_unchecked(&ap_wfs_count);
26114 if (num_online_cpus() == 1)
26115 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
26116 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
26117 return NOTIFY_BAD;
26118 break;
26119 }
26120 return NOTIFY_OK;
26121 }
26122
26123 -static struct notifier_block tboot_cpu_notifier __cpuinitdata =
26124 +static struct notifier_block tboot_cpu_notifier =
26125 {
26126 .notifier_call = tboot_cpu_callback,
26127 };
26128 @@ -345,7 +345,7 @@ static __init int tboot_late_init(void)
26129
26130 tboot_create_trampoline();
26131
26132 - atomic_set(&ap_wfs_count, 0);
26133 + atomic_set_unchecked(&ap_wfs_count, 0);
26134 register_hotcpu_notifier(&tboot_cpu_notifier);
26135
26136 acpi_os_set_prepare_sleep(&tboot_sleep);
26137 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
26138 index 24d3c91..d06b473 100644
26139 --- a/arch/x86/kernel/time.c
26140 +++ b/arch/x86/kernel/time.c
26141 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
26142 {
26143 unsigned long pc = instruction_pointer(regs);
26144
26145 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
26146 + if (!user_mode(regs) && in_lock_functions(pc)) {
26147 #ifdef CONFIG_FRAME_POINTER
26148 - return *(unsigned long *)(regs->bp + sizeof(long));
26149 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
26150 #else
26151 unsigned long *sp =
26152 (unsigned long *)kernel_stack_pointer(regs);
26153 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
26154 * or above a saved flags. Eflags has bits 22-31 zero,
26155 * kernel addresses don't.
26156 */
26157 +
26158 +#ifdef CONFIG_PAX_KERNEXEC
26159 + return ktla_ktva(sp[0]);
26160 +#else
26161 if (sp[0] >> 22)
26162 return sp[0];
26163 if (sp[1] >> 22)
26164 return sp[1];
26165 #endif
26166 +
26167 +#endif
26168 }
26169 return pc;
26170 }
26171 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
26172 index f7fec09..9991981 100644
26173 --- a/arch/x86/kernel/tls.c
26174 +++ b/arch/x86/kernel/tls.c
26175 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
26176 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
26177 return -EINVAL;
26178
26179 +#ifdef CONFIG_PAX_SEGMEXEC
26180 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
26181 + return -EINVAL;
26182 +#endif
26183 +
26184 set_tls_desc(p, idx, &info, 1);
26185
26186 return 0;
26187 @@ -200,7 +205,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
26188
26189 if (kbuf)
26190 info = kbuf;
26191 - else if (__copy_from_user(infobuf, ubuf, count))
26192 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
26193 return -EFAULT;
26194 else
26195 info = infobuf;
26196 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
26197 index 772e2a8..bad5bf6 100644
26198 --- a/arch/x86/kernel/traps.c
26199 +++ b/arch/x86/kernel/traps.c
26200 @@ -68,12 +68,6 @@
26201 #include <asm/setup.h>
26202
26203 asmlinkage int system_call(void);
26204 -
26205 -/*
26206 - * The IDT has to be page-aligned to simplify the Pentium
26207 - * F0 0F bug workaround.
26208 - */
26209 -gate_desc idt_table[NR_VECTORS] __page_aligned_data = { { { { 0, 0 } } }, };
26210 #endif
26211
26212 DECLARE_BITMAP(used_vectors, NR_VECTORS);
26213 @@ -106,11 +100,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
26214 }
26215
26216 static int __kprobes
26217 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
26218 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
26219 struct pt_regs *regs, long error_code)
26220 {
26221 #ifdef CONFIG_X86_32
26222 - if (regs->flags & X86_VM_MASK) {
26223 + if (v8086_mode(regs)) {
26224 /*
26225 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
26226 * On nmi (interrupt 2), do_trap should not be called.
26227 @@ -123,12 +117,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
26228 return -1;
26229 }
26230 #endif
26231 - if (!user_mode(regs)) {
26232 + if (!user_mode_novm(regs)) {
26233 if (!fixup_exception(regs)) {
26234 tsk->thread.error_code = error_code;
26235 tsk->thread.trap_nr = trapnr;
26236 +
26237 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26238 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
26239 + str = "PAX: suspicious stack segment fault";
26240 +#endif
26241 +
26242 die(str, regs, error_code);
26243 }
26244 +
26245 +#ifdef CONFIG_PAX_REFCOUNT
26246 + if (trapnr == 4)
26247 + pax_report_refcount_overflow(regs);
26248 +#endif
26249 +
26250 return 0;
26251 }
26252
26253 @@ -136,7 +142,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
26254 }
26255
26256 static void __kprobes
26257 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
26258 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
26259 long error_code, siginfo_t *info)
26260 {
26261 struct task_struct *tsk = current;
26262 @@ -160,7 +166,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
26263 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
26264 printk_ratelimit()) {
26265 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
26266 - tsk->comm, tsk->pid, str,
26267 + tsk->comm, task_pid_nr(tsk), str,
26268 regs->ip, regs->sp, error_code);
26269 print_vma_addr(" in ", regs->ip);
26270 pr_cont("\n");
26271 @@ -273,7 +279,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
26272 conditional_sti(regs);
26273
26274 #ifdef CONFIG_X86_32
26275 - if (regs->flags & X86_VM_MASK) {
26276 + if (v8086_mode(regs)) {
26277 local_irq_enable();
26278 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
26279 goto exit;
26280 @@ -281,18 +287,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
26281 #endif
26282
26283 tsk = current;
26284 - if (!user_mode(regs)) {
26285 + if (!user_mode_novm(regs)) {
26286 if (fixup_exception(regs))
26287 goto exit;
26288
26289 tsk->thread.error_code = error_code;
26290 tsk->thread.trap_nr = X86_TRAP_GP;
26291 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
26292 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
26293 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
26294 +
26295 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26296 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
26297 + die("PAX: suspicious general protection fault", regs, error_code);
26298 + else
26299 +#endif
26300 +
26301 die("general protection fault", regs, error_code);
26302 + }
26303 goto exit;
26304 }
26305
26306 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
26307 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
26308 + struct mm_struct *mm = tsk->mm;
26309 + unsigned long limit;
26310 +
26311 + down_write(&mm->mmap_sem);
26312 + limit = mm->context.user_cs_limit;
26313 + if (limit < TASK_SIZE) {
26314 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
26315 + up_write(&mm->mmap_sem);
26316 + return;
26317 + }
26318 + up_write(&mm->mmap_sem);
26319 + }
26320 +#endif
26321 +
26322 tsk->thread.error_code = error_code;
26323 tsk->thread.trap_nr = X86_TRAP_GP;
26324
26325 @@ -450,7 +480,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
26326 /* It's safe to allow irq's after DR6 has been saved */
26327 preempt_conditional_sti(regs);
26328
26329 - if (regs->flags & X86_VM_MASK) {
26330 + if (v8086_mode(regs)) {
26331 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
26332 X86_TRAP_DB);
26333 preempt_conditional_cli(regs);
26334 @@ -465,7 +495,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
26335 * We already checked v86 mode above, so we can check for kernel mode
26336 * by just checking the CPL of CS.
26337 */
26338 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
26339 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
26340 tsk->thread.debugreg6 &= ~DR_STEP;
26341 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
26342 regs->flags &= ~X86_EFLAGS_TF;
26343 @@ -497,7 +527,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
26344 return;
26345 conditional_sti(regs);
26346
26347 - if (!user_mode_vm(regs))
26348 + if (!user_mode(regs))
26349 {
26350 if (!fixup_exception(regs)) {
26351 task->thread.error_code = error_code;
26352 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
26353 index 2ed8459..7cf329f 100644
26354 --- a/arch/x86/kernel/uprobes.c
26355 +++ b/arch/x86/kernel/uprobes.c
26356 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
26357 int ret = NOTIFY_DONE;
26358
26359 /* We are only interested in userspace traps */
26360 - if (regs && !user_mode_vm(regs))
26361 + if (regs && !user_mode(regs))
26362 return NOTIFY_DONE;
26363
26364 switch (val) {
26365 @@ -719,7 +719,7 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs
26366
26367 if (ncopied != rasize) {
26368 pr_err("uprobe: return address clobbered: pid=%d, %%sp=%#lx, "
26369 - "%%ip=%#lx\n", current->pid, regs->sp, regs->ip);
26370 + "%%ip=%#lx\n", task_pid_nr(current), regs->sp, regs->ip);
26371
26372 force_sig_info(SIGSEGV, SEND_SIG_FORCED, current);
26373 }
26374 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
26375 index b9242ba..50c5edd 100644
26376 --- a/arch/x86/kernel/verify_cpu.S
26377 +++ b/arch/x86/kernel/verify_cpu.S
26378 @@ -20,6 +20,7 @@
26379 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
26380 * arch/x86/kernel/trampoline_64.S: secondary processor verification
26381 * arch/x86/kernel/head_32.S: processor startup
26382 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
26383 *
26384 * verify_cpu, returns the status of longmode and SSE in register %eax.
26385 * 0: Success 1: Failure
26386 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
26387 index e8edcf5..27f9344 100644
26388 --- a/arch/x86/kernel/vm86_32.c
26389 +++ b/arch/x86/kernel/vm86_32.c
26390 @@ -44,6 +44,7 @@
26391 #include <linux/ptrace.h>
26392 #include <linux/audit.h>
26393 #include <linux/stddef.h>
26394 +#include <linux/grsecurity.h>
26395
26396 #include <asm/uaccess.h>
26397 #include <asm/io.h>
26398 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
26399 do_exit(SIGSEGV);
26400 }
26401
26402 - tss = &per_cpu(init_tss, get_cpu());
26403 + tss = init_tss + get_cpu();
26404 current->thread.sp0 = current->thread.saved_sp0;
26405 current->thread.sysenter_cs = __KERNEL_CS;
26406 load_sp0(tss, &current->thread);
26407 @@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
26408
26409 if (tsk->thread.saved_sp0)
26410 return -EPERM;
26411 +
26412 +#ifdef CONFIG_GRKERNSEC_VM86
26413 + if (!capable(CAP_SYS_RAWIO)) {
26414 + gr_handle_vm86();
26415 + return -EPERM;
26416 + }
26417 +#endif
26418 +
26419 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
26420 offsetof(struct kernel_vm86_struct, vm86plus) -
26421 sizeof(info.regs));
26422 @@ -238,6 +247,13 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
26423 int tmp;
26424 struct vm86plus_struct __user *v86;
26425
26426 +#ifdef CONFIG_GRKERNSEC_VM86
26427 + if (!capable(CAP_SYS_RAWIO)) {
26428 + gr_handle_vm86();
26429 + return -EPERM;
26430 + }
26431 +#endif
26432 +
26433 tsk = current;
26434 switch (cmd) {
26435 case VM86_REQUEST_IRQ:
26436 @@ -318,7 +334,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
26437 tsk->thread.saved_fs = info->regs32->fs;
26438 tsk->thread.saved_gs = get_user_gs(info->regs32);
26439
26440 - tss = &per_cpu(init_tss, get_cpu());
26441 + tss = init_tss + get_cpu();
26442 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
26443 if (cpu_has_sep)
26444 tsk->thread.sysenter_cs = 0;
26445 @@ -525,7 +541,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
26446 goto cannot_handle;
26447 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
26448 goto cannot_handle;
26449 - intr_ptr = (unsigned long __user *) (i << 2);
26450 + intr_ptr = (__force unsigned long __user *) (i << 2);
26451 if (get_user(segoffs, intr_ptr))
26452 goto cannot_handle;
26453 if ((segoffs >> 16) == BIOSSEG)
26454 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
26455 index 10c4f30..57377c2 100644
26456 --- a/arch/x86/kernel/vmlinux.lds.S
26457 +++ b/arch/x86/kernel/vmlinux.lds.S
26458 @@ -26,6 +26,13 @@
26459 #include <asm/page_types.h>
26460 #include <asm/cache.h>
26461 #include <asm/boot.h>
26462 +#include <asm/segment.h>
26463 +
26464 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26465 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
26466 +#else
26467 +#define __KERNEL_TEXT_OFFSET 0
26468 +#endif
26469
26470 #undef i386 /* in case the preprocessor is a 32bit one */
26471
26472 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
26473
26474 PHDRS {
26475 text PT_LOAD FLAGS(5); /* R_E */
26476 +#ifdef CONFIG_X86_32
26477 + module PT_LOAD FLAGS(5); /* R_E */
26478 +#endif
26479 +#ifdef CONFIG_XEN
26480 + rodata PT_LOAD FLAGS(5); /* R_E */
26481 +#else
26482 + rodata PT_LOAD FLAGS(4); /* R__ */
26483 +#endif
26484 data PT_LOAD FLAGS(6); /* RW_ */
26485 -#ifdef CONFIG_X86_64
26486 + init.begin PT_LOAD FLAGS(6); /* RW_ */
26487 #ifdef CONFIG_SMP
26488 percpu PT_LOAD FLAGS(6); /* RW_ */
26489 #endif
26490 + text.init PT_LOAD FLAGS(5); /* R_E */
26491 + text.exit PT_LOAD FLAGS(5); /* R_E */
26492 init PT_LOAD FLAGS(7); /* RWE */
26493 -#endif
26494 note PT_NOTE FLAGS(0); /* ___ */
26495 }
26496
26497 SECTIONS
26498 {
26499 #ifdef CONFIG_X86_32
26500 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
26501 - phys_startup_32 = startup_32 - LOAD_OFFSET;
26502 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
26503 #else
26504 - . = __START_KERNEL;
26505 - phys_startup_64 = startup_64 - LOAD_OFFSET;
26506 + . = __START_KERNEL;
26507 #endif
26508
26509 /* Text and read-only data */
26510 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
26511 - _text = .;
26512 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
26513 /* bootstrapping code */
26514 +#ifdef CONFIG_X86_32
26515 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26516 +#else
26517 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26518 +#endif
26519 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26520 + _text = .;
26521 HEAD_TEXT
26522 . = ALIGN(8);
26523 _stext = .;
26524 @@ -104,13 +124,48 @@ SECTIONS
26525 IRQENTRY_TEXT
26526 *(.fixup)
26527 *(.gnu.warning)
26528 - /* End of text section */
26529 - _etext = .;
26530 } :text = 0x9090
26531
26532 - NOTES :text :note
26533 + . += __KERNEL_TEXT_OFFSET;
26534
26535 - EXCEPTION_TABLE(16) :text = 0x9090
26536 +#ifdef CONFIG_X86_32
26537 + . = ALIGN(PAGE_SIZE);
26538 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
26539 +
26540 +#ifdef CONFIG_PAX_KERNEXEC
26541 + MODULES_EXEC_VADDR = .;
26542 + BYTE(0)
26543 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
26544 + . = ALIGN(HPAGE_SIZE) - 1;
26545 + MODULES_EXEC_END = .;
26546 +#endif
26547 +
26548 + } :module
26549 +#endif
26550 +
26551 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
26552 + /* End of text section */
26553 + BYTE(0)
26554 + _etext = . - __KERNEL_TEXT_OFFSET;
26555 + }
26556 +
26557 +#ifdef CONFIG_X86_32
26558 + . = ALIGN(PAGE_SIZE);
26559 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
26560 + *(.idt)
26561 + . = ALIGN(PAGE_SIZE);
26562 + *(.empty_zero_page)
26563 + *(.initial_pg_fixmap)
26564 + *(.initial_pg_pmd)
26565 + *(.initial_page_table)
26566 + *(.swapper_pg_dir)
26567 + } :rodata
26568 +#endif
26569 +
26570 + . = ALIGN(PAGE_SIZE);
26571 + NOTES :rodata :note
26572 +
26573 + EXCEPTION_TABLE(16) :rodata
26574
26575 #if defined(CONFIG_DEBUG_RODATA)
26576 /* .text should occupy whole number of pages */
26577 @@ -122,16 +177,20 @@ SECTIONS
26578
26579 /* Data */
26580 .data : AT(ADDR(.data) - LOAD_OFFSET) {
26581 +
26582 +#ifdef CONFIG_PAX_KERNEXEC
26583 + . = ALIGN(HPAGE_SIZE);
26584 +#else
26585 + . = ALIGN(PAGE_SIZE);
26586 +#endif
26587 +
26588 /* Start of data section */
26589 _sdata = .;
26590
26591 /* init_task */
26592 INIT_TASK_DATA(THREAD_SIZE)
26593
26594 -#ifdef CONFIG_X86_32
26595 - /* 32 bit has nosave before _edata */
26596 NOSAVE_DATA
26597 -#endif
26598
26599 PAGE_ALIGNED_DATA(PAGE_SIZE)
26600
26601 @@ -172,12 +231,19 @@ SECTIONS
26602 #endif /* CONFIG_X86_64 */
26603
26604 /* Init code and data - will be freed after init */
26605 - . = ALIGN(PAGE_SIZE);
26606 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
26607 + BYTE(0)
26608 +
26609 +#ifdef CONFIG_PAX_KERNEXEC
26610 + . = ALIGN(HPAGE_SIZE);
26611 +#else
26612 + . = ALIGN(PAGE_SIZE);
26613 +#endif
26614 +
26615 __init_begin = .; /* paired with __init_end */
26616 - }
26617 + } :init.begin
26618
26619 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
26620 +#ifdef CONFIG_SMP
26621 /*
26622 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
26623 * output PHDR, so the next output section - .init.text - should
26624 @@ -186,12 +252,27 @@ SECTIONS
26625 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
26626 #endif
26627
26628 - INIT_TEXT_SECTION(PAGE_SIZE)
26629 -#ifdef CONFIG_X86_64
26630 - :init
26631 -#endif
26632 + . = ALIGN(PAGE_SIZE);
26633 + init_begin = .;
26634 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
26635 + VMLINUX_SYMBOL(_sinittext) = .;
26636 + INIT_TEXT
26637 + VMLINUX_SYMBOL(_einittext) = .;
26638 + . = ALIGN(PAGE_SIZE);
26639 + } :text.init
26640
26641 - INIT_DATA_SECTION(16)
26642 + /*
26643 + * .exit.text is discard at runtime, not link time, to deal with
26644 + * references from .altinstructions and .eh_frame
26645 + */
26646 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
26647 + EXIT_TEXT
26648 + . = ALIGN(16);
26649 + } :text.exit
26650 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
26651 +
26652 + . = ALIGN(PAGE_SIZE);
26653 + INIT_DATA_SECTION(16) :init
26654
26655 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
26656 __x86_cpu_dev_start = .;
26657 @@ -253,19 +334,12 @@ SECTIONS
26658 }
26659
26660 . = ALIGN(8);
26661 - /*
26662 - * .exit.text is discard at runtime, not link time, to deal with
26663 - * references from .altinstructions and .eh_frame
26664 - */
26665 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
26666 - EXIT_TEXT
26667 - }
26668
26669 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
26670 EXIT_DATA
26671 }
26672
26673 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
26674 +#ifndef CONFIG_SMP
26675 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
26676 #endif
26677
26678 @@ -284,16 +358,10 @@ SECTIONS
26679 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
26680 __smp_locks = .;
26681 *(.smp_locks)
26682 - . = ALIGN(PAGE_SIZE);
26683 __smp_locks_end = .;
26684 + . = ALIGN(PAGE_SIZE);
26685 }
26686
26687 -#ifdef CONFIG_X86_64
26688 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
26689 - NOSAVE_DATA
26690 - }
26691 -#endif
26692 -
26693 /* BSS */
26694 . = ALIGN(PAGE_SIZE);
26695 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
26696 @@ -309,6 +377,7 @@ SECTIONS
26697 __brk_base = .;
26698 . += 64 * 1024; /* 64k alignment slop space */
26699 *(.brk_reservation) /* areas brk users have reserved */
26700 + . = ALIGN(HPAGE_SIZE);
26701 __brk_limit = .;
26702 }
26703
26704 @@ -335,13 +404,12 @@ SECTIONS
26705 * for the boot processor.
26706 */
26707 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
26708 -INIT_PER_CPU(gdt_page);
26709 INIT_PER_CPU(irq_stack_union);
26710
26711 /*
26712 * Build-time check on the image size:
26713 */
26714 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
26715 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
26716 "kernel image bigger than KERNEL_IMAGE_SIZE");
26717
26718 #ifdef CONFIG_SMP
26719 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
26720 index 9a907a6..f83f921 100644
26721 --- a/arch/x86/kernel/vsyscall_64.c
26722 +++ b/arch/x86/kernel/vsyscall_64.c
26723 @@ -56,15 +56,13 @@
26724 DEFINE_VVAR(int, vgetcpu_mode);
26725 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
26726
26727 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
26728 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
26729
26730 static int __init vsyscall_setup(char *str)
26731 {
26732 if (str) {
26733 if (!strcmp("emulate", str))
26734 vsyscall_mode = EMULATE;
26735 - else if (!strcmp("native", str))
26736 - vsyscall_mode = NATIVE;
26737 else if (!strcmp("none", str))
26738 vsyscall_mode = NONE;
26739 else
26740 @@ -323,8 +321,7 @@ do_ret:
26741 return true;
26742
26743 sigsegv:
26744 - force_sig(SIGSEGV, current);
26745 - return true;
26746 + do_group_exit(SIGKILL);
26747 }
26748
26749 /*
26750 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
26751 extern char __vvar_page;
26752 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
26753
26754 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
26755 - vsyscall_mode == NATIVE
26756 - ? PAGE_KERNEL_VSYSCALL
26757 - : PAGE_KERNEL_VVAR);
26758 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
26759 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
26760 (unsigned long)VSYSCALL_START);
26761
26762 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
26763 index b014d94..e775258 100644
26764 --- a/arch/x86/kernel/x8664_ksyms_64.c
26765 +++ b/arch/x86/kernel/x8664_ksyms_64.c
26766 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
26767 EXPORT_SYMBOL(copy_user_generic_unrolled);
26768 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
26769 EXPORT_SYMBOL(__copy_user_nocache);
26770 -EXPORT_SYMBOL(_copy_from_user);
26771 -EXPORT_SYMBOL(_copy_to_user);
26772
26773 EXPORT_SYMBOL(copy_page);
26774 EXPORT_SYMBOL(clear_page);
26775 @@ -66,3 +64,7 @@ EXPORT_SYMBOL(empty_zero_page);
26776 #ifndef CONFIG_PARAVIRT
26777 EXPORT_SYMBOL(native_load_gs_index);
26778 #endif
26779 +
26780 +#ifdef CONFIG_PAX_PER_CPU_PGD
26781 +EXPORT_SYMBOL(cpu_pgd);
26782 +#endif
26783 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
26784 index 45a14db..075bb9b 100644
26785 --- a/arch/x86/kernel/x86_init.c
26786 +++ b/arch/x86/kernel/x86_init.c
26787 @@ -85,7 +85,7 @@ struct x86_init_ops x86_init __initdata = {
26788 },
26789 };
26790
26791 -struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
26792 +struct x86_cpuinit_ops x86_cpuinit __cpuinitconst = {
26793 .early_percpu_clock_init = x86_init_noop,
26794 .setup_percpu_clockev = setup_secondary_APIC_clock,
26795 };
26796 @@ -93,7 +93,7 @@ struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
26797 static void default_nmi_init(void) { };
26798 static int default_i8042_detect(void) { return 1; };
26799
26800 -struct x86_platform_ops x86_platform = {
26801 +struct x86_platform_ops x86_platform __read_only = {
26802 .calibrate_tsc = native_calibrate_tsc,
26803 .get_wallclock = mach_get_cmos_time,
26804 .set_wallclock = mach_set_rtc_mmss,
26805 @@ -107,7 +107,7 @@ struct x86_platform_ops x86_platform = {
26806 };
26807
26808 EXPORT_SYMBOL_GPL(x86_platform);
26809 -struct x86_msi_ops x86_msi = {
26810 +struct x86_msi_ops x86_msi __read_only = {
26811 .setup_msi_irqs = native_setup_msi_irqs,
26812 .compose_msi_msg = native_compose_msi_msg,
26813 .teardown_msi_irq = native_teardown_msi_irq,
26814 @@ -116,7 +116,7 @@ struct x86_msi_ops x86_msi = {
26815 .setup_hpet_msi = default_setup_hpet_msi,
26816 };
26817
26818 -struct x86_io_apic_ops x86_io_apic_ops = {
26819 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
26820 .init = native_io_apic_init_mappings,
26821 .read = native_io_apic_read,
26822 .write = native_io_apic_write,
26823 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
26824 index ada87a3..afea76d 100644
26825 --- a/arch/x86/kernel/xsave.c
26826 +++ b/arch/x86/kernel/xsave.c
26827 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
26828 {
26829 int err;
26830
26831 + buf = (struct xsave_struct __user *)____m(buf);
26832 if (use_xsave())
26833 err = xsave_user(buf);
26834 else if (use_fxsr())
26835 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
26836 */
26837 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
26838 {
26839 + buf = (void __user *)____m(buf);
26840 if (use_xsave()) {
26841 if ((unsigned long)buf % 64 || fx_only) {
26842 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
26843 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
26844 index a20ecb5..d0e2194 100644
26845 --- a/arch/x86/kvm/cpuid.c
26846 +++ b/arch/x86/kvm/cpuid.c
26847 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
26848 struct kvm_cpuid2 *cpuid,
26849 struct kvm_cpuid_entry2 __user *entries)
26850 {
26851 - int r;
26852 + int r, i;
26853
26854 r = -E2BIG;
26855 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
26856 goto out;
26857 r = -EFAULT;
26858 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
26859 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
26860 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
26861 goto out;
26862 + for (i = 0; i < cpuid->nent; ++i) {
26863 + struct kvm_cpuid_entry2 cpuid_entry;
26864 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
26865 + goto out;
26866 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
26867 + }
26868 vcpu->arch.cpuid_nent = cpuid->nent;
26869 kvm_apic_set_version(vcpu);
26870 kvm_x86_ops->cpuid_update(vcpu);
26871 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
26872 struct kvm_cpuid2 *cpuid,
26873 struct kvm_cpuid_entry2 __user *entries)
26874 {
26875 - int r;
26876 + int r, i;
26877
26878 r = -E2BIG;
26879 if (cpuid->nent < vcpu->arch.cpuid_nent)
26880 goto out;
26881 r = -EFAULT;
26882 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
26883 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
26884 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
26885 goto out;
26886 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
26887 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
26888 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
26889 + goto out;
26890 + }
26891 return 0;
26892
26893 out:
26894 diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
26895 index 5953dce..f11a7d2 100644
26896 --- a/arch/x86/kvm/emulate.c
26897 +++ b/arch/x86/kvm/emulate.c
26898 @@ -329,6 +329,7 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
26899
26900 #define ____emulate_2op(ctxt, _op, _x, _y, _suffix, _dsttype) \
26901 do { \
26902 + unsigned long _tmp; \
26903 __asm__ __volatile__ ( \
26904 _PRE_EFLAGS("0", "4", "2") \
26905 _op _suffix " %"_x"3,%1; " \
26906 @@ -343,8 +344,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
26907 /* Raw emulation: instruction has two explicit operands. */
26908 #define __emulate_2op_nobyte(ctxt,_op,_wx,_wy,_lx,_ly,_qx,_qy) \
26909 do { \
26910 - unsigned long _tmp; \
26911 - \
26912 switch ((ctxt)->dst.bytes) { \
26913 case 2: \
26914 ____emulate_2op(ctxt,_op,_wx,_wy,"w",u16); \
26915 @@ -360,7 +359,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
26916
26917 #define __emulate_2op(ctxt,_op,_bx,_by,_wx,_wy,_lx,_ly,_qx,_qy) \
26918 do { \
26919 - unsigned long _tmp; \
26920 switch ((ctxt)->dst.bytes) { \
26921 case 1: \
26922 ____emulate_2op(ctxt,_op,_bx,_by,"b",u8); \
26923 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
26924 index 0eee2c8..94a32c3 100644
26925 --- a/arch/x86/kvm/lapic.c
26926 +++ b/arch/x86/kvm/lapic.c
26927 @@ -55,7 +55,7 @@
26928 #define APIC_BUS_CYCLE_NS 1
26929
26930 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
26931 -#define apic_debug(fmt, arg...)
26932 +#define apic_debug(fmt, arg...) do {} while (0)
26933
26934 #define APIC_LVT_NUM 6
26935 /* 14 is the version for Xeon and Pentium 8.4.8*/
26936 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
26937 index da20860..d19fdf5 100644
26938 --- a/arch/x86/kvm/paging_tmpl.h
26939 +++ b/arch/x86/kvm/paging_tmpl.h
26940 @@ -208,7 +208,7 @@ retry_walk:
26941 if (unlikely(kvm_is_error_hva(host_addr)))
26942 goto error;
26943
26944 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
26945 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
26946 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
26947 goto error;
26948 walker->ptep_user[walker->level - 1] = ptep_user;
26949 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
26950 index a14a6ea..dc86cf0 100644
26951 --- a/arch/x86/kvm/svm.c
26952 +++ b/arch/x86/kvm/svm.c
26953 @@ -3493,7 +3493,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
26954 int cpu = raw_smp_processor_id();
26955
26956 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
26957 +
26958 + pax_open_kernel();
26959 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
26960 + pax_close_kernel();
26961 +
26962 load_TR_desc();
26963 }
26964
26965 @@ -3894,6 +3898,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
26966 #endif
26967 #endif
26968
26969 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26970 + __set_fs(current_thread_info()->addr_limit);
26971 +#endif
26972 +
26973 reload_tss(vcpu);
26974
26975 local_irq_disable();
26976 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
26977 index 5402c94..c3bdeee 100644
26978 --- a/arch/x86/kvm/vmx.c
26979 +++ b/arch/x86/kvm/vmx.c
26980 @@ -1311,12 +1311,12 @@ static void vmcs_write64(unsigned long field, u64 value)
26981 #endif
26982 }
26983
26984 -static void vmcs_clear_bits(unsigned long field, u32 mask)
26985 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
26986 {
26987 vmcs_writel(field, vmcs_readl(field) & ~mask);
26988 }
26989
26990 -static void vmcs_set_bits(unsigned long field, u32 mask)
26991 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
26992 {
26993 vmcs_writel(field, vmcs_readl(field) | mask);
26994 }
26995 @@ -1517,7 +1517,11 @@ static void reload_tss(void)
26996 struct desc_struct *descs;
26997
26998 descs = (void *)gdt->address;
26999 +
27000 + pax_open_kernel();
27001 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
27002 + pax_close_kernel();
27003 +
27004 load_TR_desc();
27005 }
27006
27007 @@ -1741,6 +1745,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
27008 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
27009 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
27010
27011 +#ifdef CONFIG_PAX_PER_CPU_PGD
27012 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
27013 +#endif
27014 +
27015 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
27016 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
27017 vmx->loaded_vmcs->cpu = cpu;
27018 @@ -2935,8 +2943,11 @@ static __init int hardware_setup(void)
27019 if (!cpu_has_vmx_flexpriority())
27020 flexpriority_enabled = 0;
27021
27022 - if (!cpu_has_vmx_tpr_shadow())
27023 - kvm_x86_ops->update_cr8_intercept = NULL;
27024 + if (!cpu_has_vmx_tpr_shadow()) {
27025 + pax_open_kernel();
27026 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
27027 + pax_close_kernel();
27028 + }
27029
27030 if (enable_ept && !cpu_has_vmx_ept_2m_page())
27031 kvm_disable_largepages();
27032 @@ -2947,13 +2958,15 @@ static __init int hardware_setup(void)
27033 if (!cpu_has_vmx_apicv())
27034 enable_apicv = 0;
27035
27036 + pax_open_kernel();
27037 if (enable_apicv)
27038 - kvm_x86_ops->update_cr8_intercept = NULL;
27039 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
27040 else {
27041 - kvm_x86_ops->hwapic_irr_update = NULL;
27042 - kvm_x86_ops->deliver_posted_interrupt = NULL;
27043 - kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
27044 + *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
27045 + *(void **)&kvm_x86_ops->deliver_posted_interrupt = NULL;
27046 + *(void **)&kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
27047 }
27048 + pax_close_kernel();
27049
27050 if (nested)
27051 nested_vmx_setup_ctls_msrs();
27052 @@ -4076,7 +4089,10 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
27053
27054 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
27055 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
27056 +
27057 +#ifndef CONFIG_PAX_PER_CPU_PGD
27058 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
27059 +#endif
27060
27061 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
27062 #ifdef CONFIG_X86_64
27063 @@ -4098,7 +4114,7 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
27064 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
27065 vmx->host_idt_base = dt.address;
27066
27067 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
27068 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
27069
27070 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
27071 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
27072 @@ -7030,6 +7046,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
27073 "jmp 2f \n\t"
27074 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
27075 "2: "
27076 +
27077 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27078 + "ljmp %[cs],$3f\n\t"
27079 + "3: "
27080 +#endif
27081 +
27082 /* Save guest registers, load host registers, keep flags */
27083 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
27084 "pop %0 \n\t"
27085 @@ -7082,6 +7104,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
27086 #endif
27087 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
27088 [wordsize]"i"(sizeof(ulong))
27089 +
27090 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27091 + ,[cs]"i"(__KERNEL_CS)
27092 +#endif
27093 +
27094 : "cc", "memory"
27095 #ifdef CONFIG_X86_64
27096 , "rax", "rbx", "rdi", "rsi"
27097 @@ -7095,7 +7122,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
27098 if (debugctlmsr)
27099 update_debugctlmsr(debugctlmsr);
27100
27101 -#ifndef CONFIG_X86_64
27102 +#ifdef CONFIG_X86_32
27103 /*
27104 * The sysexit path does not restore ds/es, so we must set them to
27105 * a reasonable value ourselves.
27106 @@ -7104,8 +7131,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
27107 * may be executed in interrupt context, which saves and restore segments
27108 * around it, nullifying its effect.
27109 */
27110 - loadsegment(ds, __USER_DS);
27111 - loadsegment(es, __USER_DS);
27112 + loadsegment(ds, __KERNEL_DS);
27113 + loadsegment(es, __KERNEL_DS);
27114 + loadsegment(ss, __KERNEL_DS);
27115 +
27116 +#ifdef CONFIG_PAX_KERNEXEC
27117 + loadsegment(fs, __KERNEL_PERCPU);
27118 +#endif
27119 +
27120 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27121 + __set_fs(current_thread_info()->addr_limit);
27122 +#endif
27123 +
27124 #endif
27125
27126 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
27127 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
27128 index e8ba99c..ee9d7d9 100644
27129 --- a/arch/x86/kvm/x86.c
27130 +++ b/arch/x86/kvm/x86.c
27131 @@ -1725,8 +1725,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
27132 {
27133 struct kvm *kvm = vcpu->kvm;
27134 int lm = is_long_mode(vcpu);
27135 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
27136 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
27137 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
27138 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
27139 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
27140 : kvm->arch.xen_hvm_config.blob_size_32;
27141 u32 page_num = data & ~PAGE_MASK;
27142 @@ -2609,6 +2609,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
27143 if (n < msr_list.nmsrs)
27144 goto out;
27145 r = -EFAULT;
27146 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
27147 + goto out;
27148 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
27149 num_msrs_to_save * sizeof(u32)))
27150 goto out;
27151 @@ -5297,7 +5299,7 @@ static struct notifier_block pvclock_gtod_notifier = {
27152 };
27153 #endif
27154
27155 -int kvm_arch_init(void *opaque)
27156 +int kvm_arch_init(const void *opaque)
27157 {
27158 int r;
27159 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
27160 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
27161 index 7114c63..a1018fc 100644
27162 --- a/arch/x86/lguest/boot.c
27163 +++ b/arch/x86/lguest/boot.c
27164 @@ -1201,9 +1201,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
27165 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
27166 * Launcher to reboot us.
27167 */
27168 -static void lguest_restart(char *reason)
27169 +static __noreturn void lguest_restart(char *reason)
27170 {
27171 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
27172 + BUG();
27173 }
27174
27175 /*G:050
27176 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
27177 index 00933d5..3a64af9 100644
27178 --- a/arch/x86/lib/atomic64_386_32.S
27179 +++ b/arch/x86/lib/atomic64_386_32.S
27180 @@ -48,6 +48,10 @@ BEGIN(read)
27181 movl (v), %eax
27182 movl 4(v), %edx
27183 RET_ENDP
27184 +BEGIN(read_unchecked)
27185 + movl (v), %eax
27186 + movl 4(v), %edx
27187 +RET_ENDP
27188 #undef v
27189
27190 #define v %esi
27191 @@ -55,6 +59,10 @@ BEGIN(set)
27192 movl %ebx, (v)
27193 movl %ecx, 4(v)
27194 RET_ENDP
27195 +BEGIN(set_unchecked)
27196 + movl %ebx, (v)
27197 + movl %ecx, 4(v)
27198 +RET_ENDP
27199 #undef v
27200
27201 #define v %esi
27202 @@ -70,6 +78,20 @@ RET_ENDP
27203 BEGIN(add)
27204 addl %eax, (v)
27205 adcl %edx, 4(v)
27206 +
27207 +#ifdef CONFIG_PAX_REFCOUNT
27208 + jno 0f
27209 + subl %eax, (v)
27210 + sbbl %edx, 4(v)
27211 + int $4
27212 +0:
27213 + _ASM_EXTABLE(0b, 0b)
27214 +#endif
27215 +
27216 +RET_ENDP
27217 +BEGIN(add_unchecked)
27218 + addl %eax, (v)
27219 + adcl %edx, 4(v)
27220 RET_ENDP
27221 #undef v
27222
27223 @@ -77,6 +99,24 @@ RET_ENDP
27224 BEGIN(add_return)
27225 addl (v), %eax
27226 adcl 4(v), %edx
27227 +
27228 +#ifdef CONFIG_PAX_REFCOUNT
27229 + into
27230 +1234:
27231 + _ASM_EXTABLE(1234b, 2f)
27232 +#endif
27233 +
27234 + movl %eax, (v)
27235 + movl %edx, 4(v)
27236 +
27237 +#ifdef CONFIG_PAX_REFCOUNT
27238 +2:
27239 +#endif
27240 +
27241 +RET_ENDP
27242 +BEGIN(add_return_unchecked)
27243 + addl (v), %eax
27244 + adcl 4(v), %edx
27245 movl %eax, (v)
27246 movl %edx, 4(v)
27247 RET_ENDP
27248 @@ -86,6 +126,20 @@ RET_ENDP
27249 BEGIN(sub)
27250 subl %eax, (v)
27251 sbbl %edx, 4(v)
27252 +
27253 +#ifdef CONFIG_PAX_REFCOUNT
27254 + jno 0f
27255 + addl %eax, (v)
27256 + adcl %edx, 4(v)
27257 + int $4
27258 +0:
27259 + _ASM_EXTABLE(0b, 0b)
27260 +#endif
27261 +
27262 +RET_ENDP
27263 +BEGIN(sub_unchecked)
27264 + subl %eax, (v)
27265 + sbbl %edx, 4(v)
27266 RET_ENDP
27267 #undef v
27268
27269 @@ -96,6 +150,27 @@ BEGIN(sub_return)
27270 sbbl $0, %edx
27271 addl (v), %eax
27272 adcl 4(v), %edx
27273 +
27274 +#ifdef CONFIG_PAX_REFCOUNT
27275 + into
27276 +1234:
27277 + _ASM_EXTABLE(1234b, 2f)
27278 +#endif
27279 +
27280 + movl %eax, (v)
27281 + movl %edx, 4(v)
27282 +
27283 +#ifdef CONFIG_PAX_REFCOUNT
27284 +2:
27285 +#endif
27286 +
27287 +RET_ENDP
27288 +BEGIN(sub_return_unchecked)
27289 + negl %edx
27290 + negl %eax
27291 + sbbl $0, %edx
27292 + addl (v), %eax
27293 + adcl 4(v), %edx
27294 movl %eax, (v)
27295 movl %edx, 4(v)
27296 RET_ENDP
27297 @@ -105,6 +180,20 @@ RET_ENDP
27298 BEGIN(inc)
27299 addl $1, (v)
27300 adcl $0, 4(v)
27301 +
27302 +#ifdef CONFIG_PAX_REFCOUNT
27303 + jno 0f
27304 + subl $1, (v)
27305 + sbbl $0, 4(v)
27306 + int $4
27307 +0:
27308 + _ASM_EXTABLE(0b, 0b)
27309 +#endif
27310 +
27311 +RET_ENDP
27312 +BEGIN(inc_unchecked)
27313 + addl $1, (v)
27314 + adcl $0, 4(v)
27315 RET_ENDP
27316 #undef v
27317
27318 @@ -114,6 +203,26 @@ BEGIN(inc_return)
27319 movl 4(v), %edx
27320 addl $1, %eax
27321 adcl $0, %edx
27322 +
27323 +#ifdef CONFIG_PAX_REFCOUNT
27324 + into
27325 +1234:
27326 + _ASM_EXTABLE(1234b, 2f)
27327 +#endif
27328 +
27329 + movl %eax, (v)
27330 + movl %edx, 4(v)
27331 +
27332 +#ifdef CONFIG_PAX_REFCOUNT
27333 +2:
27334 +#endif
27335 +
27336 +RET_ENDP
27337 +BEGIN(inc_return_unchecked)
27338 + movl (v), %eax
27339 + movl 4(v), %edx
27340 + addl $1, %eax
27341 + adcl $0, %edx
27342 movl %eax, (v)
27343 movl %edx, 4(v)
27344 RET_ENDP
27345 @@ -123,6 +232,20 @@ RET_ENDP
27346 BEGIN(dec)
27347 subl $1, (v)
27348 sbbl $0, 4(v)
27349 +
27350 +#ifdef CONFIG_PAX_REFCOUNT
27351 + jno 0f
27352 + addl $1, (v)
27353 + adcl $0, 4(v)
27354 + int $4
27355 +0:
27356 + _ASM_EXTABLE(0b, 0b)
27357 +#endif
27358 +
27359 +RET_ENDP
27360 +BEGIN(dec_unchecked)
27361 + subl $1, (v)
27362 + sbbl $0, 4(v)
27363 RET_ENDP
27364 #undef v
27365
27366 @@ -132,6 +255,26 @@ BEGIN(dec_return)
27367 movl 4(v), %edx
27368 subl $1, %eax
27369 sbbl $0, %edx
27370 +
27371 +#ifdef CONFIG_PAX_REFCOUNT
27372 + into
27373 +1234:
27374 + _ASM_EXTABLE(1234b, 2f)
27375 +#endif
27376 +
27377 + movl %eax, (v)
27378 + movl %edx, 4(v)
27379 +
27380 +#ifdef CONFIG_PAX_REFCOUNT
27381 +2:
27382 +#endif
27383 +
27384 +RET_ENDP
27385 +BEGIN(dec_return_unchecked)
27386 + movl (v), %eax
27387 + movl 4(v), %edx
27388 + subl $1, %eax
27389 + sbbl $0, %edx
27390 movl %eax, (v)
27391 movl %edx, 4(v)
27392 RET_ENDP
27393 @@ -143,6 +286,13 @@ BEGIN(add_unless)
27394 adcl %edx, %edi
27395 addl (v), %eax
27396 adcl 4(v), %edx
27397 +
27398 +#ifdef CONFIG_PAX_REFCOUNT
27399 + into
27400 +1234:
27401 + _ASM_EXTABLE(1234b, 2f)
27402 +#endif
27403 +
27404 cmpl %eax, %ecx
27405 je 3f
27406 1:
27407 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
27408 1:
27409 addl $1, %eax
27410 adcl $0, %edx
27411 +
27412 +#ifdef CONFIG_PAX_REFCOUNT
27413 + into
27414 +1234:
27415 + _ASM_EXTABLE(1234b, 2f)
27416 +#endif
27417 +
27418 movl %eax, (v)
27419 movl %edx, 4(v)
27420 movl $1, %eax
27421 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
27422 movl 4(v), %edx
27423 subl $1, %eax
27424 sbbl $0, %edx
27425 +
27426 +#ifdef CONFIG_PAX_REFCOUNT
27427 + into
27428 +1234:
27429 + _ASM_EXTABLE(1234b, 1f)
27430 +#endif
27431 +
27432 js 1f
27433 movl %eax, (v)
27434 movl %edx, 4(v)
27435 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
27436 index f5cc9eb..51fa319 100644
27437 --- a/arch/x86/lib/atomic64_cx8_32.S
27438 +++ b/arch/x86/lib/atomic64_cx8_32.S
27439 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
27440 CFI_STARTPROC
27441
27442 read64 %ecx
27443 + pax_force_retaddr
27444 ret
27445 CFI_ENDPROC
27446 ENDPROC(atomic64_read_cx8)
27447
27448 +ENTRY(atomic64_read_unchecked_cx8)
27449 + CFI_STARTPROC
27450 +
27451 + read64 %ecx
27452 + pax_force_retaddr
27453 + ret
27454 + CFI_ENDPROC
27455 +ENDPROC(atomic64_read_unchecked_cx8)
27456 +
27457 ENTRY(atomic64_set_cx8)
27458 CFI_STARTPROC
27459
27460 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
27461 cmpxchg8b (%esi)
27462 jne 1b
27463
27464 + pax_force_retaddr
27465 ret
27466 CFI_ENDPROC
27467 ENDPROC(atomic64_set_cx8)
27468
27469 +ENTRY(atomic64_set_unchecked_cx8)
27470 + CFI_STARTPROC
27471 +
27472 +1:
27473 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
27474 + * are atomic on 586 and newer */
27475 + cmpxchg8b (%esi)
27476 + jne 1b
27477 +
27478 + pax_force_retaddr
27479 + ret
27480 + CFI_ENDPROC
27481 +ENDPROC(atomic64_set_unchecked_cx8)
27482 +
27483 ENTRY(atomic64_xchg_cx8)
27484 CFI_STARTPROC
27485
27486 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
27487 cmpxchg8b (%esi)
27488 jne 1b
27489
27490 + pax_force_retaddr
27491 ret
27492 CFI_ENDPROC
27493 ENDPROC(atomic64_xchg_cx8)
27494
27495 -.macro addsub_return func ins insc
27496 -ENTRY(atomic64_\func\()_return_cx8)
27497 +.macro addsub_return func ins insc unchecked=""
27498 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
27499 CFI_STARTPROC
27500 SAVE ebp
27501 SAVE ebx
27502 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
27503 movl %edx, %ecx
27504 \ins\()l %esi, %ebx
27505 \insc\()l %edi, %ecx
27506 +
27507 +.ifb \unchecked
27508 +#ifdef CONFIG_PAX_REFCOUNT
27509 + into
27510 +2:
27511 + _ASM_EXTABLE(2b, 3f)
27512 +#endif
27513 +.endif
27514 +
27515 LOCK_PREFIX
27516 cmpxchg8b (%ebp)
27517 jne 1b
27518 -
27519 -10:
27520 movl %ebx, %eax
27521 movl %ecx, %edx
27522 +
27523 +.ifb \unchecked
27524 +#ifdef CONFIG_PAX_REFCOUNT
27525 +3:
27526 +#endif
27527 +.endif
27528 +
27529 RESTORE edi
27530 RESTORE esi
27531 RESTORE ebx
27532 RESTORE ebp
27533 + pax_force_retaddr
27534 ret
27535 CFI_ENDPROC
27536 -ENDPROC(atomic64_\func\()_return_cx8)
27537 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
27538 .endm
27539
27540 addsub_return add add adc
27541 addsub_return sub sub sbb
27542 +addsub_return add add adc _unchecked
27543 +addsub_return sub sub sbb _unchecked
27544
27545 -.macro incdec_return func ins insc
27546 -ENTRY(atomic64_\func\()_return_cx8)
27547 +.macro incdec_return func ins insc unchecked=""
27548 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
27549 CFI_STARTPROC
27550 SAVE ebx
27551
27552 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
27553 movl %edx, %ecx
27554 \ins\()l $1, %ebx
27555 \insc\()l $0, %ecx
27556 +
27557 +.ifb \unchecked
27558 +#ifdef CONFIG_PAX_REFCOUNT
27559 + into
27560 +2:
27561 + _ASM_EXTABLE(2b, 3f)
27562 +#endif
27563 +.endif
27564 +
27565 LOCK_PREFIX
27566 cmpxchg8b (%esi)
27567 jne 1b
27568
27569 -10:
27570 movl %ebx, %eax
27571 movl %ecx, %edx
27572 +
27573 +.ifb \unchecked
27574 +#ifdef CONFIG_PAX_REFCOUNT
27575 +3:
27576 +#endif
27577 +.endif
27578 +
27579 RESTORE ebx
27580 + pax_force_retaddr
27581 ret
27582 CFI_ENDPROC
27583 -ENDPROC(atomic64_\func\()_return_cx8)
27584 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
27585 .endm
27586
27587 incdec_return inc add adc
27588 incdec_return dec sub sbb
27589 +incdec_return inc add adc _unchecked
27590 +incdec_return dec sub sbb _unchecked
27591
27592 ENTRY(atomic64_dec_if_positive_cx8)
27593 CFI_STARTPROC
27594 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
27595 movl %edx, %ecx
27596 subl $1, %ebx
27597 sbb $0, %ecx
27598 +
27599 +#ifdef CONFIG_PAX_REFCOUNT
27600 + into
27601 +1234:
27602 + _ASM_EXTABLE(1234b, 2f)
27603 +#endif
27604 +
27605 js 2f
27606 LOCK_PREFIX
27607 cmpxchg8b (%esi)
27608 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
27609 movl %ebx, %eax
27610 movl %ecx, %edx
27611 RESTORE ebx
27612 + pax_force_retaddr
27613 ret
27614 CFI_ENDPROC
27615 ENDPROC(atomic64_dec_if_positive_cx8)
27616 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
27617 movl %edx, %ecx
27618 addl %ebp, %ebx
27619 adcl %edi, %ecx
27620 +
27621 +#ifdef CONFIG_PAX_REFCOUNT
27622 + into
27623 +1234:
27624 + _ASM_EXTABLE(1234b, 3f)
27625 +#endif
27626 +
27627 LOCK_PREFIX
27628 cmpxchg8b (%esi)
27629 jne 1b
27630 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
27631 CFI_ADJUST_CFA_OFFSET -8
27632 RESTORE ebx
27633 RESTORE ebp
27634 + pax_force_retaddr
27635 ret
27636 4:
27637 cmpl %edx, 4(%esp)
27638 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
27639 xorl %ecx, %ecx
27640 addl $1, %ebx
27641 adcl %edx, %ecx
27642 +
27643 +#ifdef CONFIG_PAX_REFCOUNT
27644 + into
27645 +1234:
27646 + _ASM_EXTABLE(1234b, 3f)
27647 +#endif
27648 +
27649 LOCK_PREFIX
27650 cmpxchg8b (%esi)
27651 jne 1b
27652 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
27653 movl $1, %eax
27654 3:
27655 RESTORE ebx
27656 + pax_force_retaddr
27657 ret
27658 CFI_ENDPROC
27659 ENDPROC(atomic64_inc_not_zero_cx8)
27660 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
27661 index e78b8ee..7e173a8 100644
27662 --- a/arch/x86/lib/checksum_32.S
27663 +++ b/arch/x86/lib/checksum_32.S
27664 @@ -29,7 +29,8 @@
27665 #include <asm/dwarf2.h>
27666 #include <asm/errno.h>
27667 #include <asm/asm.h>
27668 -
27669 +#include <asm/segment.h>
27670 +
27671 /*
27672 * computes a partial checksum, e.g. for TCP/UDP fragments
27673 */
27674 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
27675
27676 #define ARGBASE 16
27677 #define FP 12
27678 -
27679 -ENTRY(csum_partial_copy_generic)
27680 +
27681 +ENTRY(csum_partial_copy_generic_to_user)
27682 CFI_STARTPROC
27683 +
27684 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27685 + pushl_cfi %gs
27686 + popl_cfi %es
27687 + jmp csum_partial_copy_generic
27688 +#endif
27689 +
27690 +ENTRY(csum_partial_copy_generic_from_user)
27691 +
27692 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27693 + pushl_cfi %gs
27694 + popl_cfi %ds
27695 +#endif
27696 +
27697 +ENTRY(csum_partial_copy_generic)
27698 subl $4,%esp
27699 CFI_ADJUST_CFA_OFFSET 4
27700 pushl_cfi %edi
27701 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
27702 jmp 4f
27703 SRC(1: movw (%esi), %bx )
27704 addl $2, %esi
27705 -DST( movw %bx, (%edi) )
27706 +DST( movw %bx, %es:(%edi) )
27707 addl $2, %edi
27708 addw %bx, %ax
27709 adcl $0, %eax
27710 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
27711 SRC(1: movl (%esi), %ebx )
27712 SRC( movl 4(%esi), %edx )
27713 adcl %ebx, %eax
27714 -DST( movl %ebx, (%edi) )
27715 +DST( movl %ebx, %es:(%edi) )
27716 adcl %edx, %eax
27717 -DST( movl %edx, 4(%edi) )
27718 +DST( movl %edx, %es:4(%edi) )
27719
27720 SRC( movl 8(%esi), %ebx )
27721 SRC( movl 12(%esi), %edx )
27722 adcl %ebx, %eax
27723 -DST( movl %ebx, 8(%edi) )
27724 +DST( movl %ebx, %es:8(%edi) )
27725 adcl %edx, %eax
27726 -DST( movl %edx, 12(%edi) )
27727 +DST( movl %edx, %es:12(%edi) )
27728
27729 SRC( movl 16(%esi), %ebx )
27730 SRC( movl 20(%esi), %edx )
27731 adcl %ebx, %eax
27732 -DST( movl %ebx, 16(%edi) )
27733 +DST( movl %ebx, %es:16(%edi) )
27734 adcl %edx, %eax
27735 -DST( movl %edx, 20(%edi) )
27736 +DST( movl %edx, %es:20(%edi) )
27737
27738 SRC( movl 24(%esi), %ebx )
27739 SRC( movl 28(%esi), %edx )
27740 adcl %ebx, %eax
27741 -DST( movl %ebx, 24(%edi) )
27742 +DST( movl %ebx, %es:24(%edi) )
27743 adcl %edx, %eax
27744 -DST( movl %edx, 28(%edi) )
27745 +DST( movl %edx, %es:28(%edi) )
27746
27747 lea 32(%esi), %esi
27748 lea 32(%edi), %edi
27749 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
27750 shrl $2, %edx # This clears CF
27751 SRC(3: movl (%esi), %ebx )
27752 adcl %ebx, %eax
27753 -DST( movl %ebx, (%edi) )
27754 +DST( movl %ebx, %es:(%edi) )
27755 lea 4(%esi), %esi
27756 lea 4(%edi), %edi
27757 dec %edx
27758 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
27759 jb 5f
27760 SRC( movw (%esi), %cx )
27761 leal 2(%esi), %esi
27762 -DST( movw %cx, (%edi) )
27763 +DST( movw %cx, %es:(%edi) )
27764 leal 2(%edi), %edi
27765 je 6f
27766 shll $16,%ecx
27767 SRC(5: movb (%esi), %cl )
27768 -DST( movb %cl, (%edi) )
27769 +DST( movb %cl, %es:(%edi) )
27770 6: addl %ecx, %eax
27771 adcl $0, %eax
27772 7:
27773 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
27774
27775 6001:
27776 movl ARGBASE+20(%esp), %ebx # src_err_ptr
27777 - movl $-EFAULT, (%ebx)
27778 + movl $-EFAULT, %ss:(%ebx)
27779
27780 # zero the complete destination - computing the rest
27781 # is too much work
27782 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
27783
27784 6002:
27785 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
27786 - movl $-EFAULT,(%ebx)
27787 + movl $-EFAULT,%ss:(%ebx)
27788 jmp 5000b
27789
27790 .previous
27791
27792 + pushl_cfi %ss
27793 + popl_cfi %ds
27794 + pushl_cfi %ss
27795 + popl_cfi %es
27796 popl_cfi %ebx
27797 CFI_RESTORE ebx
27798 popl_cfi %esi
27799 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
27800 popl_cfi %ecx # equivalent to addl $4,%esp
27801 ret
27802 CFI_ENDPROC
27803 -ENDPROC(csum_partial_copy_generic)
27804 +ENDPROC(csum_partial_copy_generic_to_user)
27805
27806 #else
27807
27808 /* Version for PentiumII/PPro */
27809
27810 #define ROUND1(x) \
27811 + nop; nop; nop; \
27812 SRC(movl x(%esi), %ebx ) ; \
27813 addl %ebx, %eax ; \
27814 - DST(movl %ebx, x(%edi) ) ;
27815 + DST(movl %ebx, %es:x(%edi)) ;
27816
27817 #define ROUND(x) \
27818 + nop; nop; nop; \
27819 SRC(movl x(%esi), %ebx ) ; \
27820 adcl %ebx, %eax ; \
27821 - DST(movl %ebx, x(%edi) ) ;
27822 + DST(movl %ebx, %es:x(%edi)) ;
27823
27824 #define ARGBASE 12
27825 -
27826 -ENTRY(csum_partial_copy_generic)
27827 +
27828 +ENTRY(csum_partial_copy_generic_to_user)
27829 CFI_STARTPROC
27830 +
27831 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27832 + pushl_cfi %gs
27833 + popl_cfi %es
27834 + jmp csum_partial_copy_generic
27835 +#endif
27836 +
27837 +ENTRY(csum_partial_copy_generic_from_user)
27838 +
27839 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27840 + pushl_cfi %gs
27841 + popl_cfi %ds
27842 +#endif
27843 +
27844 +ENTRY(csum_partial_copy_generic)
27845 pushl_cfi %ebx
27846 CFI_REL_OFFSET ebx, 0
27847 pushl_cfi %edi
27848 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
27849 subl %ebx, %edi
27850 lea -1(%esi),%edx
27851 andl $-32,%edx
27852 - lea 3f(%ebx,%ebx), %ebx
27853 + lea 3f(%ebx,%ebx,2), %ebx
27854 testl %esi, %esi
27855 jmp *%ebx
27856 1: addl $64,%esi
27857 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
27858 jb 5f
27859 SRC( movw (%esi), %dx )
27860 leal 2(%esi), %esi
27861 -DST( movw %dx, (%edi) )
27862 +DST( movw %dx, %es:(%edi) )
27863 leal 2(%edi), %edi
27864 je 6f
27865 shll $16,%edx
27866 5:
27867 SRC( movb (%esi), %dl )
27868 -DST( movb %dl, (%edi) )
27869 +DST( movb %dl, %es:(%edi) )
27870 6: addl %edx, %eax
27871 adcl $0, %eax
27872 7:
27873 .section .fixup, "ax"
27874 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
27875 - movl $-EFAULT, (%ebx)
27876 + movl $-EFAULT, %ss:(%ebx)
27877 # zero the complete destination (computing the rest is too much work)
27878 movl ARGBASE+8(%esp),%edi # dst
27879 movl ARGBASE+12(%esp),%ecx # len
27880 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
27881 rep; stosb
27882 jmp 7b
27883 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
27884 - movl $-EFAULT, (%ebx)
27885 + movl $-EFAULT, %ss:(%ebx)
27886 jmp 7b
27887 .previous
27888
27889 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27890 + pushl_cfi %ss
27891 + popl_cfi %ds
27892 + pushl_cfi %ss
27893 + popl_cfi %es
27894 +#endif
27895 +
27896 popl_cfi %esi
27897 CFI_RESTORE esi
27898 popl_cfi %edi
27899 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
27900 CFI_RESTORE ebx
27901 ret
27902 CFI_ENDPROC
27903 -ENDPROC(csum_partial_copy_generic)
27904 +ENDPROC(csum_partial_copy_generic_to_user)
27905
27906 #undef ROUND
27907 #undef ROUND1
27908 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
27909 index f2145cf..cea889d 100644
27910 --- a/arch/x86/lib/clear_page_64.S
27911 +++ b/arch/x86/lib/clear_page_64.S
27912 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
27913 movl $4096/8,%ecx
27914 xorl %eax,%eax
27915 rep stosq
27916 + pax_force_retaddr
27917 ret
27918 CFI_ENDPROC
27919 ENDPROC(clear_page_c)
27920 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
27921 movl $4096,%ecx
27922 xorl %eax,%eax
27923 rep stosb
27924 + pax_force_retaddr
27925 ret
27926 CFI_ENDPROC
27927 ENDPROC(clear_page_c_e)
27928 @@ -43,6 +45,7 @@ ENTRY(clear_page)
27929 leaq 64(%rdi),%rdi
27930 jnz .Lloop
27931 nop
27932 + pax_force_retaddr
27933 ret
27934 CFI_ENDPROC
27935 .Lclear_page_end:
27936 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
27937
27938 #include <asm/cpufeature.h>
27939
27940 - .section .altinstr_replacement,"ax"
27941 + .section .altinstr_replacement,"a"
27942 1: .byte 0xeb /* jmp <disp8> */
27943 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
27944 2: .byte 0xeb /* jmp <disp8> */
27945 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
27946 index 1e572c5..2a162cd 100644
27947 --- a/arch/x86/lib/cmpxchg16b_emu.S
27948 +++ b/arch/x86/lib/cmpxchg16b_emu.S
27949 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
27950
27951 popf
27952 mov $1, %al
27953 + pax_force_retaddr
27954 ret
27955
27956 not_same:
27957 popf
27958 xor %al,%al
27959 + pax_force_retaddr
27960 ret
27961
27962 CFI_ENDPROC
27963 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
27964 index 176cca6..1166c50 100644
27965 --- a/arch/x86/lib/copy_page_64.S
27966 +++ b/arch/x86/lib/copy_page_64.S
27967 @@ -9,6 +9,7 @@ copy_page_rep:
27968 CFI_STARTPROC
27969 movl $4096/8, %ecx
27970 rep movsq
27971 + pax_force_retaddr
27972 ret
27973 CFI_ENDPROC
27974 ENDPROC(copy_page_rep)
27975 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
27976
27977 ENTRY(copy_page)
27978 CFI_STARTPROC
27979 - subq $2*8, %rsp
27980 - CFI_ADJUST_CFA_OFFSET 2*8
27981 + subq $3*8, %rsp
27982 + CFI_ADJUST_CFA_OFFSET 3*8
27983 movq %rbx, (%rsp)
27984 CFI_REL_OFFSET rbx, 0
27985 movq %r12, 1*8(%rsp)
27986 CFI_REL_OFFSET r12, 1*8
27987 + movq %r13, 2*8(%rsp)
27988 + CFI_REL_OFFSET r13, 2*8
27989
27990 movl $(4096/64)-5, %ecx
27991 .p2align 4
27992 @@ -36,7 +39,7 @@ ENTRY(copy_page)
27993 movq 0x8*2(%rsi), %rdx
27994 movq 0x8*3(%rsi), %r8
27995 movq 0x8*4(%rsi), %r9
27996 - movq 0x8*5(%rsi), %r10
27997 + movq 0x8*5(%rsi), %r13
27998 movq 0x8*6(%rsi), %r11
27999 movq 0x8*7(%rsi), %r12
28000
28001 @@ -47,7 +50,7 @@ ENTRY(copy_page)
28002 movq %rdx, 0x8*2(%rdi)
28003 movq %r8, 0x8*3(%rdi)
28004 movq %r9, 0x8*4(%rdi)
28005 - movq %r10, 0x8*5(%rdi)
28006 + movq %r13, 0x8*5(%rdi)
28007 movq %r11, 0x8*6(%rdi)
28008 movq %r12, 0x8*7(%rdi)
28009
28010 @@ -66,7 +69,7 @@ ENTRY(copy_page)
28011 movq 0x8*2(%rsi), %rdx
28012 movq 0x8*3(%rsi), %r8
28013 movq 0x8*4(%rsi), %r9
28014 - movq 0x8*5(%rsi), %r10
28015 + movq 0x8*5(%rsi), %r13
28016 movq 0x8*6(%rsi), %r11
28017 movq 0x8*7(%rsi), %r12
28018
28019 @@ -75,7 +78,7 @@ ENTRY(copy_page)
28020 movq %rdx, 0x8*2(%rdi)
28021 movq %r8, 0x8*3(%rdi)
28022 movq %r9, 0x8*4(%rdi)
28023 - movq %r10, 0x8*5(%rdi)
28024 + movq %r13, 0x8*5(%rdi)
28025 movq %r11, 0x8*6(%rdi)
28026 movq %r12, 0x8*7(%rdi)
28027
28028 @@ -87,8 +90,11 @@ ENTRY(copy_page)
28029 CFI_RESTORE rbx
28030 movq 1*8(%rsp), %r12
28031 CFI_RESTORE r12
28032 - addq $2*8, %rsp
28033 - CFI_ADJUST_CFA_OFFSET -2*8
28034 + movq 2*8(%rsp), %r13
28035 + CFI_RESTORE r13
28036 + addq $3*8, %rsp
28037 + CFI_ADJUST_CFA_OFFSET -3*8
28038 + pax_force_retaddr
28039 ret
28040 .Lcopy_page_end:
28041 CFI_ENDPROC
28042 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
28043
28044 #include <asm/cpufeature.h>
28045
28046 - .section .altinstr_replacement,"ax"
28047 + .section .altinstr_replacement,"a"
28048 1: .byte 0xeb /* jmp <disp8> */
28049 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
28050 2:
28051 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
28052 index a30ca15..6b3f4e1 100644
28053 --- a/arch/x86/lib/copy_user_64.S
28054 +++ b/arch/x86/lib/copy_user_64.S
28055 @@ -18,31 +18,7 @@
28056 #include <asm/alternative-asm.h>
28057 #include <asm/asm.h>
28058 #include <asm/smap.h>
28059 -
28060 -/*
28061 - * By placing feature2 after feature1 in altinstructions section, we logically
28062 - * implement:
28063 - * If CPU has feature2, jmp to alt2 is used
28064 - * else if CPU has feature1, jmp to alt1 is used
28065 - * else jmp to orig is used.
28066 - */
28067 - .macro ALTERNATIVE_JUMP feature1,feature2,orig,alt1,alt2
28068 -0:
28069 - .byte 0xe9 /* 32bit jump */
28070 - .long \orig-1f /* by default jump to orig */
28071 -1:
28072 - .section .altinstr_replacement,"ax"
28073 -2: .byte 0xe9 /* near jump with 32bit immediate */
28074 - .long \alt1-1b /* offset */ /* or alternatively to alt1 */
28075 -3: .byte 0xe9 /* near jump with 32bit immediate */
28076 - .long \alt2-1b /* offset */ /* or alternatively to alt2 */
28077 - .previous
28078 -
28079 - .section .altinstructions,"a"
28080 - altinstruction_entry 0b,2b,\feature1,5,5
28081 - altinstruction_entry 0b,3b,\feature2,5,5
28082 - .previous
28083 - .endm
28084 +#include <asm/pgtable.h>
28085
28086 .macro ALIGN_DESTINATION
28087 #ifdef FIX_ALIGNMENT
28088 @@ -70,52 +46,6 @@
28089 #endif
28090 .endm
28091
28092 -/* Standard copy_to_user with segment limit checking */
28093 -ENTRY(_copy_to_user)
28094 - CFI_STARTPROC
28095 - GET_THREAD_INFO(%rax)
28096 - movq %rdi,%rcx
28097 - addq %rdx,%rcx
28098 - jc bad_to_user
28099 - cmpq TI_addr_limit(%rax),%rcx
28100 - ja bad_to_user
28101 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
28102 - copy_user_generic_unrolled,copy_user_generic_string, \
28103 - copy_user_enhanced_fast_string
28104 - CFI_ENDPROC
28105 -ENDPROC(_copy_to_user)
28106 -
28107 -/* Standard copy_from_user with segment limit checking */
28108 -ENTRY(_copy_from_user)
28109 - CFI_STARTPROC
28110 - GET_THREAD_INFO(%rax)
28111 - movq %rsi,%rcx
28112 - addq %rdx,%rcx
28113 - jc bad_from_user
28114 - cmpq TI_addr_limit(%rax),%rcx
28115 - ja bad_from_user
28116 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
28117 - copy_user_generic_unrolled,copy_user_generic_string, \
28118 - copy_user_enhanced_fast_string
28119 - CFI_ENDPROC
28120 -ENDPROC(_copy_from_user)
28121 -
28122 - .section .fixup,"ax"
28123 - /* must zero dest */
28124 -ENTRY(bad_from_user)
28125 -bad_from_user:
28126 - CFI_STARTPROC
28127 - movl %edx,%ecx
28128 - xorl %eax,%eax
28129 - rep
28130 - stosb
28131 -bad_to_user:
28132 - movl %edx,%eax
28133 - ret
28134 - CFI_ENDPROC
28135 -ENDPROC(bad_from_user)
28136 - .previous
28137 -
28138 /*
28139 * copy_user_generic_unrolled - memory copy with exception handling.
28140 * This version is for CPUs like P4 that don't have efficient micro
28141 @@ -131,6 +61,7 @@ ENDPROC(bad_from_user)
28142 */
28143 ENTRY(copy_user_generic_unrolled)
28144 CFI_STARTPROC
28145 + ASM_PAX_OPEN_USERLAND
28146 ASM_STAC
28147 cmpl $8,%edx
28148 jb 20f /* less then 8 bytes, go to byte copy loop */
28149 @@ -141,19 +72,19 @@ ENTRY(copy_user_generic_unrolled)
28150 jz 17f
28151 1: movq (%rsi),%r8
28152 2: movq 1*8(%rsi),%r9
28153 -3: movq 2*8(%rsi),%r10
28154 +3: movq 2*8(%rsi),%rax
28155 4: movq 3*8(%rsi),%r11
28156 5: movq %r8,(%rdi)
28157 6: movq %r9,1*8(%rdi)
28158 -7: movq %r10,2*8(%rdi)
28159 +7: movq %rax,2*8(%rdi)
28160 8: movq %r11,3*8(%rdi)
28161 9: movq 4*8(%rsi),%r8
28162 10: movq 5*8(%rsi),%r9
28163 -11: movq 6*8(%rsi),%r10
28164 +11: movq 6*8(%rsi),%rax
28165 12: movq 7*8(%rsi),%r11
28166 13: movq %r8,4*8(%rdi)
28167 14: movq %r9,5*8(%rdi)
28168 -15: movq %r10,6*8(%rdi)
28169 +15: movq %rax,6*8(%rdi)
28170 16: movq %r11,7*8(%rdi)
28171 leaq 64(%rsi),%rsi
28172 leaq 64(%rdi),%rdi
28173 @@ -180,6 +111,8 @@ ENTRY(copy_user_generic_unrolled)
28174 jnz 21b
28175 23: xor %eax,%eax
28176 ASM_CLAC
28177 + ASM_PAX_CLOSE_USERLAND
28178 + pax_force_retaddr
28179 ret
28180
28181 .section .fixup,"ax"
28182 @@ -235,6 +168,7 @@ ENDPROC(copy_user_generic_unrolled)
28183 */
28184 ENTRY(copy_user_generic_string)
28185 CFI_STARTPROC
28186 + ASM_PAX_OPEN_USERLAND
28187 ASM_STAC
28188 andl %edx,%edx
28189 jz 4f
28190 @@ -251,6 +185,8 @@ ENTRY(copy_user_generic_string)
28191 movsb
28192 4: xorl %eax,%eax
28193 ASM_CLAC
28194 + ASM_PAX_CLOSE_USERLAND
28195 + pax_force_retaddr
28196 ret
28197
28198 .section .fixup,"ax"
28199 @@ -278,6 +214,7 @@ ENDPROC(copy_user_generic_string)
28200 */
28201 ENTRY(copy_user_enhanced_fast_string)
28202 CFI_STARTPROC
28203 + ASM_PAX_OPEN_USERLAND
28204 ASM_STAC
28205 andl %edx,%edx
28206 jz 2f
28207 @@ -286,6 +223,8 @@ ENTRY(copy_user_enhanced_fast_string)
28208 movsb
28209 2: xorl %eax,%eax
28210 ASM_CLAC
28211 + ASM_PAX_CLOSE_USERLAND
28212 + pax_force_retaddr
28213 ret
28214
28215 .section .fixup,"ax"
28216 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
28217 index 6a4f43c..55d26f2 100644
28218 --- a/arch/x86/lib/copy_user_nocache_64.S
28219 +++ b/arch/x86/lib/copy_user_nocache_64.S
28220 @@ -8,6 +8,7 @@
28221
28222 #include <linux/linkage.h>
28223 #include <asm/dwarf2.h>
28224 +#include <asm/alternative-asm.h>
28225
28226 #define FIX_ALIGNMENT 1
28227
28228 @@ -16,6 +17,7 @@
28229 #include <asm/thread_info.h>
28230 #include <asm/asm.h>
28231 #include <asm/smap.h>
28232 +#include <asm/pgtable.h>
28233
28234 .macro ALIGN_DESTINATION
28235 #ifdef FIX_ALIGNMENT
28236 @@ -49,6 +51,16 @@
28237 */
28238 ENTRY(__copy_user_nocache)
28239 CFI_STARTPROC
28240 +
28241 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28242 + mov pax_user_shadow_base,%rcx
28243 + cmp %rcx,%rsi
28244 + jae 1f
28245 + add %rcx,%rsi
28246 +1:
28247 +#endif
28248 +
28249 + ASM_PAX_OPEN_USERLAND
28250 ASM_STAC
28251 cmpl $8,%edx
28252 jb 20f /* less then 8 bytes, go to byte copy loop */
28253 @@ -59,19 +71,19 @@ ENTRY(__copy_user_nocache)
28254 jz 17f
28255 1: movq (%rsi),%r8
28256 2: movq 1*8(%rsi),%r9
28257 -3: movq 2*8(%rsi),%r10
28258 +3: movq 2*8(%rsi),%rax
28259 4: movq 3*8(%rsi),%r11
28260 5: movnti %r8,(%rdi)
28261 6: movnti %r9,1*8(%rdi)
28262 -7: movnti %r10,2*8(%rdi)
28263 +7: movnti %rax,2*8(%rdi)
28264 8: movnti %r11,3*8(%rdi)
28265 9: movq 4*8(%rsi),%r8
28266 10: movq 5*8(%rsi),%r9
28267 -11: movq 6*8(%rsi),%r10
28268 +11: movq 6*8(%rsi),%rax
28269 12: movq 7*8(%rsi),%r11
28270 13: movnti %r8,4*8(%rdi)
28271 14: movnti %r9,5*8(%rdi)
28272 -15: movnti %r10,6*8(%rdi)
28273 +15: movnti %rax,6*8(%rdi)
28274 16: movnti %r11,7*8(%rdi)
28275 leaq 64(%rsi),%rsi
28276 leaq 64(%rdi),%rdi
28277 @@ -98,7 +110,9 @@ ENTRY(__copy_user_nocache)
28278 jnz 21b
28279 23: xorl %eax,%eax
28280 ASM_CLAC
28281 + ASM_PAX_CLOSE_USERLAND
28282 sfence
28283 + pax_force_retaddr
28284 ret
28285
28286 .section .fixup,"ax"
28287 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
28288 index 2419d5f..953ee51 100644
28289 --- a/arch/x86/lib/csum-copy_64.S
28290 +++ b/arch/x86/lib/csum-copy_64.S
28291 @@ -9,6 +9,7 @@
28292 #include <asm/dwarf2.h>
28293 #include <asm/errno.h>
28294 #include <asm/asm.h>
28295 +#include <asm/alternative-asm.h>
28296
28297 /*
28298 * Checksum copy with exception handling.
28299 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
28300 CFI_RESTORE rbp
28301 addq $7*8, %rsp
28302 CFI_ADJUST_CFA_OFFSET -7*8
28303 + pax_force_retaddr 0, 1
28304 ret
28305 CFI_RESTORE_STATE
28306
28307 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
28308 index 25b7ae8..c40113e 100644
28309 --- a/arch/x86/lib/csum-wrappers_64.c
28310 +++ b/arch/x86/lib/csum-wrappers_64.c
28311 @@ -52,8 +52,12 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
28312 len -= 2;
28313 }
28314 }
28315 - isum = csum_partial_copy_generic((__force const void *)src,
28316 + pax_open_userland();
28317 + stac();
28318 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
28319 dst, len, isum, errp, NULL);
28320 + clac();
28321 + pax_close_userland();
28322 if (unlikely(*errp))
28323 goto out_err;
28324
28325 @@ -105,8 +109,13 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
28326 }
28327
28328 *errp = 0;
28329 - return csum_partial_copy_generic(src, (void __force *)dst,
28330 + pax_open_userland();
28331 + stac();
28332 + isum = csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
28333 len, isum, NULL, errp);
28334 + clac();
28335 + pax_close_userland();
28336 + return isum;
28337 }
28338 EXPORT_SYMBOL(csum_partial_copy_to_user);
28339
28340 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
28341 index a451235..1daa956 100644
28342 --- a/arch/x86/lib/getuser.S
28343 +++ b/arch/x86/lib/getuser.S
28344 @@ -33,17 +33,40 @@
28345 #include <asm/thread_info.h>
28346 #include <asm/asm.h>
28347 #include <asm/smap.h>
28348 +#include <asm/segment.h>
28349 +#include <asm/pgtable.h>
28350 +#include <asm/alternative-asm.h>
28351 +
28352 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
28353 +#define __copyuser_seg gs;
28354 +#else
28355 +#define __copyuser_seg
28356 +#endif
28357
28358 .text
28359 ENTRY(__get_user_1)
28360 CFI_STARTPROC
28361 +
28362 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28363 GET_THREAD_INFO(%_ASM_DX)
28364 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28365 jae bad_get_user
28366 ASM_STAC
28367 -1: movzbl (%_ASM_AX),%edx
28368 +
28369 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28370 + mov pax_user_shadow_base,%_ASM_DX
28371 + cmp %_ASM_DX,%_ASM_AX
28372 + jae 1234f
28373 + add %_ASM_DX,%_ASM_AX
28374 +1234:
28375 +#endif
28376 +
28377 +#endif
28378 +
28379 +1: __copyuser_seg movzbl (%_ASM_AX),%edx
28380 xor %eax,%eax
28381 ASM_CLAC
28382 + pax_force_retaddr
28383 ret
28384 CFI_ENDPROC
28385 ENDPROC(__get_user_1)
28386 @@ -51,14 +74,28 @@ ENDPROC(__get_user_1)
28387 ENTRY(__get_user_2)
28388 CFI_STARTPROC
28389 add $1,%_ASM_AX
28390 +
28391 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28392 jc bad_get_user
28393 GET_THREAD_INFO(%_ASM_DX)
28394 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28395 jae bad_get_user
28396 ASM_STAC
28397 -2: movzwl -1(%_ASM_AX),%edx
28398 +
28399 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28400 + mov pax_user_shadow_base,%_ASM_DX
28401 + cmp %_ASM_DX,%_ASM_AX
28402 + jae 1234f
28403 + add %_ASM_DX,%_ASM_AX
28404 +1234:
28405 +#endif
28406 +
28407 +#endif
28408 +
28409 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
28410 xor %eax,%eax
28411 ASM_CLAC
28412 + pax_force_retaddr
28413 ret
28414 CFI_ENDPROC
28415 ENDPROC(__get_user_2)
28416 @@ -66,14 +103,28 @@ ENDPROC(__get_user_2)
28417 ENTRY(__get_user_4)
28418 CFI_STARTPROC
28419 add $3,%_ASM_AX
28420 +
28421 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28422 jc bad_get_user
28423 GET_THREAD_INFO(%_ASM_DX)
28424 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28425 jae bad_get_user
28426 ASM_STAC
28427 -3: movl -3(%_ASM_AX),%edx
28428 +
28429 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28430 + mov pax_user_shadow_base,%_ASM_DX
28431 + cmp %_ASM_DX,%_ASM_AX
28432 + jae 1234f
28433 + add %_ASM_DX,%_ASM_AX
28434 +1234:
28435 +#endif
28436 +
28437 +#endif
28438 +
28439 +3: __copyuser_seg movl -3(%_ASM_AX),%edx
28440 xor %eax,%eax
28441 ASM_CLAC
28442 + pax_force_retaddr
28443 ret
28444 CFI_ENDPROC
28445 ENDPROC(__get_user_4)
28446 @@ -86,10 +137,20 @@ ENTRY(__get_user_8)
28447 GET_THREAD_INFO(%_ASM_DX)
28448 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28449 jae bad_get_user
28450 +
28451 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28452 + mov pax_user_shadow_base,%_ASM_DX
28453 + cmp %_ASM_DX,%_ASM_AX
28454 + jae 1234f
28455 + add %_ASM_DX,%_ASM_AX
28456 +1234:
28457 +#endif
28458 +
28459 ASM_STAC
28460 4: movq -7(%_ASM_AX),%rdx
28461 xor %eax,%eax
28462 ASM_CLAC
28463 + pax_force_retaddr
28464 ret
28465 #else
28466 add $7,%_ASM_AX
28467 @@ -98,10 +159,11 @@ ENTRY(__get_user_8)
28468 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28469 jae bad_get_user_8
28470 ASM_STAC
28471 -4: movl -7(%_ASM_AX),%edx
28472 -5: movl -3(%_ASM_AX),%ecx
28473 +4: __copyuser_seg movl -7(%_ASM_AX),%edx
28474 +5: __copyuser_seg movl -3(%_ASM_AX),%ecx
28475 xor %eax,%eax
28476 ASM_CLAC
28477 + pax_force_retaddr
28478 ret
28479 #endif
28480 CFI_ENDPROC
28481 @@ -113,6 +175,7 @@ bad_get_user:
28482 xor %edx,%edx
28483 mov $(-EFAULT),%_ASM_AX
28484 ASM_CLAC
28485 + pax_force_retaddr
28486 ret
28487 CFI_ENDPROC
28488 END(bad_get_user)
28489 @@ -124,6 +187,7 @@ bad_get_user_8:
28490 xor %ecx,%ecx
28491 mov $(-EFAULT),%_ASM_AX
28492 ASM_CLAC
28493 + pax_force_retaddr
28494 ret
28495 CFI_ENDPROC
28496 END(bad_get_user_8)
28497 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
28498 index 54fcffe..7be149e 100644
28499 --- a/arch/x86/lib/insn.c
28500 +++ b/arch/x86/lib/insn.c
28501 @@ -20,8 +20,10 @@
28502
28503 #ifdef __KERNEL__
28504 #include <linux/string.h>
28505 +#include <asm/pgtable_types.h>
28506 #else
28507 #include <string.h>
28508 +#define ktla_ktva(addr) addr
28509 #endif
28510 #include <asm/inat.h>
28511 #include <asm/insn.h>
28512 @@ -53,8 +55,8 @@
28513 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
28514 {
28515 memset(insn, 0, sizeof(*insn));
28516 - insn->kaddr = kaddr;
28517 - insn->next_byte = kaddr;
28518 + insn->kaddr = ktla_ktva(kaddr);
28519 + insn->next_byte = ktla_ktva(kaddr);
28520 insn->x86_64 = x86_64 ? 1 : 0;
28521 insn->opnd_bytes = 4;
28522 if (x86_64)
28523 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
28524 index 05a95e7..326f2fa 100644
28525 --- a/arch/x86/lib/iomap_copy_64.S
28526 +++ b/arch/x86/lib/iomap_copy_64.S
28527 @@ -17,6 +17,7 @@
28528
28529 #include <linux/linkage.h>
28530 #include <asm/dwarf2.h>
28531 +#include <asm/alternative-asm.h>
28532
28533 /*
28534 * override generic version in lib/iomap_copy.c
28535 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
28536 CFI_STARTPROC
28537 movl %edx,%ecx
28538 rep movsd
28539 + pax_force_retaddr
28540 ret
28541 CFI_ENDPROC
28542 ENDPROC(__iowrite32_copy)
28543 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
28544 index 56313a3..9b59269 100644
28545 --- a/arch/x86/lib/memcpy_64.S
28546 +++ b/arch/x86/lib/memcpy_64.S
28547 @@ -24,7 +24,7 @@
28548 * This gets patched over the unrolled variant (below) via the
28549 * alternative instructions framework:
28550 */
28551 - .section .altinstr_replacement, "ax", @progbits
28552 + .section .altinstr_replacement, "a", @progbits
28553 .Lmemcpy_c:
28554 movq %rdi, %rax
28555 movq %rdx, %rcx
28556 @@ -33,6 +33,7 @@
28557 rep movsq
28558 movl %edx, %ecx
28559 rep movsb
28560 + pax_force_retaddr
28561 ret
28562 .Lmemcpy_e:
28563 .previous
28564 @@ -44,11 +45,12 @@
28565 * This gets patched over the unrolled variant (below) via the
28566 * alternative instructions framework:
28567 */
28568 - .section .altinstr_replacement, "ax", @progbits
28569 + .section .altinstr_replacement, "a", @progbits
28570 .Lmemcpy_c_e:
28571 movq %rdi, %rax
28572 movq %rdx, %rcx
28573 rep movsb
28574 + pax_force_retaddr
28575 ret
28576 .Lmemcpy_e_e:
28577 .previous
28578 @@ -76,13 +78,13 @@ ENTRY(memcpy)
28579 */
28580 movq 0*8(%rsi), %r8
28581 movq 1*8(%rsi), %r9
28582 - movq 2*8(%rsi), %r10
28583 + movq 2*8(%rsi), %rcx
28584 movq 3*8(%rsi), %r11
28585 leaq 4*8(%rsi), %rsi
28586
28587 movq %r8, 0*8(%rdi)
28588 movq %r9, 1*8(%rdi)
28589 - movq %r10, 2*8(%rdi)
28590 + movq %rcx, 2*8(%rdi)
28591 movq %r11, 3*8(%rdi)
28592 leaq 4*8(%rdi), %rdi
28593 jae .Lcopy_forward_loop
28594 @@ -105,12 +107,12 @@ ENTRY(memcpy)
28595 subq $0x20, %rdx
28596 movq -1*8(%rsi), %r8
28597 movq -2*8(%rsi), %r9
28598 - movq -3*8(%rsi), %r10
28599 + movq -3*8(%rsi), %rcx
28600 movq -4*8(%rsi), %r11
28601 leaq -4*8(%rsi), %rsi
28602 movq %r8, -1*8(%rdi)
28603 movq %r9, -2*8(%rdi)
28604 - movq %r10, -3*8(%rdi)
28605 + movq %rcx, -3*8(%rdi)
28606 movq %r11, -4*8(%rdi)
28607 leaq -4*8(%rdi), %rdi
28608 jae .Lcopy_backward_loop
28609 @@ -130,12 +132,13 @@ ENTRY(memcpy)
28610 */
28611 movq 0*8(%rsi), %r8
28612 movq 1*8(%rsi), %r9
28613 - movq -2*8(%rsi, %rdx), %r10
28614 + movq -2*8(%rsi, %rdx), %rcx
28615 movq -1*8(%rsi, %rdx), %r11
28616 movq %r8, 0*8(%rdi)
28617 movq %r9, 1*8(%rdi)
28618 - movq %r10, -2*8(%rdi, %rdx)
28619 + movq %rcx, -2*8(%rdi, %rdx)
28620 movq %r11, -1*8(%rdi, %rdx)
28621 + pax_force_retaddr
28622 retq
28623 .p2align 4
28624 .Lless_16bytes:
28625 @@ -148,6 +151,7 @@ ENTRY(memcpy)
28626 movq -1*8(%rsi, %rdx), %r9
28627 movq %r8, 0*8(%rdi)
28628 movq %r9, -1*8(%rdi, %rdx)
28629 + pax_force_retaddr
28630 retq
28631 .p2align 4
28632 .Lless_8bytes:
28633 @@ -161,6 +165,7 @@ ENTRY(memcpy)
28634 movl -4(%rsi, %rdx), %r8d
28635 movl %ecx, (%rdi)
28636 movl %r8d, -4(%rdi, %rdx)
28637 + pax_force_retaddr
28638 retq
28639 .p2align 4
28640 .Lless_3bytes:
28641 @@ -179,6 +184,7 @@ ENTRY(memcpy)
28642 movb %cl, (%rdi)
28643
28644 .Lend:
28645 + pax_force_retaddr
28646 retq
28647 CFI_ENDPROC
28648 ENDPROC(memcpy)
28649 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
28650 index 65268a6..5aa7815 100644
28651 --- a/arch/x86/lib/memmove_64.S
28652 +++ b/arch/x86/lib/memmove_64.S
28653 @@ -61,13 +61,13 @@ ENTRY(memmove)
28654 5:
28655 sub $0x20, %rdx
28656 movq 0*8(%rsi), %r11
28657 - movq 1*8(%rsi), %r10
28658 + movq 1*8(%rsi), %rcx
28659 movq 2*8(%rsi), %r9
28660 movq 3*8(%rsi), %r8
28661 leaq 4*8(%rsi), %rsi
28662
28663 movq %r11, 0*8(%rdi)
28664 - movq %r10, 1*8(%rdi)
28665 + movq %rcx, 1*8(%rdi)
28666 movq %r9, 2*8(%rdi)
28667 movq %r8, 3*8(%rdi)
28668 leaq 4*8(%rdi), %rdi
28669 @@ -81,10 +81,10 @@ ENTRY(memmove)
28670 4:
28671 movq %rdx, %rcx
28672 movq -8(%rsi, %rdx), %r11
28673 - lea -8(%rdi, %rdx), %r10
28674 + lea -8(%rdi, %rdx), %r9
28675 shrq $3, %rcx
28676 rep movsq
28677 - movq %r11, (%r10)
28678 + movq %r11, (%r9)
28679 jmp 13f
28680 .Lmemmove_end_forward:
28681
28682 @@ -95,14 +95,14 @@ ENTRY(memmove)
28683 7:
28684 movq %rdx, %rcx
28685 movq (%rsi), %r11
28686 - movq %rdi, %r10
28687 + movq %rdi, %r9
28688 leaq -8(%rsi, %rdx), %rsi
28689 leaq -8(%rdi, %rdx), %rdi
28690 shrq $3, %rcx
28691 std
28692 rep movsq
28693 cld
28694 - movq %r11, (%r10)
28695 + movq %r11, (%r9)
28696 jmp 13f
28697
28698 /*
28699 @@ -127,13 +127,13 @@ ENTRY(memmove)
28700 8:
28701 subq $0x20, %rdx
28702 movq -1*8(%rsi), %r11
28703 - movq -2*8(%rsi), %r10
28704 + movq -2*8(%rsi), %rcx
28705 movq -3*8(%rsi), %r9
28706 movq -4*8(%rsi), %r8
28707 leaq -4*8(%rsi), %rsi
28708
28709 movq %r11, -1*8(%rdi)
28710 - movq %r10, -2*8(%rdi)
28711 + movq %rcx, -2*8(%rdi)
28712 movq %r9, -3*8(%rdi)
28713 movq %r8, -4*8(%rdi)
28714 leaq -4*8(%rdi), %rdi
28715 @@ -151,11 +151,11 @@ ENTRY(memmove)
28716 * Move data from 16 bytes to 31 bytes.
28717 */
28718 movq 0*8(%rsi), %r11
28719 - movq 1*8(%rsi), %r10
28720 + movq 1*8(%rsi), %rcx
28721 movq -2*8(%rsi, %rdx), %r9
28722 movq -1*8(%rsi, %rdx), %r8
28723 movq %r11, 0*8(%rdi)
28724 - movq %r10, 1*8(%rdi)
28725 + movq %rcx, 1*8(%rdi)
28726 movq %r9, -2*8(%rdi, %rdx)
28727 movq %r8, -1*8(%rdi, %rdx)
28728 jmp 13f
28729 @@ -167,9 +167,9 @@ ENTRY(memmove)
28730 * Move data from 8 bytes to 15 bytes.
28731 */
28732 movq 0*8(%rsi), %r11
28733 - movq -1*8(%rsi, %rdx), %r10
28734 + movq -1*8(%rsi, %rdx), %r9
28735 movq %r11, 0*8(%rdi)
28736 - movq %r10, -1*8(%rdi, %rdx)
28737 + movq %r9, -1*8(%rdi, %rdx)
28738 jmp 13f
28739 10:
28740 cmpq $4, %rdx
28741 @@ -178,9 +178,9 @@ ENTRY(memmove)
28742 * Move data from 4 bytes to 7 bytes.
28743 */
28744 movl (%rsi), %r11d
28745 - movl -4(%rsi, %rdx), %r10d
28746 + movl -4(%rsi, %rdx), %r9d
28747 movl %r11d, (%rdi)
28748 - movl %r10d, -4(%rdi, %rdx)
28749 + movl %r9d, -4(%rdi, %rdx)
28750 jmp 13f
28751 11:
28752 cmp $2, %rdx
28753 @@ -189,9 +189,9 @@ ENTRY(memmove)
28754 * Move data from 2 bytes to 3 bytes.
28755 */
28756 movw (%rsi), %r11w
28757 - movw -2(%rsi, %rdx), %r10w
28758 + movw -2(%rsi, %rdx), %r9w
28759 movw %r11w, (%rdi)
28760 - movw %r10w, -2(%rdi, %rdx)
28761 + movw %r9w, -2(%rdi, %rdx)
28762 jmp 13f
28763 12:
28764 cmp $1, %rdx
28765 @@ -202,14 +202,16 @@ ENTRY(memmove)
28766 movb (%rsi), %r11b
28767 movb %r11b, (%rdi)
28768 13:
28769 + pax_force_retaddr
28770 retq
28771 CFI_ENDPROC
28772
28773 - .section .altinstr_replacement,"ax"
28774 + .section .altinstr_replacement,"a"
28775 .Lmemmove_begin_forward_efs:
28776 /* Forward moving data. */
28777 movq %rdx, %rcx
28778 rep movsb
28779 + pax_force_retaddr
28780 retq
28781 .Lmemmove_end_forward_efs:
28782 .previous
28783 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
28784 index 2dcb380..50a78bc 100644
28785 --- a/arch/x86/lib/memset_64.S
28786 +++ b/arch/x86/lib/memset_64.S
28787 @@ -16,7 +16,7 @@
28788 *
28789 * rax original destination
28790 */
28791 - .section .altinstr_replacement, "ax", @progbits
28792 + .section .altinstr_replacement, "a", @progbits
28793 .Lmemset_c:
28794 movq %rdi,%r9
28795 movq %rdx,%rcx
28796 @@ -30,6 +30,7 @@
28797 movl %edx,%ecx
28798 rep stosb
28799 movq %r9,%rax
28800 + pax_force_retaddr
28801 ret
28802 .Lmemset_e:
28803 .previous
28804 @@ -45,13 +46,14 @@
28805 *
28806 * rax original destination
28807 */
28808 - .section .altinstr_replacement, "ax", @progbits
28809 + .section .altinstr_replacement, "a", @progbits
28810 .Lmemset_c_e:
28811 movq %rdi,%r9
28812 movb %sil,%al
28813 movq %rdx,%rcx
28814 rep stosb
28815 movq %r9,%rax
28816 + pax_force_retaddr
28817 ret
28818 .Lmemset_e_e:
28819 .previous
28820 @@ -59,7 +61,7 @@
28821 ENTRY(memset)
28822 ENTRY(__memset)
28823 CFI_STARTPROC
28824 - movq %rdi,%r10
28825 + movq %rdi,%r11
28826
28827 /* expand byte value */
28828 movzbl %sil,%ecx
28829 @@ -117,7 +119,8 @@ ENTRY(__memset)
28830 jnz .Lloop_1
28831
28832 .Lende:
28833 - movq %r10,%rax
28834 + movq %r11,%rax
28835 + pax_force_retaddr
28836 ret
28837
28838 CFI_RESTORE_STATE
28839 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
28840 index c9f2d9b..e7fd2c0 100644
28841 --- a/arch/x86/lib/mmx_32.c
28842 +++ b/arch/x86/lib/mmx_32.c
28843 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
28844 {
28845 void *p;
28846 int i;
28847 + unsigned long cr0;
28848
28849 if (unlikely(in_interrupt()))
28850 return __memcpy(to, from, len);
28851 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
28852 kernel_fpu_begin();
28853
28854 __asm__ __volatile__ (
28855 - "1: prefetch (%0)\n" /* This set is 28 bytes */
28856 - " prefetch 64(%0)\n"
28857 - " prefetch 128(%0)\n"
28858 - " prefetch 192(%0)\n"
28859 - " prefetch 256(%0)\n"
28860 + "1: prefetch (%1)\n" /* This set is 28 bytes */
28861 + " prefetch 64(%1)\n"
28862 + " prefetch 128(%1)\n"
28863 + " prefetch 192(%1)\n"
28864 + " prefetch 256(%1)\n"
28865 "2: \n"
28866 ".section .fixup, \"ax\"\n"
28867 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28868 + "3: \n"
28869 +
28870 +#ifdef CONFIG_PAX_KERNEXEC
28871 + " movl %%cr0, %0\n"
28872 + " movl %0, %%eax\n"
28873 + " andl $0xFFFEFFFF, %%eax\n"
28874 + " movl %%eax, %%cr0\n"
28875 +#endif
28876 +
28877 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28878 +
28879 +#ifdef CONFIG_PAX_KERNEXEC
28880 + " movl %0, %%cr0\n"
28881 +#endif
28882 +
28883 " jmp 2b\n"
28884 ".previous\n"
28885 _ASM_EXTABLE(1b, 3b)
28886 - : : "r" (from));
28887 + : "=&r" (cr0) : "r" (from) : "ax");
28888
28889 for ( ; i > 5; i--) {
28890 __asm__ __volatile__ (
28891 - "1: prefetch 320(%0)\n"
28892 - "2: movq (%0), %%mm0\n"
28893 - " movq 8(%0), %%mm1\n"
28894 - " movq 16(%0), %%mm2\n"
28895 - " movq 24(%0), %%mm3\n"
28896 - " movq %%mm0, (%1)\n"
28897 - " movq %%mm1, 8(%1)\n"
28898 - " movq %%mm2, 16(%1)\n"
28899 - " movq %%mm3, 24(%1)\n"
28900 - " movq 32(%0), %%mm0\n"
28901 - " movq 40(%0), %%mm1\n"
28902 - " movq 48(%0), %%mm2\n"
28903 - " movq 56(%0), %%mm3\n"
28904 - " movq %%mm0, 32(%1)\n"
28905 - " movq %%mm1, 40(%1)\n"
28906 - " movq %%mm2, 48(%1)\n"
28907 - " movq %%mm3, 56(%1)\n"
28908 + "1: prefetch 320(%1)\n"
28909 + "2: movq (%1), %%mm0\n"
28910 + " movq 8(%1), %%mm1\n"
28911 + " movq 16(%1), %%mm2\n"
28912 + " movq 24(%1), %%mm3\n"
28913 + " movq %%mm0, (%2)\n"
28914 + " movq %%mm1, 8(%2)\n"
28915 + " movq %%mm2, 16(%2)\n"
28916 + " movq %%mm3, 24(%2)\n"
28917 + " movq 32(%1), %%mm0\n"
28918 + " movq 40(%1), %%mm1\n"
28919 + " movq 48(%1), %%mm2\n"
28920 + " movq 56(%1), %%mm3\n"
28921 + " movq %%mm0, 32(%2)\n"
28922 + " movq %%mm1, 40(%2)\n"
28923 + " movq %%mm2, 48(%2)\n"
28924 + " movq %%mm3, 56(%2)\n"
28925 ".section .fixup, \"ax\"\n"
28926 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28927 + "3:\n"
28928 +
28929 +#ifdef CONFIG_PAX_KERNEXEC
28930 + " movl %%cr0, %0\n"
28931 + " movl %0, %%eax\n"
28932 + " andl $0xFFFEFFFF, %%eax\n"
28933 + " movl %%eax, %%cr0\n"
28934 +#endif
28935 +
28936 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28937 +
28938 +#ifdef CONFIG_PAX_KERNEXEC
28939 + " movl %0, %%cr0\n"
28940 +#endif
28941 +
28942 " jmp 2b\n"
28943 ".previous\n"
28944 _ASM_EXTABLE(1b, 3b)
28945 - : : "r" (from), "r" (to) : "memory");
28946 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28947
28948 from += 64;
28949 to += 64;
28950 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
28951 static void fast_copy_page(void *to, void *from)
28952 {
28953 int i;
28954 + unsigned long cr0;
28955
28956 kernel_fpu_begin();
28957
28958 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
28959 * but that is for later. -AV
28960 */
28961 __asm__ __volatile__(
28962 - "1: prefetch (%0)\n"
28963 - " prefetch 64(%0)\n"
28964 - " prefetch 128(%0)\n"
28965 - " prefetch 192(%0)\n"
28966 - " prefetch 256(%0)\n"
28967 + "1: prefetch (%1)\n"
28968 + " prefetch 64(%1)\n"
28969 + " prefetch 128(%1)\n"
28970 + " prefetch 192(%1)\n"
28971 + " prefetch 256(%1)\n"
28972 "2: \n"
28973 ".section .fixup, \"ax\"\n"
28974 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28975 + "3: \n"
28976 +
28977 +#ifdef CONFIG_PAX_KERNEXEC
28978 + " movl %%cr0, %0\n"
28979 + " movl %0, %%eax\n"
28980 + " andl $0xFFFEFFFF, %%eax\n"
28981 + " movl %%eax, %%cr0\n"
28982 +#endif
28983 +
28984 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28985 +
28986 +#ifdef CONFIG_PAX_KERNEXEC
28987 + " movl %0, %%cr0\n"
28988 +#endif
28989 +
28990 " jmp 2b\n"
28991 ".previous\n"
28992 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
28993 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
28994
28995 for (i = 0; i < (4096-320)/64; i++) {
28996 __asm__ __volatile__ (
28997 - "1: prefetch 320(%0)\n"
28998 - "2: movq (%0), %%mm0\n"
28999 - " movntq %%mm0, (%1)\n"
29000 - " movq 8(%0), %%mm1\n"
29001 - " movntq %%mm1, 8(%1)\n"
29002 - " movq 16(%0), %%mm2\n"
29003 - " movntq %%mm2, 16(%1)\n"
29004 - " movq 24(%0), %%mm3\n"
29005 - " movntq %%mm3, 24(%1)\n"
29006 - " movq 32(%0), %%mm4\n"
29007 - " movntq %%mm4, 32(%1)\n"
29008 - " movq 40(%0), %%mm5\n"
29009 - " movntq %%mm5, 40(%1)\n"
29010 - " movq 48(%0), %%mm6\n"
29011 - " movntq %%mm6, 48(%1)\n"
29012 - " movq 56(%0), %%mm7\n"
29013 - " movntq %%mm7, 56(%1)\n"
29014 + "1: prefetch 320(%1)\n"
29015 + "2: movq (%1), %%mm0\n"
29016 + " movntq %%mm0, (%2)\n"
29017 + " movq 8(%1), %%mm1\n"
29018 + " movntq %%mm1, 8(%2)\n"
29019 + " movq 16(%1), %%mm2\n"
29020 + " movntq %%mm2, 16(%2)\n"
29021 + " movq 24(%1), %%mm3\n"
29022 + " movntq %%mm3, 24(%2)\n"
29023 + " movq 32(%1), %%mm4\n"
29024 + " movntq %%mm4, 32(%2)\n"
29025 + " movq 40(%1), %%mm5\n"
29026 + " movntq %%mm5, 40(%2)\n"
29027 + " movq 48(%1), %%mm6\n"
29028 + " movntq %%mm6, 48(%2)\n"
29029 + " movq 56(%1), %%mm7\n"
29030 + " movntq %%mm7, 56(%2)\n"
29031 ".section .fixup, \"ax\"\n"
29032 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
29033 + "3:\n"
29034 +
29035 +#ifdef CONFIG_PAX_KERNEXEC
29036 + " movl %%cr0, %0\n"
29037 + " movl %0, %%eax\n"
29038 + " andl $0xFFFEFFFF, %%eax\n"
29039 + " movl %%eax, %%cr0\n"
29040 +#endif
29041 +
29042 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
29043 +
29044 +#ifdef CONFIG_PAX_KERNEXEC
29045 + " movl %0, %%cr0\n"
29046 +#endif
29047 +
29048 " jmp 2b\n"
29049 ".previous\n"
29050 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
29051 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
29052
29053 from += 64;
29054 to += 64;
29055 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
29056 static void fast_copy_page(void *to, void *from)
29057 {
29058 int i;
29059 + unsigned long cr0;
29060
29061 kernel_fpu_begin();
29062
29063 __asm__ __volatile__ (
29064 - "1: prefetch (%0)\n"
29065 - " prefetch 64(%0)\n"
29066 - " prefetch 128(%0)\n"
29067 - " prefetch 192(%0)\n"
29068 - " prefetch 256(%0)\n"
29069 + "1: prefetch (%1)\n"
29070 + " prefetch 64(%1)\n"
29071 + " prefetch 128(%1)\n"
29072 + " prefetch 192(%1)\n"
29073 + " prefetch 256(%1)\n"
29074 "2: \n"
29075 ".section .fixup, \"ax\"\n"
29076 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
29077 + "3: \n"
29078 +
29079 +#ifdef CONFIG_PAX_KERNEXEC
29080 + " movl %%cr0, %0\n"
29081 + " movl %0, %%eax\n"
29082 + " andl $0xFFFEFFFF, %%eax\n"
29083 + " movl %%eax, %%cr0\n"
29084 +#endif
29085 +
29086 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
29087 +
29088 +#ifdef CONFIG_PAX_KERNEXEC
29089 + " movl %0, %%cr0\n"
29090 +#endif
29091 +
29092 " jmp 2b\n"
29093 ".previous\n"
29094 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
29095 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
29096
29097 for (i = 0; i < 4096/64; i++) {
29098 __asm__ __volatile__ (
29099 - "1: prefetch 320(%0)\n"
29100 - "2: movq (%0), %%mm0\n"
29101 - " movq 8(%0), %%mm1\n"
29102 - " movq 16(%0), %%mm2\n"
29103 - " movq 24(%0), %%mm3\n"
29104 - " movq %%mm0, (%1)\n"
29105 - " movq %%mm1, 8(%1)\n"
29106 - " movq %%mm2, 16(%1)\n"
29107 - " movq %%mm3, 24(%1)\n"
29108 - " movq 32(%0), %%mm0\n"
29109 - " movq 40(%0), %%mm1\n"
29110 - " movq 48(%0), %%mm2\n"
29111 - " movq 56(%0), %%mm3\n"
29112 - " movq %%mm0, 32(%1)\n"
29113 - " movq %%mm1, 40(%1)\n"
29114 - " movq %%mm2, 48(%1)\n"
29115 - " movq %%mm3, 56(%1)\n"
29116 + "1: prefetch 320(%1)\n"
29117 + "2: movq (%1), %%mm0\n"
29118 + " movq 8(%1), %%mm1\n"
29119 + " movq 16(%1), %%mm2\n"
29120 + " movq 24(%1), %%mm3\n"
29121 + " movq %%mm0, (%2)\n"
29122 + " movq %%mm1, 8(%2)\n"
29123 + " movq %%mm2, 16(%2)\n"
29124 + " movq %%mm3, 24(%2)\n"
29125 + " movq 32(%1), %%mm0\n"
29126 + " movq 40(%1), %%mm1\n"
29127 + " movq 48(%1), %%mm2\n"
29128 + " movq 56(%1), %%mm3\n"
29129 + " movq %%mm0, 32(%2)\n"
29130 + " movq %%mm1, 40(%2)\n"
29131 + " movq %%mm2, 48(%2)\n"
29132 + " movq %%mm3, 56(%2)\n"
29133 ".section .fixup, \"ax\"\n"
29134 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
29135 + "3:\n"
29136 +
29137 +#ifdef CONFIG_PAX_KERNEXEC
29138 + " movl %%cr0, %0\n"
29139 + " movl %0, %%eax\n"
29140 + " andl $0xFFFEFFFF, %%eax\n"
29141 + " movl %%eax, %%cr0\n"
29142 +#endif
29143 +
29144 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
29145 +
29146 +#ifdef CONFIG_PAX_KERNEXEC
29147 + " movl %0, %%cr0\n"
29148 +#endif
29149 +
29150 " jmp 2b\n"
29151 ".previous\n"
29152 _ASM_EXTABLE(1b, 3b)
29153 - : : "r" (from), "r" (to) : "memory");
29154 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
29155
29156 from += 64;
29157 to += 64;
29158 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
29159 index f6d13ee..aca5f0b 100644
29160 --- a/arch/x86/lib/msr-reg.S
29161 +++ b/arch/x86/lib/msr-reg.S
29162 @@ -3,6 +3,7 @@
29163 #include <asm/dwarf2.h>
29164 #include <asm/asm.h>
29165 #include <asm/msr.h>
29166 +#include <asm/alternative-asm.h>
29167
29168 #ifdef CONFIG_X86_64
29169 /*
29170 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
29171 CFI_STARTPROC
29172 pushq_cfi %rbx
29173 pushq_cfi %rbp
29174 - movq %rdi, %r10 /* Save pointer */
29175 + movq %rdi, %r9 /* Save pointer */
29176 xorl %r11d, %r11d /* Return value */
29177 movl (%rdi), %eax
29178 movl 4(%rdi), %ecx
29179 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
29180 movl 28(%rdi), %edi
29181 CFI_REMEMBER_STATE
29182 1: \op
29183 -2: movl %eax, (%r10)
29184 +2: movl %eax, (%r9)
29185 movl %r11d, %eax /* Return value */
29186 - movl %ecx, 4(%r10)
29187 - movl %edx, 8(%r10)
29188 - movl %ebx, 12(%r10)
29189 - movl %ebp, 20(%r10)
29190 - movl %esi, 24(%r10)
29191 - movl %edi, 28(%r10)
29192 + movl %ecx, 4(%r9)
29193 + movl %edx, 8(%r9)
29194 + movl %ebx, 12(%r9)
29195 + movl %ebp, 20(%r9)
29196 + movl %esi, 24(%r9)
29197 + movl %edi, 28(%r9)
29198 popq_cfi %rbp
29199 popq_cfi %rbx
29200 + pax_force_retaddr
29201 ret
29202 3:
29203 CFI_RESTORE_STATE
29204 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
29205 index fc6ba17..d4d989d 100644
29206 --- a/arch/x86/lib/putuser.S
29207 +++ b/arch/x86/lib/putuser.S
29208 @@ -16,7 +16,9 @@
29209 #include <asm/errno.h>
29210 #include <asm/asm.h>
29211 #include <asm/smap.h>
29212 -
29213 +#include <asm/segment.h>
29214 +#include <asm/pgtable.h>
29215 +#include <asm/alternative-asm.h>
29216
29217 /*
29218 * __put_user_X
29219 @@ -30,57 +32,125 @@
29220 * as they get called from within inline assembly.
29221 */
29222
29223 -#define ENTER CFI_STARTPROC ; \
29224 - GET_THREAD_INFO(%_ASM_BX)
29225 -#define EXIT ASM_CLAC ; \
29226 - ret ; \
29227 +#define ENTER CFI_STARTPROC
29228 +#define EXIT ASM_CLAC ; \
29229 + pax_force_retaddr ; \
29230 + ret ; \
29231 CFI_ENDPROC
29232
29233 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29234 +#define _DEST %_ASM_CX,%_ASM_BX
29235 +#else
29236 +#define _DEST %_ASM_CX
29237 +#endif
29238 +
29239 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
29240 +#define __copyuser_seg gs;
29241 +#else
29242 +#define __copyuser_seg
29243 +#endif
29244 +
29245 .text
29246 ENTRY(__put_user_1)
29247 ENTER
29248 +
29249 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
29250 + GET_THREAD_INFO(%_ASM_BX)
29251 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
29252 jae bad_put_user
29253 ASM_STAC
29254 -1: movb %al,(%_ASM_CX)
29255 +
29256 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29257 + mov pax_user_shadow_base,%_ASM_BX
29258 + cmp %_ASM_BX,%_ASM_CX
29259 + jb 1234f
29260 + xor %ebx,%ebx
29261 +1234:
29262 +#endif
29263 +
29264 +#endif
29265 +
29266 +1: __copyuser_seg movb %al,(_DEST)
29267 xor %eax,%eax
29268 EXIT
29269 ENDPROC(__put_user_1)
29270
29271 ENTRY(__put_user_2)
29272 ENTER
29273 +
29274 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
29275 + GET_THREAD_INFO(%_ASM_BX)
29276 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
29277 sub $1,%_ASM_BX
29278 cmp %_ASM_BX,%_ASM_CX
29279 jae bad_put_user
29280 ASM_STAC
29281 -2: movw %ax,(%_ASM_CX)
29282 +
29283 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29284 + mov pax_user_shadow_base,%_ASM_BX
29285 + cmp %_ASM_BX,%_ASM_CX
29286 + jb 1234f
29287 + xor %ebx,%ebx
29288 +1234:
29289 +#endif
29290 +
29291 +#endif
29292 +
29293 +2: __copyuser_seg movw %ax,(_DEST)
29294 xor %eax,%eax
29295 EXIT
29296 ENDPROC(__put_user_2)
29297
29298 ENTRY(__put_user_4)
29299 ENTER
29300 +
29301 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
29302 + GET_THREAD_INFO(%_ASM_BX)
29303 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
29304 sub $3,%_ASM_BX
29305 cmp %_ASM_BX,%_ASM_CX
29306 jae bad_put_user
29307 ASM_STAC
29308 -3: movl %eax,(%_ASM_CX)
29309 +
29310 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29311 + mov pax_user_shadow_base,%_ASM_BX
29312 + cmp %_ASM_BX,%_ASM_CX
29313 + jb 1234f
29314 + xor %ebx,%ebx
29315 +1234:
29316 +#endif
29317 +
29318 +#endif
29319 +
29320 +3: __copyuser_seg movl %eax,(_DEST)
29321 xor %eax,%eax
29322 EXIT
29323 ENDPROC(__put_user_4)
29324
29325 ENTRY(__put_user_8)
29326 ENTER
29327 +
29328 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
29329 + GET_THREAD_INFO(%_ASM_BX)
29330 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
29331 sub $7,%_ASM_BX
29332 cmp %_ASM_BX,%_ASM_CX
29333 jae bad_put_user
29334 ASM_STAC
29335 -4: mov %_ASM_AX,(%_ASM_CX)
29336 +
29337 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29338 + mov pax_user_shadow_base,%_ASM_BX
29339 + cmp %_ASM_BX,%_ASM_CX
29340 + jb 1234f
29341 + xor %ebx,%ebx
29342 +1234:
29343 +#endif
29344 +
29345 +#endif
29346 +
29347 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
29348 #ifdef CONFIG_X86_32
29349 -5: movl %edx,4(%_ASM_CX)
29350 +5: __copyuser_seg movl %edx,4(_DEST)
29351 #endif
29352 xor %eax,%eax
29353 EXIT
29354 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
29355 index 1cad221..de671ee 100644
29356 --- a/arch/x86/lib/rwlock.S
29357 +++ b/arch/x86/lib/rwlock.S
29358 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
29359 FRAME
29360 0: LOCK_PREFIX
29361 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
29362 +
29363 +#ifdef CONFIG_PAX_REFCOUNT
29364 + jno 1234f
29365 + LOCK_PREFIX
29366 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
29367 + int $4
29368 +1234:
29369 + _ASM_EXTABLE(1234b, 1234b)
29370 +#endif
29371 +
29372 1: rep; nop
29373 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
29374 jne 1b
29375 LOCK_PREFIX
29376 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
29377 +
29378 +#ifdef CONFIG_PAX_REFCOUNT
29379 + jno 1234f
29380 + LOCK_PREFIX
29381 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
29382 + int $4
29383 +1234:
29384 + _ASM_EXTABLE(1234b, 1234b)
29385 +#endif
29386 +
29387 jnz 0b
29388 ENDFRAME
29389 + pax_force_retaddr
29390 ret
29391 CFI_ENDPROC
29392 END(__write_lock_failed)
29393 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
29394 FRAME
29395 0: LOCK_PREFIX
29396 READ_LOCK_SIZE(inc) (%__lock_ptr)
29397 +
29398 +#ifdef CONFIG_PAX_REFCOUNT
29399 + jno 1234f
29400 + LOCK_PREFIX
29401 + READ_LOCK_SIZE(dec) (%__lock_ptr)
29402 + int $4
29403 +1234:
29404 + _ASM_EXTABLE(1234b, 1234b)
29405 +#endif
29406 +
29407 1: rep; nop
29408 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
29409 js 1b
29410 LOCK_PREFIX
29411 READ_LOCK_SIZE(dec) (%__lock_ptr)
29412 +
29413 +#ifdef CONFIG_PAX_REFCOUNT
29414 + jno 1234f
29415 + LOCK_PREFIX
29416 + READ_LOCK_SIZE(inc) (%__lock_ptr)
29417 + int $4
29418 +1234:
29419 + _ASM_EXTABLE(1234b, 1234b)
29420 +#endif
29421 +
29422 js 0b
29423 ENDFRAME
29424 + pax_force_retaddr
29425 ret
29426 CFI_ENDPROC
29427 END(__read_lock_failed)
29428 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
29429 index 5dff5f0..cadebf4 100644
29430 --- a/arch/x86/lib/rwsem.S
29431 +++ b/arch/x86/lib/rwsem.S
29432 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
29433 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29434 CFI_RESTORE __ASM_REG(dx)
29435 restore_common_regs
29436 + pax_force_retaddr
29437 ret
29438 CFI_ENDPROC
29439 ENDPROC(call_rwsem_down_read_failed)
29440 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
29441 movq %rax,%rdi
29442 call rwsem_down_write_failed
29443 restore_common_regs
29444 + pax_force_retaddr
29445 ret
29446 CFI_ENDPROC
29447 ENDPROC(call_rwsem_down_write_failed)
29448 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
29449 movq %rax,%rdi
29450 call rwsem_wake
29451 restore_common_regs
29452 -1: ret
29453 +1: pax_force_retaddr
29454 + ret
29455 CFI_ENDPROC
29456 ENDPROC(call_rwsem_wake)
29457
29458 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
29459 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29460 CFI_RESTORE __ASM_REG(dx)
29461 restore_common_regs
29462 + pax_force_retaddr
29463 ret
29464 CFI_ENDPROC
29465 ENDPROC(call_rwsem_downgrade_wake)
29466 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
29467 index a63efd6..ccecad8 100644
29468 --- a/arch/x86/lib/thunk_64.S
29469 +++ b/arch/x86/lib/thunk_64.S
29470 @@ -8,6 +8,7 @@
29471 #include <linux/linkage.h>
29472 #include <asm/dwarf2.h>
29473 #include <asm/calling.h>
29474 +#include <asm/alternative-asm.h>
29475
29476 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
29477 .macro THUNK name, func, put_ret_addr_in_rdi=0
29478 @@ -41,5 +42,6 @@
29479 SAVE_ARGS
29480 restore:
29481 RESTORE_ARGS
29482 + pax_force_retaddr
29483 ret
29484 CFI_ENDPROC
29485 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
29486 index 3eb18ac..6890bc3 100644
29487 --- a/arch/x86/lib/usercopy_32.c
29488 +++ b/arch/x86/lib/usercopy_32.c
29489 @@ -42,11 +42,13 @@ do { \
29490 int __d0; \
29491 might_fault(); \
29492 __asm__ __volatile__( \
29493 + __COPYUSER_SET_ES \
29494 ASM_STAC "\n" \
29495 "0: rep; stosl\n" \
29496 " movl %2,%0\n" \
29497 "1: rep; stosb\n" \
29498 "2: " ASM_CLAC "\n" \
29499 + __COPYUSER_RESTORE_ES \
29500 ".section .fixup,\"ax\"\n" \
29501 "3: lea 0(%2,%0,4),%0\n" \
29502 " jmp 2b\n" \
29503 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
29504
29505 #ifdef CONFIG_X86_INTEL_USERCOPY
29506 static unsigned long
29507 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
29508 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
29509 {
29510 int d0, d1;
29511 __asm__ __volatile__(
29512 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29513 " .align 2,0x90\n"
29514 "3: movl 0(%4), %%eax\n"
29515 "4: movl 4(%4), %%edx\n"
29516 - "5: movl %%eax, 0(%3)\n"
29517 - "6: movl %%edx, 4(%3)\n"
29518 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
29519 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
29520 "7: movl 8(%4), %%eax\n"
29521 "8: movl 12(%4),%%edx\n"
29522 - "9: movl %%eax, 8(%3)\n"
29523 - "10: movl %%edx, 12(%3)\n"
29524 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
29525 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
29526 "11: movl 16(%4), %%eax\n"
29527 "12: movl 20(%4), %%edx\n"
29528 - "13: movl %%eax, 16(%3)\n"
29529 - "14: movl %%edx, 20(%3)\n"
29530 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
29531 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
29532 "15: movl 24(%4), %%eax\n"
29533 "16: movl 28(%4), %%edx\n"
29534 - "17: movl %%eax, 24(%3)\n"
29535 - "18: movl %%edx, 28(%3)\n"
29536 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
29537 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
29538 "19: movl 32(%4), %%eax\n"
29539 "20: movl 36(%4), %%edx\n"
29540 - "21: movl %%eax, 32(%3)\n"
29541 - "22: movl %%edx, 36(%3)\n"
29542 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
29543 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
29544 "23: movl 40(%4), %%eax\n"
29545 "24: movl 44(%4), %%edx\n"
29546 - "25: movl %%eax, 40(%3)\n"
29547 - "26: movl %%edx, 44(%3)\n"
29548 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
29549 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
29550 "27: movl 48(%4), %%eax\n"
29551 "28: movl 52(%4), %%edx\n"
29552 - "29: movl %%eax, 48(%3)\n"
29553 - "30: movl %%edx, 52(%3)\n"
29554 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
29555 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
29556 "31: movl 56(%4), %%eax\n"
29557 "32: movl 60(%4), %%edx\n"
29558 - "33: movl %%eax, 56(%3)\n"
29559 - "34: movl %%edx, 60(%3)\n"
29560 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
29561 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
29562 " addl $-64, %0\n"
29563 " addl $64, %4\n"
29564 " addl $64, %3\n"
29565 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29566 " shrl $2, %0\n"
29567 " andl $3, %%eax\n"
29568 " cld\n"
29569 + __COPYUSER_SET_ES
29570 "99: rep; movsl\n"
29571 "36: movl %%eax, %0\n"
29572 "37: rep; movsb\n"
29573 "100:\n"
29574 + __COPYUSER_RESTORE_ES
29575 ".section .fixup,\"ax\"\n"
29576 "101: lea 0(%%eax,%0,4),%0\n"
29577 " jmp 100b\n"
29578 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29579 }
29580
29581 static unsigned long
29582 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
29583 +{
29584 + int d0, d1;
29585 + __asm__ __volatile__(
29586 + " .align 2,0x90\n"
29587 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
29588 + " cmpl $67, %0\n"
29589 + " jbe 3f\n"
29590 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
29591 + " .align 2,0x90\n"
29592 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
29593 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
29594 + "5: movl %%eax, 0(%3)\n"
29595 + "6: movl %%edx, 4(%3)\n"
29596 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
29597 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
29598 + "9: movl %%eax, 8(%3)\n"
29599 + "10: movl %%edx, 12(%3)\n"
29600 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
29601 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
29602 + "13: movl %%eax, 16(%3)\n"
29603 + "14: movl %%edx, 20(%3)\n"
29604 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
29605 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
29606 + "17: movl %%eax, 24(%3)\n"
29607 + "18: movl %%edx, 28(%3)\n"
29608 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
29609 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
29610 + "21: movl %%eax, 32(%3)\n"
29611 + "22: movl %%edx, 36(%3)\n"
29612 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
29613 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
29614 + "25: movl %%eax, 40(%3)\n"
29615 + "26: movl %%edx, 44(%3)\n"
29616 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
29617 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
29618 + "29: movl %%eax, 48(%3)\n"
29619 + "30: movl %%edx, 52(%3)\n"
29620 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
29621 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
29622 + "33: movl %%eax, 56(%3)\n"
29623 + "34: movl %%edx, 60(%3)\n"
29624 + " addl $-64, %0\n"
29625 + " addl $64, %4\n"
29626 + " addl $64, %3\n"
29627 + " cmpl $63, %0\n"
29628 + " ja 1b\n"
29629 + "35: movl %0, %%eax\n"
29630 + " shrl $2, %0\n"
29631 + " andl $3, %%eax\n"
29632 + " cld\n"
29633 + "99: rep; "__copyuser_seg" movsl\n"
29634 + "36: movl %%eax, %0\n"
29635 + "37: rep; "__copyuser_seg" movsb\n"
29636 + "100:\n"
29637 + ".section .fixup,\"ax\"\n"
29638 + "101: lea 0(%%eax,%0,4),%0\n"
29639 + " jmp 100b\n"
29640 + ".previous\n"
29641 + _ASM_EXTABLE(1b,100b)
29642 + _ASM_EXTABLE(2b,100b)
29643 + _ASM_EXTABLE(3b,100b)
29644 + _ASM_EXTABLE(4b,100b)
29645 + _ASM_EXTABLE(5b,100b)
29646 + _ASM_EXTABLE(6b,100b)
29647 + _ASM_EXTABLE(7b,100b)
29648 + _ASM_EXTABLE(8b,100b)
29649 + _ASM_EXTABLE(9b,100b)
29650 + _ASM_EXTABLE(10b,100b)
29651 + _ASM_EXTABLE(11b,100b)
29652 + _ASM_EXTABLE(12b,100b)
29653 + _ASM_EXTABLE(13b,100b)
29654 + _ASM_EXTABLE(14b,100b)
29655 + _ASM_EXTABLE(15b,100b)
29656 + _ASM_EXTABLE(16b,100b)
29657 + _ASM_EXTABLE(17b,100b)
29658 + _ASM_EXTABLE(18b,100b)
29659 + _ASM_EXTABLE(19b,100b)
29660 + _ASM_EXTABLE(20b,100b)
29661 + _ASM_EXTABLE(21b,100b)
29662 + _ASM_EXTABLE(22b,100b)
29663 + _ASM_EXTABLE(23b,100b)
29664 + _ASM_EXTABLE(24b,100b)
29665 + _ASM_EXTABLE(25b,100b)
29666 + _ASM_EXTABLE(26b,100b)
29667 + _ASM_EXTABLE(27b,100b)
29668 + _ASM_EXTABLE(28b,100b)
29669 + _ASM_EXTABLE(29b,100b)
29670 + _ASM_EXTABLE(30b,100b)
29671 + _ASM_EXTABLE(31b,100b)
29672 + _ASM_EXTABLE(32b,100b)
29673 + _ASM_EXTABLE(33b,100b)
29674 + _ASM_EXTABLE(34b,100b)
29675 + _ASM_EXTABLE(35b,100b)
29676 + _ASM_EXTABLE(36b,100b)
29677 + _ASM_EXTABLE(37b,100b)
29678 + _ASM_EXTABLE(99b,101b)
29679 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
29680 + : "1"(to), "2"(from), "0"(size)
29681 + : "eax", "edx", "memory");
29682 + return size;
29683 +}
29684 +
29685 +static unsigned long __size_overflow(3)
29686 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29687 {
29688 int d0, d1;
29689 __asm__ __volatile__(
29690 " .align 2,0x90\n"
29691 - "0: movl 32(%4), %%eax\n"
29692 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29693 " cmpl $67, %0\n"
29694 " jbe 2f\n"
29695 - "1: movl 64(%4), %%eax\n"
29696 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29697 " .align 2,0x90\n"
29698 - "2: movl 0(%4), %%eax\n"
29699 - "21: movl 4(%4), %%edx\n"
29700 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29701 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29702 " movl %%eax, 0(%3)\n"
29703 " movl %%edx, 4(%3)\n"
29704 - "3: movl 8(%4), %%eax\n"
29705 - "31: movl 12(%4),%%edx\n"
29706 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29707 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29708 " movl %%eax, 8(%3)\n"
29709 " movl %%edx, 12(%3)\n"
29710 - "4: movl 16(%4), %%eax\n"
29711 - "41: movl 20(%4), %%edx\n"
29712 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29713 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29714 " movl %%eax, 16(%3)\n"
29715 " movl %%edx, 20(%3)\n"
29716 - "10: movl 24(%4), %%eax\n"
29717 - "51: movl 28(%4), %%edx\n"
29718 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29719 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29720 " movl %%eax, 24(%3)\n"
29721 " movl %%edx, 28(%3)\n"
29722 - "11: movl 32(%4), %%eax\n"
29723 - "61: movl 36(%4), %%edx\n"
29724 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29725 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29726 " movl %%eax, 32(%3)\n"
29727 " movl %%edx, 36(%3)\n"
29728 - "12: movl 40(%4), %%eax\n"
29729 - "71: movl 44(%4), %%edx\n"
29730 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29731 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29732 " movl %%eax, 40(%3)\n"
29733 " movl %%edx, 44(%3)\n"
29734 - "13: movl 48(%4), %%eax\n"
29735 - "81: movl 52(%4), %%edx\n"
29736 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29737 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29738 " movl %%eax, 48(%3)\n"
29739 " movl %%edx, 52(%3)\n"
29740 - "14: movl 56(%4), %%eax\n"
29741 - "91: movl 60(%4), %%edx\n"
29742 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29743 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29744 " movl %%eax, 56(%3)\n"
29745 " movl %%edx, 60(%3)\n"
29746 " addl $-64, %0\n"
29747 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29748 " shrl $2, %0\n"
29749 " andl $3, %%eax\n"
29750 " cld\n"
29751 - "6: rep; movsl\n"
29752 + "6: rep; "__copyuser_seg" movsl\n"
29753 " movl %%eax,%0\n"
29754 - "7: rep; movsb\n"
29755 + "7: rep; "__copyuser_seg" movsb\n"
29756 "8:\n"
29757 ".section .fixup,\"ax\"\n"
29758 "9: lea 0(%%eax,%0,4),%0\n"
29759 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29760 * hyoshiok@miraclelinux.com
29761 */
29762
29763 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29764 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
29765 const void __user *from, unsigned long size)
29766 {
29767 int d0, d1;
29768
29769 __asm__ __volatile__(
29770 " .align 2,0x90\n"
29771 - "0: movl 32(%4), %%eax\n"
29772 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29773 " cmpl $67, %0\n"
29774 " jbe 2f\n"
29775 - "1: movl 64(%4), %%eax\n"
29776 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29777 " .align 2,0x90\n"
29778 - "2: movl 0(%4), %%eax\n"
29779 - "21: movl 4(%4), %%edx\n"
29780 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29781 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29782 " movnti %%eax, 0(%3)\n"
29783 " movnti %%edx, 4(%3)\n"
29784 - "3: movl 8(%4), %%eax\n"
29785 - "31: movl 12(%4),%%edx\n"
29786 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29787 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29788 " movnti %%eax, 8(%3)\n"
29789 " movnti %%edx, 12(%3)\n"
29790 - "4: movl 16(%4), %%eax\n"
29791 - "41: movl 20(%4), %%edx\n"
29792 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29793 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29794 " movnti %%eax, 16(%3)\n"
29795 " movnti %%edx, 20(%3)\n"
29796 - "10: movl 24(%4), %%eax\n"
29797 - "51: movl 28(%4), %%edx\n"
29798 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29799 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29800 " movnti %%eax, 24(%3)\n"
29801 " movnti %%edx, 28(%3)\n"
29802 - "11: movl 32(%4), %%eax\n"
29803 - "61: movl 36(%4), %%edx\n"
29804 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29805 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29806 " movnti %%eax, 32(%3)\n"
29807 " movnti %%edx, 36(%3)\n"
29808 - "12: movl 40(%4), %%eax\n"
29809 - "71: movl 44(%4), %%edx\n"
29810 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29811 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29812 " movnti %%eax, 40(%3)\n"
29813 " movnti %%edx, 44(%3)\n"
29814 - "13: movl 48(%4), %%eax\n"
29815 - "81: movl 52(%4), %%edx\n"
29816 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29817 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29818 " movnti %%eax, 48(%3)\n"
29819 " movnti %%edx, 52(%3)\n"
29820 - "14: movl 56(%4), %%eax\n"
29821 - "91: movl 60(%4), %%edx\n"
29822 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29823 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29824 " movnti %%eax, 56(%3)\n"
29825 " movnti %%edx, 60(%3)\n"
29826 " addl $-64, %0\n"
29827 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29828 " shrl $2, %0\n"
29829 " andl $3, %%eax\n"
29830 " cld\n"
29831 - "6: rep; movsl\n"
29832 + "6: rep; "__copyuser_seg" movsl\n"
29833 " movl %%eax,%0\n"
29834 - "7: rep; movsb\n"
29835 + "7: rep; "__copyuser_seg" movsb\n"
29836 "8:\n"
29837 ".section .fixup,\"ax\"\n"
29838 "9: lea 0(%%eax,%0,4),%0\n"
29839 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29840 return size;
29841 }
29842
29843 -static unsigned long __copy_user_intel_nocache(void *to,
29844 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
29845 const void __user *from, unsigned long size)
29846 {
29847 int d0, d1;
29848
29849 __asm__ __volatile__(
29850 " .align 2,0x90\n"
29851 - "0: movl 32(%4), %%eax\n"
29852 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29853 " cmpl $67, %0\n"
29854 " jbe 2f\n"
29855 - "1: movl 64(%4), %%eax\n"
29856 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29857 " .align 2,0x90\n"
29858 - "2: movl 0(%4), %%eax\n"
29859 - "21: movl 4(%4), %%edx\n"
29860 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29861 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29862 " movnti %%eax, 0(%3)\n"
29863 " movnti %%edx, 4(%3)\n"
29864 - "3: movl 8(%4), %%eax\n"
29865 - "31: movl 12(%4),%%edx\n"
29866 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29867 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29868 " movnti %%eax, 8(%3)\n"
29869 " movnti %%edx, 12(%3)\n"
29870 - "4: movl 16(%4), %%eax\n"
29871 - "41: movl 20(%4), %%edx\n"
29872 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29873 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29874 " movnti %%eax, 16(%3)\n"
29875 " movnti %%edx, 20(%3)\n"
29876 - "10: movl 24(%4), %%eax\n"
29877 - "51: movl 28(%4), %%edx\n"
29878 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29879 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29880 " movnti %%eax, 24(%3)\n"
29881 " movnti %%edx, 28(%3)\n"
29882 - "11: movl 32(%4), %%eax\n"
29883 - "61: movl 36(%4), %%edx\n"
29884 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29885 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29886 " movnti %%eax, 32(%3)\n"
29887 " movnti %%edx, 36(%3)\n"
29888 - "12: movl 40(%4), %%eax\n"
29889 - "71: movl 44(%4), %%edx\n"
29890 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29891 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29892 " movnti %%eax, 40(%3)\n"
29893 " movnti %%edx, 44(%3)\n"
29894 - "13: movl 48(%4), %%eax\n"
29895 - "81: movl 52(%4), %%edx\n"
29896 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29897 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29898 " movnti %%eax, 48(%3)\n"
29899 " movnti %%edx, 52(%3)\n"
29900 - "14: movl 56(%4), %%eax\n"
29901 - "91: movl 60(%4), %%edx\n"
29902 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29903 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29904 " movnti %%eax, 56(%3)\n"
29905 " movnti %%edx, 60(%3)\n"
29906 " addl $-64, %0\n"
29907 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
29908 " shrl $2, %0\n"
29909 " andl $3, %%eax\n"
29910 " cld\n"
29911 - "6: rep; movsl\n"
29912 + "6: rep; "__copyuser_seg" movsl\n"
29913 " movl %%eax,%0\n"
29914 - "7: rep; movsb\n"
29915 + "7: rep; "__copyuser_seg" movsb\n"
29916 "8:\n"
29917 ".section .fixup,\"ax\"\n"
29918 "9: lea 0(%%eax,%0,4),%0\n"
29919 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
29920 */
29921 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
29922 unsigned long size);
29923 -unsigned long __copy_user_intel(void __user *to, const void *from,
29924 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
29925 + unsigned long size);
29926 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
29927 unsigned long size);
29928 unsigned long __copy_user_zeroing_intel_nocache(void *to,
29929 const void __user *from, unsigned long size);
29930 #endif /* CONFIG_X86_INTEL_USERCOPY */
29931
29932 /* Generic arbitrary sized copy. */
29933 -#define __copy_user(to, from, size) \
29934 +#define __copy_user(to, from, size, prefix, set, restore) \
29935 do { \
29936 int __d0, __d1, __d2; \
29937 __asm__ __volatile__( \
29938 + set \
29939 " cmp $7,%0\n" \
29940 " jbe 1f\n" \
29941 " movl %1,%0\n" \
29942 " negl %0\n" \
29943 " andl $7,%0\n" \
29944 " subl %0,%3\n" \
29945 - "4: rep; movsb\n" \
29946 + "4: rep; "prefix"movsb\n" \
29947 " movl %3,%0\n" \
29948 " shrl $2,%0\n" \
29949 " andl $3,%3\n" \
29950 " .align 2,0x90\n" \
29951 - "0: rep; movsl\n" \
29952 + "0: rep; "prefix"movsl\n" \
29953 " movl %3,%0\n" \
29954 - "1: rep; movsb\n" \
29955 + "1: rep; "prefix"movsb\n" \
29956 "2:\n" \
29957 + restore \
29958 ".section .fixup,\"ax\"\n" \
29959 "5: addl %3,%0\n" \
29960 " jmp 2b\n" \
29961 @@ -538,14 +650,14 @@ do { \
29962 " negl %0\n" \
29963 " andl $7,%0\n" \
29964 " subl %0,%3\n" \
29965 - "4: rep; movsb\n" \
29966 + "4: rep; "__copyuser_seg"movsb\n" \
29967 " movl %3,%0\n" \
29968 " shrl $2,%0\n" \
29969 " andl $3,%3\n" \
29970 " .align 2,0x90\n" \
29971 - "0: rep; movsl\n" \
29972 + "0: rep; "__copyuser_seg"movsl\n" \
29973 " movl %3,%0\n" \
29974 - "1: rep; movsb\n" \
29975 + "1: rep; "__copyuser_seg"movsb\n" \
29976 "2:\n" \
29977 ".section .fixup,\"ax\"\n" \
29978 "5: addl %3,%0\n" \
29979 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
29980 {
29981 stac();
29982 if (movsl_is_ok(to, from, n))
29983 - __copy_user(to, from, n);
29984 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
29985 else
29986 - n = __copy_user_intel(to, from, n);
29987 + n = __generic_copy_to_user_intel(to, from, n);
29988 clac();
29989 return n;
29990 }
29991 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
29992 {
29993 stac();
29994 if (movsl_is_ok(to, from, n))
29995 - __copy_user(to, from, n);
29996 + __copy_user(to, from, n, __copyuser_seg, "", "");
29997 else
29998 - n = __copy_user_intel((void __user *)to,
29999 - (const void *)from, n);
30000 + n = __generic_copy_from_user_intel(to, from, n);
30001 clac();
30002 return n;
30003 }
30004 @@ -632,60 +743,38 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
30005 if (n > 64 && cpu_has_xmm2)
30006 n = __copy_user_intel_nocache(to, from, n);
30007 else
30008 - __copy_user(to, from, n);
30009 + __copy_user(to, from, n, __copyuser_seg, "", "");
30010 #else
30011 - __copy_user(to, from, n);
30012 + __copy_user(to, from, n, __copyuser_seg, "", "");
30013 #endif
30014 clac();
30015 return n;
30016 }
30017 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
30018
30019 -/**
30020 - * copy_to_user: - Copy a block of data into user space.
30021 - * @to: Destination address, in user space.
30022 - * @from: Source address, in kernel space.
30023 - * @n: Number of bytes to copy.
30024 - *
30025 - * Context: User context only. This function may sleep.
30026 - *
30027 - * Copy data from kernel space to user space.
30028 - *
30029 - * Returns number of bytes that could not be copied.
30030 - * On success, this will be zero.
30031 - */
30032 -unsigned long
30033 -copy_to_user(void __user *to, const void *from, unsigned long n)
30034 +#ifdef CONFIG_PAX_MEMORY_UDEREF
30035 +void __set_fs(mm_segment_t x)
30036 {
30037 - if (access_ok(VERIFY_WRITE, to, n))
30038 - n = __copy_to_user(to, from, n);
30039 - return n;
30040 + switch (x.seg) {
30041 + case 0:
30042 + loadsegment(gs, 0);
30043 + break;
30044 + case TASK_SIZE_MAX:
30045 + loadsegment(gs, __USER_DS);
30046 + break;
30047 + case -1UL:
30048 + loadsegment(gs, __KERNEL_DS);
30049 + break;
30050 + default:
30051 + BUG();
30052 + }
30053 }
30054 -EXPORT_SYMBOL(copy_to_user);
30055 +EXPORT_SYMBOL(__set_fs);
30056
30057 -/**
30058 - * copy_from_user: - Copy a block of data from user space.
30059 - * @to: Destination address, in kernel space.
30060 - * @from: Source address, in user space.
30061 - * @n: Number of bytes to copy.
30062 - *
30063 - * Context: User context only. This function may sleep.
30064 - *
30065 - * Copy data from user space to kernel space.
30066 - *
30067 - * Returns number of bytes that could not be copied.
30068 - * On success, this will be zero.
30069 - *
30070 - * If some data could not be copied, this function will pad the copied
30071 - * data to the requested size using zero bytes.
30072 - */
30073 -unsigned long
30074 -_copy_from_user(void *to, const void __user *from, unsigned long n)
30075 +void set_fs(mm_segment_t x)
30076 {
30077 - if (access_ok(VERIFY_READ, from, n))
30078 - n = __copy_from_user(to, from, n);
30079 - else
30080 - memset(to, 0, n);
30081 - return n;
30082 + current_thread_info()->addr_limit = x;
30083 + __set_fs(x);
30084 }
30085 -EXPORT_SYMBOL(_copy_from_user);
30086 +EXPORT_SYMBOL(set_fs);
30087 +#endif
30088 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
30089 index 906fea3..0194a18 100644
30090 --- a/arch/x86/lib/usercopy_64.c
30091 +++ b/arch/x86/lib/usercopy_64.c
30092 @@ -18,6 +18,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
30093 might_fault();
30094 /* no memory constraint because it doesn't change any memory gcc knows
30095 about */
30096 + pax_open_userland();
30097 stac();
30098 asm volatile(
30099 " testq %[size8],%[size8]\n"
30100 @@ -39,9 +40,10 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
30101 _ASM_EXTABLE(0b,3b)
30102 _ASM_EXTABLE(1b,2b)
30103 : [size8] "=&c"(size), [dst] "=&D" (__d0)
30104 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
30105 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
30106 [zero] "r" (0UL), [eight] "r" (8UL));
30107 clac();
30108 + pax_close_userland();
30109 return size;
30110 }
30111 EXPORT_SYMBOL(__clear_user);
30112 @@ -54,12 +56,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
30113 }
30114 EXPORT_SYMBOL(clear_user);
30115
30116 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
30117 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
30118 {
30119 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
30120 - return copy_user_generic((__force void *)to, (__force void *)from, len);
30121 - }
30122 - return len;
30123 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
30124 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
30125 + return len;
30126 }
30127 EXPORT_SYMBOL(copy_in_user);
30128
30129 @@ -69,11 +70,13 @@ EXPORT_SYMBOL(copy_in_user);
30130 * it is not necessary to optimize tail handling.
30131 */
30132 unsigned long
30133 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
30134 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
30135 {
30136 char c;
30137 unsigned zero_len;
30138
30139 + clac();
30140 + pax_close_userland();
30141 for (; len; --len, to++) {
30142 if (__get_user_nocheck(c, from++, sizeof(char)))
30143 break;
30144 @@ -84,6 +87,5 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
30145 for (c = 0, zero_len = len; zerorest && zero_len; --zero_len)
30146 if (__put_user_nocheck(c, to++, sizeof(char)))
30147 break;
30148 - clac();
30149 return len;
30150 }
30151 diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile
30152 index 23d8e5f..9ccc13a 100644
30153 --- a/arch/x86/mm/Makefile
30154 +++ b/arch/x86/mm/Makefile
30155 @@ -28,3 +28,7 @@ obj-$(CONFIG_ACPI_NUMA) += srat.o
30156 obj-$(CONFIG_NUMA_EMU) += numa_emulation.o
30157
30158 obj-$(CONFIG_MEMTEST) += memtest.o
30159 +
30160 +quote:="
30161 +obj-$(CONFIG_X86_64) += uderef_64.o
30162 +CFLAGS_uderef_64.o := $(subst $(quote),,$(CONFIG_ARCH_HWEIGHT_CFLAGS))
30163 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
30164 index 903ec1e..c4166b2 100644
30165 --- a/arch/x86/mm/extable.c
30166 +++ b/arch/x86/mm/extable.c
30167 @@ -6,12 +6,24 @@
30168 static inline unsigned long
30169 ex_insn_addr(const struct exception_table_entry *x)
30170 {
30171 - return (unsigned long)&x->insn + x->insn;
30172 + unsigned long reloc = 0;
30173 +
30174 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
30175 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
30176 +#endif
30177 +
30178 + return (unsigned long)&x->insn + x->insn + reloc;
30179 }
30180 static inline unsigned long
30181 ex_fixup_addr(const struct exception_table_entry *x)
30182 {
30183 - return (unsigned long)&x->fixup + x->fixup;
30184 + unsigned long reloc = 0;
30185 +
30186 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
30187 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
30188 +#endif
30189 +
30190 + return (unsigned long)&x->fixup + x->fixup + reloc;
30191 }
30192
30193 int fixup_exception(struct pt_regs *regs)
30194 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
30195 unsigned long new_ip;
30196
30197 #ifdef CONFIG_PNPBIOS
30198 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
30199 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
30200 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
30201 extern u32 pnp_bios_is_utter_crap;
30202 pnp_bios_is_utter_crap = 1;
30203 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
30204 i += 4;
30205 p->fixup -= i;
30206 i += 4;
30207 +
30208 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
30209 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
30210 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
30211 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
30212 +#endif
30213 +
30214 }
30215 }
30216
30217 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
30218 index 654be4a..a4a3da1 100644
30219 --- a/arch/x86/mm/fault.c
30220 +++ b/arch/x86/mm/fault.c
30221 @@ -14,11 +14,18 @@
30222 #include <linux/hugetlb.h> /* hstate_index_to_shift */
30223 #include <linux/prefetch.h> /* prefetchw */
30224 #include <linux/context_tracking.h> /* exception_enter(), ... */
30225 +#include <linux/unistd.h>
30226 +#include <linux/compiler.h>
30227
30228 #include <asm/traps.h> /* dotraplinkage, ... */
30229 #include <asm/pgalloc.h> /* pgd_*(), ... */
30230 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
30231 #include <asm/fixmap.h> /* VSYSCALL_START */
30232 +#include <asm/tlbflush.h>
30233 +
30234 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
30235 +#include <asm/stacktrace.h>
30236 +#endif
30237
30238 /*
30239 * Page fault error code bits:
30240 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
30241 int ret = 0;
30242
30243 /* kprobe_running() needs smp_processor_id() */
30244 - if (kprobes_built_in() && !user_mode_vm(regs)) {
30245 + if (kprobes_built_in() && !user_mode(regs)) {
30246 preempt_disable();
30247 if (kprobe_running() && kprobe_fault_handler(regs, 14))
30248 ret = 1;
30249 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
30250 return !instr_lo || (instr_lo>>1) == 1;
30251 case 0x00:
30252 /* Prefetch instruction is 0x0F0D or 0x0F18 */
30253 - if (probe_kernel_address(instr, opcode))
30254 + if (user_mode(regs)) {
30255 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
30256 + return 0;
30257 + } else if (probe_kernel_address(instr, opcode))
30258 return 0;
30259
30260 *prefetch = (instr_lo == 0xF) &&
30261 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
30262 while (instr < max_instr) {
30263 unsigned char opcode;
30264
30265 - if (probe_kernel_address(instr, opcode))
30266 + if (user_mode(regs)) {
30267 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
30268 + break;
30269 + } else if (probe_kernel_address(instr, opcode))
30270 break;
30271
30272 instr++;
30273 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
30274 force_sig_info(si_signo, &info, tsk);
30275 }
30276
30277 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30278 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
30279 +#endif
30280 +
30281 +#ifdef CONFIG_PAX_EMUTRAMP
30282 +static int pax_handle_fetch_fault(struct pt_regs *regs);
30283 +#endif
30284 +
30285 +#ifdef CONFIG_PAX_PAGEEXEC
30286 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
30287 +{
30288 + pgd_t *pgd;
30289 + pud_t *pud;
30290 + pmd_t *pmd;
30291 +
30292 + pgd = pgd_offset(mm, address);
30293 + if (!pgd_present(*pgd))
30294 + return NULL;
30295 + pud = pud_offset(pgd, address);
30296 + if (!pud_present(*pud))
30297 + return NULL;
30298 + pmd = pmd_offset(pud, address);
30299 + if (!pmd_present(*pmd))
30300 + return NULL;
30301 + return pmd;
30302 +}
30303 +#endif
30304 +
30305 DEFINE_SPINLOCK(pgd_lock);
30306 LIST_HEAD(pgd_list);
30307
30308 @@ -232,10 +273,27 @@ void vmalloc_sync_all(void)
30309 for (address = VMALLOC_START & PMD_MASK;
30310 address >= TASK_SIZE && address < FIXADDR_TOP;
30311 address += PMD_SIZE) {
30312 +
30313 +#ifdef CONFIG_PAX_PER_CPU_PGD
30314 + unsigned long cpu;
30315 +#else
30316 struct page *page;
30317 +#endif
30318
30319 spin_lock(&pgd_lock);
30320 +
30321 +#ifdef CONFIG_PAX_PER_CPU_PGD
30322 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
30323 + pgd_t *pgd = get_cpu_pgd(cpu, user);
30324 + pmd_t *ret;
30325 +
30326 + ret = vmalloc_sync_one(pgd, address);
30327 + if (!ret)
30328 + break;
30329 + pgd = get_cpu_pgd(cpu, kernel);
30330 +#else
30331 list_for_each_entry(page, &pgd_list, lru) {
30332 + pgd_t *pgd;
30333 spinlock_t *pgt_lock;
30334 pmd_t *ret;
30335
30336 @@ -243,8 +301,14 @@ void vmalloc_sync_all(void)
30337 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
30338
30339 spin_lock(pgt_lock);
30340 - ret = vmalloc_sync_one(page_address(page), address);
30341 + pgd = page_address(page);
30342 +#endif
30343 +
30344 + ret = vmalloc_sync_one(pgd, address);
30345 +
30346 +#ifndef CONFIG_PAX_PER_CPU_PGD
30347 spin_unlock(pgt_lock);
30348 +#endif
30349
30350 if (!ret)
30351 break;
30352 @@ -278,6 +342,12 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
30353 * an interrupt in the middle of a task switch..
30354 */
30355 pgd_paddr = read_cr3();
30356 +
30357 +#ifdef CONFIG_PAX_PER_CPU_PGD
30358 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (pgd_paddr & __PHYSICAL_MASK));
30359 + vmalloc_sync_one(__va(pgd_paddr + PAGE_SIZE), address);
30360 +#endif
30361 +
30362 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
30363 if (!pmd_k)
30364 return -1;
30365 @@ -373,11 +443,25 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
30366 * happen within a race in page table update. In the later
30367 * case just flush:
30368 */
30369 - pgd = pgd_offset(current->active_mm, address);
30370 +
30371 pgd_ref = pgd_offset_k(address);
30372 if (pgd_none(*pgd_ref))
30373 return -1;
30374
30375 +#ifdef CONFIG_PAX_PER_CPU_PGD
30376 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (read_cr3() & __PHYSICAL_MASK));
30377 + pgd = pgd_offset_cpu(smp_processor_id(), user, address);
30378 + if (pgd_none(*pgd)) {
30379 + set_pgd(pgd, *pgd_ref);
30380 + arch_flush_lazy_mmu_mode();
30381 + } else {
30382 + BUG_ON(pgd_page_vaddr(*pgd) != pgd_page_vaddr(*pgd_ref));
30383 + }
30384 + pgd = pgd_offset_cpu(smp_processor_id(), kernel, address);
30385 +#else
30386 + pgd = pgd_offset(current->active_mm, address);
30387 +#endif
30388 +
30389 if (pgd_none(*pgd)) {
30390 set_pgd(pgd, *pgd_ref);
30391 arch_flush_lazy_mmu_mode();
30392 @@ -543,7 +627,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
30393 static int is_errata100(struct pt_regs *regs, unsigned long address)
30394 {
30395 #ifdef CONFIG_X86_64
30396 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
30397 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
30398 return 1;
30399 #endif
30400 return 0;
30401 @@ -570,7 +654,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
30402 }
30403
30404 static const char nx_warning[] = KERN_CRIT
30405 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
30406 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
30407
30408 static void
30409 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30410 @@ -579,15 +663,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30411 if (!oops_may_print())
30412 return;
30413
30414 - if (error_code & PF_INSTR) {
30415 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
30416 unsigned int level;
30417
30418 pte_t *pte = lookup_address(address, &level);
30419
30420 if (pte && pte_present(*pte) && !pte_exec(*pte))
30421 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
30422 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
30423 }
30424
30425 +#ifdef CONFIG_PAX_KERNEXEC
30426 + if (init_mm.start_code <= address && address < init_mm.end_code) {
30427 + if (current->signal->curr_ip)
30428 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
30429 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
30430 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30431 + else
30432 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
30433 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30434 + }
30435 +#endif
30436 +
30437 printk(KERN_ALERT "BUG: unable to handle kernel ");
30438 if (address < PAGE_SIZE)
30439 printk(KERN_CONT "NULL pointer dereference");
30440 @@ -750,6 +846,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
30441 return;
30442 }
30443 #endif
30444 +
30445 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30446 + if (pax_is_fetch_fault(regs, error_code, address)) {
30447 +
30448 +#ifdef CONFIG_PAX_EMUTRAMP
30449 + switch (pax_handle_fetch_fault(regs)) {
30450 + case 2:
30451 + return;
30452 + }
30453 +#endif
30454 +
30455 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30456 + do_group_exit(SIGKILL);
30457 + }
30458 +#endif
30459 +
30460 /* Kernel addresses are always protection faults: */
30461 if (address >= TASK_SIZE)
30462 error_code |= PF_PROT;
30463 @@ -835,7 +947,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
30464 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
30465 printk(KERN_ERR
30466 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
30467 - tsk->comm, tsk->pid, address);
30468 + tsk->comm, task_pid_nr(tsk), address);
30469 code = BUS_MCEERR_AR;
30470 }
30471 #endif
30472 @@ -898,6 +1010,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
30473 return 1;
30474 }
30475
30476 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30477 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
30478 +{
30479 + pte_t *pte;
30480 + pmd_t *pmd;
30481 + spinlock_t *ptl;
30482 + unsigned char pte_mask;
30483 +
30484 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
30485 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
30486 + return 0;
30487 +
30488 + /* PaX: it's our fault, let's handle it if we can */
30489 +
30490 + /* PaX: take a look at read faults before acquiring any locks */
30491 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
30492 + /* instruction fetch attempt from a protected page in user mode */
30493 + up_read(&mm->mmap_sem);
30494 +
30495 +#ifdef CONFIG_PAX_EMUTRAMP
30496 + switch (pax_handle_fetch_fault(regs)) {
30497 + case 2:
30498 + return 1;
30499 + }
30500 +#endif
30501 +
30502 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30503 + do_group_exit(SIGKILL);
30504 + }
30505 +
30506 + pmd = pax_get_pmd(mm, address);
30507 + if (unlikely(!pmd))
30508 + return 0;
30509 +
30510 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
30511 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
30512 + pte_unmap_unlock(pte, ptl);
30513 + return 0;
30514 + }
30515 +
30516 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
30517 + /* write attempt to a protected page in user mode */
30518 + pte_unmap_unlock(pte, ptl);
30519 + return 0;
30520 + }
30521 +
30522 +#ifdef CONFIG_SMP
30523 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
30524 +#else
30525 + if (likely(address > get_limit(regs->cs)))
30526 +#endif
30527 + {
30528 + set_pte(pte, pte_mkread(*pte));
30529 + __flush_tlb_one(address);
30530 + pte_unmap_unlock(pte, ptl);
30531 + up_read(&mm->mmap_sem);
30532 + return 1;
30533 + }
30534 +
30535 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
30536 +
30537 + /*
30538 + * PaX: fill DTLB with user rights and retry
30539 + */
30540 + __asm__ __volatile__ (
30541 + "orb %2,(%1)\n"
30542 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
30543 +/*
30544 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
30545 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
30546 + * page fault when examined during a TLB load attempt. this is true not only
30547 + * for PTEs holding a non-present entry but also present entries that will
30548 + * raise a page fault (such as those set up by PaX, or the copy-on-write
30549 + * mechanism). in effect it means that we do *not* need to flush the TLBs
30550 + * for our target pages since their PTEs are simply not in the TLBs at all.
30551 +
30552 + * the best thing in omitting it is that we gain around 15-20% speed in the
30553 + * fast path of the page fault handler and can get rid of tracing since we
30554 + * can no longer flush unintended entries.
30555 + */
30556 + "invlpg (%0)\n"
30557 +#endif
30558 + __copyuser_seg"testb $0,(%0)\n"
30559 + "xorb %3,(%1)\n"
30560 + :
30561 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
30562 + : "memory", "cc");
30563 + pte_unmap_unlock(pte, ptl);
30564 + up_read(&mm->mmap_sem);
30565 + return 1;
30566 +}
30567 +#endif
30568 +
30569 /*
30570 * Handle a spurious fault caused by a stale TLB entry.
30571 *
30572 @@ -964,6 +1169,9 @@ int show_unhandled_signals = 1;
30573 static inline int
30574 access_error(unsigned long error_code, struct vm_area_struct *vma)
30575 {
30576 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
30577 + return 1;
30578 +
30579 if (error_code & PF_WRITE) {
30580 /* write, present and write, not present: */
30581 if (unlikely(!(vma->vm_flags & VM_WRITE)))
30582 @@ -992,7 +1200,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
30583 if (error_code & PF_USER)
30584 return false;
30585
30586 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
30587 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
30588 return false;
30589
30590 return true;
30591 @@ -1008,18 +1216,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30592 {
30593 struct vm_area_struct *vma;
30594 struct task_struct *tsk;
30595 - unsigned long address;
30596 struct mm_struct *mm;
30597 int fault;
30598 int write = error_code & PF_WRITE;
30599 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
30600 (write ? FAULT_FLAG_WRITE : 0);
30601
30602 - tsk = current;
30603 - mm = tsk->mm;
30604 -
30605 /* Get the faulting address: */
30606 - address = read_cr2();
30607 + unsigned long address = read_cr2();
30608 +
30609 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
30610 + if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
30611 + if (!search_exception_tables(regs->ip)) {
30612 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30613 + bad_area_nosemaphore(regs, error_code, address);
30614 + return;
30615 + }
30616 + if (address < pax_user_shadow_base) {
30617 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30618 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
30619 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
30620 + } else
30621 + address -= pax_user_shadow_base;
30622 + }
30623 +#endif
30624 +
30625 + tsk = current;
30626 + mm = tsk->mm;
30627
30628 /*
30629 * Detect and handle instructions that would cause a page fault for
30630 @@ -1080,7 +1303,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30631 * User-mode registers count as a user access even for any
30632 * potential system fault or CPU buglet:
30633 */
30634 - if (user_mode_vm(regs)) {
30635 + if (user_mode(regs)) {
30636 local_irq_enable();
30637 error_code |= PF_USER;
30638 } else {
30639 @@ -1142,6 +1365,11 @@ retry:
30640 might_sleep();
30641 }
30642
30643 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30644 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
30645 + return;
30646 +#endif
30647 +
30648 vma = find_vma(mm, address);
30649 if (unlikely(!vma)) {
30650 bad_area(regs, error_code, address);
30651 @@ -1153,18 +1381,24 @@ retry:
30652 bad_area(regs, error_code, address);
30653 return;
30654 }
30655 - if (error_code & PF_USER) {
30656 - /*
30657 - * Accessing the stack below %sp is always a bug.
30658 - * The large cushion allows instructions like enter
30659 - * and pusha to work. ("enter $65535, $31" pushes
30660 - * 32 pointers and then decrements %sp by 65535.)
30661 - */
30662 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
30663 - bad_area(regs, error_code, address);
30664 - return;
30665 - }
30666 + /*
30667 + * Accessing the stack below %sp is always a bug.
30668 + * The large cushion allows instructions like enter
30669 + * and pusha to work. ("enter $65535, $31" pushes
30670 + * 32 pointers and then decrements %sp by 65535.)
30671 + */
30672 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
30673 + bad_area(regs, error_code, address);
30674 + return;
30675 }
30676 +
30677 +#ifdef CONFIG_PAX_SEGMEXEC
30678 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
30679 + bad_area(regs, error_code, address);
30680 + return;
30681 + }
30682 +#endif
30683 +
30684 if (unlikely(expand_stack(vma, address))) {
30685 bad_area(regs, error_code, address);
30686 return;
30687 @@ -1230,3 +1464,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
30688 __do_page_fault(regs, error_code);
30689 exception_exit(prev_state);
30690 }
30691 +
30692 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30693 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
30694 +{
30695 + struct mm_struct *mm = current->mm;
30696 + unsigned long ip = regs->ip;
30697 +
30698 + if (v8086_mode(regs))
30699 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
30700 +
30701 +#ifdef CONFIG_PAX_PAGEEXEC
30702 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
30703 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
30704 + return true;
30705 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
30706 + return true;
30707 + return false;
30708 + }
30709 +#endif
30710 +
30711 +#ifdef CONFIG_PAX_SEGMEXEC
30712 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
30713 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
30714 + return true;
30715 + return false;
30716 + }
30717 +#endif
30718 +
30719 + return false;
30720 +}
30721 +#endif
30722 +
30723 +#ifdef CONFIG_PAX_EMUTRAMP
30724 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
30725 +{
30726 + int err;
30727 +
30728 + do { /* PaX: libffi trampoline emulation */
30729 + unsigned char mov, jmp;
30730 + unsigned int addr1, addr2;
30731 +
30732 +#ifdef CONFIG_X86_64
30733 + if ((regs->ip + 9) >> 32)
30734 + break;
30735 +#endif
30736 +
30737 + err = get_user(mov, (unsigned char __user *)regs->ip);
30738 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30739 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
30740 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30741 +
30742 + if (err)
30743 + break;
30744 +
30745 + if (mov == 0xB8 && jmp == 0xE9) {
30746 + regs->ax = addr1;
30747 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
30748 + return 2;
30749 + }
30750 + } while (0);
30751 +
30752 + do { /* PaX: gcc trampoline emulation #1 */
30753 + unsigned char mov1, mov2;
30754 + unsigned short jmp;
30755 + unsigned int addr1, addr2;
30756 +
30757 +#ifdef CONFIG_X86_64
30758 + if ((regs->ip + 11) >> 32)
30759 + break;
30760 +#endif
30761 +
30762 + err = get_user(mov1, (unsigned char __user *)regs->ip);
30763 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30764 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
30765 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30766 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
30767 +
30768 + if (err)
30769 + break;
30770 +
30771 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
30772 + regs->cx = addr1;
30773 + regs->ax = addr2;
30774 + regs->ip = addr2;
30775 + return 2;
30776 + }
30777 + } while (0);
30778 +
30779 + do { /* PaX: gcc trampoline emulation #2 */
30780 + unsigned char mov, jmp;
30781 + unsigned int addr1, addr2;
30782 +
30783 +#ifdef CONFIG_X86_64
30784 + if ((regs->ip + 9) >> 32)
30785 + break;
30786 +#endif
30787 +
30788 + err = get_user(mov, (unsigned char __user *)regs->ip);
30789 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30790 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
30791 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30792 +
30793 + if (err)
30794 + break;
30795 +
30796 + if (mov == 0xB9 && jmp == 0xE9) {
30797 + regs->cx = addr1;
30798 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
30799 + return 2;
30800 + }
30801 + } while (0);
30802 +
30803 + return 1; /* PaX in action */
30804 +}
30805 +
30806 +#ifdef CONFIG_X86_64
30807 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
30808 +{
30809 + int err;
30810 +
30811 + do { /* PaX: libffi trampoline emulation */
30812 + unsigned short mov1, mov2, jmp1;
30813 + unsigned char stcclc, jmp2;
30814 + unsigned long addr1, addr2;
30815 +
30816 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30817 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
30818 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
30819 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
30820 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
30821 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
30822 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
30823 +
30824 + if (err)
30825 + break;
30826 +
30827 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30828 + regs->r11 = addr1;
30829 + regs->r10 = addr2;
30830 + if (stcclc == 0xF8)
30831 + regs->flags &= ~X86_EFLAGS_CF;
30832 + else
30833 + regs->flags |= X86_EFLAGS_CF;
30834 + regs->ip = addr1;
30835 + return 2;
30836 + }
30837 + } while (0);
30838 +
30839 + do { /* PaX: gcc trampoline emulation #1 */
30840 + unsigned short mov1, mov2, jmp1;
30841 + unsigned char jmp2;
30842 + unsigned int addr1;
30843 + unsigned long addr2;
30844 +
30845 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30846 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
30847 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
30848 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
30849 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
30850 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
30851 +
30852 + if (err)
30853 + break;
30854 +
30855 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30856 + regs->r11 = addr1;
30857 + regs->r10 = addr2;
30858 + regs->ip = addr1;
30859 + return 2;
30860 + }
30861 + } while (0);
30862 +
30863 + do { /* PaX: gcc trampoline emulation #2 */
30864 + unsigned short mov1, mov2, jmp1;
30865 + unsigned char jmp2;
30866 + unsigned long addr1, addr2;
30867 +
30868 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30869 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
30870 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
30871 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
30872 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
30873 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
30874 +
30875 + if (err)
30876 + break;
30877 +
30878 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30879 + regs->r11 = addr1;
30880 + regs->r10 = addr2;
30881 + regs->ip = addr1;
30882 + return 2;
30883 + }
30884 + } while (0);
30885 +
30886 + return 1; /* PaX in action */
30887 +}
30888 +#endif
30889 +
30890 +/*
30891 + * PaX: decide what to do with offenders (regs->ip = fault address)
30892 + *
30893 + * returns 1 when task should be killed
30894 + * 2 when gcc trampoline was detected
30895 + */
30896 +static int pax_handle_fetch_fault(struct pt_regs *regs)
30897 +{
30898 + if (v8086_mode(regs))
30899 + return 1;
30900 +
30901 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
30902 + return 1;
30903 +
30904 +#ifdef CONFIG_X86_32
30905 + return pax_handle_fetch_fault_32(regs);
30906 +#else
30907 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
30908 + return pax_handle_fetch_fault_32(regs);
30909 + else
30910 + return pax_handle_fetch_fault_64(regs);
30911 +#endif
30912 +}
30913 +#endif
30914 +
30915 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30916 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
30917 +{
30918 + long i;
30919 +
30920 + printk(KERN_ERR "PAX: bytes at PC: ");
30921 + for (i = 0; i < 20; i++) {
30922 + unsigned char c;
30923 + if (get_user(c, (unsigned char __force_user *)pc+i))
30924 + printk(KERN_CONT "?? ");
30925 + else
30926 + printk(KERN_CONT "%02x ", c);
30927 + }
30928 + printk("\n");
30929 +
30930 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
30931 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
30932 + unsigned long c;
30933 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
30934 +#ifdef CONFIG_X86_32
30935 + printk(KERN_CONT "???????? ");
30936 +#else
30937 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
30938 + printk(KERN_CONT "???????? ???????? ");
30939 + else
30940 + printk(KERN_CONT "???????????????? ");
30941 +#endif
30942 + } else {
30943 +#ifdef CONFIG_X86_64
30944 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
30945 + printk(KERN_CONT "%08x ", (unsigned int)c);
30946 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
30947 + } else
30948 +#endif
30949 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
30950 + }
30951 + }
30952 + printk("\n");
30953 +}
30954 +#endif
30955 +
30956 +/**
30957 + * probe_kernel_write(): safely attempt to write to a location
30958 + * @dst: address to write to
30959 + * @src: pointer to the data that shall be written
30960 + * @size: size of the data chunk
30961 + *
30962 + * Safely write to address @dst from the buffer at @src. If a kernel fault
30963 + * happens, handle that and return -EFAULT.
30964 + */
30965 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
30966 +{
30967 + long ret;
30968 + mm_segment_t old_fs = get_fs();
30969 +
30970 + set_fs(KERNEL_DS);
30971 + pagefault_disable();
30972 + pax_open_kernel();
30973 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
30974 + pax_close_kernel();
30975 + pagefault_enable();
30976 + set_fs(old_fs);
30977 +
30978 + return ret ? -EFAULT : 0;
30979 +}
30980 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
30981 index dd74e46..7d26398 100644
30982 --- a/arch/x86/mm/gup.c
30983 +++ b/arch/x86/mm/gup.c
30984 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
30985 addr = start;
30986 len = (unsigned long) nr_pages << PAGE_SHIFT;
30987 end = start + len;
30988 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
30989 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
30990 (void __user *)start, len)))
30991 return 0;
30992
30993 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
30994 index 252b8f5..4dcfdc1 100644
30995 --- a/arch/x86/mm/highmem_32.c
30996 +++ b/arch/x86/mm/highmem_32.c
30997 @@ -44,7 +44,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
30998 idx = type + KM_TYPE_NR*smp_processor_id();
30999 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
31000 BUG_ON(!pte_none(*(kmap_pte-idx)));
31001 +
31002 + pax_open_kernel();
31003 set_pte(kmap_pte-idx, mk_pte(page, prot));
31004 + pax_close_kernel();
31005 +
31006 arch_flush_lazy_mmu_mode();
31007
31008 return (void *)vaddr;
31009 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
31010 index ae1aa71..d9bea75 100644
31011 --- a/arch/x86/mm/hugetlbpage.c
31012 +++ b/arch/x86/mm/hugetlbpage.c
31013 @@ -271,23 +271,30 @@ follow_huge_pud(struct mm_struct *mm, unsigned long address,
31014 #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
31015 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
31016 unsigned long addr, unsigned long len,
31017 - unsigned long pgoff, unsigned long flags)
31018 + unsigned long pgoff, unsigned long flags, unsigned long offset)
31019 {
31020 struct hstate *h = hstate_file(file);
31021 struct vm_unmapped_area_info info;
31022 -
31023 +
31024 info.flags = 0;
31025 info.length = len;
31026 info.low_limit = TASK_UNMAPPED_BASE;
31027 +
31028 +#ifdef CONFIG_PAX_RANDMMAP
31029 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
31030 + info.low_limit += current->mm->delta_mmap;
31031 +#endif
31032 +
31033 info.high_limit = TASK_SIZE;
31034 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
31035 info.align_offset = 0;
31036 + info.threadstack_offset = offset;
31037 return vm_unmapped_area(&info);
31038 }
31039
31040 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
31041 unsigned long addr0, unsigned long len,
31042 - unsigned long pgoff, unsigned long flags)
31043 + unsigned long pgoff, unsigned long flags, unsigned long offset)
31044 {
31045 struct hstate *h = hstate_file(file);
31046 struct vm_unmapped_area_info info;
31047 @@ -299,6 +306,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
31048 info.high_limit = current->mm->mmap_base;
31049 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
31050 info.align_offset = 0;
31051 + info.threadstack_offset = offset;
31052 addr = vm_unmapped_area(&info);
31053
31054 /*
31055 @@ -311,6 +319,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
31056 VM_BUG_ON(addr != -ENOMEM);
31057 info.flags = 0;
31058 info.low_limit = TASK_UNMAPPED_BASE;
31059 +
31060 +#ifdef CONFIG_PAX_RANDMMAP
31061 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
31062 + info.low_limit += current->mm->delta_mmap;
31063 +#endif
31064 +
31065 info.high_limit = TASK_SIZE;
31066 addr = vm_unmapped_area(&info);
31067 }
31068 @@ -325,10 +339,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
31069 struct hstate *h = hstate_file(file);
31070 struct mm_struct *mm = current->mm;
31071 struct vm_area_struct *vma;
31072 + unsigned long pax_task_size = TASK_SIZE;
31073 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
31074
31075 if (len & ~huge_page_mask(h))
31076 return -EINVAL;
31077 - if (len > TASK_SIZE)
31078 +
31079 +#ifdef CONFIG_PAX_SEGMEXEC
31080 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
31081 + pax_task_size = SEGMEXEC_TASK_SIZE;
31082 +#endif
31083 +
31084 + pax_task_size -= PAGE_SIZE;
31085 +
31086 + if (len > pax_task_size)
31087 return -ENOMEM;
31088
31089 if (flags & MAP_FIXED) {
31090 @@ -337,19 +361,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
31091 return addr;
31092 }
31093
31094 +#ifdef CONFIG_PAX_RANDMMAP
31095 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
31096 +#endif
31097 +
31098 if (addr) {
31099 addr = ALIGN(addr, huge_page_size(h));
31100 vma = find_vma(mm, addr);
31101 - if (TASK_SIZE - len >= addr &&
31102 - (!vma || addr + len <= vma->vm_start))
31103 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
31104 return addr;
31105 }
31106 if (mm->get_unmapped_area == arch_get_unmapped_area)
31107 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
31108 - pgoff, flags);
31109 + pgoff, flags, offset);
31110 else
31111 return hugetlb_get_unmapped_area_topdown(file, addr, len,
31112 - pgoff, flags);
31113 + pgoff, flags, offset);
31114 }
31115
31116 #endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
31117 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
31118 index 1f34e92..c97b98f 100644
31119 --- a/arch/x86/mm/init.c
31120 +++ b/arch/x86/mm/init.c
31121 @@ -4,6 +4,7 @@
31122 #include <linux/swap.h>
31123 #include <linux/memblock.h>
31124 #include <linux/bootmem.h> /* for max_low_pfn */
31125 +#include <linux/tboot.h>
31126
31127 #include <asm/cacheflush.h>
31128 #include <asm/e820.h>
31129 @@ -17,6 +18,8 @@
31130 #include <asm/proto.h>
31131 #include <asm/dma.h> /* for MAX_DMA_PFN */
31132 #include <asm/microcode.h>
31133 +#include <asm/desc.h>
31134 +#include <asm/bios_ebda.h>
31135
31136 #include "mm_internal.h"
31137
31138 @@ -465,7 +468,18 @@ void __init init_mem_mapping(void)
31139 early_ioremap_page_table_range_init();
31140 #endif
31141
31142 +#ifdef CONFIG_PAX_PER_CPU_PGD
31143 + clone_pgd_range(get_cpu_pgd(0, kernel) + KERNEL_PGD_BOUNDARY,
31144 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
31145 + KERNEL_PGD_PTRS);
31146 + clone_pgd_range(get_cpu_pgd(0, user) + KERNEL_PGD_BOUNDARY,
31147 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
31148 + KERNEL_PGD_PTRS);
31149 + load_cr3(get_cpu_pgd(0, kernel));
31150 +#else
31151 load_cr3(swapper_pg_dir);
31152 +#endif
31153 +
31154 __flush_tlb_all();
31155
31156 early_memtest(0, max_pfn_mapped << PAGE_SHIFT);
31157 @@ -481,10 +495,40 @@ void __init init_mem_mapping(void)
31158 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
31159 * mmio resources as well as potential bios/acpi data regions.
31160 */
31161 +
31162 +#ifdef CONFIG_GRKERNSEC_KMEM
31163 +static unsigned int ebda_start __read_only;
31164 +static unsigned int ebda_end __read_only;
31165 +#endif
31166 +
31167 int devmem_is_allowed(unsigned long pagenr)
31168 {
31169 - if (pagenr < 256)
31170 +#ifdef CONFIG_GRKERNSEC_KMEM
31171 + /* allow BDA */
31172 + if (!pagenr)
31173 return 1;
31174 + /* allow EBDA */
31175 + if (pagenr >= ebda_start && pagenr < ebda_end)
31176 + return 1;
31177 + /* if tboot is in use, allow access to its hardcoded serial log range */
31178 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
31179 + return 1;
31180 +#else
31181 + if (!pagenr)
31182 + return 1;
31183 +#ifdef CONFIG_VM86
31184 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
31185 + return 1;
31186 +#endif
31187 +#endif
31188 +
31189 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
31190 + return 1;
31191 +#ifdef CONFIG_GRKERNSEC_KMEM
31192 + /* throw out everything else below 1MB */
31193 + if (pagenr <= 256)
31194 + return 0;
31195 +#endif
31196 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
31197 return 0;
31198 if (!page_is_ram(pagenr))
31199 @@ -538,8 +582,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
31200 #endif
31201 }
31202
31203 +#ifdef CONFIG_GRKERNSEC_KMEM
31204 +static inline void gr_init_ebda(void)
31205 +{
31206 + unsigned int ebda_addr;
31207 + unsigned int ebda_size = 0;
31208 +
31209 + ebda_addr = get_bios_ebda();
31210 + if (ebda_addr) {
31211 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
31212 + ebda_size <<= 10;
31213 + }
31214 + if (ebda_addr && ebda_size) {
31215 + ebda_start = ebda_addr >> PAGE_SHIFT;
31216 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
31217 + } else {
31218 + ebda_start = 0x9f000 >> PAGE_SHIFT;
31219 + ebda_end = 0xa0000 >> PAGE_SHIFT;
31220 + }
31221 +}
31222 +#else
31223 +static inline void gr_init_ebda(void) { }
31224 +#endif
31225 +
31226 void free_initmem(void)
31227 {
31228 +#ifdef CONFIG_PAX_KERNEXEC
31229 +#ifdef CONFIG_X86_32
31230 + /* PaX: limit KERNEL_CS to actual size */
31231 + unsigned long addr, limit;
31232 + struct desc_struct d;
31233 + int cpu;
31234 +#else
31235 + pgd_t *pgd;
31236 + pud_t *pud;
31237 + pmd_t *pmd;
31238 + unsigned long addr, end;
31239 +#endif
31240 +#endif
31241 +
31242 + gr_init_ebda();
31243 +
31244 +#ifdef CONFIG_PAX_KERNEXEC
31245 +#ifdef CONFIG_X86_32
31246 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
31247 + limit = (limit - 1UL) >> PAGE_SHIFT;
31248 +
31249 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
31250 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
31251 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
31252 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
31253 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
31254 + }
31255 +
31256 + /* PaX: make KERNEL_CS read-only */
31257 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
31258 + if (!paravirt_enabled())
31259 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
31260 +/*
31261 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
31262 + pgd = pgd_offset_k(addr);
31263 + pud = pud_offset(pgd, addr);
31264 + pmd = pmd_offset(pud, addr);
31265 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
31266 + }
31267 +*/
31268 +#ifdef CONFIG_X86_PAE
31269 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
31270 +/*
31271 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
31272 + pgd = pgd_offset_k(addr);
31273 + pud = pud_offset(pgd, addr);
31274 + pmd = pmd_offset(pud, addr);
31275 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
31276 + }
31277 +*/
31278 +#endif
31279 +
31280 +#ifdef CONFIG_MODULES
31281 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
31282 +#endif
31283 +
31284 +#else
31285 + /* PaX: make kernel code/rodata read-only, rest non-executable */
31286 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
31287 + pgd = pgd_offset_k(addr);
31288 + pud = pud_offset(pgd, addr);
31289 + pmd = pmd_offset(pud, addr);
31290 + if (!pmd_present(*pmd))
31291 + continue;
31292 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
31293 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
31294 + else
31295 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
31296 + }
31297 +
31298 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
31299 + end = addr + KERNEL_IMAGE_SIZE;
31300 + for (; addr < end; addr += PMD_SIZE) {
31301 + pgd = pgd_offset_k(addr);
31302 + pud = pud_offset(pgd, addr);
31303 + pmd = pmd_offset(pud, addr);
31304 + if (!pmd_present(*pmd))
31305 + continue;
31306 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
31307 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
31308 + }
31309 +#endif
31310 +
31311 + flush_tlb_all();
31312 +#endif
31313 +
31314 free_init_pages("unused kernel memory",
31315 (unsigned long)(&__init_begin),
31316 (unsigned long)(&__init_end));
31317 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
31318 index 3ac7e31..89611b7 100644
31319 --- a/arch/x86/mm/init_32.c
31320 +++ b/arch/x86/mm/init_32.c
31321 @@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
31322 bool __read_mostly __vmalloc_start_set = false;
31323
31324 /*
31325 - * Creates a middle page table and puts a pointer to it in the
31326 - * given global directory entry. This only returns the gd entry
31327 - * in non-PAE compilation mode, since the middle layer is folded.
31328 - */
31329 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
31330 -{
31331 - pud_t *pud;
31332 - pmd_t *pmd_table;
31333 -
31334 -#ifdef CONFIG_X86_PAE
31335 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
31336 - pmd_table = (pmd_t *)alloc_low_page();
31337 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
31338 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
31339 - pud = pud_offset(pgd, 0);
31340 - BUG_ON(pmd_table != pmd_offset(pud, 0));
31341 -
31342 - return pmd_table;
31343 - }
31344 -#endif
31345 - pud = pud_offset(pgd, 0);
31346 - pmd_table = pmd_offset(pud, 0);
31347 -
31348 - return pmd_table;
31349 -}
31350 -
31351 -/*
31352 * Create a page table and place a pointer to it in a middle page
31353 * directory entry:
31354 */
31355 @@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
31356 pte_t *page_table = (pte_t *)alloc_low_page();
31357
31358 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
31359 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
31360 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
31361 +#else
31362 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
31363 +#endif
31364 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
31365 }
31366
31367 return pte_offset_kernel(pmd, 0);
31368 }
31369
31370 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
31371 +{
31372 + pud_t *pud;
31373 + pmd_t *pmd_table;
31374 +
31375 + pud = pud_offset(pgd, 0);
31376 + pmd_table = pmd_offset(pud, 0);
31377 +
31378 + return pmd_table;
31379 +}
31380 +
31381 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
31382 {
31383 int pgd_idx = pgd_index(vaddr);
31384 @@ -208,6 +196,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31385 int pgd_idx, pmd_idx;
31386 unsigned long vaddr;
31387 pgd_t *pgd;
31388 + pud_t *pud;
31389 pmd_t *pmd;
31390 pte_t *pte = NULL;
31391 unsigned long count = page_table_range_init_count(start, end);
31392 @@ -222,8 +211,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31393 pgd = pgd_base + pgd_idx;
31394
31395 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
31396 - pmd = one_md_table_init(pgd);
31397 - pmd = pmd + pmd_index(vaddr);
31398 + pud = pud_offset(pgd, vaddr);
31399 + pmd = pmd_offset(pud, vaddr);
31400 +
31401 +#ifdef CONFIG_X86_PAE
31402 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
31403 +#endif
31404 +
31405 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
31406 pmd++, pmd_idx++) {
31407 pte = page_table_kmap_check(one_page_table_init(pmd),
31408 @@ -235,11 +229,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31409 }
31410 }
31411
31412 -static inline int is_kernel_text(unsigned long addr)
31413 +static inline int is_kernel_text(unsigned long start, unsigned long end)
31414 {
31415 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
31416 - return 1;
31417 - return 0;
31418 + if ((start > ktla_ktva((unsigned long)_etext) ||
31419 + end <= ktla_ktva((unsigned long)_stext)) &&
31420 + (start > ktla_ktva((unsigned long)_einittext) ||
31421 + end <= ktla_ktva((unsigned long)_sinittext)) &&
31422 +
31423 +#ifdef CONFIG_ACPI_SLEEP
31424 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
31425 +#endif
31426 +
31427 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
31428 + return 0;
31429 + return 1;
31430 }
31431
31432 /*
31433 @@ -256,9 +259,10 @@ kernel_physical_mapping_init(unsigned long start,
31434 unsigned long last_map_addr = end;
31435 unsigned long start_pfn, end_pfn;
31436 pgd_t *pgd_base = swapper_pg_dir;
31437 - int pgd_idx, pmd_idx, pte_ofs;
31438 + unsigned int pgd_idx, pmd_idx, pte_ofs;
31439 unsigned long pfn;
31440 pgd_t *pgd;
31441 + pud_t *pud;
31442 pmd_t *pmd;
31443 pte_t *pte;
31444 unsigned pages_2m, pages_4k;
31445 @@ -291,8 +295,13 @@ repeat:
31446 pfn = start_pfn;
31447 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31448 pgd = pgd_base + pgd_idx;
31449 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
31450 - pmd = one_md_table_init(pgd);
31451 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
31452 + pud = pud_offset(pgd, 0);
31453 + pmd = pmd_offset(pud, 0);
31454 +
31455 +#ifdef CONFIG_X86_PAE
31456 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
31457 +#endif
31458
31459 if (pfn >= end_pfn)
31460 continue;
31461 @@ -304,14 +313,13 @@ repeat:
31462 #endif
31463 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
31464 pmd++, pmd_idx++) {
31465 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
31466 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
31467
31468 /*
31469 * Map with big pages if possible, otherwise
31470 * create normal page tables:
31471 */
31472 if (use_pse) {
31473 - unsigned int addr2;
31474 pgprot_t prot = PAGE_KERNEL_LARGE;
31475 /*
31476 * first pass will use the same initial
31477 @@ -322,11 +330,7 @@ repeat:
31478 _PAGE_PSE);
31479
31480 pfn &= PMD_MASK >> PAGE_SHIFT;
31481 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
31482 - PAGE_OFFSET + PAGE_SIZE-1;
31483 -
31484 - if (is_kernel_text(addr) ||
31485 - is_kernel_text(addr2))
31486 + if (is_kernel_text(address, address + PMD_SIZE))
31487 prot = PAGE_KERNEL_LARGE_EXEC;
31488
31489 pages_2m++;
31490 @@ -343,7 +347,7 @@ repeat:
31491 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31492 pte += pte_ofs;
31493 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
31494 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
31495 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
31496 pgprot_t prot = PAGE_KERNEL;
31497 /*
31498 * first pass will use the same initial
31499 @@ -351,7 +355,7 @@ repeat:
31500 */
31501 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
31502
31503 - if (is_kernel_text(addr))
31504 + if (is_kernel_text(address, address + PAGE_SIZE))
31505 prot = PAGE_KERNEL_EXEC;
31506
31507 pages_4k++;
31508 @@ -474,7 +478,7 @@ void __init native_pagetable_init(void)
31509
31510 pud = pud_offset(pgd, va);
31511 pmd = pmd_offset(pud, va);
31512 - if (!pmd_present(*pmd))
31513 + if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
31514 break;
31515
31516 /* should not be large page here */
31517 @@ -532,12 +536,10 @@ void __init early_ioremap_page_table_range_init(void)
31518
31519 static void __init pagetable_init(void)
31520 {
31521 - pgd_t *pgd_base = swapper_pg_dir;
31522 -
31523 - permanent_kmaps_init(pgd_base);
31524 + permanent_kmaps_init(swapper_pg_dir);
31525 }
31526
31527 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31528 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31529 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31530
31531 /* user-defined highmem size */
31532 @@ -772,7 +774,7 @@ void __init mem_init(void)
31533 after_bootmem = 1;
31534
31535 codesize = (unsigned long) &_etext - (unsigned long) &_text;
31536 - datasize = (unsigned long) &_edata - (unsigned long) &_etext;
31537 + datasize = (unsigned long) &_edata - (unsigned long) &_sdata;
31538 initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
31539
31540 printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
31541 @@ -813,10 +815,10 @@ void __init mem_init(void)
31542 ((unsigned long)&__init_end -
31543 (unsigned long)&__init_begin) >> 10,
31544
31545 - (unsigned long)&_etext, (unsigned long)&_edata,
31546 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
31547 + (unsigned long)&_sdata, (unsigned long)&_edata,
31548 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
31549
31550 - (unsigned long)&_text, (unsigned long)&_etext,
31551 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
31552 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
31553
31554 /*
31555 @@ -906,6 +908,7 @@ void set_kernel_text_rw(void)
31556 if (!kernel_set_to_readonly)
31557 return;
31558
31559 + start = ktla_ktva(start);
31560 pr_debug("Set kernel text: %lx - %lx for read write\n",
31561 start, start+size);
31562
31563 @@ -920,6 +923,7 @@ void set_kernel_text_ro(void)
31564 if (!kernel_set_to_readonly)
31565 return;
31566
31567 + start = ktla_ktva(start);
31568 pr_debug("Set kernel text: %lx - %lx for read only\n",
31569 start, start+size);
31570
31571 @@ -948,6 +952,7 @@ void mark_rodata_ro(void)
31572 unsigned long start = PFN_ALIGN(_text);
31573 unsigned long size = PFN_ALIGN(_etext) - start;
31574
31575 + start = ktla_ktva(start);
31576 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
31577 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
31578 size >> 10);
31579 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
31580 index bb00c46..bf91a67 100644
31581 --- a/arch/x86/mm/init_64.c
31582 +++ b/arch/x86/mm/init_64.c
31583 @@ -151,7 +151,7 @@ early_param("gbpages", parse_direct_gbpages_on);
31584 * around without checking the pgd every time.
31585 */
31586
31587 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
31588 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
31589 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31590
31591 int force_personality32;
31592 @@ -184,12 +184,29 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31593
31594 for (address = start; address <= end; address += PGDIR_SIZE) {
31595 const pgd_t *pgd_ref = pgd_offset_k(address);
31596 +
31597 +#ifdef CONFIG_PAX_PER_CPU_PGD
31598 + unsigned long cpu;
31599 +#else
31600 struct page *page;
31601 +#endif
31602
31603 if (pgd_none(*pgd_ref))
31604 continue;
31605
31606 spin_lock(&pgd_lock);
31607 +
31608 +#ifdef CONFIG_PAX_PER_CPU_PGD
31609 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
31610 + pgd_t *pgd = pgd_offset_cpu(cpu, user, address);
31611 +
31612 + if (pgd_none(*pgd))
31613 + set_pgd(pgd, *pgd_ref);
31614 + else
31615 + BUG_ON(pgd_page_vaddr(*pgd)
31616 + != pgd_page_vaddr(*pgd_ref));
31617 + pgd = pgd_offset_cpu(cpu, kernel, address);
31618 +#else
31619 list_for_each_entry(page, &pgd_list, lru) {
31620 pgd_t *pgd;
31621 spinlock_t *pgt_lock;
31622 @@ -198,6 +215,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31623 /* the pgt_lock only for Xen */
31624 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
31625 spin_lock(pgt_lock);
31626 +#endif
31627
31628 if (pgd_none(*pgd))
31629 set_pgd(pgd, *pgd_ref);
31630 @@ -205,7 +223,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31631 BUG_ON(pgd_page_vaddr(*pgd)
31632 != pgd_page_vaddr(*pgd_ref));
31633
31634 +#ifndef CONFIG_PAX_PER_CPU_PGD
31635 spin_unlock(pgt_lock);
31636 +#endif
31637 +
31638 }
31639 spin_unlock(&pgd_lock);
31640 }
31641 @@ -238,7 +259,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
31642 {
31643 if (pgd_none(*pgd)) {
31644 pud_t *pud = (pud_t *)spp_getpage();
31645 - pgd_populate(&init_mm, pgd, pud);
31646 + pgd_populate_kernel(&init_mm, pgd, pud);
31647 if (pud != pud_offset(pgd, 0))
31648 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
31649 pud, pud_offset(pgd, 0));
31650 @@ -250,7 +271,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
31651 {
31652 if (pud_none(*pud)) {
31653 pmd_t *pmd = (pmd_t *) spp_getpage();
31654 - pud_populate(&init_mm, pud, pmd);
31655 + pud_populate_kernel(&init_mm, pud, pmd);
31656 if (pmd != pmd_offset(pud, 0))
31657 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
31658 pmd, pmd_offset(pud, 0));
31659 @@ -279,7 +300,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
31660 pmd = fill_pmd(pud, vaddr);
31661 pte = fill_pte(pmd, vaddr);
31662
31663 + pax_open_kernel();
31664 set_pte(pte, new_pte);
31665 + pax_close_kernel();
31666
31667 /*
31668 * It's enough to flush this one mapping.
31669 @@ -338,14 +361,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
31670 pgd = pgd_offset_k((unsigned long)__va(phys));
31671 if (pgd_none(*pgd)) {
31672 pud = (pud_t *) spp_getpage();
31673 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
31674 - _PAGE_USER));
31675 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
31676 }
31677 pud = pud_offset(pgd, (unsigned long)__va(phys));
31678 if (pud_none(*pud)) {
31679 pmd = (pmd_t *) spp_getpage();
31680 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
31681 - _PAGE_USER));
31682 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
31683 }
31684 pmd = pmd_offset(pud, phys);
31685 BUG_ON(!pmd_none(*pmd));
31686 @@ -586,7 +607,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
31687 prot);
31688
31689 spin_lock(&init_mm.page_table_lock);
31690 - pud_populate(&init_mm, pud, pmd);
31691 + pud_populate_kernel(&init_mm, pud, pmd);
31692 spin_unlock(&init_mm.page_table_lock);
31693 }
31694 __flush_tlb_all();
31695 @@ -627,7 +648,7 @@ kernel_physical_mapping_init(unsigned long start,
31696 page_size_mask);
31697
31698 spin_lock(&init_mm.page_table_lock);
31699 - pgd_populate(&init_mm, pgd, pud);
31700 + pgd_populate_kernel(&init_mm, pgd, pud);
31701 spin_unlock(&init_mm.page_table_lock);
31702 pgd_changed = true;
31703 }
31704 @@ -1221,8 +1242,8 @@ int kern_addr_valid(unsigned long addr)
31705 static struct vm_area_struct gate_vma = {
31706 .vm_start = VSYSCALL_START,
31707 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
31708 - .vm_page_prot = PAGE_READONLY_EXEC,
31709 - .vm_flags = VM_READ | VM_EXEC
31710 + .vm_page_prot = PAGE_READONLY,
31711 + .vm_flags = VM_READ
31712 };
31713
31714 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31715 @@ -1256,7 +1277,7 @@ int in_gate_area_no_mm(unsigned long addr)
31716
31717 const char *arch_vma_name(struct vm_area_struct *vma)
31718 {
31719 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31720 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31721 return "[vdso]";
31722 if (vma == &gate_vma)
31723 return "[vsyscall]";
31724 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
31725 index 7b179b4..6bd17777 100644
31726 --- a/arch/x86/mm/iomap_32.c
31727 +++ b/arch/x86/mm/iomap_32.c
31728 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
31729 type = kmap_atomic_idx_push();
31730 idx = type + KM_TYPE_NR * smp_processor_id();
31731 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
31732 +
31733 + pax_open_kernel();
31734 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
31735 + pax_close_kernel();
31736 +
31737 arch_flush_lazy_mmu_mode();
31738
31739 return (void *)vaddr;
31740 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
31741 index 9a1e658..da003f3 100644
31742 --- a/arch/x86/mm/ioremap.c
31743 +++ b/arch/x86/mm/ioremap.c
31744 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
31745 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
31746 int is_ram = page_is_ram(pfn);
31747
31748 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
31749 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
31750 return NULL;
31751 WARN_ON_ONCE(is_ram);
31752 }
31753 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
31754 *
31755 * Caller must ensure there is only one unmapping for the same pointer.
31756 */
31757 -void iounmap(volatile void __iomem *addr)
31758 +void iounmap(const volatile void __iomem *addr)
31759 {
31760 struct vm_struct *p, *o;
31761
31762 @@ -310,6 +310,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
31763
31764 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
31765 if (page_is_ram(start >> PAGE_SHIFT))
31766 +#ifdef CONFIG_HIGHMEM
31767 + if ((start >> PAGE_SHIFT) < max_low_pfn)
31768 +#endif
31769 return __va(phys);
31770
31771 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
31772 @@ -322,6 +325,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
31773 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
31774 {
31775 if (page_is_ram(phys >> PAGE_SHIFT))
31776 +#ifdef CONFIG_HIGHMEM
31777 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
31778 +#endif
31779 return;
31780
31781 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
31782 @@ -339,7 +345,7 @@ static int __init early_ioremap_debug_setup(char *str)
31783 early_param("early_ioremap_debug", early_ioremap_debug_setup);
31784
31785 static __initdata int after_paging_init;
31786 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
31787 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
31788
31789 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
31790 {
31791 @@ -376,8 +382,7 @@ void __init early_ioremap_init(void)
31792 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
31793
31794 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
31795 - memset(bm_pte, 0, sizeof(bm_pte));
31796 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
31797 + pmd_populate_user(&init_mm, pmd, bm_pte);
31798
31799 /*
31800 * The boot-ioremap range spans multiple pmds, for which
31801 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
31802 index d87dd6d..bf3fa66 100644
31803 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
31804 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
31805 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
31806 * memory (e.g. tracked pages)? For now, we need this to avoid
31807 * invoking kmemcheck for PnP BIOS calls.
31808 */
31809 - if (regs->flags & X86_VM_MASK)
31810 + if (v8086_mode(regs))
31811 return false;
31812 - if (regs->cs != __KERNEL_CS)
31813 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
31814 return false;
31815
31816 pte = kmemcheck_pte_lookup(address);
31817 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
31818 index 5c1ae28..45f4ac9 100644
31819 --- a/arch/x86/mm/mmap.c
31820 +++ b/arch/x86/mm/mmap.c
31821 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
31822 * Leave an at least ~128 MB hole with possible stack randomization.
31823 */
31824 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
31825 -#define MAX_GAP (TASK_SIZE/6*5)
31826 +#define MAX_GAP (pax_task_size/6*5)
31827
31828 static int mmap_is_legacy(void)
31829 {
31830 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
31831 return rnd << PAGE_SHIFT;
31832 }
31833
31834 -static unsigned long mmap_base(void)
31835 +static unsigned long mmap_base(struct mm_struct *mm)
31836 {
31837 unsigned long gap = rlimit(RLIMIT_STACK);
31838 + unsigned long pax_task_size = TASK_SIZE;
31839 +
31840 +#ifdef CONFIG_PAX_SEGMEXEC
31841 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
31842 + pax_task_size = SEGMEXEC_TASK_SIZE;
31843 +#endif
31844
31845 if (gap < MIN_GAP)
31846 gap = MIN_GAP;
31847 else if (gap > MAX_GAP)
31848 gap = MAX_GAP;
31849
31850 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
31851 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
31852 }
31853
31854 /*
31855 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
31856 * does, but not when emulating X86_32
31857 */
31858 -static unsigned long mmap_legacy_base(void)
31859 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
31860 {
31861 - if (mmap_is_ia32())
31862 + if (mmap_is_ia32()) {
31863 +
31864 +#ifdef CONFIG_PAX_SEGMEXEC
31865 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
31866 + return SEGMEXEC_TASK_UNMAPPED_BASE;
31867 + else
31868 +#endif
31869 +
31870 return TASK_UNMAPPED_BASE;
31871 - else
31872 + } else
31873 return TASK_UNMAPPED_BASE + mmap_rnd();
31874 }
31875
31876 @@ -112,8 +125,15 @@ static unsigned long mmap_legacy_base(void)
31877 */
31878 void arch_pick_mmap_layout(struct mm_struct *mm)
31879 {
31880 - mm->mmap_legacy_base = mmap_legacy_base();
31881 - mm->mmap_base = mmap_base();
31882 + mm->mmap_legacy_base = mmap_legacy_base(mm);
31883 + mm->mmap_base = mmap_base(mm);
31884 +
31885 +#ifdef CONFIG_PAX_RANDMMAP
31886 + if (mm->pax_flags & MF_PAX_RANDMMAP) {
31887 + mm->mmap_legacy_base += mm->delta_mmap;
31888 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
31889 + }
31890 +#endif
31891
31892 if (mmap_is_legacy()) {
31893 mm->mmap_base = mm->mmap_legacy_base;
31894 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
31895 index dc0b727..f612039 100644
31896 --- a/arch/x86/mm/mmio-mod.c
31897 +++ b/arch/x86/mm/mmio-mod.c
31898 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
31899 break;
31900 default:
31901 {
31902 - unsigned char *ip = (unsigned char *)instptr;
31903 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
31904 my_trace->opcode = MMIO_UNKNOWN_OP;
31905 my_trace->width = 0;
31906 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
31907 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
31908 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
31909 void __iomem *addr)
31910 {
31911 - static atomic_t next_id;
31912 + static atomic_unchecked_t next_id;
31913 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
31914 /* These are page-unaligned. */
31915 struct mmiotrace_map map = {
31916 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
31917 .private = trace
31918 },
31919 .phys = offset,
31920 - .id = atomic_inc_return(&next_id)
31921 + .id = atomic_inc_return_unchecked(&next_id)
31922 };
31923 map.map_id = trace->id;
31924
31925 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
31926 ioremap_trace_core(offset, size, addr);
31927 }
31928
31929 -static void iounmap_trace_core(volatile void __iomem *addr)
31930 +static void iounmap_trace_core(const volatile void __iomem *addr)
31931 {
31932 struct mmiotrace_map map = {
31933 .phys = 0,
31934 @@ -328,7 +328,7 @@ not_enabled:
31935 }
31936 }
31937
31938 -void mmiotrace_iounmap(volatile void __iomem *addr)
31939 +void mmiotrace_iounmap(const volatile void __iomem *addr)
31940 {
31941 might_sleep();
31942 if (is_enabled()) /* recheck and proper locking in *_core() */
31943 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
31944 index a71c4e2..301ae44 100644
31945 --- a/arch/x86/mm/numa.c
31946 +++ b/arch/x86/mm/numa.c
31947 @@ -474,7 +474,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
31948 return true;
31949 }
31950
31951 -static int __init numa_register_memblks(struct numa_meminfo *mi)
31952 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
31953 {
31954 unsigned long uninitialized_var(pfn_align);
31955 int i, nid;
31956 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
31957 index d0b1773..4c3327c 100644
31958 --- a/arch/x86/mm/pageattr-test.c
31959 +++ b/arch/x86/mm/pageattr-test.c
31960 @@ -36,7 +36,7 @@ enum {
31961
31962 static int pte_testbit(pte_t pte)
31963 {
31964 - return pte_flags(pte) & _PAGE_UNUSED1;
31965 + return pte_flags(pte) & _PAGE_CPA_TEST;
31966 }
31967
31968 struct split_state {
31969 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
31970 index bb32480..75f2f5e 100644
31971 --- a/arch/x86/mm/pageattr.c
31972 +++ b/arch/x86/mm/pageattr.c
31973 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31974 */
31975 #ifdef CONFIG_PCI_BIOS
31976 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
31977 - pgprot_val(forbidden) |= _PAGE_NX;
31978 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31979 #endif
31980
31981 /*
31982 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31983 * Does not cover __inittext since that is gone later on. On
31984 * 64bit we do not enforce !NX on the low mapping
31985 */
31986 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
31987 - pgprot_val(forbidden) |= _PAGE_NX;
31988 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
31989 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31990
31991 +#ifdef CONFIG_DEBUG_RODATA
31992 /*
31993 * The .rodata section needs to be read-only. Using the pfn
31994 * catches all aliases.
31995 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31996 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
31997 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
31998 pgprot_val(forbidden) |= _PAGE_RW;
31999 +#endif
32000
32001 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
32002 /*
32003 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
32004 }
32005 #endif
32006
32007 +#ifdef CONFIG_PAX_KERNEXEC
32008 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
32009 + pgprot_val(forbidden) |= _PAGE_RW;
32010 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
32011 + }
32012 +#endif
32013 +
32014 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
32015
32016 return prot;
32017 @@ -400,23 +409,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
32018 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
32019 {
32020 /* change init_mm */
32021 + pax_open_kernel();
32022 set_pte_atomic(kpte, pte);
32023 +
32024 #ifdef CONFIG_X86_32
32025 if (!SHARED_KERNEL_PMD) {
32026 +
32027 +#ifdef CONFIG_PAX_PER_CPU_PGD
32028 + unsigned long cpu;
32029 +#else
32030 struct page *page;
32031 +#endif
32032
32033 +#ifdef CONFIG_PAX_PER_CPU_PGD
32034 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
32035 + pgd_t *pgd = get_cpu_pgd(cpu, kernel);
32036 +#else
32037 list_for_each_entry(page, &pgd_list, lru) {
32038 - pgd_t *pgd;
32039 + pgd_t *pgd = (pgd_t *)page_address(page);
32040 +#endif
32041 +
32042 pud_t *pud;
32043 pmd_t *pmd;
32044
32045 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
32046 + pgd += pgd_index(address);
32047 pud = pud_offset(pgd, address);
32048 pmd = pmd_offset(pud, address);
32049 set_pte_atomic((pte_t *)pmd, pte);
32050 }
32051 }
32052 #endif
32053 + pax_close_kernel();
32054 }
32055
32056 static int
32057 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
32058 index 6574388..87e9bef 100644
32059 --- a/arch/x86/mm/pat.c
32060 +++ b/arch/x86/mm/pat.c
32061 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
32062
32063 if (!entry) {
32064 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
32065 - current->comm, current->pid, start, end - 1);
32066 + current->comm, task_pid_nr(current), start, end - 1);
32067 return -EINVAL;
32068 }
32069
32070 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
32071
32072 while (cursor < to) {
32073 if (!devmem_is_allowed(pfn)) {
32074 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
32075 - current->comm, from, to - 1);
32076 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
32077 + current->comm, from, to - 1, cursor);
32078 return 0;
32079 }
32080 cursor += PAGE_SIZE;
32081 @@ -577,7 +577,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
32082 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
32083 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
32084 "for [mem %#010Lx-%#010Lx]\n",
32085 - current->comm, current->pid,
32086 + current->comm, task_pid_nr(current),
32087 cattr_name(flags),
32088 base, (unsigned long long)(base + size-1));
32089 return -EINVAL;
32090 @@ -612,7 +612,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
32091 flags = lookup_memtype(paddr);
32092 if (want_flags != flags) {
32093 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
32094 - current->comm, current->pid,
32095 + current->comm, task_pid_nr(current),
32096 cattr_name(want_flags),
32097 (unsigned long long)paddr,
32098 (unsigned long long)(paddr + size - 1),
32099 @@ -634,7 +634,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
32100 free_memtype(paddr, paddr + size);
32101 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
32102 " for [mem %#010Lx-%#010Lx], got %s\n",
32103 - current->comm, current->pid,
32104 + current->comm, task_pid_nr(current),
32105 cattr_name(want_flags),
32106 (unsigned long long)paddr,
32107 (unsigned long long)(paddr + size - 1),
32108 diff --git a/arch/x86/mm/pat_rbtree.c b/arch/x86/mm/pat_rbtree.c
32109 index 415f6c4..d319983 100644
32110 --- a/arch/x86/mm/pat_rbtree.c
32111 +++ b/arch/x86/mm/pat_rbtree.c
32112 @@ -160,7 +160,7 @@ success:
32113
32114 failure:
32115 printk(KERN_INFO "%s:%d conflicting memory types "
32116 - "%Lx-%Lx %s<->%s\n", current->comm, current->pid, start,
32117 + "%Lx-%Lx %s<->%s\n", current->comm, task_pid_nr(current), start,
32118 end, cattr_name(found_type), cattr_name(match->type));
32119 return -EBUSY;
32120 }
32121 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
32122 index 9f0614d..92ae64a 100644
32123 --- a/arch/x86/mm/pf_in.c
32124 +++ b/arch/x86/mm/pf_in.c
32125 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
32126 int i;
32127 enum reason_type rv = OTHERS;
32128
32129 - p = (unsigned char *)ins_addr;
32130 + p = (unsigned char *)ktla_ktva(ins_addr);
32131 p += skip_prefix(p, &prf);
32132 p += get_opcode(p, &opcode);
32133
32134 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
32135 struct prefix_bits prf;
32136 int i;
32137
32138 - p = (unsigned char *)ins_addr;
32139 + p = (unsigned char *)ktla_ktva(ins_addr);
32140 p += skip_prefix(p, &prf);
32141 p += get_opcode(p, &opcode);
32142
32143 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
32144 struct prefix_bits prf;
32145 int i;
32146
32147 - p = (unsigned char *)ins_addr;
32148 + p = (unsigned char *)ktla_ktva(ins_addr);
32149 p += skip_prefix(p, &prf);
32150 p += get_opcode(p, &opcode);
32151
32152 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
32153 struct prefix_bits prf;
32154 int i;
32155
32156 - p = (unsigned char *)ins_addr;
32157 + p = (unsigned char *)ktla_ktva(ins_addr);
32158 p += skip_prefix(p, &prf);
32159 p += get_opcode(p, &opcode);
32160 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
32161 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
32162 struct prefix_bits prf;
32163 int i;
32164
32165 - p = (unsigned char *)ins_addr;
32166 + p = (unsigned char *)ktla_ktva(ins_addr);
32167 p += skip_prefix(p, &prf);
32168 p += get_opcode(p, &opcode);
32169 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
32170 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
32171 index 17fda6a..f7d54a0 100644
32172 --- a/arch/x86/mm/pgtable.c
32173 +++ b/arch/x86/mm/pgtable.c
32174 @@ -91,10 +91,67 @@ static inline void pgd_list_del(pgd_t *pgd)
32175 list_del(&page->lru);
32176 }
32177
32178 -#define UNSHARED_PTRS_PER_PGD \
32179 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
32180 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
32181 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
32182
32183 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
32184 +{
32185 + unsigned int count = USER_PGD_PTRS;
32186
32187 + if (!pax_user_shadow_base)
32188 + return;
32189 +
32190 + while (count--)
32191 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
32192 +}
32193 +#endif
32194 +
32195 +#ifdef CONFIG_PAX_PER_CPU_PGD
32196 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
32197 +{
32198 + unsigned int count = USER_PGD_PTRS;
32199 +
32200 + while (count--) {
32201 + pgd_t pgd;
32202 +
32203 +#ifdef CONFIG_X86_64
32204 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
32205 +#else
32206 + pgd = *src++;
32207 +#endif
32208 +
32209 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
32210 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
32211 +#endif
32212 +
32213 + *dst++ = pgd;
32214 + }
32215 +
32216 +}
32217 +#endif
32218 +
32219 +#ifdef CONFIG_X86_64
32220 +#define pxd_t pud_t
32221 +#define pyd_t pgd_t
32222 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
32223 +#define pxd_free(mm, pud) pud_free((mm), (pud))
32224 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
32225 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
32226 +#define PYD_SIZE PGDIR_SIZE
32227 +#else
32228 +#define pxd_t pmd_t
32229 +#define pyd_t pud_t
32230 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
32231 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
32232 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
32233 +#define pyd_offset(mm, address) pud_offset((mm), (address))
32234 +#define PYD_SIZE PUD_SIZE
32235 +#endif
32236 +
32237 +#ifdef CONFIG_PAX_PER_CPU_PGD
32238 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
32239 +static inline void pgd_dtor(pgd_t *pgd) {}
32240 +#else
32241 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
32242 {
32243 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
32244 @@ -135,6 +192,7 @@ static void pgd_dtor(pgd_t *pgd)
32245 pgd_list_del(pgd);
32246 spin_unlock(&pgd_lock);
32247 }
32248 +#endif
32249
32250 /*
32251 * List of all pgd's needed for non-PAE so it can invalidate entries
32252 @@ -147,7 +205,7 @@ static void pgd_dtor(pgd_t *pgd)
32253 * -- nyc
32254 */
32255
32256 -#ifdef CONFIG_X86_PAE
32257 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
32258 /*
32259 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
32260 * updating the top-level pagetable entries to guarantee the
32261 @@ -159,7 +217,7 @@ static void pgd_dtor(pgd_t *pgd)
32262 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
32263 * and initialize the kernel pmds here.
32264 */
32265 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
32266 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
32267
32268 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
32269 {
32270 @@ -177,36 +235,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
32271 */
32272 flush_tlb_mm(mm);
32273 }
32274 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
32275 +#define PREALLOCATED_PXDS USER_PGD_PTRS
32276 #else /* !CONFIG_X86_PAE */
32277
32278 /* No need to prepopulate any pagetable entries in non-PAE modes. */
32279 -#define PREALLOCATED_PMDS 0
32280 +#define PREALLOCATED_PXDS 0
32281
32282 #endif /* CONFIG_X86_PAE */
32283
32284 -static void free_pmds(pmd_t *pmds[])
32285 +static void free_pxds(pxd_t *pxds[])
32286 {
32287 int i;
32288
32289 - for(i = 0; i < PREALLOCATED_PMDS; i++)
32290 - if (pmds[i])
32291 - free_page((unsigned long)pmds[i]);
32292 + for(i = 0; i < PREALLOCATED_PXDS; i++)
32293 + if (pxds[i])
32294 + free_page((unsigned long)pxds[i]);
32295 }
32296
32297 -static int preallocate_pmds(pmd_t *pmds[])
32298 +static int preallocate_pxds(pxd_t *pxds[])
32299 {
32300 int i;
32301 bool failed = false;
32302
32303 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
32304 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
32305 - if (pmd == NULL)
32306 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
32307 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
32308 + if (pxd == NULL)
32309 failed = true;
32310 - pmds[i] = pmd;
32311 + pxds[i] = pxd;
32312 }
32313
32314 if (failed) {
32315 - free_pmds(pmds);
32316 + free_pxds(pxds);
32317 return -ENOMEM;
32318 }
32319
32320 @@ -219,51 +279,55 @@ static int preallocate_pmds(pmd_t *pmds[])
32321 * preallocate which never got a corresponding vma will need to be
32322 * freed manually.
32323 */
32324 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
32325 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
32326 {
32327 int i;
32328
32329 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
32330 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
32331 pgd_t pgd = pgdp[i];
32332
32333 if (pgd_val(pgd) != 0) {
32334 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
32335 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
32336
32337 - pgdp[i] = native_make_pgd(0);
32338 + set_pgd(pgdp + i, native_make_pgd(0));
32339
32340 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
32341 - pmd_free(mm, pmd);
32342 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
32343 + pxd_free(mm, pxd);
32344 }
32345 }
32346 }
32347
32348 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
32349 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
32350 {
32351 - pud_t *pud;
32352 + pyd_t *pyd;
32353 unsigned long addr;
32354 int i;
32355
32356 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
32357 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
32358 return;
32359
32360 - pud = pud_offset(pgd, 0);
32361 +#ifdef CONFIG_X86_64
32362 + pyd = pyd_offset(mm, 0L);
32363 +#else
32364 + pyd = pyd_offset(pgd, 0L);
32365 +#endif
32366
32367 - for (addr = i = 0; i < PREALLOCATED_PMDS;
32368 - i++, pud++, addr += PUD_SIZE) {
32369 - pmd_t *pmd = pmds[i];
32370 + for (addr = i = 0; i < PREALLOCATED_PXDS;
32371 + i++, pyd++, addr += PYD_SIZE) {
32372 + pxd_t *pxd = pxds[i];
32373
32374 if (i >= KERNEL_PGD_BOUNDARY)
32375 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
32376 - sizeof(pmd_t) * PTRS_PER_PMD);
32377 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
32378 + sizeof(pxd_t) * PTRS_PER_PMD);
32379
32380 - pud_populate(mm, pud, pmd);
32381 + pyd_populate(mm, pyd, pxd);
32382 }
32383 }
32384
32385 pgd_t *pgd_alloc(struct mm_struct *mm)
32386 {
32387 pgd_t *pgd;
32388 - pmd_t *pmds[PREALLOCATED_PMDS];
32389 + pxd_t *pxds[PREALLOCATED_PXDS];
32390
32391 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
32392
32393 @@ -272,11 +336,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
32394
32395 mm->pgd = pgd;
32396
32397 - if (preallocate_pmds(pmds) != 0)
32398 + if (preallocate_pxds(pxds) != 0)
32399 goto out_free_pgd;
32400
32401 if (paravirt_pgd_alloc(mm) != 0)
32402 - goto out_free_pmds;
32403 + goto out_free_pxds;
32404
32405 /*
32406 * Make sure that pre-populating the pmds is atomic with
32407 @@ -286,14 +350,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
32408 spin_lock(&pgd_lock);
32409
32410 pgd_ctor(mm, pgd);
32411 - pgd_prepopulate_pmd(mm, pgd, pmds);
32412 + pgd_prepopulate_pxd(mm, pgd, pxds);
32413
32414 spin_unlock(&pgd_lock);
32415
32416 return pgd;
32417
32418 -out_free_pmds:
32419 - free_pmds(pmds);
32420 +out_free_pxds:
32421 + free_pxds(pxds);
32422 out_free_pgd:
32423 free_page((unsigned long)pgd);
32424 out:
32425 @@ -302,7 +366,7 @@ out:
32426
32427 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
32428 {
32429 - pgd_mop_up_pmds(mm, pgd);
32430 + pgd_mop_up_pxds(mm, pgd);
32431 pgd_dtor(pgd);
32432 paravirt_pgd_free(mm, pgd);
32433 free_page((unsigned long)pgd);
32434 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
32435 index a69bcb8..19068ab 100644
32436 --- a/arch/x86/mm/pgtable_32.c
32437 +++ b/arch/x86/mm/pgtable_32.c
32438 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
32439 return;
32440 }
32441 pte = pte_offset_kernel(pmd, vaddr);
32442 +
32443 + pax_open_kernel();
32444 if (pte_val(pteval))
32445 set_pte_at(&init_mm, vaddr, pte, pteval);
32446 else
32447 pte_clear(&init_mm, vaddr, pte);
32448 + pax_close_kernel();
32449
32450 /*
32451 * It's enough to flush this one mapping.
32452 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
32453 index e666cbb..61788c45 100644
32454 --- a/arch/x86/mm/physaddr.c
32455 +++ b/arch/x86/mm/physaddr.c
32456 @@ -10,7 +10,7 @@
32457 #ifdef CONFIG_X86_64
32458
32459 #ifdef CONFIG_DEBUG_VIRTUAL
32460 -unsigned long __phys_addr(unsigned long x)
32461 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32462 {
32463 unsigned long y = x - __START_KERNEL_map;
32464
32465 @@ -67,7 +67,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
32466 #else
32467
32468 #ifdef CONFIG_DEBUG_VIRTUAL
32469 -unsigned long __phys_addr(unsigned long x)
32470 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32471 {
32472 unsigned long phys_addr = x - PAGE_OFFSET;
32473 /* VMALLOC_* aren't constants */
32474 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
32475 index 410531d..0f16030 100644
32476 --- a/arch/x86/mm/setup_nx.c
32477 +++ b/arch/x86/mm/setup_nx.c
32478 @@ -5,8 +5,10 @@
32479 #include <asm/pgtable.h>
32480 #include <asm/proto.h>
32481
32482 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32483 static int disable_nx __cpuinitdata;
32484
32485 +#ifndef CONFIG_PAX_PAGEEXEC
32486 /*
32487 * noexec = on|off
32488 *
32489 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
32490 return 0;
32491 }
32492 early_param("noexec", noexec_setup);
32493 +#endif
32494 +
32495 +#endif
32496
32497 void __cpuinit x86_configure_nx(void)
32498 {
32499 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32500 if (cpu_has_nx && !disable_nx)
32501 __supported_pte_mask |= _PAGE_NX;
32502 else
32503 +#endif
32504 __supported_pte_mask &= ~_PAGE_NX;
32505 }
32506
32507 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
32508 index 282375f..e03a98f 100644
32509 --- a/arch/x86/mm/tlb.c
32510 +++ b/arch/x86/mm/tlb.c
32511 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
32512 BUG();
32513 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
32514 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
32515 +
32516 +#ifndef CONFIG_PAX_PER_CPU_PGD
32517 load_cr3(swapper_pg_dir);
32518 +#endif
32519 +
32520 }
32521 }
32522 EXPORT_SYMBOL_GPL(leave_mm);
32523 diff --git a/arch/x86/mm/uderef_64.c b/arch/x86/mm/uderef_64.c
32524 new file mode 100644
32525 index 0000000..dace51c
32526 --- /dev/null
32527 +++ b/arch/x86/mm/uderef_64.c
32528 @@ -0,0 +1,37 @@
32529 +#include <linux/mm.h>
32530 +#include <asm/pgtable.h>
32531 +#include <asm/uaccess.h>
32532 +
32533 +#ifdef CONFIG_PAX_MEMORY_UDEREF
32534 +/* PaX: due to the special call convention these functions must
32535 + * - remain leaf functions under all configurations,
32536 + * - never be called directly, only dereferenced from the wrappers.
32537 + */
32538 +void __pax_open_userland(void)
32539 +{
32540 + unsigned int cpu;
32541 +
32542 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32543 + return;
32544 +
32545 + cpu = raw_get_cpu();
32546 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_KERNEL);
32547 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
32548 + raw_put_cpu_no_resched();
32549 +}
32550 +EXPORT_SYMBOL(__pax_open_userland);
32551 +
32552 +void __pax_close_userland(void)
32553 +{
32554 + unsigned int cpu;
32555 +
32556 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32557 + return;
32558 +
32559 + cpu = raw_get_cpu();
32560 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_USER);
32561 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
32562 + raw_put_cpu_no_resched();
32563 +}
32564 +EXPORT_SYMBOL(__pax_close_userland);
32565 +#endif
32566 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
32567 index 877b9a1..a8ecf42 100644
32568 --- a/arch/x86/net/bpf_jit.S
32569 +++ b/arch/x86/net/bpf_jit.S
32570 @@ -9,6 +9,7 @@
32571 */
32572 #include <linux/linkage.h>
32573 #include <asm/dwarf2.h>
32574 +#include <asm/alternative-asm.h>
32575
32576 /*
32577 * Calling convention :
32578 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
32579 jle bpf_slow_path_word
32580 mov (SKBDATA,%rsi),%eax
32581 bswap %eax /* ntohl() */
32582 + pax_force_retaddr
32583 ret
32584
32585 sk_load_half:
32586 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
32587 jle bpf_slow_path_half
32588 movzwl (SKBDATA,%rsi),%eax
32589 rol $8,%ax # ntohs()
32590 + pax_force_retaddr
32591 ret
32592
32593 sk_load_byte:
32594 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
32595 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
32596 jle bpf_slow_path_byte
32597 movzbl (SKBDATA,%rsi),%eax
32598 + pax_force_retaddr
32599 ret
32600
32601 /**
32602 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
32603 movzbl (SKBDATA,%rsi),%ebx
32604 and $15,%bl
32605 shl $2,%bl
32606 + pax_force_retaddr
32607 ret
32608
32609 /* rsi contains offset and can be scratched */
32610 @@ -109,6 +114,7 @@ bpf_slow_path_word:
32611 js bpf_error
32612 mov -12(%rbp),%eax
32613 bswap %eax
32614 + pax_force_retaddr
32615 ret
32616
32617 bpf_slow_path_half:
32618 @@ -117,12 +123,14 @@ bpf_slow_path_half:
32619 mov -12(%rbp),%ax
32620 rol $8,%ax
32621 movzwl %ax,%eax
32622 + pax_force_retaddr
32623 ret
32624
32625 bpf_slow_path_byte:
32626 bpf_slow_path_common(1)
32627 js bpf_error
32628 movzbl -12(%rbp),%eax
32629 + pax_force_retaddr
32630 ret
32631
32632 bpf_slow_path_byte_msh:
32633 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
32634 and $15,%al
32635 shl $2,%al
32636 xchg %eax,%ebx
32637 + pax_force_retaddr
32638 ret
32639
32640 #define sk_negative_common(SIZE) \
32641 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
32642 sk_negative_common(4)
32643 mov (%rax), %eax
32644 bswap %eax
32645 + pax_force_retaddr
32646 ret
32647
32648 bpf_slow_path_half_neg:
32649 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
32650 mov (%rax),%ax
32651 rol $8,%ax
32652 movzwl %ax,%eax
32653 + pax_force_retaddr
32654 ret
32655
32656 bpf_slow_path_byte_neg:
32657 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
32658 .globl sk_load_byte_negative_offset
32659 sk_negative_common(1)
32660 movzbl (%rax), %eax
32661 + pax_force_retaddr
32662 ret
32663
32664 bpf_slow_path_byte_msh_neg:
32665 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
32666 and $15,%al
32667 shl $2,%al
32668 xchg %eax,%ebx
32669 + pax_force_retaddr
32670 ret
32671
32672 bpf_error:
32673 @@ -197,4 +210,5 @@ bpf_error:
32674 xor %eax,%eax
32675 mov -8(%rbp),%rbx
32676 leaveq
32677 + pax_force_retaddr
32678 ret
32679 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
32680 index f66b540..3e88dfb 100644
32681 --- a/arch/x86/net/bpf_jit_comp.c
32682 +++ b/arch/x86/net/bpf_jit_comp.c
32683 @@ -12,6 +12,7 @@
32684 #include <linux/netdevice.h>
32685 #include <linux/filter.h>
32686 #include <linux/if_vlan.h>
32687 +#include <linux/random.h>
32688
32689 /*
32690 * Conventions :
32691 @@ -49,13 +50,90 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
32692 return ptr + len;
32693 }
32694
32695 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32696 +#define MAX_INSTR_CODE_SIZE 96
32697 +#else
32698 +#define MAX_INSTR_CODE_SIZE 64
32699 +#endif
32700 +
32701 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
32702
32703 #define EMIT1(b1) EMIT(b1, 1)
32704 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
32705 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
32706 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
32707 +
32708 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32709 +/* original constant will appear in ecx */
32710 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
32711 +do { \
32712 + /* mov ecx, randkey */ \
32713 + EMIT1(0xb9); \
32714 + EMIT(_key, 4); \
32715 + /* xor ecx, randkey ^ off */ \
32716 + EMIT2(0x81, 0xf1); \
32717 + EMIT((_key) ^ (_off), 4); \
32718 +} while (0)
32719 +
32720 +#define EMIT1_off32(b1, _off) \
32721 +do { \
32722 + switch (b1) { \
32723 + case 0x05: /* add eax, imm32 */ \
32724 + case 0x2d: /* sub eax, imm32 */ \
32725 + case 0x25: /* and eax, imm32 */ \
32726 + case 0x0d: /* or eax, imm32 */ \
32727 + case 0xb8: /* mov eax, imm32 */ \
32728 + case 0x35: /* xor eax, imm32 */ \
32729 + case 0x3d: /* cmp eax, imm32 */ \
32730 + case 0xa9: /* test eax, imm32 */ \
32731 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32732 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
32733 + break; \
32734 + case 0xbb: /* mov ebx, imm32 */ \
32735 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32736 + /* mov ebx, ecx */ \
32737 + EMIT2(0x89, 0xcb); \
32738 + break; \
32739 + case 0xbe: /* mov esi, imm32 */ \
32740 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32741 + /* mov esi, ecx */ \
32742 + EMIT2(0x89, 0xce); \
32743 + break; \
32744 + case 0xe8: /* call rel imm32, always to known funcs */ \
32745 + EMIT1(b1); \
32746 + EMIT(_off, 4); \
32747 + break; \
32748 + case 0xe9: /* jmp rel imm32 */ \
32749 + EMIT1(b1); \
32750 + EMIT(_off, 4); \
32751 + /* prevent fall-through, we're not called if off = 0 */ \
32752 + EMIT(0xcccccccc, 4); \
32753 + EMIT(0xcccccccc, 4); \
32754 + break; \
32755 + default: \
32756 + BUILD_BUG(); \
32757 + } \
32758 +} while (0)
32759 +
32760 +#define EMIT2_off32(b1, b2, _off) \
32761 +do { \
32762 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
32763 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
32764 + EMIT(randkey, 4); \
32765 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
32766 + EMIT((_off) - randkey, 4); \
32767 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
32768 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32769 + /* imul eax, ecx */ \
32770 + EMIT3(0x0f, 0xaf, 0xc1); \
32771 + } else { \
32772 + BUILD_BUG(); \
32773 + } \
32774 +} while (0)
32775 +#else
32776 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
32777 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
32778 +#endif
32779
32780 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
32781 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
32782 @@ -90,6 +168,24 @@ do { \
32783 #define X86_JBE 0x76
32784 #define X86_JA 0x77
32785
32786 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32787 +#define APPEND_FLOW_VERIFY() \
32788 +do { \
32789 + /* mov ecx, randkey */ \
32790 + EMIT1(0xb9); \
32791 + EMIT(randkey, 4); \
32792 + /* cmp ecx, randkey */ \
32793 + EMIT2(0x81, 0xf9); \
32794 + EMIT(randkey, 4); \
32795 + /* jz after 8 int 3s */ \
32796 + EMIT2(0x74, 0x08); \
32797 + EMIT(0xcccccccc, 4); \
32798 + EMIT(0xcccccccc, 4); \
32799 +} while (0)
32800 +#else
32801 +#define APPEND_FLOW_VERIFY() do { } while (0)
32802 +#endif
32803 +
32804 #define EMIT_COND_JMP(op, offset) \
32805 do { \
32806 if (is_near(offset)) \
32807 @@ -97,6 +193,7 @@ do { \
32808 else { \
32809 EMIT2(0x0f, op + 0x10); \
32810 EMIT(offset, 4); /* jxx .+off32 */ \
32811 + APPEND_FLOW_VERIFY(); \
32812 } \
32813 } while (0)
32814
32815 @@ -121,6 +218,11 @@ static inline void bpf_flush_icache(void *start, void *end)
32816 set_fs(old_fs);
32817 }
32818
32819 +struct bpf_jit_work {
32820 + struct work_struct work;
32821 + void *image;
32822 +};
32823 +
32824 #define CHOOSE_LOAD_FUNC(K, func) \
32825 ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset)
32826
32827 @@ -146,7 +248,7 @@ static int pkt_type_offset(void)
32828
32829 void bpf_jit_compile(struct sk_filter *fp)
32830 {
32831 - u8 temp[64];
32832 + u8 temp[MAX_INSTR_CODE_SIZE];
32833 u8 *prog;
32834 unsigned int proglen, oldproglen = 0;
32835 int ilen, i;
32836 @@ -159,6 +261,9 @@ void bpf_jit_compile(struct sk_filter *fp)
32837 unsigned int *addrs;
32838 const struct sock_filter *filter = fp->insns;
32839 int flen = fp->len;
32840 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32841 + unsigned int randkey;
32842 +#endif
32843
32844 if (!bpf_jit_enable)
32845 return;
32846 @@ -167,11 +272,19 @@ void bpf_jit_compile(struct sk_filter *fp)
32847 if (addrs == NULL)
32848 return;
32849
32850 + fp->work = kmalloc(sizeof(*fp->work), GFP_KERNEL);
32851 + if (!fp->work)
32852 + goto out;
32853 +
32854 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32855 + randkey = get_random_int();
32856 +#endif
32857 +
32858 /* Before first pass, make a rough estimation of addrs[]
32859 - * each bpf instruction is translated to less than 64 bytes
32860 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
32861 */
32862 for (proglen = 0, i = 0; i < flen; i++) {
32863 - proglen += 64;
32864 + proglen += MAX_INSTR_CODE_SIZE;
32865 addrs[i] = proglen;
32866 }
32867 cleanup_addr = proglen; /* epilogue address */
32868 @@ -282,10 +395,8 @@ void bpf_jit_compile(struct sk_filter *fp)
32869 case BPF_S_ALU_MUL_K: /* A *= K */
32870 if (is_imm8(K))
32871 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
32872 - else {
32873 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
32874 - EMIT(K, 4);
32875 - }
32876 + else
32877 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
32878 break;
32879 case BPF_S_ALU_DIV_X: /* A /= X; */
32880 seen |= SEEN_XREG;
32881 @@ -325,13 +436,23 @@ void bpf_jit_compile(struct sk_filter *fp)
32882 break;
32883 case BPF_S_ALU_MOD_K: /* A %= K; */
32884 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
32885 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32886 + DILUTE_CONST_SEQUENCE(K, randkey);
32887 +#else
32888 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
32889 +#endif
32890 EMIT2(0xf7, 0xf1); /* div %ecx */
32891 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
32892 break;
32893 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
32894 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32895 + DILUTE_CONST_SEQUENCE(K, randkey);
32896 + // imul rax, rcx
32897 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
32898 +#else
32899 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
32900 EMIT(K, 4);
32901 +#endif
32902 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
32903 break;
32904 case BPF_S_ALU_AND_X:
32905 @@ -602,8 +723,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
32906 if (is_imm8(K)) {
32907 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
32908 } else {
32909 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
32910 - EMIT(K, 4);
32911 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
32912 }
32913 } else {
32914 EMIT2(0x89,0xde); /* mov %ebx,%esi */
32915 @@ -686,17 +806,18 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
32916 break;
32917 default:
32918 /* hmm, too complex filter, give up with jit compiler */
32919 - goto out;
32920 + goto error;
32921 }
32922 ilen = prog - temp;
32923 if (image) {
32924 if (unlikely(proglen + ilen > oldproglen)) {
32925 pr_err("bpb_jit_compile fatal error\n");
32926 - kfree(addrs);
32927 - module_free(NULL, image);
32928 - return;
32929 + module_free_exec(NULL, image);
32930 + goto error;
32931 }
32932 + pax_open_kernel();
32933 memcpy(image + proglen, temp, ilen);
32934 + pax_close_kernel();
32935 }
32936 proglen += ilen;
32937 addrs[i] = proglen;
32938 @@ -717,11 +838,9 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
32939 break;
32940 }
32941 if (proglen == oldproglen) {
32942 - image = module_alloc(max_t(unsigned int,
32943 - proglen,
32944 - sizeof(struct work_struct)));
32945 + image = module_alloc_exec(proglen);
32946 if (!image)
32947 - goto out;
32948 + goto error;
32949 }
32950 oldproglen = proglen;
32951 }
32952 @@ -732,7 +851,10 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
32953 if (image) {
32954 bpf_flush_icache(image, image + proglen);
32955 fp->bpf_func = (void *)image;
32956 - }
32957 + } else
32958 +error:
32959 + kfree(fp->work);
32960 +
32961 out:
32962 kfree(addrs);
32963 return;
32964 @@ -740,18 +862,20 @@ out:
32965
32966 static void jit_free_defer(struct work_struct *arg)
32967 {
32968 - module_free(NULL, arg);
32969 + module_free_exec(NULL, ((struct bpf_jit_work *)arg)->image);
32970 + kfree(arg);
32971 }
32972
32973 /* run from softirq, we must use a work_struct to call
32974 - * module_free() from process context
32975 + * module_free_exec() from process context
32976 */
32977 void bpf_jit_free(struct sk_filter *fp)
32978 {
32979 if (fp->bpf_func != sk_run_filter) {
32980 - struct work_struct *work = (struct work_struct *)fp->bpf_func;
32981 + struct work_struct *work = &fp->work->work;
32982
32983 INIT_WORK(work, jit_free_defer);
32984 + fp->work->image = fp->bpf_func;
32985 schedule_work(work);
32986 }
32987 }
32988 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
32989 index d6aa6e8..266395a 100644
32990 --- a/arch/x86/oprofile/backtrace.c
32991 +++ b/arch/x86/oprofile/backtrace.c
32992 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
32993 struct stack_frame_ia32 *fp;
32994 unsigned long bytes;
32995
32996 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
32997 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
32998 if (bytes != sizeof(bufhead))
32999 return NULL;
33000
33001 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
33002 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
33003
33004 oprofile_add_trace(bufhead[0].return_address);
33005
33006 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
33007 struct stack_frame bufhead[2];
33008 unsigned long bytes;
33009
33010 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
33011 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
33012 if (bytes != sizeof(bufhead))
33013 return NULL;
33014
33015 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
33016 {
33017 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
33018
33019 - if (!user_mode_vm(regs)) {
33020 + if (!user_mode(regs)) {
33021 unsigned long stack = kernel_stack_pointer(regs);
33022 if (depth)
33023 dump_trace(NULL, regs, (unsigned long *)stack, 0,
33024 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
33025 index 48768df..ba9143c 100644
33026 --- a/arch/x86/oprofile/nmi_int.c
33027 +++ b/arch/x86/oprofile/nmi_int.c
33028 @@ -23,6 +23,7 @@
33029 #include <asm/nmi.h>
33030 #include <asm/msr.h>
33031 #include <asm/apic.h>
33032 +#include <asm/pgtable.h>
33033
33034 #include "op_counter.h"
33035 #include "op_x86_model.h"
33036 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
33037 if (ret)
33038 return ret;
33039
33040 - if (!model->num_virt_counters)
33041 - model->num_virt_counters = model->num_counters;
33042 + if (!model->num_virt_counters) {
33043 + pax_open_kernel();
33044 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
33045 + pax_close_kernel();
33046 + }
33047
33048 mux_init(ops);
33049
33050 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
33051 index b2b9443..be58856 100644
33052 --- a/arch/x86/oprofile/op_model_amd.c
33053 +++ b/arch/x86/oprofile/op_model_amd.c
33054 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
33055 num_counters = AMD64_NUM_COUNTERS;
33056 }
33057
33058 - op_amd_spec.num_counters = num_counters;
33059 - op_amd_spec.num_controls = num_counters;
33060 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
33061 + pax_open_kernel();
33062 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
33063 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
33064 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
33065 + pax_close_kernel();
33066
33067 return 0;
33068 }
33069 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
33070 index d90528e..0127e2b 100644
33071 --- a/arch/x86/oprofile/op_model_ppro.c
33072 +++ b/arch/x86/oprofile/op_model_ppro.c
33073 @@ -19,6 +19,7 @@
33074 #include <asm/msr.h>
33075 #include <asm/apic.h>
33076 #include <asm/nmi.h>
33077 +#include <asm/pgtable.h>
33078
33079 #include "op_x86_model.h"
33080 #include "op_counter.h"
33081 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
33082
33083 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
33084
33085 - op_arch_perfmon_spec.num_counters = num_counters;
33086 - op_arch_perfmon_spec.num_controls = num_counters;
33087 + pax_open_kernel();
33088 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
33089 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
33090 + pax_close_kernel();
33091 }
33092
33093 static int arch_perfmon_init(struct oprofile_operations *ignore)
33094 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
33095 index 71e8a67..6a313bb 100644
33096 --- a/arch/x86/oprofile/op_x86_model.h
33097 +++ b/arch/x86/oprofile/op_x86_model.h
33098 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
33099 void (*switch_ctrl)(struct op_x86_model_spec const *model,
33100 struct op_msrs const * const msrs);
33101 #endif
33102 -};
33103 +} __do_const;
33104
33105 struct op_counter_config;
33106
33107 diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
33108 index e9e6ed5..e47ae67 100644
33109 --- a/arch/x86/pci/amd_bus.c
33110 +++ b/arch/x86/pci/amd_bus.c
33111 @@ -337,7 +337,7 @@ static int __cpuinit amd_cpu_notify(struct notifier_block *self,
33112 return NOTIFY_OK;
33113 }
33114
33115 -static struct notifier_block __cpuinitdata amd_cpu_notifier = {
33116 +static struct notifier_block amd_cpu_notifier = {
33117 .notifier_call = amd_cpu_notify,
33118 };
33119
33120 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
33121 index 372e9b8..e775a6c 100644
33122 --- a/arch/x86/pci/irq.c
33123 +++ b/arch/x86/pci/irq.c
33124 @@ -50,7 +50,7 @@ struct irq_router {
33125 struct irq_router_handler {
33126 u16 vendor;
33127 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
33128 -};
33129 +} __do_const;
33130
33131 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
33132 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
33133 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
33134 return 0;
33135 }
33136
33137 -static __initdata struct irq_router_handler pirq_routers[] = {
33138 +static __initconst const struct irq_router_handler pirq_routers[] = {
33139 { PCI_VENDOR_ID_INTEL, intel_router_probe },
33140 { PCI_VENDOR_ID_AL, ali_router_probe },
33141 { PCI_VENDOR_ID_ITE, ite_router_probe },
33142 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
33143 static void __init pirq_find_router(struct irq_router *r)
33144 {
33145 struct irq_routing_table *rt = pirq_table;
33146 - struct irq_router_handler *h;
33147 + const struct irq_router_handler *h;
33148
33149 #ifdef CONFIG_PCI_BIOS
33150 if (!rt->signature) {
33151 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
33152 return 0;
33153 }
33154
33155 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
33156 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
33157 {
33158 .callback = fix_broken_hp_bios_irq9,
33159 .ident = "HP Pavilion N5400 Series Laptop",
33160 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
33161 index 6eb18c4..20d83de 100644
33162 --- a/arch/x86/pci/mrst.c
33163 +++ b/arch/x86/pci/mrst.c
33164 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
33165 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
33166 pci_mmcfg_late_init();
33167 pcibios_enable_irq = mrst_pci_irq_enable;
33168 - pci_root_ops = pci_mrst_ops;
33169 + pax_open_kernel();
33170 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
33171 + pax_close_kernel();
33172 pci_soc_mode = 1;
33173 /* Continue with standard init */
33174 return 1;
33175 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
33176 index c77b24a..c979855 100644
33177 --- a/arch/x86/pci/pcbios.c
33178 +++ b/arch/x86/pci/pcbios.c
33179 @@ -79,7 +79,7 @@ union bios32 {
33180 static struct {
33181 unsigned long address;
33182 unsigned short segment;
33183 -} bios32_indirect = { 0, __KERNEL_CS };
33184 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
33185
33186 /*
33187 * Returns the entry point for the given service, NULL on error
33188 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
33189 unsigned long length; /* %ecx */
33190 unsigned long entry; /* %edx */
33191 unsigned long flags;
33192 + struct desc_struct d, *gdt;
33193
33194 local_irq_save(flags);
33195 - __asm__("lcall *(%%edi); cld"
33196 +
33197 + gdt = get_cpu_gdt_table(smp_processor_id());
33198 +
33199 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
33200 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
33201 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
33202 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
33203 +
33204 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
33205 : "=a" (return_code),
33206 "=b" (address),
33207 "=c" (length),
33208 "=d" (entry)
33209 : "0" (service),
33210 "1" (0),
33211 - "D" (&bios32_indirect));
33212 + "D" (&bios32_indirect),
33213 + "r"(__PCIBIOS_DS)
33214 + : "memory");
33215 +
33216 + pax_open_kernel();
33217 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
33218 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
33219 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
33220 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
33221 + pax_close_kernel();
33222 +
33223 local_irq_restore(flags);
33224
33225 switch (return_code) {
33226 - case 0:
33227 - return address + entry;
33228 - case 0x80: /* Not present */
33229 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
33230 - return 0;
33231 - default: /* Shouldn't happen */
33232 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
33233 - service, return_code);
33234 + case 0: {
33235 + int cpu;
33236 + unsigned char flags;
33237 +
33238 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
33239 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
33240 + printk(KERN_WARNING "bios32_service: not valid\n");
33241 return 0;
33242 + }
33243 + address = address + PAGE_OFFSET;
33244 + length += 16UL; /* some BIOSs underreport this... */
33245 + flags = 4;
33246 + if (length >= 64*1024*1024) {
33247 + length >>= PAGE_SHIFT;
33248 + flags |= 8;
33249 + }
33250 +
33251 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
33252 + gdt = get_cpu_gdt_table(cpu);
33253 + pack_descriptor(&d, address, length, 0x9b, flags);
33254 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
33255 + pack_descriptor(&d, address, length, 0x93, flags);
33256 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
33257 + }
33258 + return entry;
33259 + }
33260 + case 0x80: /* Not present */
33261 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
33262 + return 0;
33263 + default: /* Shouldn't happen */
33264 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
33265 + service, return_code);
33266 + return 0;
33267 }
33268 }
33269
33270 static struct {
33271 unsigned long address;
33272 unsigned short segment;
33273 -} pci_indirect = { 0, __KERNEL_CS };
33274 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
33275
33276 -static int pci_bios_present;
33277 +static int pci_bios_present __read_only;
33278
33279 static int check_pcibios(void)
33280 {
33281 @@ -131,11 +174,13 @@ static int check_pcibios(void)
33282 unsigned long flags, pcibios_entry;
33283
33284 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
33285 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
33286 + pci_indirect.address = pcibios_entry;
33287
33288 local_irq_save(flags);
33289 - __asm__(
33290 - "lcall *(%%edi); cld\n\t"
33291 + __asm__("movw %w6, %%ds\n\t"
33292 + "lcall *%%ss:(%%edi); cld\n\t"
33293 + "push %%ss\n\t"
33294 + "pop %%ds\n\t"
33295 "jc 1f\n\t"
33296 "xor %%ah, %%ah\n"
33297 "1:"
33298 @@ -144,7 +189,8 @@ static int check_pcibios(void)
33299 "=b" (ebx),
33300 "=c" (ecx)
33301 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
33302 - "D" (&pci_indirect)
33303 + "D" (&pci_indirect),
33304 + "r" (__PCIBIOS_DS)
33305 : "memory");
33306 local_irq_restore(flags);
33307
33308 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
33309
33310 switch (len) {
33311 case 1:
33312 - __asm__("lcall *(%%esi); cld\n\t"
33313 + __asm__("movw %w6, %%ds\n\t"
33314 + "lcall *%%ss:(%%esi); cld\n\t"
33315 + "push %%ss\n\t"
33316 + "pop %%ds\n\t"
33317 "jc 1f\n\t"
33318 "xor %%ah, %%ah\n"
33319 "1:"
33320 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
33321 : "1" (PCIBIOS_READ_CONFIG_BYTE),
33322 "b" (bx),
33323 "D" ((long)reg),
33324 - "S" (&pci_indirect));
33325 + "S" (&pci_indirect),
33326 + "r" (__PCIBIOS_DS));
33327 /*
33328 * Zero-extend the result beyond 8 bits, do not trust the
33329 * BIOS having done it:
33330 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
33331 *value &= 0xff;
33332 break;
33333 case 2:
33334 - __asm__("lcall *(%%esi); cld\n\t"
33335 + __asm__("movw %w6, %%ds\n\t"
33336 + "lcall *%%ss:(%%esi); cld\n\t"
33337 + "push %%ss\n\t"
33338 + "pop %%ds\n\t"
33339 "jc 1f\n\t"
33340 "xor %%ah, %%ah\n"
33341 "1:"
33342 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
33343 : "1" (PCIBIOS_READ_CONFIG_WORD),
33344 "b" (bx),
33345 "D" ((long)reg),
33346 - "S" (&pci_indirect));
33347 + "S" (&pci_indirect),
33348 + "r" (__PCIBIOS_DS));
33349 /*
33350 * Zero-extend the result beyond 16 bits, do not trust the
33351 * BIOS having done it:
33352 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
33353 *value &= 0xffff;
33354 break;
33355 case 4:
33356 - __asm__("lcall *(%%esi); cld\n\t"
33357 + __asm__("movw %w6, %%ds\n\t"
33358 + "lcall *%%ss:(%%esi); cld\n\t"
33359 + "push %%ss\n\t"
33360 + "pop %%ds\n\t"
33361 "jc 1f\n\t"
33362 "xor %%ah, %%ah\n"
33363 "1:"
33364 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
33365 : "1" (PCIBIOS_READ_CONFIG_DWORD),
33366 "b" (bx),
33367 "D" ((long)reg),
33368 - "S" (&pci_indirect));
33369 + "S" (&pci_indirect),
33370 + "r" (__PCIBIOS_DS));
33371 break;
33372 }
33373
33374 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33375
33376 switch (len) {
33377 case 1:
33378 - __asm__("lcall *(%%esi); cld\n\t"
33379 + __asm__("movw %w6, %%ds\n\t"
33380 + "lcall *%%ss:(%%esi); cld\n\t"
33381 + "push %%ss\n\t"
33382 + "pop %%ds\n\t"
33383 "jc 1f\n\t"
33384 "xor %%ah, %%ah\n"
33385 "1:"
33386 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33387 "c" (value),
33388 "b" (bx),
33389 "D" ((long)reg),
33390 - "S" (&pci_indirect));
33391 + "S" (&pci_indirect),
33392 + "r" (__PCIBIOS_DS));
33393 break;
33394 case 2:
33395 - __asm__("lcall *(%%esi); cld\n\t"
33396 + __asm__("movw %w6, %%ds\n\t"
33397 + "lcall *%%ss:(%%esi); cld\n\t"
33398 + "push %%ss\n\t"
33399 + "pop %%ds\n\t"
33400 "jc 1f\n\t"
33401 "xor %%ah, %%ah\n"
33402 "1:"
33403 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33404 "c" (value),
33405 "b" (bx),
33406 "D" ((long)reg),
33407 - "S" (&pci_indirect));
33408 + "S" (&pci_indirect),
33409 + "r" (__PCIBIOS_DS));
33410 break;
33411 case 4:
33412 - __asm__("lcall *(%%esi); cld\n\t"
33413 + __asm__("movw %w6, %%ds\n\t"
33414 + "lcall *%%ss:(%%esi); cld\n\t"
33415 + "push %%ss\n\t"
33416 + "pop %%ds\n\t"
33417 "jc 1f\n\t"
33418 "xor %%ah, %%ah\n"
33419 "1:"
33420 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33421 "c" (value),
33422 "b" (bx),
33423 "D" ((long)reg),
33424 - "S" (&pci_indirect));
33425 + "S" (&pci_indirect),
33426 + "r" (__PCIBIOS_DS));
33427 break;
33428 }
33429
33430 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
33431
33432 DBG("PCI: Fetching IRQ routing table... ");
33433 __asm__("push %%es\n\t"
33434 + "movw %w8, %%ds\n\t"
33435 "push %%ds\n\t"
33436 "pop %%es\n\t"
33437 - "lcall *(%%esi); cld\n\t"
33438 + "lcall *%%ss:(%%esi); cld\n\t"
33439 "pop %%es\n\t"
33440 + "push %%ss\n\t"
33441 + "pop %%ds\n"
33442 "jc 1f\n\t"
33443 "xor %%ah, %%ah\n"
33444 "1:"
33445 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
33446 "1" (0),
33447 "D" ((long) &opt),
33448 "S" (&pci_indirect),
33449 - "m" (opt)
33450 + "m" (opt),
33451 + "r" (__PCIBIOS_DS)
33452 : "memory");
33453 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
33454 if (ret & 0xff00)
33455 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33456 {
33457 int ret;
33458
33459 - __asm__("lcall *(%%esi); cld\n\t"
33460 + __asm__("movw %w5, %%ds\n\t"
33461 + "lcall *%%ss:(%%esi); cld\n\t"
33462 + "push %%ss\n\t"
33463 + "pop %%ds\n"
33464 "jc 1f\n\t"
33465 "xor %%ah, %%ah\n"
33466 "1:"
33467 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33468 : "0" (PCIBIOS_SET_PCI_HW_INT),
33469 "b" ((dev->bus->number << 8) | dev->devfn),
33470 "c" ((irq << 8) | (pin + 10)),
33471 - "S" (&pci_indirect));
33472 + "S" (&pci_indirect),
33473 + "r" (__PCIBIOS_DS));
33474 return !(ret & 0xff00);
33475 }
33476 EXPORT_SYMBOL(pcibios_set_irq_routing);
33477 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
33478 index 40e4469..d915bf9 100644
33479 --- a/arch/x86/platform/efi/efi_32.c
33480 +++ b/arch/x86/platform/efi/efi_32.c
33481 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
33482 {
33483 struct desc_ptr gdt_descr;
33484
33485 +#ifdef CONFIG_PAX_KERNEXEC
33486 + struct desc_struct d;
33487 +#endif
33488 +
33489 local_irq_save(efi_rt_eflags);
33490
33491 load_cr3(initial_page_table);
33492 __flush_tlb_all();
33493
33494 +#ifdef CONFIG_PAX_KERNEXEC
33495 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
33496 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33497 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
33498 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33499 +#endif
33500 +
33501 gdt_descr.address = __pa(get_cpu_gdt_table(0));
33502 gdt_descr.size = GDT_SIZE - 1;
33503 load_gdt(&gdt_descr);
33504 @@ -58,11 +69,24 @@ void efi_call_phys_epilog(void)
33505 {
33506 struct desc_ptr gdt_descr;
33507
33508 +#ifdef CONFIG_PAX_KERNEXEC
33509 + struct desc_struct d;
33510 +
33511 + memset(&d, 0, sizeof d);
33512 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33513 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33514 +#endif
33515 +
33516 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
33517 gdt_descr.size = GDT_SIZE - 1;
33518 load_gdt(&gdt_descr);
33519
33520 +#ifdef CONFIG_PAX_PER_CPU_PGD
33521 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33522 +#else
33523 load_cr3(swapper_pg_dir);
33524 +#endif
33525 +
33526 __flush_tlb_all();
33527
33528 local_irq_restore(efi_rt_eflags);
33529 diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
33530 index 39a0e7f1..872396e 100644
33531 --- a/arch/x86/platform/efi/efi_64.c
33532 +++ b/arch/x86/platform/efi/efi_64.c
33533 @@ -76,6 +76,11 @@ void __init efi_call_phys_prelog(void)
33534 vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
33535 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress));
33536 }
33537 +
33538 +#ifdef CONFIG_PAX_PER_CPU_PGD
33539 + load_cr3(swapper_pg_dir);
33540 +#endif
33541 +
33542 __flush_tlb_all();
33543 }
33544
33545 @@ -89,6 +94,11 @@ void __init efi_call_phys_epilog(void)
33546 for (pgd = 0; pgd < n_pgds; pgd++)
33547 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), save_pgd[pgd]);
33548 kfree(save_pgd);
33549 +
33550 +#ifdef CONFIG_PAX_PER_CPU_PGD
33551 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33552 +#endif
33553 +
33554 __flush_tlb_all();
33555 local_irq_restore(efi_flags);
33556 early_code_mapping_set_exec(0);
33557 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
33558 index fbe66e6..eae5e38 100644
33559 --- a/arch/x86/platform/efi/efi_stub_32.S
33560 +++ b/arch/x86/platform/efi/efi_stub_32.S
33561 @@ -6,7 +6,9 @@
33562 */
33563
33564 #include <linux/linkage.h>
33565 +#include <linux/init.h>
33566 #include <asm/page_types.h>
33567 +#include <asm/segment.h>
33568
33569 /*
33570 * efi_call_phys(void *, ...) is a function with variable parameters.
33571 @@ -20,7 +22,7 @@
33572 * service functions will comply with gcc calling convention, too.
33573 */
33574
33575 -.text
33576 +__INIT
33577 ENTRY(efi_call_phys)
33578 /*
33579 * 0. The function can only be called in Linux kernel. So CS has been
33580 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
33581 * The mapping of lower virtual memory has been created in prelog and
33582 * epilog.
33583 */
33584 - movl $1f, %edx
33585 - subl $__PAGE_OFFSET, %edx
33586 - jmp *%edx
33587 +#ifdef CONFIG_PAX_KERNEXEC
33588 + movl $(__KERNEXEC_EFI_DS), %edx
33589 + mov %edx, %ds
33590 + mov %edx, %es
33591 + mov %edx, %ss
33592 + addl $2f,(1f)
33593 + ljmp *(1f)
33594 +
33595 +__INITDATA
33596 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
33597 +.previous
33598 +
33599 +2:
33600 + subl $2b,(1b)
33601 +#else
33602 + jmp 1f-__PAGE_OFFSET
33603 1:
33604 +#endif
33605
33606 /*
33607 * 2. Now on the top of stack is the return
33608 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
33609 * parameter 2, ..., param n. To make things easy, we save the return
33610 * address of efi_call_phys in a global variable.
33611 */
33612 - popl %edx
33613 - movl %edx, saved_return_addr
33614 - /* get the function pointer into ECX*/
33615 - popl %ecx
33616 - movl %ecx, efi_rt_function_ptr
33617 - movl $2f, %edx
33618 - subl $__PAGE_OFFSET, %edx
33619 - pushl %edx
33620 + popl (saved_return_addr)
33621 + popl (efi_rt_function_ptr)
33622
33623 /*
33624 * 3. Clear PG bit in %CR0.
33625 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
33626 /*
33627 * 5. Call the physical function.
33628 */
33629 - jmp *%ecx
33630 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
33631
33632 -2:
33633 /*
33634 * 6. After EFI runtime service returns, control will return to
33635 * following instruction. We'd better readjust stack pointer first.
33636 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
33637 movl %cr0, %edx
33638 orl $0x80000000, %edx
33639 movl %edx, %cr0
33640 - jmp 1f
33641 -1:
33642 +
33643 /*
33644 * 8. Now restore the virtual mode from flat mode by
33645 * adding EIP with PAGE_OFFSET.
33646 */
33647 - movl $1f, %edx
33648 - jmp *%edx
33649 +#ifdef CONFIG_PAX_KERNEXEC
33650 + movl $(__KERNEL_DS), %edx
33651 + mov %edx, %ds
33652 + mov %edx, %es
33653 + mov %edx, %ss
33654 + ljmp $(__KERNEL_CS),$1f
33655 +#else
33656 + jmp 1f+__PAGE_OFFSET
33657 +#endif
33658 1:
33659
33660 /*
33661 * 9. Balance the stack. And because EAX contain the return value,
33662 * we'd better not clobber it.
33663 */
33664 - leal efi_rt_function_ptr, %edx
33665 - movl (%edx), %ecx
33666 - pushl %ecx
33667 + pushl (efi_rt_function_ptr)
33668
33669 /*
33670 - * 10. Push the saved return address onto the stack and return.
33671 + * 10. Return to the saved return address.
33672 */
33673 - leal saved_return_addr, %edx
33674 - movl (%edx), %ecx
33675 - pushl %ecx
33676 - ret
33677 + jmpl *(saved_return_addr)
33678 ENDPROC(efi_call_phys)
33679 .previous
33680
33681 -.data
33682 +__INITDATA
33683 saved_return_addr:
33684 .long 0
33685 efi_rt_function_ptr:
33686 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
33687 index 4c07cca..2c8427d 100644
33688 --- a/arch/x86/platform/efi/efi_stub_64.S
33689 +++ b/arch/x86/platform/efi/efi_stub_64.S
33690 @@ -7,6 +7,7 @@
33691 */
33692
33693 #include <linux/linkage.h>
33694 +#include <asm/alternative-asm.h>
33695
33696 #define SAVE_XMM \
33697 mov %rsp, %rax; \
33698 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
33699 call *%rdi
33700 addq $32, %rsp
33701 RESTORE_XMM
33702 + pax_force_retaddr 0, 1
33703 ret
33704 ENDPROC(efi_call0)
33705
33706 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
33707 call *%rdi
33708 addq $32, %rsp
33709 RESTORE_XMM
33710 + pax_force_retaddr 0, 1
33711 ret
33712 ENDPROC(efi_call1)
33713
33714 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
33715 call *%rdi
33716 addq $32, %rsp
33717 RESTORE_XMM
33718 + pax_force_retaddr 0, 1
33719 ret
33720 ENDPROC(efi_call2)
33721
33722 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
33723 call *%rdi
33724 addq $32, %rsp
33725 RESTORE_XMM
33726 + pax_force_retaddr 0, 1
33727 ret
33728 ENDPROC(efi_call3)
33729
33730 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
33731 call *%rdi
33732 addq $32, %rsp
33733 RESTORE_XMM
33734 + pax_force_retaddr 0, 1
33735 ret
33736 ENDPROC(efi_call4)
33737
33738 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
33739 call *%rdi
33740 addq $48, %rsp
33741 RESTORE_XMM
33742 + pax_force_retaddr 0, 1
33743 ret
33744 ENDPROC(efi_call5)
33745
33746 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
33747 call *%rdi
33748 addq $48, %rsp
33749 RESTORE_XMM
33750 + pax_force_retaddr 0, 1
33751 ret
33752 ENDPROC(efi_call6)
33753 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
33754 index a0a0a43..a48e233 100644
33755 --- a/arch/x86/platform/mrst/mrst.c
33756 +++ b/arch/x86/platform/mrst/mrst.c
33757 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
33758 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
33759 int sfi_mrtc_num;
33760
33761 -static void mrst_power_off(void)
33762 +static __noreturn void mrst_power_off(void)
33763 {
33764 + BUG();
33765 }
33766
33767 -static void mrst_reboot(void)
33768 +static __noreturn void mrst_reboot(void)
33769 {
33770 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
33771 + BUG();
33772 }
33773
33774 /* parse all the mtimer info to a static mtimer array */
33775 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
33776 index d6ee929..3637cb5 100644
33777 --- a/arch/x86/platform/olpc/olpc_dt.c
33778 +++ b/arch/x86/platform/olpc/olpc_dt.c
33779 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
33780 return res;
33781 }
33782
33783 -static struct of_pdt_ops prom_olpc_ops __initdata = {
33784 +static struct of_pdt_ops prom_olpc_ops __initconst = {
33785 .nextprop = olpc_dt_nextprop,
33786 .getproplen = olpc_dt_getproplen,
33787 .getproperty = olpc_dt_getproperty,
33788 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
33789 index 1cf5b30..fd45732 100644
33790 --- a/arch/x86/power/cpu.c
33791 +++ b/arch/x86/power/cpu.c
33792 @@ -137,11 +137,8 @@ static void do_fpu_end(void)
33793 static void fix_processor_context(void)
33794 {
33795 int cpu = smp_processor_id();
33796 - struct tss_struct *t = &per_cpu(init_tss, cpu);
33797 -#ifdef CONFIG_X86_64
33798 - struct desc_struct *desc = get_cpu_gdt_table(cpu);
33799 - tss_desc tss;
33800 -#endif
33801 + struct tss_struct *t = init_tss + cpu;
33802 +
33803 set_tss_desc(cpu, t); /*
33804 * This just modifies memory; should not be
33805 * necessary. But... This is necessary, because
33806 @@ -150,10 +147,6 @@ static void fix_processor_context(void)
33807 */
33808
33809 #ifdef CONFIG_X86_64
33810 - memcpy(&tss, &desc[GDT_ENTRY_TSS], sizeof(tss_desc));
33811 - tss.type = 0x9; /* The available 64-bit TSS (see AMD vol 2, pg 91 */
33812 - write_gdt_entry(desc, GDT_ENTRY_TSS, &tss, DESC_TSS);
33813 -
33814 syscall_init(); /* This sets MSR_*STAR and related */
33815 #endif
33816 load_TR_desc(); /* This does ltr */
33817 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
33818 index a44f457..9140171 100644
33819 --- a/arch/x86/realmode/init.c
33820 +++ b/arch/x86/realmode/init.c
33821 @@ -70,7 +70,13 @@ void __init setup_real_mode(void)
33822 __va(real_mode_header->trampoline_header);
33823
33824 #ifdef CONFIG_X86_32
33825 - trampoline_header->start = __pa_symbol(startup_32_smp);
33826 + trampoline_header->start = __pa_symbol(ktla_ktva(startup_32_smp));
33827 +
33828 +#ifdef CONFIG_PAX_KERNEXEC
33829 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
33830 +#endif
33831 +
33832 + trampoline_header->boot_cs = __BOOT_CS;
33833 trampoline_header->gdt_limit = __BOOT_DS + 7;
33834 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
33835 #else
33836 @@ -86,7 +92,7 @@ void __init setup_real_mode(void)
33837 *trampoline_cr4_features = read_cr4();
33838
33839 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
33840 - trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
33841 + trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
33842 trampoline_pgd[511] = init_level4_pgt[511].pgd;
33843 #endif
33844 }
33845 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
33846 index 8869287..d577672 100644
33847 --- a/arch/x86/realmode/rm/Makefile
33848 +++ b/arch/x86/realmode/rm/Makefile
33849 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
33850 $(call cc-option, -fno-unit-at-a-time)) \
33851 $(call cc-option, -fno-stack-protector) \
33852 $(call cc-option, -mpreferred-stack-boundary=2)
33853 +ifdef CONSTIFY_PLUGIN
33854 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
33855 +endif
33856 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
33857 GCOV_PROFILE := n
33858 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
33859 index a28221d..93c40f1 100644
33860 --- a/arch/x86/realmode/rm/header.S
33861 +++ b/arch/x86/realmode/rm/header.S
33862 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
33863 #endif
33864 /* APM/BIOS reboot */
33865 .long pa_machine_real_restart_asm
33866 -#ifdef CONFIG_X86_64
33867 +#ifdef CONFIG_X86_32
33868 + .long __KERNEL_CS
33869 +#else
33870 .long __KERNEL32_CS
33871 #endif
33872 END(real_mode_header)
33873 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
33874 index c1b2791..f9e31c7 100644
33875 --- a/arch/x86/realmode/rm/trampoline_32.S
33876 +++ b/arch/x86/realmode/rm/trampoline_32.S
33877 @@ -25,6 +25,12 @@
33878 #include <asm/page_types.h>
33879 #include "realmode.h"
33880
33881 +#ifdef CONFIG_PAX_KERNEXEC
33882 +#define ta(X) (X)
33883 +#else
33884 +#define ta(X) (pa_ ## X)
33885 +#endif
33886 +
33887 .text
33888 .code16
33889
33890 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
33891
33892 cli # We should be safe anyway
33893
33894 - movl tr_start, %eax # where we need to go
33895 -
33896 movl $0xA5A5A5A5, trampoline_status
33897 # write marker for master knows we're running
33898
33899 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
33900 movw $1, %dx # protected mode (PE) bit
33901 lmsw %dx # into protected mode
33902
33903 - ljmpl $__BOOT_CS, $pa_startup_32
33904 + ljmpl *(trampoline_header)
33905
33906 .section ".text32","ax"
33907 .code32
33908 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
33909 .balign 8
33910 GLOBAL(trampoline_header)
33911 tr_start: .space 4
33912 - tr_gdt_pad: .space 2
33913 + tr_boot_cs: .space 2
33914 tr_gdt: .space 6
33915 END(trampoline_header)
33916
33917 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
33918 index bb360dc..d0fd8f8 100644
33919 --- a/arch/x86/realmode/rm/trampoline_64.S
33920 +++ b/arch/x86/realmode/rm/trampoline_64.S
33921 @@ -94,6 +94,7 @@ ENTRY(startup_32)
33922 movl %edx, %gs
33923
33924 movl pa_tr_cr4, %eax
33925 + andl $~X86_CR4_PCIDE, %eax
33926 movl %eax, %cr4 # Enable PAE mode
33927
33928 # Setup trampoline 4 level pagetables
33929 @@ -107,7 +108,7 @@ ENTRY(startup_32)
33930 wrmsr
33931
33932 # Enable paging and in turn activate Long Mode
33933 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
33934 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
33935 movl %eax, %cr0
33936
33937 /*
33938 diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
33939 index e812034..c747134 100644
33940 --- a/arch/x86/tools/Makefile
33941 +++ b/arch/x86/tools/Makefile
33942 @@ -37,7 +37,7 @@ $(obj)/test_get_len.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/in
33943
33944 $(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
33945
33946 -HOST_EXTRACFLAGS += -I$(srctree)/tools/include
33947 +HOST_EXTRACFLAGS += -I$(srctree)/tools/include -ggdb
33948 hostprogs-y += relocs
33949 relocs-objs := relocs_32.o relocs_64.o relocs_common.o
33950 relocs: $(obj)/relocs
33951 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
33952 index f7bab68..b6d9886 100644
33953 --- a/arch/x86/tools/relocs.c
33954 +++ b/arch/x86/tools/relocs.c
33955 @@ -1,5 +1,7 @@
33956 /* This is included from relocs_32/64.c */
33957
33958 +#include "../../../include/generated/autoconf.h"
33959 +
33960 #define ElfW(type) _ElfW(ELF_BITS, type)
33961 #define _ElfW(bits, type) __ElfW(bits, type)
33962 #define __ElfW(bits, type) Elf##bits##_##type
33963 @@ -11,6 +13,7 @@
33964 #define Elf_Sym ElfW(Sym)
33965
33966 static Elf_Ehdr ehdr;
33967 +static Elf_Phdr *phdr;
33968
33969 struct relocs {
33970 uint32_t *offset;
33971 @@ -383,9 +386,39 @@ static void read_ehdr(FILE *fp)
33972 }
33973 }
33974
33975 +static void read_phdrs(FILE *fp)
33976 +{
33977 + unsigned int i;
33978 +
33979 + phdr = calloc(ehdr.e_phnum, sizeof(Elf_Phdr));
33980 + if (!phdr) {
33981 + die("Unable to allocate %d program headers\n",
33982 + ehdr.e_phnum);
33983 + }
33984 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
33985 + die("Seek to %d failed: %s\n",
33986 + ehdr.e_phoff, strerror(errno));
33987 + }
33988 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
33989 + die("Cannot read ELF program headers: %s\n",
33990 + strerror(errno));
33991 + }
33992 + for(i = 0; i < ehdr.e_phnum; i++) {
33993 + phdr[i].p_type = elf_word_to_cpu(phdr[i].p_type);
33994 + phdr[i].p_offset = elf_off_to_cpu(phdr[i].p_offset);
33995 + phdr[i].p_vaddr = elf_addr_to_cpu(phdr[i].p_vaddr);
33996 + phdr[i].p_paddr = elf_addr_to_cpu(phdr[i].p_paddr);
33997 + phdr[i].p_filesz = elf_word_to_cpu(phdr[i].p_filesz);
33998 + phdr[i].p_memsz = elf_word_to_cpu(phdr[i].p_memsz);
33999 + phdr[i].p_flags = elf_word_to_cpu(phdr[i].p_flags);
34000 + phdr[i].p_align = elf_word_to_cpu(phdr[i].p_align);
34001 + }
34002 +
34003 +}
34004 +
34005 static void read_shdrs(FILE *fp)
34006 {
34007 - int i;
34008 + unsigned int i;
34009 Elf_Shdr shdr;
34010
34011 secs = calloc(ehdr.e_shnum, sizeof(struct section));
34012 @@ -420,7 +453,7 @@ static void read_shdrs(FILE *fp)
34013
34014 static void read_strtabs(FILE *fp)
34015 {
34016 - int i;
34017 + unsigned int i;
34018 for (i = 0; i < ehdr.e_shnum; i++) {
34019 struct section *sec = &secs[i];
34020 if (sec->shdr.sh_type != SHT_STRTAB) {
34021 @@ -445,7 +478,7 @@ static void read_strtabs(FILE *fp)
34022
34023 static void read_symtabs(FILE *fp)
34024 {
34025 - int i,j;
34026 + unsigned int i,j;
34027 for (i = 0; i < ehdr.e_shnum; i++) {
34028 struct section *sec = &secs[i];
34029 if (sec->shdr.sh_type != SHT_SYMTAB) {
34030 @@ -476,9 +509,11 @@ static void read_symtabs(FILE *fp)
34031 }
34032
34033
34034 -static void read_relocs(FILE *fp)
34035 +static void read_relocs(FILE *fp, int use_real_mode)
34036 {
34037 - int i,j;
34038 + unsigned int i,j;
34039 + uint32_t base;
34040 +
34041 for (i = 0; i < ehdr.e_shnum; i++) {
34042 struct section *sec = &secs[i];
34043 if (sec->shdr.sh_type != SHT_REL_TYPE) {
34044 @@ -498,9 +533,22 @@ static void read_relocs(FILE *fp)
34045 die("Cannot read symbol table: %s\n",
34046 strerror(errno));
34047 }
34048 + base = 0;
34049 +
34050 +#ifdef CONFIG_X86_32
34051 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
34052 + if (phdr[j].p_type != PT_LOAD )
34053 + continue;
34054 + 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)
34055 + continue;
34056 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
34057 + break;
34058 + }
34059 +#endif
34060 +
34061 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf_Rel); j++) {
34062 Elf_Rel *rel = &sec->reltab[j];
34063 - rel->r_offset = elf_addr_to_cpu(rel->r_offset);
34064 + rel->r_offset = elf_addr_to_cpu(rel->r_offset) + base;
34065 rel->r_info = elf_xword_to_cpu(rel->r_info);
34066 #if (SHT_REL_TYPE == SHT_RELA)
34067 rel->r_addend = elf_xword_to_cpu(rel->r_addend);
34068 @@ -512,7 +560,7 @@ static void read_relocs(FILE *fp)
34069
34070 static void print_absolute_symbols(void)
34071 {
34072 - int i;
34073 + unsigned int i;
34074 const char *format;
34075
34076 if (ELF_BITS == 64)
34077 @@ -525,7 +573,7 @@ static void print_absolute_symbols(void)
34078 for (i = 0; i < ehdr.e_shnum; i++) {
34079 struct section *sec = &secs[i];
34080 char *sym_strtab;
34081 - int j;
34082 + unsigned int j;
34083
34084 if (sec->shdr.sh_type != SHT_SYMTAB) {
34085 continue;
34086 @@ -552,7 +600,7 @@ static void print_absolute_symbols(void)
34087
34088 static void print_absolute_relocs(void)
34089 {
34090 - int i, printed = 0;
34091 + unsigned int i, printed = 0;
34092 const char *format;
34093
34094 if (ELF_BITS == 64)
34095 @@ -565,7 +613,7 @@ static void print_absolute_relocs(void)
34096 struct section *sec_applies, *sec_symtab;
34097 char *sym_strtab;
34098 Elf_Sym *sh_symtab;
34099 - int j;
34100 + unsigned int j;
34101 if (sec->shdr.sh_type != SHT_REL_TYPE) {
34102 continue;
34103 }
34104 @@ -642,13 +690,13 @@ static void add_reloc(struct relocs *r, uint32_t offset)
34105 static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
34106 Elf_Sym *sym, const char *symname))
34107 {
34108 - int i;
34109 + unsigned int i;
34110 /* Walk through the relocations */
34111 for (i = 0; i < ehdr.e_shnum; i++) {
34112 char *sym_strtab;
34113 Elf_Sym *sh_symtab;
34114 struct section *sec_applies, *sec_symtab;
34115 - int j;
34116 + unsigned int j;
34117 struct section *sec = &secs[i];
34118
34119 if (sec->shdr.sh_type != SHT_REL_TYPE) {
34120 @@ -812,6 +860,23 @@ static int do_reloc32(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
34121 {
34122 unsigned r_type = ELF32_R_TYPE(rel->r_info);
34123 int shn_abs = (sym->st_shndx == SHN_ABS) && !is_reloc(S_REL, symname);
34124 + char *sym_strtab = sec->link->link->strtab;
34125 +
34126 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
34127 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
34128 + return 0;
34129 +
34130 +#ifdef CONFIG_PAX_KERNEXEC
34131 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
34132 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
34133 + return 0;
34134 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
34135 + return 0;
34136 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
34137 + return 0;
34138 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
34139 + return 0;
34140 +#endif
34141
34142 switch (r_type) {
34143 case R_386_NONE:
34144 @@ -950,7 +1015,7 @@ static int write32_as_text(uint32_t v, FILE *f)
34145
34146 static void emit_relocs(int as_text, int use_real_mode)
34147 {
34148 - int i;
34149 + unsigned int i;
34150 int (*write_reloc)(uint32_t, FILE *) = write32;
34151 int (*do_reloc)(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
34152 const char *symname);
34153 @@ -1026,10 +1091,11 @@ void process(FILE *fp, int use_real_mode, int as_text,
34154 {
34155 regex_init(use_real_mode);
34156 read_ehdr(fp);
34157 + read_phdrs(fp);
34158 read_shdrs(fp);
34159 read_strtabs(fp);
34160 read_symtabs(fp);
34161 - read_relocs(fp);
34162 + read_relocs(fp, use_real_mode);
34163 if (ELF_BITS == 64)
34164 percpu_init();
34165 if (show_absolute_syms) {
34166 diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c
34167 index 80ffa5b..a33bd15 100644
34168 --- a/arch/x86/um/tls_32.c
34169 +++ b/arch/x86/um/tls_32.c
34170 @@ -260,7 +260,7 @@ out:
34171 if (unlikely(task == current &&
34172 !t->arch.tls_array[idx - GDT_ENTRY_TLS_MIN].flushed)) {
34173 printk(KERN_ERR "get_tls_entry: task with pid %d got here "
34174 - "without flushed TLS.", current->pid);
34175 + "without flushed TLS.", task_pid_nr(current));
34176 }
34177
34178 return 0;
34179 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
34180 index fd14be1..e3c79c0 100644
34181 --- a/arch/x86/vdso/Makefile
34182 +++ b/arch/x86/vdso/Makefile
34183 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
34184 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
34185 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
34186
34187 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
34188 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
34189 GCOV_PROFILE := n
34190
34191 #
34192 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
34193 index 0faad64..39ef157 100644
34194 --- a/arch/x86/vdso/vdso32-setup.c
34195 +++ b/arch/x86/vdso/vdso32-setup.c
34196 @@ -25,6 +25,7 @@
34197 #include <asm/tlbflush.h>
34198 #include <asm/vdso.h>
34199 #include <asm/proto.h>
34200 +#include <asm/mman.h>
34201
34202 enum {
34203 VDSO_DISABLED = 0,
34204 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
34205 void enable_sep_cpu(void)
34206 {
34207 int cpu = get_cpu();
34208 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
34209 + struct tss_struct *tss = init_tss + cpu;
34210
34211 if (!boot_cpu_has(X86_FEATURE_SEP)) {
34212 put_cpu();
34213 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
34214 gate_vma.vm_start = FIXADDR_USER_START;
34215 gate_vma.vm_end = FIXADDR_USER_END;
34216 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
34217 - gate_vma.vm_page_prot = __P101;
34218 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
34219
34220 return 0;
34221 }
34222 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
34223 if (compat)
34224 addr = VDSO_HIGH_BASE;
34225 else {
34226 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
34227 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
34228 if (IS_ERR_VALUE(addr)) {
34229 ret = addr;
34230 goto up_fail;
34231 }
34232 }
34233
34234 - current->mm->context.vdso = (void *)addr;
34235 + current->mm->context.vdso = addr;
34236
34237 if (compat_uses_vma || !compat) {
34238 /*
34239 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
34240 }
34241
34242 current_thread_info()->sysenter_return =
34243 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
34244 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
34245
34246 up_fail:
34247 if (ret)
34248 - current->mm->context.vdso = NULL;
34249 + current->mm->context.vdso = 0;
34250
34251 up_write(&mm->mmap_sem);
34252
34253 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
34254
34255 const char *arch_vma_name(struct vm_area_struct *vma)
34256 {
34257 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
34258 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
34259 return "[vdso]";
34260 +
34261 +#ifdef CONFIG_PAX_SEGMEXEC
34262 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
34263 + return "[vdso]";
34264 +#endif
34265 +
34266 return NULL;
34267 }
34268
34269 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
34270 * Check to see if the corresponding task was created in compat vdso
34271 * mode.
34272 */
34273 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
34274 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
34275 return &gate_vma;
34276 return NULL;
34277 }
34278 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
34279 index 431e875..cbb23f3 100644
34280 --- a/arch/x86/vdso/vma.c
34281 +++ b/arch/x86/vdso/vma.c
34282 @@ -16,8 +16,6 @@
34283 #include <asm/vdso.h>
34284 #include <asm/page.h>
34285
34286 -unsigned int __read_mostly vdso_enabled = 1;
34287 -
34288 extern char vdso_start[], vdso_end[];
34289 extern unsigned short vdso_sync_cpuid;
34290
34291 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
34292 * unaligned here as a result of stack start randomization.
34293 */
34294 addr = PAGE_ALIGN(addr);
34295 - addr = align_vdso_addr(addr);
34296
34297 return addr;
34298 }
34299 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
34300 unsigned size)
34301 {
34302 struct mm_struct *mm = current->mm;
34303 - unsigned long addr;
34304 + unsigned long addr = 0;
34305 int ret;
34306
34307 - if (!vdso_enabled)
34308 - return 0;
34309 -
34310 down_write(&mm->mmap_sem);
34311 +
34312 +#ifdef CONFIG_PAX_RANDMMAP
34313 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
34314 +#endif
34315 +
34316 addr = vdso_addr(mm->start_stack, size);
34317 + addr = align_vdso_addr(addr);
34318 addr = get_unmapped_area(NULL, addr, size, 0, 0);
34319 if (IS_ERR_VALUE(addr)) {
34320 ret = addr;
34321 goto up_fail;
34322 }
34323
34324 - current->mm->context.vdso = (void *)addr;
34325 + mm->context.vdso = addr;
34326
34327 ret = install_special_mapping(mm, addr, size,
34328 VM_READ|VM_EXEC|
34329 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
34330 pages);
34331 - if (ret) {
34332 - current->mm->context.vdso = NULL;
34333 - goto up_fail;
34334 - }
34335 + if (ret)
34336 + mm->context.vdso = 0;
34337
34338 up_fail:
34339 up_write(&mm->mmap_sem);
34340 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
34341 vdsox32_size);
34342 }
34343 #endif
34344 -
34345 -static __init int vdso_setup(char *s)
34346 -{
34347 - vdso_enabled = simple_strtoul(s, NULL, 0);
34348 - return 0;
34349 -}
34350 -__setup("vdso=", vdso_setup);
34351 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
34352 index a492be2..08678da 100644
34353 --- a/arch/x86/xen/enlighten.c
34354 +++ b/arch/x86/xen/enlighten.c
34355 @@ -123,8 +123,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
34356
34357 struct shared_info xen_dummy_shared_info;
34358
34359 -void *xen_initial_gdt;
34360 -
34361 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
34362 __read_mostly int xen_have_vector_callback;
34363 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
34364 @@ -542,8 +540,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
34365 {
34366 unsigned long va = dtr->address;
34367 unsigned int size = dtr->size + 1;
34368 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
34369 - unsigned long frames[pages];
34370 + unsigned long frames[65536 / PAGE_SIZE];
34371 int f;
34372
34373 /*
34374 @@ -591,8 +588,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
34375 {
34376 unsigned long va = dtr->address;
34377 unsigned int size = dtr->size + 1;
34378 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
34379 - unsigned long frames[pages];
34380 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
34381 int f;
34382
34383 /*
34384 @@ -600,7 +596,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
34385 * 8-byte entries, or 16 4k pages..
34386 */
34387
34388 - BUG_ON(size > 65536);
34389 + BUG_ON(size > GDT_SIZE);
34390 BUG_ON(va & ~PAGE_MASK);
34391
34392 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
34393 @@ -985,7 +981,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
34394 return 0;
34395 }
34396
34397 -static void set_xen_basic_apic_ops(void)
34398 +static void __init set_xen_basic_apic_ops(void)
34399 {
34400 apic->read = xen_apic_read;
34401 apic->write = xen_apic_write;
34402 @@ -1290,30 +1286,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
34403 #endif
34404 };
34405
34406 -static void xen_reboot(int reason)
34407 +static __noreturn void xen_reboot(int reason)
34408 {
34409 struct sched_shutdown r = { .reason = reason };
34410
34411 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
34412 - BUG();
34413 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
34414 + BUG();
34415 }
34416
34417 -static void xen_restart(char *msg)
34418 +static __noreturn void xen_restart(char *msg)
34419 {
34420 xen_reboot(SHUTDOWN_reboot);
34421 }
34422
34423 -static void xen_emergency_restart(void)
34424 +static __noreturn void xen_emergency_restart(void)
34425 {
34426 xen_reboot(SHUTDOWN_reboot);
34427 }
34428
34429 -static void xen_machine_halt(void)
34430 +static __noreturn void xen_machine_halt(void)
34431 {
34432 xen_reboot(SHUTDOWN_poweroff);
34433 }
34434
34435 -static void xen_machine_power_off(void)
34436 +static __noreturn void xen_machine_power_off(void)
34437 {
34438 if (pm_power_off)
34439 pm_power_off();
34440 @@ -1464,7 +1460,17 @@ asmlinkage void __init xen_start_kernel(void)
34441 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
34442
34443 /* Work out if we support NX */
34444 - x86_configure_nx();
34445 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
34446 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
34447 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
34448 + unsigned l, h;
34449 +
34450 + __supported_pte_mask |= _PAGE_NX;
34451 + rdmsr(MSR_EFER, l, h);
34452 + l |= EFER_NX;
34453 + wrmsr(MSR_EFER, l, h);
34454 + }
34455 +#endif
34456
34457 xen_setup_features();
34458
34459 @@ -1495,13 +1501,6 @@ asmlinkage void __init xen_start_kernel(void)
34460
34461 machine_ops = xen_machine_ops;
34462
34463 - /*
34464 - * The only reliable way to retain the initial address of the
34465 - * percpu gdt_page is to remember it here, so we can go and
34466 - * mark it RW later, when the initial percpu area is freed.
34467 - */
34468 - xen_initial_gdt = &per_cpu(gdt_page, 0);
34469 -
34470 xen_smp_init();
34471
34472 #ifdef CONFIG_ACPI_NUMA
34473 @@ -1700,7 +1699,7 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
34474 return NOTIFY_OK;
34475 }
34476
34477 -static struct notifier_block xen_hvm_cpu_notifier __cpuinitdata = {
34478 +static struct notifier_block xen_hvm_cpu_notifier = {
34479 .notifier_call = xen_hvm_cpu_notify,
34480 };
34481
34482 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
34483 index fdc3ba2..3daee39 100644
34484 --- a/arch/x86/xen/mmu.c
34485 +++ b/arch/x86/xen/mmu.c
34486 @@ -1894,6 +1894,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34487 /* L3_k[510] -> level2_kernel_pgt
34488 * L3_i[511] -> level2_fixmap_pgt */
34489 convert_pfn_mfn(level3_kernel_pgt);
34490 + convert_pfn_mfn(level3_vmalloc_start_pgt);
34491 + convert_pfn_mfn(level3_vmalloc_end_pgt);
34492 + convert_pfn_mfn(level3_vmemmap_pgt);
34493
34494 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
34495 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
34496 @@ -1923,8 +1926,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34497 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
34498 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
34499 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
34500 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
34501 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
34502 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
34503 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
34504 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
34505 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
34506 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
34507 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
34508
34509 @@ -2108,6 +2115,7 @@ static void __init xen_post_allocator_init(void)
34510 pv_mmu_ops.set_pud = xen_set_pud;
34511 #if PAGETABLE_LEVELS == 4
34512 pv_mmu_ops.set_pgd = xen_set_pgd;
34513 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
34514 #endif
34515
34516 /* This will work as long as patching hasn't happened yet
34517 @@ -2186,6 +2194,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
34518 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
34519 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
34520 .set_pgd = xen_set_pgd_hyper,
34521 + .set_pgd_batched = xen_set_pgd_hyper,
34522
34523 .alloc_pud = xen_alloc_pmd_init,
34524 .release_pud = xen_release_pmd_init,
34525 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
34526 index a1e58e1..9392ad8 100644
34527 --- a/arch/x86/xen/smp.c
34528 +++ b/arch/x86/xen/smp.c
34529 @@ -240,11 +240,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
34530 {
34531 BUG_ON(smp_processor_id() != 0);
34532 native_smp_prepare_boot_cpu();
34533 -
34534 - /* We've switched to the "real" per-cpu gdt, so make sure the
34535 - old memory can be recycled */
34536 - make_lowmem_page_readwrite(xen_initial_gdt);
34537 -
34538 xen_filter_cpu_maps();
34539 xen_setup_vcpu_info_placement();
34540 }
34541 @@ -314,7 +309,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34542 ctxt->user_regs.ss = __KERNEL_DS;
34543 #ifdef CONFIG_X86_32
34544 ctxt->user_regs.fs = __KERNEL_PERCPU;
34545 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
34546 + savesegment(gs, ctxt->user_regs.gs);
34547 #else
34548 ctxt->gs_base_kernel = per_cpu_offset(cpu);
34549 #endif
34550 @@ -324,8 +319,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34551
34552 {
34553 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
34554 - ctxt->user_regs.ds = __USER_DS;
34555 - ctxt->user_regs.es = __USER_DS;
34556 + ctxt->user_regs.ds = __KERNEL_DS;
34557 + ctxt->user_regs.es = __KERNEL_DS;
34558
34559 xen_copy_trap_info(ctxt->trap_ctxt);
34560
34561 @@ -370,13 +365,12 @@ static int __cpuinit xen_cpu_up(unsigned int cpu, struct task_struct *idle)
34562 int rc;
34563
34564 per_cpu(current_task, cpu) = idle;
34565 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
34566 #ifdef CONFIG_X86_32
34567 irq_ctx_init(cpu);
34568 #else
34569 clear_tsk_thread_flag(idle, TIF_FORK);
34570 - per_cpu(kernel_stack, cpu) =
34571 - (unsigned long)task_stack_page(idle) -
34572 - KERNEL_STACK_OFFSET + THREAD_SIZE;
34573 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
34574 #endif
34575 xen_setup_runstate_info(cpu);
34576 xen_setup_timer(cpu);
34577 @@ -651,7 +645,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
34578
34579 void __init xen_smp_init(void)
34580 {
34581 - smp_ops = xen_smp_ops;
34582 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
34583 xen_fill_possible_map();
34584 xen_init_spinlocks();
34585 }
34586 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
34587 index 33ca6e4..0ded929 100644
34588 --- a/arch/x86/xen/xen-asm_32.S
34589 +++ b/arch/x86/xen/xen-asm_32.S
34590 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
34591 ESP_OFFSET=4 # bytes pushed onto stack
34592
34593 /*
34594 - * Store vcpu_info pointer for easy access. Do it this way to
34595 - * avoid having to reload %fs
34596 + * Store vcpu_info pointer for easy access.
34597 */
34598 #ifdef CONFIG_SMP
34599 - GET_THREAD_INFO(%eax)
34600 - movl %ss:TI_cpu(%eax), %eax
34601 - movl %ss:__per_cpu_offset(,%eax,4), %eax
34602 - mov %ss:xen_vcpu(%eax), %eax
34603 + push %fs
34604 + mov $(__KERNEL_PERCPU), %eax
34605 + mov %eax, %fs
34606 + mov PER_CPU_VAR(xen_vcpu), %eax
34607 + pop %fs
34608 #else
34609 movl %ss:xen_vcpu, %eax
34610 #endif
34611 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
34612 index 7faed58..ba4427c 100644
34613 --- a/arch/x86/xen/xen-head.S
34614 +++ b/arch/x86/xen/xen-head.S
34615 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
34616 #ifdef CONFIG_X86_32
34617 mov %esi,xen_start_info
34618 mov $init_thread_union+THREAD_SIZE,%esp
34619 +#ifdef CONFIG_SMP
34620 + movl $cpu_gdt_table,%edi
34621 + movl $__per_cpu_load,%eax
34622 + movw %ax,__KERNEL_PERCPU + 2(%edi)
34623 + rorl $16,%eax
34624 + movb %al,__KERNEL_PERCPU + 4(%edi)
34625 + movb %ah,__KERNEL_PERCPU + 7(%edi)
34626 + movl $__per_cpu_end - 1,%eax
34627 + subl $__per_cpu_start,%eax
34628 + movw %ax,__KERNEL_PERCPU + 0(%edi)
34629 +#endif
34630 #else
34631 mov %rsi,xen_start_info
34632 mov $init_thread_union+THREAD_SIZE,%rsp
34633 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
34634 index a95b417..b6dbd0b 100644
34635 --- a/arch/x86/xen/xen-ops.h
34636 +++ b/arch/x86/xen/xen-ops.h
34637 @@ -10,8 +10,6 @@
34638 extern const char xen_hypervisor_callback[];
34639 extern const char xen_failsafe_callback[];
34640
34641 -extern void *xen_initial_gdt;
34642 -
34643 struct trap_info;
34644 void xen_copy_trap_info(struct trap_info *traps);
34645
34646 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
34647 index 525bd3d..ef888b1 100644
34648 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
34649 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
34650 @@ -119,9 +119,9 @@
34651 ----------------------------------------------------------------------*/
34652
34653 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
34654 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
34655 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
34656 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
34657 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34658
34659 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
34660 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
34661 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
34662 index 2f33760..835e50a 100644
34663 --- a/arch/xtensa/variants/fsf/include/variant/core.h
34664 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
34665 @@ -11,6 +11,7 @@
34666 #ifndef _XTENSA_CORE_H
34667 #define _XTENSA_CORE_H
34668
34669 +#include <linux/const.h>
34670
34671 /****************************************************************************
34672 Parameters Useful for Any Code, USER or PRIVILEGED
34673 @@ -112,9 +113,9 @@
34674 ----------------------------------------------------------------------*/
34675
34676 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
34677 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
34678 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
34679 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
34680 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34681
34682 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
34683 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
34684 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
34685 index af00795..2bb8105 100644
34686 --- a/arch/xtensa/variants/s6000/include/variant/core.h
34687 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
34688 @@ -11,6 +11,7 @@
34689 #ifndef _XTENSA_CORE_CONFIGURATION_H
34690 #define _XTENSA_CORE_CONFIGURATION_H
34691
34692 +#include <linux/const.h>
34693
34694 /****************************************************************************
34695 Parameters Useful for Any Code, USER or PRIVILEGED
34696 @@ -118,9 +119,9 @@
34697 ----------------------------------------------------------------------*/
34698
34699 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
34700 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
34701 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
34702 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
34703 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34704
34705 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
34706 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
34707 diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
34708 index e8918ff..b3ffc51 100644
34709 --- a/block/blk-cgroup.c
34710 +++ b/block/blk-cgroup.c
34711 @@ -825,7 +825,7 @@ static void blkcg_css_free(struct cgroup *cgroup)
34712
34713 static struct cgroup_subsys_state *blkcg_css_alloc(struct cgroup *cgroup)
34714 {
34715 - static atomic64_t id_seq = ATOMIC64_INIT(0);
34716 + static atomic64_unchecked_t id_seq = ATOMIC64_INIT(0);
34717 struct blkcg *blkcg;
34718 struct cgroup *parent = cgroup->parent;
34719
34720 @@ -840,7 +840,7 @@ static struct cgroup_subsys_state *blkcg_css_alloc(struct cgroup *cgroup)
34721
34722 blkcg->cfq_weight = CFQ_WEIGHT_DEFAULT;
34723 blkcg->cfq_leaf_weight = CFQ_WEIGHT_DEFAULT;
34724 - blkcg->id = atomic64_inc_return(&id_seq); /* root is 0, start from 1 */
34725 + blkcg->id = atomic64_inc_return_unchecked(&id_seq); /* root is 0, start from 1 */
34726 done:
34727 spin_lock_init(&blkcg->lock);
34728 INIT_RADIX_TREE(&blkcg->blkg_tree, GFP_ATOMIC);
34729 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
34730 index 58916af..eb9dbcf6 100644
34731 --- a/block/blk-iopoll.c
34732 +++ b/block/blk-iopoll.c
34733 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
34734 }
34735 EXPORT_SYMBOL(blk_iopoll_complete);
34736
34737 -static void blk_iopoll_softirq(struct softirq_action *h)
34738 +static void blk_iopoll_softirq(void)
34739 {
34740 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
34741 int rearm = 0, budget = blk_iopoll_budget;
34742 @@ -209,7 +209,7 @@ static int __cpuinit blk_iopoll_cpu_notify(struct notifier_block *self,
34743 return NOTIFY_OK;
34744 }
34745
34746 -static struct notifier_block __cpuinitdata blk_iopoll_cpu_notifier = {
34747 +static struct notifier_block blk_iopoll_cpu_notifier = {
34748 .notifier_call = blk_iopoll_cpu_notify,
34749 };
34750
34751 diff --git a/block/blk-map.c b/block/blk-map.c
34752 index 623e1cd..ca1e109 100644
34753 --- a/block/blk-map.c
34754 +++ b/block/blk-map.c
34755 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
34756 if (!len || !kbuf)
34757 return -EINVAL;
34758
34759 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
34760 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
34761 if (do_copy)
34762 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
34763 else
34764 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
34765 index 467c8de..f3628c5 100644
34766 --- a/block/blk-softirq.c
34767 +++ b/block/blk-softirq.c
34768 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
34769 * Softirq action handler - move entries to local list and loop over them
34770 * while passing them to the queue registered handler.
34771 */
34772 -static void blk_done_softirq(struct softirq_action *h)
34773 +static void blk_done_softirq(void)
34774 {
34775 struct list_head *cpu_list, local_list;
34776
34777 @@ -98,7 +98,7 @@ static int __cpuinit blk_cpu_notify(struct notifier_block *self,
34778 return NOTIFY_OK;
34779 }
34780
34781 -static struct notifier_block __cpuinitdata blk_cpu_notifier = {
34782 +static struct notifier_block blk_cpu_notifier = {
34783 .notifier_call = blk_cpu_notify,
34784 };
34785
34786 diff --git a/block/bsg.c b/block/bsg.c
34787 index 420a5a9..23834aa 100644
34788 --- a/block/bsg.c
34789 +++ b/block/bsg.c
34790 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
34791 struct sg_io_v4 *hdr, struct bsg_device *bd,
34792 fmode_t has_write_perm)
34793 {
34794 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34795 + unsigned char *cmdptr;
34796 +
34797 if (hdr->request_len > BLK_MAX_CDB) {
34798 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
34799 if (!rq->cmd)
34800 return -ENOMEM;
34801 - }
34802 + cmdptr = rq->cmd;
34803 + } else
34804 + cmdptr = tmpcmd;
34805
34806 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
34807 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
34808 hdr->request_len))
34809 return -EFAULT;
34810
34811 + if (cmdptr != rq->cmd)
34812 + memcpy(rq->cmd, cmdptr, hdr->request_len);
34813 +
34814 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
34815 if (blk_verify_command(rq->cmd, has_write_perm))
34816 return -EPERM;
34817 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
34818 index 7c668c8..db3521c 100644
34819 --- a/block/compat_ioctl.c
34820 +++ b/block/compat_ioctl.c
34821 @@ -340,7 +340,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
34822 err |= __get_user(f->spec1, &uf->spec1);
34823 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
34824 err |= __get_user(name, &uf->name);
34825 - f->name = compat_ptr(name);
34826 + f->name = (void __force_kernel *)compat_ptr(name);
34827 if (err) {
34828 err = -EFAULT;
34829 goto out;
34830 diff --git a/block/genhd.c b/block/genhd.c
34831 index cdeb527..10aa34db 100644
34832 --- a/block/genhd.c
34833 +++ b/block/genhd.c
34834 @@ -467,21 +467,24 @@ static char *bdevt_str(dev_t devt, char *buf)
34835
34836 /*
34837 * Register device numbers dev..(dev+range-1)
34838 - * range must be nonzero
34839 + * Noop if @range is zero.
34840 * The hash chain is sorted on range, so that subranges can override.
34841 */
34842 void blk_register_region(dev_t devt, unsigned long range, struct module *module,
34843 struct kobject *(*probe)(dev_t, int *, void *),
34844 int (*lock)(dev_t, void *), void *data)
34845 {
34846 - kobj_map(bdev_map, devt, range, module, probe, lock, data);
34847 + if (range)
34848 + kobj_map(bdev_map, devt, range, module, probe, lock, data);
34849 }
34850
34851 EXPORT_SYMBOL(blk_register_region);
34852
34853 +/* undo blk_register_region(), noop if @range is zero */
34854 void blk_unregister_region(dev_t devt, unsigned long range)
34855 {
34856 - kobj_unmap(bdev_map, devt, range);
34857 + if (range)
34858 + kobj_unmap(bdev_map, devt, range);
34859 }
34860
34861 EXPORT_SYMBOL(blk_unregister_region);
34862 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
34863 index c85fc89..51e690b 100644
34864 --- a/block/partitions/efi.c
34865 +++ b/block/partitions/efi.c
34866 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
34867 if (!gpt)
34868 return NULL;
34869
34870 + if (!le32_to_cpu(gpt->num_partition_entries))
34871 + return NULL;
34872 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
34873 + if (!pte)
34874 + return NULL;
34875 +
34876 count = le32_to_cpu(gpt->num_partition_entries) *
34877 le32_to_cpu(gpt->sizeof_partition_entry);
34878 - if (!count)
34879 - return NULL;
34880 - pte = kmalloc(count, GFP_KERNEL);
34881 - if (!pte)
34882 - return NULL;
34883 -
34884 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
34885 (u8 *) pte,
34886 count) < count) {
34887 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
34888 index a5ffcc9..3cedc9c 100644
34889 --- a/block/scsi_ioctl.c
34890 +++ b/block/scsi_ioctl.c
34891 @@ -224,8 +224,20 @@ EXPORT_SYMBOL(blk_verify_command);
34892 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
34893 struct sg_io_hdr *hdr, fmode_t mode)
34894 {
34895 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
34896 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34897 + unsigned char *cmdptr;
34898 +
34899 + if (rq->cmd != rq->__cmd)
34900 + cmdptr = rq->cmd;
34901 + else
34902 + cmdptr = tmpcmd;
34903 +
34904 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
34905 return -EFAULT;
34906 +
34907 + if (cmdptr != rq->cmd)
34908 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
34909 +
34910 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
34911 return -EPERM;
34912
34913 @@ -434,6 +446,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
34914 int err;
34915 unsigned int in_len, out_len, bytes, opcode, cmdlen;
34916 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
34917 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34918 + unsigned char *cmdptr;
34919
34920 if (!sic)
34921 return -EINVAL;
34922 @@ -467,9 +481,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
34923 */
34924 err = -EFAULT;
34925 rq->cmd_len = cmdlen;
34926 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
34927 +
34928 + if (rq->cmd != rq->__cmd)
34929 + cmdptr = rq->cmd;
34930 + else
34931 + cmdptr = tmpcmd;
34932 +
34933 + if (copy_from_user(cmdptr, sic->data, cmdlen))
34934 goto error;
34935
34936 + if (rq->cmd != cmdptr)
34937 + memcpy(rq->cmd, cmdptr, cmdlen);
34938 +
34939 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
34940 goto error;
34941
34942 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
34943 index 7bdd61b..afec999 100644
34944 --- a/crypto/cryptd.c
34945 +++ b/crypto/cryptd.c
34946 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
34947
34948 struct cryptd_blkcipher_request_ctx {
34949 crypto_completion_t complete;
34950 -};
34951 +} __no_const;
34952
34953 struct cryptd_hash_ctx {
34954 struct crypto_shash *child;
34955 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
34956
34957 struct cryptd_aead_request_ctx {
34958 crypto_completion_t complete;
34959 -};
34960 +} __no_const;
34961
34962 static void cryptd_queue_worker(struct work_struct *work);
34963
34964 diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
34965 index b2c99dc..476c9fb 100644
34966 --- a/crypto/pcrypt.c
34967 +++ b/crypto/pcrypt.c
34968 @@ -440,7 +440,7 @@ static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name)
34969 int ret;
34970
34971 pinst->kobj.kset = pcrypt_kset;
34972 - ret = kobject_add(&pinst->kobj, NULL, name);
34973 + ret = kobject_add(&pinst->kobj, NULL, "%s", name);
34974 if (!ret)
34975 kobject_uevent(&pinst->kobj, KOBJ_ADD);
34976
34977 @@ -455,8 +455,8 @@ static int pcrypt_init_padata(struct padata_pcrypt *pcrypt,
34978
34979 get_online_cpus();
34980
34981 - pcrypt->wq = alloc_workqueue(name,
34982 - WQ_MEM_RECLAIM | WQ_CPU_INTENSIVE, 1);
34983 + pcrypt->wq = alloc_workqueue("%s",
34984 + WQ_MEM_RECLAIM | WQ_CPU_INTENSIVE, 1, name);
34985 if (!pcrypt->wq)
34986 goto err;
34987
34988 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
34989 index f220d64..d359ad6 100644
34990 --- a/drivers/acpi/apei/apei-internal.h
34991 +++ b/drivers/acpi/apei/apei-internal.h
34992 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
34993 struct apei_exec_ins_type {
34994 u32 flags;
34995 apei_exec_ins_func_t run;
34996 -};
34997 +} __do_const;
34998
34999 struct apei_exec_context {
35000 u32 ip;
35001 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
35002 index 33dc6a0..4b24b47 100644
35003 --- a/drivers/acpi/apei/cper.c
35004 +++ b/drivers/acpi/apei/cper.c
35005 @@ -39,12 +39,12 @@
35006 */
35007 u64 cper_next_record_id(void)
35008 {
35009 - static atomic64_t seq;
35010 + static atomic64_unchecked_t seq;
35011
35012 - if (!atomic64_read(&seq))
35013 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
35014 + if (!atomic64_read_unchecked(&seq))
35015 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
35016
35017 - return atomic64_inc_return(&seq);
35018 + return atomic64_inc_return_unchecked(&seq);
35019 }
35020 EXPORT_SYMBOL_GPL(cper_next_record_id);
35021
35022 diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
35023 index fcd7d91..6b2f1a3 100644
35024 --- a/drivers/acpi/apei/ghes.c
35025 +++ b/drivers/acpi/apei/ghes.c
35026 @@ -468,7 +468,7 @@ static void __ghes_print_estatus(const char *pfx,
35027 const struct acpi_hest_generic *generic,
35028 const struct acpi_hest_generic_status *estatus)
35029 {
35030 - static atomic_t seqno;
35031 + static atomic_unchecked_t seqno;
35032 unsigned int curr_seqno;
35033 char pfx_seq[64];
35034
35035 @@ -479,7 +479,7 @@ static void __ghes_print_estatus(const char *pfx,
35036 else
35037 pfx = KERN_ERR;
35038 }
35039 - curr_seqno = atomic_inc_return(&seqno);
35040 + curr_seqno = atomic_inc_return_unchecked(&seqno);
35041 snprintf(pfx_seq, sizeof(pfx_seq), "%s{%u}" HW_ERR, pfx, curr_seqno);
35042 printk("%s""Hardware error from APEI Generic Hardware Error Source: %d\n",
35043 pfx_seq, generic->header.source_id);
35044 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
35045 index be60399..778b33e8 100644
35046 --- a/drivers/acpi/bgrt.c
35047 +++ b/drivers/acpi/bgrt.c
35048 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
35049 return -ENODEV;
35050
35051 sysfs_bin_attr_init(&image_attr);
35052 - image_attr.private = bgrt_image;
35053 - image_attr.size = bgrt_image_size;
35054 + pax_open_kernel();
35055 + *(void **)&image_attr.private = bgrt_image;
35056 + *(size_t *)&image_attr.size = bgrt_image_size;
35057 + pax_close_kernel();
35058
35059 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
35060 if (!bgrt_kobj)
35061 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
35062 index cb96296..b81293b 100644
35063 --- a/drivers/acpi/blacklist.c
35064 +++ b/drivers/acpi/blacklist.c
35065 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
35066 u32 is_critical_error;
35067 };
35068
35069 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
35070 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
35071
35072 /*
35073 * POLICY: If *anything* doesn't work, put it on the blacklist.
35074 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
35075 return 0;
35076 }
35077
35078 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
35079 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
35080 {
35081 .callback = dmi_disable_osi_vista,
35082 .ident = "Fujitsu Siemens",
35083 diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
35084 index 7586544..636a2f0 100644
35085 --- a/drivers/acpi/ec_sys.c
35086 +++ b/drivers/acpi/ec_sys.c
35087 @@ -12,6 +12,7 @@
35088 #include <linux/acpi.h>
35089 #include <linux/debugfs.h>
35090 #include <linux/module.h>
35091 +#include <linux/uaccess.h>
35092 #include "internal.h"
35093
35094 MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
35095 @@ -34,7 +35,7 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
35096 * struct acpi_ec *ec = ((struct seq_file *)f->private_data)->private;
35097 */
35098 unsigned int size = EC_SPACE_SIZE;
35099 - u8 *data = (u8 *) buf;
35100 + u8 data;
35101 loff_t init_off = *off;
35102 int err = 0;
35103
35104 @@ -47,9 +48,11 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
35105 size = count;
35106
35107 while (size) {
35108 - err = ec_read(*off, &data[*off - init_off]);
35109 + err = ec_read(*off, &data);
35110 if (err)
35111 return err;
35112 + if (put_user(data, &buf[*off - init_off]))
35113 + return -EFAULT;
35114 *off += 1;
35115 size--;
35116 }
35117 @@ -65,7 +68,6 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
35118
35119 unsigned int size = count;
35120 loff_t init_off = *off;
35121 - u8 *data = (u8 *) buf;
35122 int err = 0;
35123
35124 if (*off >= EC_SPACE_SIZE)
35125 @@ -76,7 +78,9 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
35126 }
35127
35128 while (size) {
35129 - u8 byte_write = data[*off - init_off];
35130 + u8 byte_write;
35131 + if (get_user(byte_write, &buf[*off - init_off]))
35132 + return -EFAULT;
35133 err = ec_write(*off, byte_write);
35134 if (err)
35135 return err;
35136 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
35137 index eb133c7..f571552 100644
35138 --- a/drivers/acpi/processor_idle.c
35139 +++ b/drivers/acpi/processor_idle.c
35140 @@ -994,7 +994,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
35141 {
35142 int i, count = CPUIDLE_DRIVER_STATE_START;
35143 struct acpi_processor_cx *cx;
35144 - struct cpuidle_state *state;
35145 + cpuidle_state_no_const *state;
35146 struct cpuidle_driver *drv = &acpi_idle_driver;
35147
35148 if (!pr->flags.power_setup_done)
35149 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
35150 index fcae5fa..e9f71ea 100644
35151 --- a/drivers/acpi/sysfs.c
35152 +++ b/drivers/acpi/sysfs.c
35153 @@ -423,11 +423,11 @@ static u32 num_counters;
35154 static struct attribute **all_attrs;
35155 static u32 acpi_gpe_count;
35156
35157 -static struct attribute_group interrupt_stats_attr_group = {
35158 +static attribute_group_no_const interrupt_stats_attr_group = {
35159 .name = "interrupts",
35160 };
35161
35162 -static struct kobj_attribute *counter_attrs;
35163 +static kobj_attribute_no_const *counter_attrs;
35164
35165 static void delete_gpe_attr_array(void)
35166 {
35167 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
35168 index 7b9bdd8..37638ca 100644
35169 --- a/drivers/ata/libahci.c
35170 +++ b/drivers/ata/libahci.c
35171 @@ -1230,7 +1230,7 @@ int ahci_kick_engine(struct ata_port *ap)
35172 }
35173 EXPORT_SYMBOL_GPL(ahci_kick_engine);
35174
35175 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
35176 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
35177 struct ata_taskfile *tf, int is_cmd, u16 flags,
35178 unsigned long timeout_msec)
35179 {
35180 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
35181 index adf002a..06c46a7 100644
35182 --- a/drivers/ata/libata-core.c
35183 +++ b/drivers/ata/libata-core.c
35184 @@ -98,7 +98,7 @@ static unsigned int ata_dev_set_xfermode(struct ata_device *dev);
35185 static void ata_dev_xfermask(struct ata_device *dev);
35186 static unsigned long ata_dev_blacklisted(const struct ata_device *dev);
35187
35188 -atomic_t ata_print_id = ATOMIC_INIT(0);
35189 +atomic_unchecked_t ata_print_id = ATOMIC_INIT(0);
35190
35191 struct ata_force_param {
35192 const char *name;
35193 @@ -4792,7 +4792,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
35194 struct ata_port *ap;
35195 unsigned int tag;
35196
35197 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
35198 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
35199 ap = qc->ap;
35200
35201 qc->flags = 0;
35202 @@ -4808,7 +4808,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
35203 struct ata_port *ap;
35204 struct ata_link *link;
35205
35206 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
35207 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
35208 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
35209 ap = qc->ap;
35210 link = qc->dev->link;
35211 @@ -5926,6 +5926,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
35212 return;
35213
35214 spin_lock(&lock);
35215 + pax_open_kernel();
35216
35217 for (cur = ops->inherits; cur; cur = cur->inherits) {
35218 void **inherit = (void **)cur;
35219 @@ -5939,8 +5940,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
35220 if (IS_ERR(*pp))
35221 *pp = NULL;
35222
35223 - ops->inherits = NULL;
35224 + *(struct ata_port_operations **)&ops->inherits = NULL;
35225
35226 + pax_close_kernel();
35227 spin_unlock(&lock);
35228 }
35229
35230 @@ -6133,7 +6135,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
35231
35232 /* give ports names and add SCSI hosts */
35233 for (i = 0; i < host->n_ports; i++)
35234 - host->ports[i]->print_id = atomic_inc_return(&ata_print_id);
35235 + host->ports[i]->print_id = atomic_inc_return_unchecked(&ata_print_id);
35236
35237
35238 /* Create associated sysfs transport objects */
35239 diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
35240 index 0101af5..c70c325 100644
35241 --- a/drivers/ata/libata-scsi.c
35242 +++ b/drivers/ata/libata-scsi.c
35243 @@ -4105,7 +4105,7 @@ int ata_sas_port_init(struct ata_port *ap)
35244
35245 if (rc)
35246 return rc;
35247 - ap->print_id = atomic_inc_return(&ata_print_id);
35248 + ap->print_id = atomic_inc_return_unchecked(&ata_print_id);
35249 return 0;
35250 }
35251 EXPORT_SYMBOL_GPL(ata_sas_port_init);
35252 diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
35253 index 577d902b..cb4781e 100644
35254 --- a/drivers/ata/libata.h
35255 +++ b/drivers/ata/libata.h
35256 @@ -53,7 +53,7 @@ enum {
35257 ATA_DNXFER_QUIET = (1 << 31),
35258 };
35259
35260 -extern atomic_t ata_print_id;
35261 +extern atomic_unchecked_t ata_print_id;
35262 extern int atapi_passthru16;
35263 extern int libata_fua;
35264 extern int libata_noacpi;
35265 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
35266 index 7638121..357a965 100644
35267 --- a/drivers/ata/pata_arasan_cf.c
35268 +++ b/drivers/ata/pata_arasan_cf.c
35269 @@ -865,7 +865,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
35270 /* Handle platform specific quirks */
35271 if (quirk) {
35272 if (quirk & CF_BROKEN_PIO) {
35273 - ap->ops->set_piomode = NULL;
35274 + pax_open_kernel();
35275 + *(void **)&ap->ops->set_piomode = NULL;
35276 + pax_close_kernel();
35277 ap->pio_mask = 0;
35278 }
35279 if (quirk & CF_BROKEN_MWDMA)
35280 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
35281 index f9b983a..887b9d8 100644
35282 --- a/drivers/atm/adummy.c
35283 +++ b/drivers/atm/adummy.c
35284 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
35285 vcc->pop(vcc, skb);
35286 else
35287 dev_kfree_skb_any(skb);
35288 - atomic_inc(&vcc->stats->tx);
35289 + atomic_inc_unchecked(&vcc->stats->tx);
35290
35291 return 0;
35292 }
35293 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
35294 index 77a7480d..05cde58 100644
35295 --- a/drivers/atm/ambassador.c
35296 +++ b/drivers/atm/ambassador.c
35297 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
35298 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
35299
35300 // VC layer stats
35301 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
35302 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
35303
35304 // free the descriptor
35305 kfree (tx_descr);
35306 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
35307 dump_skb ("<<<", vc, skb);
35308
35309 // VC layer stats
35310 - atomic_inc(&atm_vcc->stats->rx);
35311 + atomic_inc_unchecked(&atm_vcc->stats->rx);
35312 __net_timestamp(skb);
35313 // end of our responsibility
35314 atm_vcc->push (atm_vcc, skb);
35315 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
35316 } else {
35317 PRINTK (KERN_INFO, "dropped over-size frame");
35318 // should we count this?
35319 - atomic_inc(&atm_vcc->stats->rx_drop);
35320 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
35321 }
35322
35323 } else {
35324 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
35325 }
35326
35327 if (check_area (skb->data, skb->len)) {
35328 - atomic_inc(&atm_vcc->stats->tx_err);
35329 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
35330 return -ENOMEM; // ?
35331 }
35332
35333 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
35334 index 0e3f8f9..765a7a5 100644
35335 --- a/drivers/atm/atmtcp.c
35336 +++ b/drivers/atm/atmtcp.c
35337 @@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
35338 if (vcc->pop) vcc->pop(vcc,skb);
35339 else dev_kfree_skb(skb);
35340 if (dev_data) return 0;
35341 - atomic_inc(&vcc->stats->tx_err);
35342 + atomic_inc_unchecked(&vcc->stats->tx_err);
35343 return -ENOLINK;
35344 }
35345 size = skb->len+sizeof(struct atmtcp_hdr);
35346 @@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
35347 if (!new_skb) {
35348 if (vcc->pop) vcc->pop(vcc,skb);
35349 else dev_kfree_skb(skb);
35350 - atomic_inc(&vcc->stats->tx_err);
35351 + atomic_inc_unchecked(&vcc->stats->tx_err);
35352 return -ENOBUFS;
35353 }
35354 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
35355 @@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
35356 if (vcc->pop) vcc->pop(vcc,skb);
35357 else dev_kfree_skb(skb);
35358 out_vcc->push(out_vcc,new_skb);
35359 - atomic_inc(&vcc->stats->tx);
35360 - atomic_inc(&out_vcc->stats->rx);
35361 + atomic_inc_unchecked(&vcc->stats->tx);
35362 + atomic_inc_unchecked(&out_vcc->stats->rx);
35363 return 0;
35364 }
35365
35366 @@ -299,7 +299,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
35367 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
35368 read_unlock(&vcc_sklist_lock);
35369 if (!out_vcc) {
35370 - atomic_inc(&vcc->stats->tx_err);
35371 + atomic_inc_unchecked(&vcc->stats->tx_err);
35372 goto done;
35373 }
35374 skb_pull(skb,sizeof(struct atmtcp_hdr));
35375 @@ -311,8 +311,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
35376 __net_timestamp(new_skb);
35377 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
35378 out_vcc->push(out_vcc,new_skb);
35379 - atomic_inc(&vcc->stats->tx);
35380 - atomic_inc(&out_vcc->stats->rx);
35381 + atomic_inc_unchecked(&vcc->stats->tx);
35382 + atomic_inc_unchecked(&out_vcc->stats->rx);
35383 done:
35384 if (vcc->pop) vcc->pop(vcc,skb);
35385 else dev_kfree_skb(skb);
35386 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
35387 index b1955ba..b179940 100644
35388 --- a/drivers/atm/eni.c
35389 +++ b/drivers/atm/eni.c
35390 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
35391 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
35392 vcc->dev->number);
35393 length = 0;
35394 - atomic_inc(&vcc->stats->rx_err);
35395 + atomic_inc_unchecked(&vcc->stats->rx_err);
35396 }
35397 else {
35398 length = ATM_CELL_SIZE-1; /* no HEC */
35399 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
35400 size);
35401 }
35402 eff = length = 0;
35403 - atomic_inc(&vcc->stats->rx_err);
35404 + atomic_inc_unchecked(&vcc->stats->rx_err);
35405 }
35406 else {
35407 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
35408 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
35409 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
35410 vcc->dev->number,vcc->vci,length,size << 2,descr);
35411 length = eff = 0;
35412 - atomic_inc(&vcc->stats->rx_err);
35413 + atomic_inc_unchecked(&vcc->stats->rx_err);
35414 }
35415 }
35416 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
35417 @@ -767,7 +767,7 @@ rx_dequeued++;
35418 vcc->push(vcc,skb);
35419 pushed++;
35420 }
35421 - atomic_inc(&vcc->stats->rx);
35422 + atomic_inc_unchecked(&vcc->stats->rx);
35423 }
35424 wake_up(&eni_dev->rx_wait);
35425 }
35426 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
35427 PCI_DMA_TODEVICE);
35428 if (vcc->pop) vcc->pop(vcc,skb);
35429 else dev_kfree_skb_irq(skb);
35430 - atomic_inc(&vcc->stats->tx);
35431 + atomic_inc_unchecked(&vcc->stats->tx);
35432 wake_up(&eni_dev->tx_wait);
35433 dma_complete++;
35434 }
35435 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
35436 index b41c948..a002b17 100644
35437 --- a/drivers/atm/firestream.c
35438 +++ b/drivers/atm/firestream.c
35439 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
35440 }
35441 }
35442
35443 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
35444 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
35445
35446 fs_dprintk (FS_DEBUG_TXMEM, "i");
35447 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
35448 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
35449 #endif
35450 skb_put (skb, qe->p1 & 0xffff);
35451 ATM_SKB(skb)->vcc = atm_vcc;
35452 - atomic_inc(&atm_vcc->stats->rx);
35453 + atomic_inc_unchecked(&atm_vcc->stats->rx);
35454 __net_timestamp(skb);
35455 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
35456 atm_vcc->push (atm_vcc, skb);
35457 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
35458 kfree (pe);
35459 }
35460 if (atm_vcc)
35461 - atomic_inc(&atm_vcc->stats->rx_drop);
35462 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
35463 break;
35464 case 0x1f: /* Reassembly abort: no buffers. */
35465 /* Silently increment error counter. */
35466 if (atm_vcc)
35467 - atomic_inc(&atm_vcc->stats->rx_drop);
35468 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
35469 break;
35470 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
35471 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
35472 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
35473 index 204814e..cede831 100644
35474 --- a/drivers/atm/fore200e.c
35475 +++ b/drivers/atm/fore200e.c
35476 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
35477 #endif
35478 /* check error condition */
35479 if (*entry->status & STATUS_ERROR)
35480 - atomic_inc(&vcc->stats->tx_err);
35481 + atomic_inc_unchecked(&vcc->stats->tx_err);
35482 else
35483 - atomic_inc(&vcc->stats->tx);
35484 + atomic_inc_unchecked(&vcc->stats->tx);
35485 }
35486 }
35487
35488 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
35489 if (skb == NULL) {
35490 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
35491
35492 - atomic_inc(&vcc->stats->rx_drop);
35493 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35494 return -ENOMEM;
35495 }
35496
35497 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
35498
35499 dev_kfree_skb_any(skb);
35500
35501 - atomic_inc(&vcc->stats->rx_drop);
35502 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35503 return -ENOMEM;
35504 }
35505
35506 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35507
35508 vcc->push(vcc, skb);
35509 - atomic_inc(&vcc->stats->rx);
35510 + atomic_inc_unchecked(&vcc->stats->rx);
35511
35512 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35513
35514 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
35515 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
35516 fore200e->atm_dev->number,
35517 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
35518 - atomic_inc(&vcc->stats->rx_err);
35519 + atomic_inc_unchecked(&vcc->stats->rx_err);
35520 }
35521 }
35522
35523 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
35524 goto retry_here;
35525 }
35526
35527 - atomic_inc(&vcc->stats->tx_err);
35528 + atomic_inc_unchecked(&vcc->stats->tx_err);
35529
35530 fore200e->tx_sat++;
35531 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
35532 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
35533 index 507362a..a845e57 100644
35534 --- a/drivers/atm/he.c
35535 +++ b/drivers/atm/he.c
35536 @@ -1698,7 +1698,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35537
35538 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
35539 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
35540 - atomic_inc(&vcc->stats->rx_drop);
35541 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35542 goto return_host_buffers;
35543 }
35544
35545 @@ -1725,7 +1725,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35546 RBRQ_LEN_ERR(he_dev->rbrq_head)
35547 ? "LEN_ERR" : "",
35548 vcc->vpi, vcc->vci);
35549 - atomic_inc(&vcc->stats->rx_err);
35550 + atomic_inc_unchecked(&vcc->stats->rx_err);
35551 goto return_host_buffers;
35552 }
35553
35554 @@ -1777,7 +1777,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35555 vcc->push(vcc, skb);
35556 spin_lock(&he_dev->global_lock);
35557
35558 - atomic_inc(&vcc->stats->rx);
35559 + atomic_inc_unchecked(&vcc->stats->rx);
35560
35561 return_host_buffers:
35562 ++pdus_assembled;
35563 @@ -2103,7 +2103,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
35564 tpd->vcc->pop(tpd->vcc, tpd->skb);
35565 else
35566 dev_kfree_skb_any(tpd->skb);
35567 - atomic_inc(&tpd->vcc->stats->tx_err);
35568 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
35569 }
35570 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
35571 return;
35572 @@ -2515,7 +2515,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35573 vcc->pop(vcc, skb);
35574 else
35575 dev_kfree_skb_any(skb);
35576 - atomic_inc(&vcc->stats->tx_err);
35577 + atomic_inc_unchecked(&vcc->stats->tx_err);
35578 return -EINVAL;
35579 }
35580
35581 @@ -2526,7 +2526,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35582 vcc->pop(vcc, skb);
35583 else
35584 dev_kfree_skb_any(skb);
35585 - atomic_inc(&vcc->stats->tx_err);
35586 + atomic_inc_unchecked(&vcc->stats->tx_err);
35587 return -EINVAL;
35588 }
35589 #endif
35590 @@ -2538,7 +2538,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35591 vcc->pop(vcc, skb);
35592 else
35593 dev_kfree_skb_any(skb);
35594 - atomic_inc(&vcc->stats->tx_err);
35595 + atomic_inc_unchecked(&vcc->stats->tx_err);
35596 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35597 return -ENOMEM;
35598 }
35599 @@ -2580,7 +2580,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35600 vcc->pop(vcc, skb);
35601 else
35602 dev_kfree_skb_any(skb);
35603 - atomic_inc(&vcc->stats->tx_err);
35604 + atomic_inc_unchecked(&vcc->stats->tx_err);
35605 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35606 return -ENOMEM;
35607 }
35608 @@ -2611,7 +2611,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35609 __enqueue_tpd(he_dev, tpd, cid);
35610 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35611
35612 - atomic_inc(&vcc->stats->tx);
35613 + atomic_inc_unchecked(&vcc->stats->tx);
35614
35615 return 0;
35616 }
35617 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
35618 index 1dc0519..1aadaf7 100644
35619 --- a/drivers/atm/horizon.c
35620 +++ b/drivers/atm/horizon.c
35621 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
35622 {
35623 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
35624 // VC layer stats
35625 - atomic_inc(&vcc->stats->rx);
35626 + atomic_inc_unchecked(&vcc->stats->rx);
35627 __net_timestamp(skb);
35628 // end of our responsibility
35629 vcc->push (vcc, skb);
35630 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
35631 dev->tx_iovec = NULL;
35632
35633 // VC layer stats
35634 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
35635 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
35636
35637 // free the skb
35638 hrz_kfree_skb (skb);
35639 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
35640 index 272f009..a18ba55 100644
35641 --- a/drivers/atm/idt77252.c
35642 +++ b/drivers/atm/idt77252.c
35643 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
35644 else
35645 dev_kfree_skb(skb);
35646
35647 - atomic_inc(&vcc->stats->tx);
35648 + atomic_inc_unchecked(&vcc->stats->tx);
35649 }
35650
35651 atomic_dec(&scq->used);
35652 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35653 if ((sb = dev_alloc_skb(64)) == NULL) {
35654 printk("%s: Can't allocate buffers for aal0.\n",
35655 card->name);
35656 - atomic_add(i, &vcc->stats->rx_drop);
35657 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
35658 break;
35659 }
35660 if (!atm_charge(vcc, sb->truesize)) {
35661 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
35662 card->name);
35663 - atomic_add(i - 1, &vcc->stats->rx_drop);
35664 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
35665 dev_kfree_skb(sb);
35666 break;
35667 }
35668 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35669 ATM_SKB(sb)->vcc = vcc;
35670 __net_timestamp(sb);
35671 vcc->push(vcc, sb);
35672 - atomic_inc(&vcc->stats->rx);
35673 + atomic_inc_unchecked(&vcc->stats->rx);
35674
35675 cell += ATM_CELL_PAYLOAD;
35676 }
35677 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35678 "(CDC: %08x)\n",
35679 card->name, len, rpp->len, readl(SAR_REG_CDC));
35680 recycle_rx_pool_skb(card, rpp);
35681 - atomic_inc(&vcc->stats->rx_err);
35682 + atomic_inc_unchecked(&vcc->stats->rx_err);
35683 return;
35684 }
35685 if (stat & SAR_RSQE_CRC) {
35686 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
35687 recycle_rx_pool_skb(card, rpp);
35688 - atomic_inc(&vcc->stats->rx_err);
35689 + atomic_inc_unchecked(&vcc->stats->rx_err);
35690 return;
35691 }
35692 if (skb_queue_len(&rpp->queue) > 1) {
35693 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35694 RXPRINTK("%s: Can't alloc RX skb.\n",
35695 card->name);
35696 recycle_rx_pool_skb(card, rpp);
35697 - atomic_inc(&vcc->stats->rx_err);
35698 + atomic_inc_unchecked(&vcc->stats->rx_err);
35699 return;
35700 }
35701 if (!atm_charge(vcc, skb->truesize)) {
35702 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35703 __net_timestamp(skb);
35704
35705 vcc->push(vcc, skb);
35706 - atomic_inc(&vcc->stats->rx);
35707 + atomic_inc_unchecked(&vcc->stats->rx);
35708
35709 return;
35710 }
35711 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35712 __net_timestamp(skb);
35713
35714 vcc->push(vcc, skb);
35715 - atomic_inc(&vcc->stats->rx);
35716 + atomic_inc_unchecked(&vcc->stats->rx);
35717
35718 if (skb->truesize > SAR_FB_SIZE_3)
35719 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
35720 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
35721 if (vcc->qos.aal != ATM_AAL0) {
35722 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
35723 card->name, vpi, vci);
35724 - atomic_inc(&vcc->stats->rx_drop);
35725 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35726 goto drop;
35727 }
35728
35729 if ((sb = dev_alloc_skb(64)) == NULL) {
35730 printk("%s: Can't allocate buffers for AAL0.\n",
35731 card->name);
35732 - atomic_inc(&vcc->stats->rx_err);
35733 + atomic_inc_unchecked(&vcc->stats->rx_err);
35734 goto drop;
35735 }
35736
35737 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
35738 ATM_SKB(sb)->vcc = vcc;
35739 __net_timestamp(sb);
35740 vcc->push(vcc, sb);
35741 - atomic_inc(&vcc->stats->rx);
35742 + atomic_inc_unchecked(&vcc->stats->rx);
35743
35744 drop:
35745 skb_pull(queue, 64);
35746 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35747
35748 if (vc == NULL) {
35749 printk("%s: NULL connection in send().\n", card->name);
35750 - atomic_inc(&vcc->stats->tx_err);
35751 + atomic_inc_unchecked(&vcc->stats->tx_err);
35752 dev_kfree_skb(skb);
35753 return -EINVAL;
35754 }
35755 if (!test_bit(VCF_TX, &vc->flags)) {
35756 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
35757 - atomic_inc(&vcc->stats->tx_err);
35758 + atomic_inc_unchecked(&vcc->stats->tx_err);
35759 dev_kfree_skb(skb);
35760 return -EINVAL;
35761 }
35762 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35763 break;
35764 default:
35765 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
35766 - atomic_inc(&vcc->stats->tx_err);
35767 + atomic_inc_unchecked(&vcc->stats->tx_err);
35768 dev_kfree_skb(skb);
35769 return -EINVAL;
35770 }
35771
35772 if (skb_shinfo(skb)->nr_frags != 0) {
35773 printk("%s: No scatter-gather yet.\n", card->name);
35774 - atomic_inc(&vcc->stats->tx_err);
35775 + atomic_inc_unchecked(&vcc->stats->tx_err);
35776 dev_kfree_skb(skb);
35777 return -EINVAL;
35778 }
35779 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35780
35781 err = queue_skb(card, vc, skb, oam);
35782 if (err) {
35783 - atomic_inc(&vcc->stats->tx_err);
35784 + atomic_inc_unchecked(&vcc->stats->tx_err);
35785 dev_kfree_skb(skb);
35786 return err;
35787 }
35788 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
35789 skb = dev_alloc_skb(64);
35790 if (!skb) {
35791 printk("%s: Out of memory in send_oam().\n", card->name);
35792 - atomic_inc(&vcc->stats->tx_err);
35793 + atomic_inc_unchecked(&vcc->stats->tx_err);
35794 return -ENOMEM;
35795 }
35796 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
35797 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
35798 index 4217f29..88f547a 100644
35799 --- a/drivers/atm/iphase.c
35800 +++ b/drivers/atm/iphase.c
35801 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
35802 status = (u_short) (buf_desc_ptr->desc_mode);
35803 if (status & (RX_CER | RX_PTE | RX_OFL))
35804 {
35805 - atomic_inc(&vcc->stats->rx_err);
35806 + atomic_inc_unchecked(&vcc->stats->rx_err);
35807 IF_ERR(printk("IA: bad packet, dropping it");)
35808 if (status & RX_CER) {
35809 IF_ERR(printk(" cause: packet CRC error\n");)
35810 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
35811 len = dma_addr - buf_addr;
35812 if (len > iadev->rx_buf_sz) {
35813 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
35814 - atomic_inc(&vcc->stats->rx_err);
35815 + atomic_inc_unchecked(&vcc->stats->rx_err);
35816 goto out_free_desc;
35817 }
35818
35819 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35820 ia_vcc = INPH_IA_VCC(vcc);
35821 if (ia_vcc == NULL)
35822 {
35823 - atomic_inc(&vcc->stats->rx_err);
35824 + atomic_inc_unchecked(&vcc->stats->rx_err);
35825 atm_return(vcc, skb->truesize);
35826 dev_kfree_skb_any(skb);
35827 goto INCR_DLE;
35828 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35829 if ((length > iadev->rx_buf_sz) || (length >
35830 (skb->len - sizeof(struct cpcs_trailer))))
35831 {
35832 - atomic_inc(&vcc->stats->rx_err);
35833 + atomic_inc_unchecked(&vcc->stats->rx_err);
35834 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
35835 length, skb->len);)
35836 atm_return(vcc, skb->truesize);
35837 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35838
35839 IF_RX(printk("rx_dle_intr: skb push");)
35840 vcc->push(vcc,skb);
35841 - atomic_inc(&vcc->stats->rx);
35842 + atomic_inc_unchecked(&vcc->stats->rx);
35843 iadev->rx_pkt_cnt++;
35844 }
35845 INCR_DLE:
35846 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
35847 {
35848 struct k_sonet_stats *stats;
35849 stats = &PRIV(_ia_dev[board])->sonet_stats;
35850 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
35851 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
35852 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
35853 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
35854 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
35855 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
35856 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
35857 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
35858 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
35859 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
35860 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
35861 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
35862 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
35863 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
35864 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
35865 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
35866 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
35867 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
35868 }
35869 ia_cmds.status = 0;
35870 break;
35871 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
35872 if ((desc == 0) || (desc > iadev->num_tx_desc))
35873 {
35874 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
35875 - atomic_inc(&vcc->stats->tx);
35876 + atomic_inc_unchecked(&vcc->stats->tx);
35877 if (vcc->pop)
35878 vcc->pop(vcc, skb);
35879 else
35880 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
35881 ATM_DESC(skb) = vcc->vci;
35882 skb_queue_tail(&iadev->tx_dma_q, skb);
35883
35884 - atomic_inc(&vcc->stats->tx);
35885 + atomic_inc_unchecked(&vcc->stats->tx);
35886 iadev->tx_pkt_cnt++;
35887 /* Increment transaction counter */
35888 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
35889
35890 #if 0
35891 /* add flow control logic */
35892 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
35893 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
35894 if (iavcc->vc_desc_cnt > 10) {
35895 vcc->tx_quota = vcc->tx_quota * 3 / 4;
35896 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
35897 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
35898 index fa7d701..1e404c7 100644
35899 --- a/drivers/atm/lanai.c
35900 +++ b/drivers/atm/lanai.c
35901 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
35902 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
35903 lanai_endtx(lanai, lvcc);
35904 lanai_free_skb(lvcc->tx.atmvcc, skb);
35905 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
35906 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
35907 }
35908
35909 /* Try to fill the buffer - don't call unless there is backlog */
35910 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
35911 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
35912 __net_timestamp(skb);
35913 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
35914 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
35915 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
35916 out:
35917 lvcc->rx.buf.ptr = end;
35918 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
35919 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35920 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
35921 "vcc %d\n", lanai->number, (unsigned int) s, vci);
35922 lanai->stats.service_rxnotaal5++;
35923 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35924 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35925 return 0;
35926 }
35927 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
35928 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35929 int bytes;
35930 read_unlock(&vcc_sklist_lock);
35931 DPRINTK("got trashed rx pdu on vci %d\n", vci);
35932 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35933 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35934 lvcc->stats.x.aal5.service_trash++;
35935 bytes = (SERVICE_GET_END(s) * 16) -
35936 (((unsigned long) lvcc->rx.buf.ptr) -
35937 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35938 }
35939 if (s & SERVICE_STREAM) {
35940 read_unlock(&vcc_sklist_lock);
35941 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35942 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35943 lvcc->stats.x.aal5.service_stream++;
35944 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
35945 "PDU on VCI %d!\n", lanai->number, vci);
35946 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35947 return 0;
35948 }
35949 DPRINTK("got rx crc error on vci %d\n", vci);
35950 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35951 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35952 lvcc->stats.x.aal5.service_rxcrc++;
35953 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
35954 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
35955 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
35956 index 6587dc2..149833d 100644
35957 --- a/drivers/atm/nicstar.c
35958 +++ b/drivers/atm/nicstar.c
35959 @@ -1641,7 +1641,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35960 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
35961 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
35962 card->index);
35963 - atomic_inc(&vcc->stats->tx_err);
35964 + atomic_inc_unchecked(&vcc->stats->tx_err);
35965 dev_kfree_skb_any(skb);
35966 return -EINVAL;
35967 }
35968 @@ -1649,7 +1649,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35969 if (!vc->tx) {
35970 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
35971 card->index);
35972 - atomic_inc(&vcc->stats->tx_err);
35973 + atomic_inc_unchecked(&vcc->stats->tx_err);
35974 dev_kfree_skb_any(skb);
35975 return -EINVAL;
35976 }
35977 @@ -1657,14 +1657,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35978 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
35979 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
35980 card->index);
35981 - atomic_inc(&vcc->stats->tx_err);
35982 + atomic_inc_unchecked(&vcc->stats->tx_err);
35983 dev_kfree_skb_any(skb);
35984 return -EINVAL;
35985 }
35986
35987 if (skb_shinfo(skb)->nr_frags != 0) {
35988 printk("nicstar%d: No scatter-gather yet.\n", card->index);
35989 - atomic_inc(&vcc->stats->tx_err);
35990 + atomic_inc_unchecked(&vcc->stats->tx_err);
35991 dev_kfree_skb_any(skb);
35992 return -EINVAL;
35993 }
35994 @@ -1712,11 +1712,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35995 }
35996
35997 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
35998 - atomic_inc(&vcc->stats->tx_err);
35999 + atomic_inc_unchecked(&vcc->stats->tx_err);
36000 dev_kfree_skb_any(skb);
36001 return -EIO;
36002 }
36003 - atomic_inc(&vcc->stats->tx);
36004 + atomic_inc_unchecked(&vcc->stats->tx);
36005
36006 return 0;
36007 }
36008 @@ -2033,14 +2033,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36009 printk
36010 ("nicstar%d: Can't allocate buffers for aal0.\n",
36011 card->index);
36012 - atomic_add(i, &vcc->stats->rx_drop);
36013 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
36014 break;
36015 }
36016 if (!atm_charge(vcc, sb->truesize)) {
36017 RXPRINTK
36018 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
36019 card->index);
36020 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
36021 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
36022 dev_kfree_skb_any(sb);
36023 break;
36024 }
36025 @@ -2055,7 +2055,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36026 ATM_SKB(sb)->vcc = vcc;
36027 __net_timestamp(sb);
36028 vcc->push(vcc, sb);
36029 - atomic_inc(&vcc->stats->rx);
36030 + atomic_inc_unchecked(&vcc->stats->rx);
36031 cell += ATM_CELL_PAYLOAD;
36032 }
36033
36034 @@ -2072,7 +2072,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36035 if (iovb == NULL) {
36036 printk("nicstar%d: Out of iovec buffers.\n",
36037 card->index);
36038 - atomic_inc(&vcc->stats->rx_drop);
36039 + atomic_inc_unchecked(&vcc->stats->rx_drop);
36040 recycle_rx_buf(card, skb);
36041 return;
36042 }
36043 @@ -2096,7 +2096,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36044 small or large buffer itself. */
36045 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
36046 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
36047 - atomic_inc(&vcc->stats->rx_err);
36048 + atomic_inc_unchecked(&vcc->stats->rx_err);
36049 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
36050 NS_MAX_IOVECS);
36051 NS_PRV_IOVCNT(iovb) = 0;
36052 @@ -2116,7 +2116,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36053 ("nicstar%d: Expected a small buffer, and this is not one.\n",
36054 card->index);
36055 which_list(card, skb);
36056 - atomic_inc(&vcc->stats->rx_err);
36057 + atomic_inc_unchecked(&vcc->stats->rx_err);
36058 recycle_rx_buf(card, skb);
36059 vc->rx_iov = NULL;
36060 recycle_iov_buf(card, iovb);
36061 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36062 ("nicstar%d: Expected a large buffer, and this is not one.\n",
36063 card->index);
36064 which_list(card, skb);
36065 - atomic_inc(&vcc->stats->rx_err);
36066 + atomic_inc_unchecked(&vcc->stats->rx_err);
36067 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
36068 NS_PRV_IOVCNT(iovb));
36069 vc->rx_iov = NULL;
36070 @@ -2152,7 +2152,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36071 printk(" - PDU size mismatch.\n");
36072 else
36073 printk(".\n");
36074 - atomic_inc(&vcc->stats->rx_err);
36075 + atomic_inc_unchecked(&vcc->stats->rx_err);
36076 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
36077 NS_PRV_IOVCNT(iovb));
36078 vc->rx_iov = NULL;
36079 @@ -2166,7 +2166,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36080 /* skb points to a small buffer */
36081 if (!atm_charge(vcc, skb->truesize)) {
36082 push_rxbufs(card, skb);
36083 - atomic_inc(&vcc->stats->rx_drop);
36084 + atomic_inc_unchecked(&vcc->stats->rx_drop);
36085 } else {
36086 skb_put(skb, len);
36087 dequeue_sm_buf(card, skb);
36088 @@ -2176,7 +2176,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36089 ATM_SKB(skb)->vcc = vcc;
36090 __net_timestamp(skb);
36091 vcc->push(vcc, skb);
36092 - atomic_inc(&vcc->stats->rx);
36093 + atomic_inc_unchecked(&vcc->stats->rx);
36094 }
36095 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
36096 struct sk_buff *sb;
36097 @@ -2187,7 +2187,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36098 if (len <= NS_SMBUFSIZE) {
36099 if (!atm_charge(vcc, sb->truesize)) {
36100 push_rxbufs(card, sb);
36101 - atomic_inc(&vcc->stats->rx_drop);
36102 + atomic_inc_unchecked(&vcc->stats->rx_drop);
36103 } else {
36104 skb_put(sb, len);
36105 dequeue_sm_buf(card, sb);
36106 @@ -2197,7 +2197,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36107 ATM_SKB(sb)->vcc = vcc;
36108 __net_timestamp(sb);
36109 vcc->push(vcc, sb);
36110 - atomic_inc(&vcc->stats->rx);
36111 + atomic_inc_unchecked(&vcc->stats->rx);
36112 }
36113
36114 push_rxbufs(card, skb);
36115 @@ -2206,7 +2206,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36116
36117 if (!atm_charge(vcc, skb->truesize)) {
36118 push_rxbufs(card, skb);
36119 - atomic_inc(&vcc->stats->rx_drop);
36120 + atomic_inc_unchecked(&vcc->stats->rx_drop);
36121 } else {
36122 dequeue_lg_buf(card, skb);
36123 #ifdef NS_USE_DESTRUCTORS
36124 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36125 ATM_SKB(skb)->vcc = vcc;
36126 __net_timestamp(skb);
36127 vcc->push(vcc, skb);
36128 - atomic_inc(&vcc->stats->rx);
36129 + atomic_inc_unchecked(&vcc->stats->rx);
36130 }
36131
36132 push_rxbufs(card, sb);
36133 @@ -2240,7 +2240,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36134 printk
36135 ("nicstar%d: Out of huge buffers.\n",
36136 card->index);
36137 - atomic_inc(&vcc->stats->rx_drop);
36138 + atomic_inc_unchecked(&vcc->stats->rx_drop);
36139 recycle_iovec_rx_bufs(card,
36140 (struct iovec *)
36141 iovb->data,
36142 @@ -2291,7 +2291,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36143 card->hbpool.count++;
36144 } else
36145 dev_kfree_skb_any(hb);
36146 - atomic_inc(&vcc->stats->rx_drop);
36147 + atomic_inc_unchecked(&vcc->stats->rx_drop);
36148 } else {
36149 /* Copy the small buffer to the huge buffer */
36150 sb = (struct sk_buff *)iov->iov_base;
36151 @@ -2328,7 +2328,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36152 #endif /* NS_USE_DESTRUCTORS */
36153 __net_timestamp(hb);
36154 vcc->push(vcc, hb);
36155 - atomic_inc(&vcc->stats->rx);
36156 + atomic_inc_unchecked(&vcc->stats->rx);
36157 }
36158 }
36159
36160 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
36161 index 32784d1..4a8434a 100644
36162 --- a/drivers/atm/solos-pci.c
36163 +++ b/drivers/atm/solos-pci.c
36164 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
36165 }
36166 atm_charge(vcc, skb->truesize);
36167 vcc->push(vcc, skb);
36168 - atomic_inc(&vcc->stats->rx);
36169 + atomic_inc_unchecked(&vcc->stats->rx);
36170 break;
36171
36172 case PKT_STATUS:
36173 @@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
36174 vcc = SKB_CB(oldskb)->vcc;
36175
36176 if (vcc) {
36177 - atomic_inc(&vcc->stats->tx);
36178 + atomic_inc_unchecked(&vcc->stats->tx);
36179 solos_pop(vcc, oldskb);
36180 } else {
36181 dev_kfree_skb_irq(oldskb);
36182 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
36183 index 0215934..ce9f5b1 100644
36184 --- a/drivers/atm/suni.c
36185 +++ b/drivers/atm/suni.c
36186 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
36187
36188
36189 #define ADD_LIMITED(s,v) \
36190 - atomic_add((v),&stats->s); \
36191 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
36192 + atomic_add_unchecked((v),&stats->s); \
36193 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
36194
36195
36196 static void suni_hz(unsigned long from_timer)
36197 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
36198 index 5120a96..e2572bd 100644
36199 --- a/drivers/atm/uPD98402.c
36200 +++ b/drivers/atm/uPD98402.c
36201 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
36202 struct sonet_stats tmp;
36203 int error = 0;
36204
36205 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
36206 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
36207 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
36208 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
36209 if (zero && !error) {
36210 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
36211
36212
36213 #define ADD_LIMITED(s,v) \
36214 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
36215 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
36216 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
36217 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
36218 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
36219 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
36220
36221
36222 static void stat_event(struct atm_dev *dev)
36223 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
36224 if (reason & uPD98402_INT_PFM) stat_event(dev);
36225 if (reason & uPD98402_INT_PCO) {
36226 (void) GET(PCOCR); /* clear interrupt cause */
36227 - atomic_add(GET(HECCT),
36228 + atomic_add_unchecked(GET(HECCT),
36229 &PRIV(dev)->sonet_stats.uncorr_hcs);
36230 }
36231 if ((reason & uPD98402_INT_RFO) &&
36232 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
36233 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
36234 uPD98402_INT_LOS),PIMR); /* enable them */
36235 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
36236 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
36237 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
36238 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
36239 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
36240 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
36241 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
36242 return 0;
36243 }
36244
36245 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
36246 index 969c3c2..9b72956 100644
36247 --- a/drivers/atm/zatm.c
36248 +++ b/drivers/atm/zatm.c
36249 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
36250 }
36251 if (!size) {
36252 dev_kfree_skb_irq(skb);
36253 - if (vcc) atomic_inc(&vcc->stats->rx_err);
36254 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
36255 continue;
36256 }
36257 if (!atm_charge(vcc,skb->truesize)) {
36258 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
36259 skb->len = size;
36260 ATM_SKB(skb)->vcc = vcc;
36261 vcc->push(vcc,skb);
36262 - atomic_inc(&vcc->stats->rx);
36263 + atomic_inc_unchecked(&vcc->stats->rx);
36264 }
36265 zout(pos & 0xffff,MTA(mbx));
36266 #if 0 /* probably a stupid idea */
36267 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
36268 skb_queue_head(&zatm_vcc->backlog,skb);
36269 break;
36270 }
36271 - atomic_inc(&vcc->stats->tx);
36272 + atomic_inc_unchecked(&vcc->stats->tx);
36273 wake_up(&zatm_vcc->tx_wait);
36274 }
36275
36276 diff --git a/drivers/base/attribute_container.c b/drivers/base/attribute_container.c
36277 index d78b204..ecc1929 100644
36278 --- a/drivers/base/attribute_container.c
36279 +++ b/drivers/base/attribute_container.c
36280 @@ -167,7 +167,7 @@ attribute_container_add_device(struct device *dev,
36281 ic->classdev.parent = get_device(dev);
36282 ic->classdev.class = cont->class;
36283 cont->class->dev_release = attribute_container_release;
36284 - dev_set_name(&ic->classdev, dev_name(dev));
36285 + dev_set_name(&ic->classdev, "%s", dev_name(dev));
36286 if (fn)
36287 fn(cont, dev, &ic->classdev);
36288 else
36289 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
36290 index d414331..b4dd4ba 100644
36291 --- a/drivers/base/bus.c
36292 +++ b/drivers/base/bus.c
36293 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
36294 return -EINVAL;
36295
36296 mutex_lock(&subsys->p->mutex);
36297 - list_add_tail(&sif->node, &subsys->p->interfaces);
36298 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
36299 if (sif->add_dev) {
36300 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
36301 while ((dev = subsys_dev_iter_next(&iter)))
36302 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
36303 subsys = sif->subsys;
36304
36305 mutex_lock(&subsys->p->mutex);
36306 - list_del_init(&sif->node);
36307 + pax_list_del_init((struct list_head *)&sif->node);
36308 if (sif->remove_dev) {
36309 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
36310 while ((dev = subsys_dev_iter_next(&iter)))
36311 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
36312 index 7413d06..79155fa 100644
36313 --- a/drivers/base/devtmpfs.c
36314 +++ b/drivers/base/devtmpfs.c
36315 @@ -354,7 +354,7 @@ int devtmpfs_mount(const char *mntdir)
36316 if (!thread)
36317 return 0;
36318
36319 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
36320 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
36321 if (err)
36322 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
36323 else
36324 @@ -380,11 +380,11 @@ static int devtmpfsd(void *p)
36325 *err = sys_unshare(CLONE_NEWNS);
36326 if (*err)
36327 goto out;
36328 - *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
36329 + *err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)"/", (char __force_user *)"devtmpfs", MS_SILENT, (char __force_user *)options);
36330 if (*err)
36331 goto out;
36332 - sys_chdir("/.."); /* will traverse into overmounted root */
36333 - sys_chroot(".");
36334 + sys_chdir((char __force_user *)"/.."); /* will traverse into overmounted root */
36335 + sys_chroot((char __force_user *)".");
36336 complete(&setup_done);
36337 while (1) {
36338 spin_lock(&req_lock);
36339 diff --git a/drivers/base/node.c b/drivers/base/node.c
36340 index 7616a77c..8f57f51 100644
36341 --- a/drivers/base/node.c
36342 +++ b/drivers/base/node.c
36343 @@ -626,7 +626,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
36344 struct node_attr {
36345 struct device_attribute attr;
36346 enum node_states state;
36347 -};
36348 +} __do_const;
36349
36350 static ssize_t show_node_state(struct device *dev,
36351 struct device_attribute *attr, char *buf)
36352 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
36353 index 7072404..76dcebd 100644
36354 --- a/drivers/base/power/domain.c
36355 +++ b/drivers/base/power/domain.c
36356 @@ -1850,7 +1850,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
36357 {
36358 struct cpuidle_driver *cpuidle_drv;
36359 struct gpd_cpu_data *cpu_data;
36360 - struct cpuidle_state *idle_state;
36361 + cpuidle_state_no_const *idle_state;
36362 int ret = 0;
36363
36364 if (IS_ERR_OR_NULL(genpd) || state < 0)
36365 @@ -1918,7 +1918,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
36366 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
36367 {
36368 struct gpd_cpu_data *cpu_data;
36369 - struct cpuidle_state *idle_state;
36370 + cpuidle_state_no_const *idle_state;
36371 int ret = 0;
36372
36373 if (IS_ERR_OR_NULL(genpd))
36374 diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
36375 index a53ebd2..8f73eeb 100644
36376 --- a/drivers/base/power/sysfs.c
36377 +++ b/drivers/base/power/sysfs.c
36378 @@ -185,7 +185,7 @@ static ssize_t rtpm_status_show(struct device *dev,
36379 return -EIO;
36380 }
36381 }
36382 - return sprintf(buf, p);
36383 + return sprintf(buf, "%s", p);
36384 }
36385
36386 static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
36387 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
36388 index 79715e7..df06b3b 100644
36389 --- a/drivers/base/power/wakeup.c
36390 +++ b/drivers/base/power/wakeup.c
36391 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
36392 * They need to be modified together atomically, so it's better to use one
36393 * atomic variable to hold them both.
36394 */
36395 -static atomic_t combined_event_count = ATOMIC_INIT(0);
36396 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
36397
36398 #define IN_PROGRESS_BITS (sizeof(int) * 4)
36399 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
36400
36401 static void split_counters(unsigned int *cnt, unsigned int *inpr)
36402 {
36403 - unsigned int comb = atomic_read(&combined_event_count);
36404 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
36405
36406 *cnt = (comb >> IN_PROGRESS_BITS);
36407 *inpr = comb & MAX_IN_PROGRESS;
36408 @@ -395,7 +395,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
36409 ws->start_prevent_time = ws->last_time;
36410
36411 /* Increment the counter of events in progress. */
36412 - cec = atomic_inc_return(&combined_event_count);
36413 + cec = atomic_inc_return_unchecked(&combined_event_count);
36414
36415 trace_wakeup_source_activate(ws->name, cec);
36416 }
36417 @@ -521,7 +521,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
36418 * Increment the counter of registered wakeup events and decrement the
36419 * couter of wakeup events in progress simultaneously.
36420 */
36421 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
36422 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
36423 trace_wakeup_source_deactivate(ws->name, cec);
36424
36425 split_counters(&cnt, &inpr);
36426 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
36427 index e8d11b6..7b1b36f 100644
36428 --- a/drivers/base/syscore.c
36429 +++ b/drivers/base/syscore.c
36430 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
36431 void register_syscore_ops(struct syscore_ops *ops)
36432 {
36433 mutex_lock(&syscore_ops_lock);
36434 - list_add_tail(&ops->node, &syscore_ops_list);
36435 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
36436 mutex_unlock(&syscore_ops_lock);
36437 }
36438 EXPORT_SYMBOL_GPL(register_syscore_ops);
36439 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
36440 void unregister_syscore_ops(struct syscore_ops *ops)
36441 {
36442 mutex_lock(&syscore_ops_lock);
36443 - list_del(&ops->node);
36444 + pax_list_del((struct list_head *)&ops->node);
36445 mutex_unlock(&syscore_ops_lock);
36446 }
36447 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
36448 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
36449 index 62b6c2c..4a11354 100644
36450 --- a/drivers/block/cciss.c
36451 +++ b/drivers/block/cciss.c
36452 @@ -1189,6 +1189,8 @@ static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
36453 int err;
36454 u32 cp;
36455
36456 + memset(&arg64, 0, sizeof(arg64));
36457 +
36458 err = 0;
36459 err |=
36460 copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
36461 @@ -3010,7 +3012,7 @@ static void start_io(ctlr_info_t *h)
36462 while (!list_empty(&h->reqQ)) {
36463 c = list_entry(h->reqQ.next, CommandList_struct, list);
36464 /* can't do anything if fifo is full */
36465 - if ((h->access.fifo_full(h))) {
36466 + if ((h->access->fifo_full(h))) {
36467 dev_warn(&h->pdev->dev, "fifo full\n");
36468 break;
36469 }
36470 @@ -3020,7 +3022,7 @@ static void start_io(ctlr_info_t *h)
36471 h->Qdepth--;
36472
36473 /* Tell the controller execute command */
36474 - h->access.submit_command(h, c);
36475 + h->access->submit_command(h, c);
36476
36477 /* Put job onto the completed Q */
36478 addQ(&h->cmpQ, c);
36479 @@ -3446,17 +3448,17 @@ startio:
36480
36481 static inline unsigned long get_next_completion(ctlr_info_t *h)
36482 {
36483 - return h->access.command_completed(h);
36484 + return h->access->command_completed(h);
36485 }
36486
36487 static inline int interrupt_pending(ctlr_info_t *h)
36488 {
36489 - return h->access.intr_pending(h);
36490 + return h->access->intr_pending(h);
36491 }
36492
36493 static inline long interrupt_not_for_us(ctlr_info_t *h)
36494 {
36495 - return ((h->access.intr_pending(h) == 0) ||
36496 + return ((h->access->intr_pending(h) == 0) ||
36497 (h->interrupts_enabled == 0));
36498 }
36499
36500 @@ -3489,7 +3491,7 @@ static inline u32 next_command(ctlr_info_t *h)
36501 u32 a;
36502
36503 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
36504 - return h->access.command_completed(h);
36505 + return h->access->command_completed(h);
36506
36507 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
36508 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
36509 @@ -4046,7 +4048,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
36510 trans_support & CFGTBL_Trans_use_short_tags);
36511
36512 /* Change the access methods to the performant access methods */
36513 - h->access = SA5_performant_access;
36514 + h->access = &SA5_performant_access;
36515 h->transMethod = CFGTBL_Trans_Performant;
36516
36517 return;
36518 @@ -4319,7 +4321,7 @@ static int cciss_pci_init(ctlr_info_t *h)
36519 if (prod_index < 0)
36520 return -ENODEV;
36521 h->product_name = products[prod_index].product_name;
36522 - h->access = *(products[prod_index].access);
36523 + h->access = products[prod_index].access;
36524
36525 if (cciss_board_disabled(h)) {
36526 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
36527 @@ -5051,7 +5053,7 @@ reinit_after_soft_reset:
36528 }
36529
36530 /* make sure the board interrupts are off */
36531 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36532 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36533 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
36534 if (rc)
36535 goto clean2;
36536 @@ -5101,7 +5103,7 @@ reinit_after_soft_reset:
36537 * fake ones to scoop up any residual completions.
36538 */
36539 spin_lock_irqsave(&h->lock, flags);
36540 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36541 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36542 spin_unlock_irqrestore(&h->lock, flags);
36543 free_irq(h->intr[h->intr_mode], h);
36544 rc = cciss_request_irq(h, cciss_msix_discard_completions,
36545 @@ -5121,9 +5123,9 @@ reinit_after_soft_reset:
36546 dev_info(&h->pdev->dev, "Board READY.\n");
36547 dev_info(&h->pdev->dev,
36548 "Waiting for stale completions to drain.\n");
36549 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36550 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36551 msleep(10000);
36552 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36553 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36554
36555 rc = controller_reset_failed(h->cfgtable);
36556 if (rc)
36557 @@ -5146,7 +5148,7 @@ reinit_after_soft_reset:
36558 cciss_scsi_setup(h);
36559
36560 /* Turn the interrupts on so we can service requests */
36561 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36562 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36563
36564 /* Get the firmware version */
36565 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
36566 @@ -5218,7 +5220,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
36567 kfree(flush_buf);
36568 if (return_code != IO_OK)
36569 dev_warn(&h->pdev->dev, "Error flushing cache\n");
36570 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36571 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36572 free_irq(h->intr[h->intr_mode], h);
36573 }
36574
36575 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
36576 index 7fda30e..eb5dfe0 100644
36577 --- a/drivers/block/cciss.h
36578 +++ b/drivers/block/cciss.h
36579 @@ -101,7 +101,7 @@ struct ctlr_info
36580 /* information about each logical volume */
36581 drive_info_struct *drv[CISS_MAX_LUN];
36582
36583 - struct access_method access;
36584 + struct access_method *access;
36585
36586 /* queue and queue Info */
36587 struct list_head reqQ;
36588 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
36589 index 639d26b..fd6ad1f 100644
36590 --- a/drivers/block/cpqarray.c
36591 +++ b/drivers/block/cpqarray.c
36592 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36593 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
36594 goto Enomem4;
36595 }
36596 - hba[i]->access.set_intr_mask(hba[i], 0);
36597 + hba[i]->access->set_intr_mask(hba[i], 0);
36598 if (request_irq(hba[i]->intr, do_ida_intr,
36599 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
36600 {
36601 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36602 add_timer(&hba[i]->timer);
36603
36604 /* Enable IRQ now that spinlock and rate limit timer are set up */
36605 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36606 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36607
36608 for(j=0; j<NWD; j++) {
36609 struct gendisk *disk = ida_gendisk[i][j];
36610 @@ -694,7 +694,7 @@ DBGINFO(
36611 for(i=0; i<NR_PRODUCTS; i++) {
36612 if (board_id == products[i].board_id) {
36613 c->product_name = products[i].product_name;
36614 - c->access = *(products[i].access);
36615 + c->access = products[i].access;
36616 break;
36617 }
36618 }
36619 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
36620 hba[ctlr]->intr = intr;
36621 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
36622 hba[ctlr]->product_name = products[j].product_name;
36623 - hba[ctlr]->access = *(products[j].access);
36624 + hba[ctlr]->access = products[j].access;
36625 hba[ctlr]->ctlr = ctlr;
36626 hba[ctlr]->board_id = board_id;
36627 hba[ctlr]->pci_dev = NULL; /* not PCI */
36628 @@ -978,7 +978,7 @@ static void start_io(ctlr_info_t *h)
36629
36630 while((c = h->reqQ) != NULL) {
36631 /* Can't do anything if we're busy */
36632 - if (h->access.fifo_full(h) == 0)
36633 + if (h->access->fifo_full(h) == 0)
36634 return;
36635
36636 /* Get the first entry from the request Q */
36637 @@ -986,7 +986,7 @@ static void start_io(ctlr_info_t *h)
36638 h->Qdepth--;
36639
36640 /* Tell the controller to do our bidding */
36641 - h->access.submit_command(h, c);
36642 + h->access->submit_command(h, c);
36643
36644 /* Get onto the completion Q */
36645 addQ(&h->cmpQ, c);
36646 @@ -1048,7 +1048,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36647 unsigned long flags;
36648 __u32 a,a1;
36649
36650 - istat = h->access.intr_pending(h);
36651 + istat = h->access->intr_pending(h);
36652 /* Is this interrupt for us? */
36653 if (istat == 0)
36654 return IRQ_NONE;
36655 @@ -1059,7 +1059,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36656 */
36657 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
36658 if (istat & FIFO_NOT_EMPTY) {
36659 - while((a = h->access.command_completed(h))) {
36660 + while((a = h->access->command_completed(h))) {
36661 a1 = a; a &= ~3;
36662 if ((c = h->cmpQ) == NULL)
36663 {
36664 @@ -1193,6 +1193,7 @@ out_passthru:
36665 ida_pci_info_struct pciinfo;
36666
36667 if (!arg) return -EINVAL;
36668 + memset(&pciinfo, 0, sizeof(pciinfo));
36669 pciinfo.bus = host->pci_dev->bus->number;
36670 pciinfo.dev_fn = host->pci_dev->devfn;
36671 pciinfo.board_id = host->board_id;
36672 @@ -1447,11 +1448,11 @@ static int sendcmd(
36673 /*
36674 * Disable interrupt
36675 */
36676 - info_p->access.set_intr_mask(info_p, 0);
36677 + info_p->access->set_intr_mask(info_p, 0);
36678 /* Make sure there is room in the command FIFO */
36679 /* Actually it should be completely empty at this time. */
36680 for (i = 200000; i > 0; i--) {
36681 - temp = info_p->access.fifo_full(info_p);
36682 + temp = info_p->access->fifo_full(info_p);
36683 if (temp != 0) {
36684 break;
36685 }
36686 @@ -1464,7 +1465,7 @@ DBG(
36687 /*
36688 * Send the cmd
36689 */
36690 - info_p->access.submit_command(info_p, c);
36691 + info_p->access->submit_command(info_p, c);
36692 complete = pollcomplete(ctlr);
36693
36694 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
36695 @@ -1547,9 +1548,9 @@ static int revalidate_allvol(ctlr_info_t *host)
36696 * we check the new geometry. Then turn interrupts back on when
36697 * we're done.
36698 */
36699 - host->access.set_intr_mask(host, 0);
36700 + host->access->set_intr_mask(host, 0);
36701 getgeometry(ctlr);
36702 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
36703 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
36704
36705 for(i=0; i<NWD; i++) {
36706 struct gendisk *disk = ida_gendisk[ctlr][i];
36707 @@ -1589,7 +1590,7 @@ static int pollcomplete(int ctlr)
36708 /* Wait (up to 2 seconds) for a command to complete */
36709
36710 for (i = 200000; i > 0; i--) {
36711 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
36712 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
36713 if (done == 0) {
36714 udelay(10); /* a short fixed delay */
36715 } else
36716 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
36717 index be73e9d..7fbf140 100644
36718 --- a/drivers/block/cpqarray.h
36719 +++ b/drivers/block/cpqarray.h
36720 @@ -99,7 +99,7 @@ struct ctlr_info {
36721 drv_info_t drv[NWD];
36722 struct proc_dir_entry *proc;
36723
36724 - struct access_method access;
36725 + struct access_method *access;
36726
36727 cmdlist_t *reqQ;
36728 cmdlist_t *cmpQ;
36729 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
36730 index f943aac..99bfd19 100644
36731 --- a/drivers/block/drbd/drbd_int.h
36732 +++ b/drivers/block/drbd/drbd_int.h
36733 @@ -582,7 +582,7 @@ struct drbd_epoch {
36734 struct drbd_tconn *tconn;
36735 struct list_head list;
36736 unsigned int barrier_nr;
36737 - atomic_t epoch_size; /* increased on every request added. */
36738 + atomic_unchecked_t epoch_size; /* increased on every request added. */
36739 atomic_t active; /* increased on every req. added, and dec on every finished. */
36740 unsigned long flags;
36741 };
36742 @@ -1021,7 +1021,7 @@ struct drbd_conf {
36743 unsigned int al_tr_number;
36744 int al_tr_cycle;
36745 wait_queue_head_t seq_wait;
36746 - atomic_t packet_seq;
36747 + atomic_unchecked_t packet_seq;
36748 unsigned int peer_seq;
36749 spinlock_t peer_seq_lock;
36750 unsigned int minor;
36751 @@ -1562,7 +1562,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
36752 char __user *uoptval;
36753 int err;
36754
36755 - uoptval = (char __user __force *)optval;
36756 + uoptval = (char __force_user *)optval;
36757
36758 set_fs(KERNEL_DS);
36759 if (level == SOL_SOCKET)
36760 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
36761 index a5dca6a..bb27967 100644
36762 --- a/drivers/block/drbd/drbd_main.c
36763 +++ b/drivers/block/drbd/drbd_main.c
36764 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
36765 p->sector = sector;
36766 p->block_id = block_id;
36767 p->blksize = blksize;
36768 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
36769 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
36770 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
36771 }
36772
36773 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
36774 return -EIO;
36775 p->sector = cpu_to_be64(req->i.sector);
36776 p->block_id = (unsigned long)req;
36777 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
36778 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
36779 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
36780 if (mdev->state.conn >= C_SYNC_SOURCE &&
36781 mdev->state.conn <= C_PAUSED_SYNC_T)
36782 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
36783 {
36784 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
36785
36786 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
36787 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
36788 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
36789 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
36790 kfree(tconn->current_epoch);
36791
36792 idr_destroy(&tconn->volumes);
36793 diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
36794 index 9e3f441..4044d47 100644
36795 --- a/drivers/block/drbd/drbd_nl.c
36796 +++ b/drivers/block/drbd/drbd_nl.c
36797 @@ -3339,7 +3339,7 @@ out:
36798
36799 void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
36800 {
36801 - static atomic_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
36802 + static atomic_unchecked_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
36803 struct sk_buff *msg;
36804 struct drbd_genlmsghdr *d_out;
36805 unsigned seq;
36806 @@ -3352,7 +3352,7 @@ void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
36807 return;
36808 }
36809
36810 - seq = atomic_inc_return(&drbd_genl_seq);
36811 + seq = atomic_inc_return_unchecked(&drbd_genl_seq);
36812 msg = genlmsg_new(NLMSG_GOODSIZE, GFP_NOIO);
36813 if (!msg)
36814 goto failed;
36815 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
36816 index 4222aff..1f79506 100644
36817 --- a/drivers/block/drbd/drbd_receiver.c
36818 +++ b/drivers/block/drbd/drbd_receiver.c
36819 @@ -834,7 +834,7 @@ int drbd_connected(struct drbd_conf *mdev)
36820 {
36821 int err;
36822
36823 - atomic_set(&mdev->packet_seq, 0);
36824 + atomic_set_unchecked(&mdev->packet_seq, 0);
36825 mdev->peer_seq = 0;
36826
36827 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
36828 @@ -1193,7 +1193,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
36829 do {
36830 next_epoch = NULL;
36831
36832 - epoch_size = atomic_read(&epoch->epoch_size);
36833 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
36834
36835 switch (ev & ~EV_CLEANUP) {
36836 case EV_PUT:
36837 @@ -1233,7 +1233,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
36838 rv = FE_DESTROYED;
36839 } else {
36840 epoch->flags = 0;
36841 - atomic_set(&epoch->epoch_size, 0);
36842 + atomic_set_unchecked(&epoch->epoch_size, 0);
36843 /* atomic_set(&epoch->active, 0); is already zero */
36844 if (rv == FE_STILL_LIVE)
36845 rv = FE_RECYCLED;
36846 @@ -1451,7 +1451,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
36847 conn_wait_active_ee_empty(tconn);
36848 drbd_flush(tconn);
36849
36850 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
36851 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
36852 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
36853 if (epoch)
36854 break;
36855 @@ -1464,11 +1464,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
36856 }
36857
36858 epoch->flags = 0;
36859 - atomic_set(&epoch->epoch_size, 0);
36860 + atomic_set_unchecked(&epoch->epoch_size, 0);
36861 atomic_set(&epoch->active, 0);
36862
36863 spin_lock(&tconn->epoch_lock);
36864 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
36865 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
36866 list_add(&epoch->list, &tconn->current_epoch->list);
36867 tconn->current_epoch = epoch;
36868 tconn->epochs++;
36869 @@ -2172,7 +2172,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
36870
36871 err = wait_for_and_update_peer_seq(mdev, peer_seq);
36872 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
36873 - atomic_inc(&tconn->current_epoch->epoch_size);
36874 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
36875 err2 = drbd_drain_block(mdev, pi->size);
36876 if (!err)
36877 err = err2;
36878 @@ -2206,7 +2206,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
36879
36880 spin_lock(&tconn->epoch_lock);
36881 peer_req->epoch = tconn->current_epoch;
36882 - atomic_inc(&peer_req->epoch->epoch_size);
36883 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
36884 atomic_inc(&peer_req->epoch->active);
36885 spin_unlock(&tconn->epoch_lock);
36886
36887 @@ -4347,7 +4347,7 @@ struct data_cmd {
36888 int expect_payload;
36889 size_t pkt_size;
36890 int (*fn)(struct drbd_tconn *, struct packet_info *);
36891 -};
36892 +} __do_const;
36893
36894 static struct data_cmd drbd_cmd_handler[] = {
36895 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
36896 @@ -4467,7 +4467,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
36897 if (!list_empty(&tconn->current_epoch->list))
36898 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
36899 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
36900 - atomic_set(&tconn->current_epoch->epoch_size, 0);
36901 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
36902 tconn->send.seen_any_write_yet = false;
36903
36904 conn_info(tconn, "Connection closed\n");
36905 @@ -5223,7 +5223,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
36906 struct asender_cmd {
36907 size_t pkt_size;
36908 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
36909 -};
36910 +} __do_const;
36911
36912 static struct asender_cmd asender_tbl[] = {
36913 [P_PING] = { 0, got_Ping },
36914 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
36915 index d92d50f..a7e9d97 100644
36916 --- a/drivers/block/loop.c
36917 +++ b/drivers/block/loop.c
36918 @@ -232,7 +232,7 @@ static int __do_lo_send_write(struct file *file,
36919
36920 file_start_write(file);
36921 set_fs(get_ds());
36922 - bw = file->f_op->write(file, buf, len, &pos);
36923 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
36924 set_fs(old_fs);
36925 file_end_write(file);
36926 if (likely(bw == len))
36927 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
36928 index f5d0ea1..c62380a 100644
36929 --- a/drivers/block/pktcdvd.c
36930 +++ b/drivers/block/pktcdvd.c
36931 @@ -84,7 +84,7 @@
36932 #define MAX_SPEED 0xffff
36933
36934 #define ZONE(sector, pd) (((sector) + (pd)->offset) & \
36935 - ~(sector_t)((pd)->settings.size - 1))
36936 + ~(sector_t)((pd)->settings.size - 1UL))
36937
36938 static DEFINE_MUTEX(pktcdvd_mutex);
36939 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
36940 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
36941 index 8a3aff7..d7538c2 100644
36942 --- a/drivers/cdrom/cdrom.c
36943 +++ b/drivers/cdrom/cdrom.c
36944 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
36945 ENSURE(reset, CDC_RESET);
36946 ENSURE(generic_packet, CDC_GENERIC_PACKET);
36947 cdi->mc_flags = 0;
36948 - cdo->n_minors = 0;
36949 cdi->options = CDO_USE_FFLAGS;
36950
36951 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
36952 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
36953 else
36954 cdi->cdda_method = CDDA_OLD;
36955
36956 - if (!cdo->generic_packet)
36957 - cdo->generic_packet = cdrom_dummy_generic_packet;
36958 + if (!cdo->generic_packet) {
36959 + pax_open_kernel();
36960 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
36961 + pax_close_kernel();
36962 + }
36963
36964 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
36965 mutex_lock(&cdrom_mutex);
36966 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
36967 if (cdi->exit)
36968 cdi->exit(cdi);
36969
36970 - cdi->ops->n_minors--;
36971 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
36972 }
36973
36974 @@ -2107,7 +2108,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
36975 */
36976 nr = nframes;
36977 do {
36978 - cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
36979 + cgc.buffer = kzalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
36980 if (cgc.buffer)
36981 break;
36982
36983 @@ -3429,7 +3430,7 @@ static int cdrom_print_info(const char *header, int val, char *info,
36984 struct cdrom_device_info *cdi;
36985 int ret;
36986
36987 - ret = scnprintf(info + *pos, max_size - *pos, header);
36988 + ret = scnprintf(info + *pos, max_size - *pos, "%s", header);
36989 if (!ret)
36990 return 1;
36991
36992 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
36993 index 4afcb65..a68a32d 100644
36994 --- a/drivers/cdrom/gdrom.c
36995 +++ b/drivers/cdrom/gdrom.c
36996 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
36997 .audio_ioctl = gdrom_audio_ioctl,
36998 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
36999 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
37000 - .n_minors = 1,
37001 };
37002
37003 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
37004 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
37005 index 3bb6fa3..34013fb 100644
37006 --- a/drivers/char/Kconfig
37007 +++ b/drivers/char/Kconfig
37008 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
37009
37010 config DEVKMEM
37011 bool "/dev/kmem virtual device support"
37012 - default y
37013 + default n
37014 + depends on !GRKERNSEC_KMEM
37015 help
37016 Say Y here if you want to support the /dev/kmem device. The
37017 /dev/kmem device is rarely used, but can be used for certain
37018 @@ -582,6 +583,7 @@ config DEVPORT
37019 bool
37020 depends on !M68K
37021 depends on ISA || PCI
37022 + depends on !GRKERNSEC_KMEM
37023 default y
37024
37025 source "drivers/s390/char/Kconfig"
37026 diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
37027 index a48e05b..6bac831 100644
37028 --- a/drivers/char/agp/compat_ioctl.c
37029 +++ b/drivers/char/agp/compat_ioctl.c
37030 @@ -108,7 +108,7 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
37031 return -ENOMEM;
37032 }
37033
37034 - if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
37035 + if (copy_from_user(usegment, (void __force_user *) ureserve.seg_list,
37036 sizeof(*usegment) * ureserve.seg_count)) {
37037 kfree(usegment);
37038 kfree(ksegment);
37039 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
37040 index 2e04433..771f2cc 100644
37041 --- a/drivers/char/agp/frontend.c
37042 +++ b/drivers/char/agp/frontend.c
37043 @@ -817,7 +817,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
37044 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
37045 return -EFAULT;
37046
37047 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
37048 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
37049 return -EFAULT;
37050
37051 client = agp_find_client_by_pid(reserve.pid);
37052 @@ -847,7 +847,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
37053 if (segment == NULL)
37054 return -ENOMEM;
37055
37056 - if (copy_from_user(segment, (void __user *) reserve.seg_list,
37057 + if (copy_from_user(segment, (void __force_user *) reserve.seg_list,
37058 sizeof(struct agp_segment) * reserve.seg_count)) {
37059 kfree(segment);
37060 return -EFAULT;
37061 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
37062 index 4f94375..413694e 100644
37063 --- a/drivers/char/genrtc.c
37064 +++ b/drivers/char/genrtc.c
37065 @@ -273,6 +273,7 @@ static int gen_rtc_ioctl(struct file *file,
37066 switch (cmd) {
37067
37068 case RTC_PLL_GET:
37069 + memset(&pll, 0, sizeof(pll));
37070 if (get_rtc_pll(&pll))
37071 return -EINVAL;
37072 else
37073 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
37074 index d784650..e8bfd69 100644
37075 --- a/drivers/char/hpet.c
37076 +++ b/drivers/char/hpet.c
37077 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
37078 }
37079
37080 static int
37081 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
37082 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
37083 struct hpet_info *info)
37084 {
37085 struct hpet_timer __iomem *timer;
37086 diff --git a/drivers/char/hw_random/intel-rng.c b/drivers/char/hw_random/intel-rng.c
37087 index 86fe45c..c0ea948 100644
37088 --- a/drivers/char/hw_random/intel-rng.c
37089 +++ b/drivers/char/hw_random/intel-rng.c
37090 @@ -314,7 +314,7 @@ PFX "RNG, try using the 'no_fwh_detect' option.\n";
37091
37092 if (no_fwh_detect)
37093 return -ENODEV;
37094 - printk(warning);
37095 + printk("%s", warning);
37096 return -EBUSY;
37097 }
37098
37099 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
37100 index 4445fa1..7c6de37 100644
37101 --- a/drivers/char/ipmi/ipmi_msghandler.c
37102 +++ b/drivers/char/ipmi/ipmi_msghandler.c
37103 @@ -420,7 +420,7 @@ struct ipmi_smi {
37104 struct proc_dir_entry *proc_dir;
37105 char proc_dir_name[10];
37106
37107 - atomic_t stats[IPMI_NUM_STATS];
37108 + atomic_unchecked_t stats[IPMI_NUM_STATS];
37109
37110 /*
37111 * run_to_completion duplicate of smb_info, smi_info
37112 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
37113
37114
37115 #define ipmi_inc_stat(intf, stat) \
37116 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
37117 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
37118 #define ipmi_get_stat(intf, stat) \
37119 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
37120 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
37121
37122 static int is_lan_addr(struct ipmi_addr *addr)
37123 {
37124 @@ -2883,7 +2883,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
37125 INIT_LIST_HEAD(&intf->cmd_rcvrs);
37126 init_waitqueue_head(&intf->waitq);
37127 for (i = 0; i < IPMI_NUM_STATS; i++)
37128 - atomic_set(&intf->stats[i], 0);
37129 + atomic_set_unchecked(&intf->stats[i], 0);
37130
37131 intf->proc_dir = NULL;
37132
37133 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
37134 index af4b23f..79806fc 100644
37135 --- a/drivers/char/ipmi/ipmi_si_intf.c
37136 +++ b/drivers/char/ipmi/ipmi_si_intf.c
37137 @@ -275,7 +275,7 @@ struct smi_info {
37138 unsigned char slave_addr;
37139
37140 /* Counters and things for the proc filesystem. */
37141 - atomic_t stats[SI_NUM_STATS];
37142 + atomic_unchecked_t stats[SI_NUM_STATS];
37143
37144 struct task_struct *thread;
37145
37146 @@ -284,9 +284,9 @@ struct smi_info {
37147 };
37148
37149 #define smi_inc_stat(smi, stat) \
37150 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
37151 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
37152 #define smi_get_stat(smi, stat) \
37153 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
37154 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
37155
37156 #define SI_MAX_PARMS 4
37157
37158 @@ -3258,7 +3258,7 @@ static int try_smi_init(struct smi_info *new_smi)
37159 atomic_set(&new_smi->req_events, 0);
37160 new_smi->run_to_completion = 0;
37161 for (i = 0; i < SI_NUM_STATS; i++)
37162 - atomic_set(&new_smi->stats[i], 0);
37163 + atomic_set_unchecked(&new_smi->stats[i], 0);
37164
37165 new_smi->interrupt_disabled = 1;
37166 atomic_set(&new_smi->stop_operation, 0);
37167 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
37168 index 1ccbe94..6ad651a 100644
37169 --- a/drivers/char/mem.c
37170 +++ b/drivers/char/mem.c
37171 @@ -18,6 +18,7 @@
37172 #include <linux/raw.h>
37173 #include <linux/tty.h>
37174 #include <linux/capability.h>
37175 +#include <linux/security.h>
37176 #include <linux/ptrace.h>
37177 #include <linux/device.h>
37178 #include <linux/highmem.h>
37179 @@ -38,6 +39,10 @@
37180
37181 #define DEVPORT_MINOR 4
37182
37183 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
37184 +extern const struct file_operations grsec_fops;
37185 +#endif
37186 +
37187 static inline unsigned long size_inside_page(unsigned long start,
37188 unsigned long size)
37189 {
37190 @@ -69,9 +74,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
37191
37192 while (cursor < to) {
37193 if (!devmem_is_allowed(pfn)) {
37194 +#ifdef CONFIG_GRKERNSEC_KMEM
37195 + gr_handle_mem_readwrite(from, to);
37196 +#else
37197 printk(KERN_INFO
37198 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
37199 current->comm, from, to);
37200 +#endif
37201 return 0;
37202 }
37203 cursor += PAGE_SIZE;
37204 @@ -79,6 +88,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
37205 }
37206 return 1;
37207 }
37208 +#elif defined(CONFIG_GRKERNSEC_KMEM)
37209 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
37210 +{
37211 + return 0;
37212 +}
37213 #else
37214 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
37215 {
37216 @@ -121,6 +135,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
37217
37218 while (count > 0) {
37219 unsigned long remaining;
37220 + char *temp;
37221
37222 sz = size_inside_page(p, count);
37223
37224 @@ -136,7 +151,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
37225 if (!ptr)
37226 return -EFAULT;
37227
37228 - remaining = copy_to_user(buf, ptr, sz);
37229 +#ifdef CONFIG_PAX_USERCOPY
37230 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
37231 + if (!temp) {
37232 + unxlate_dev_mem_ptr(p, ptr);
37233 + return -ENOMEM;
37234 + }
37235 + memcpy(temp, ptr, sz);
37236 +#else
37237 + temp = ptr;
37238 +#endif
37239 +
37240 + remaining = copy_to_user(buf, temp, sz);
37241 +
37242 +#ifdef CONFIG_PAX_USERCOPY
37243 + kfree(temp);
37244 +#endif
37245 +
37246 unxlate_dev_mem_ptr(p, ptr);
37247 if (remaining)
37248 return -EFAULT;
37249 @@ -379,7 +410,7 @@ static ssize_t read_oldmem(struct file *file, char __user *buf,
37250 else
37251 csize = count;
37252
37253 - rc = copy_oldmem_page(pfn, buf, csize, offset, 1);
37254 + rc = copy_oldmem_page(pfn, (char __force_kernel *)buf, csize, offset, 1);
37255 if (rc < 0)
37256 return rc;
37257 buf += csize;
37258 @@ -399,9 +430,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
37259 size_t count, loff_t *ppos)
37260 {
37261 unsigned long p = *ppos;
37262 - ssize_t low_count, read, sz;
37263 + ssize_t low_count, read, sz, err = 0;
37264 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
37265 - int err = 0;
37266
37267 read = 0;
37268 if (p < (unsigned long) high_memory) {
37269 @@ -423,6 +453,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
37270 }
37271 #endif
37272 while (low_count > 0) {
37273 + char *temp;
37274 +
37275 sz = size_inside_page(p, low_count);
37276
37277 /*
37278 @@ -432,7 +464,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
37279 */
37280 kbuf = xlate_dev_kmem_ptr((char *)p);
37281
37282 - if (copy_to_user(buf, kbuf, sz))
37283 +#ifdef CONFIG_PAX_USERCOPY
37284 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
37285 + if (!temp)
37286 + return -ENOMEM;
37287 + memcpy(temp, kbuf, sz);
37288 +#else
37289 + temp = kbuf;
37290 +#endif
37291 +
37292 + err = copy_to_user(buf, temp, sz);
37293 +
37294 +#ifdef CONFIG_PAX_USERCOPY
37295 + kfree(temp);
37296 +#endif
37297 +
37298 + if (err)
37299 return -EFAULT;
37300 buf += sz;
37301 p += sz;
37302 @@ -869,6 +916,9 @@ static const struct memdev {
37303 #ifdef CONFIG_CRASH_DUMP
37304 [12] = { "oldmem", 0, &oldmem_fops, NULL },
37305 #endif
37306 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
37307 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
37308 +#endif
37309 };
37310
37311 static int memory_open(struct inode *inode, struct file *filp)
37312 @@ -940,7 +990,7 @@ static int __init chr_dev_init(void)
37313 continue;
37314
37315 device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
37316 - NULL, devlist[minor].name);
37317 + NULL, "%s", devlist[minor].name);
37318 }
37319
37320 return tty_init();
37321 diff --git a/drivers/char/mwave/tp3780i.c b/drivers/char/mwave/tp3780i.c
37322 index c689697..04e6d6a2 100644
37323 --- a/drivers/char/mwave/tp3780i.c
37324 +++ b/drivers/char/mwave/tp3780i.c
37325 @@ -479,6 +479,7 @@ int tp3780I_QueryAbilities(THINKPAD_BD_DATA * pBDData, MW_ABILITIES * pAbilities
37326 PRINTK_2(TRACE_TP3780I,
37327 "tp3780i::tp3780I_QueryAbilities entry pBDData %p\n", pBDData);
37328
37329 + memset(pAbilities, 0, sizeof(*pAbilities));
37330 /* fill out standard constant fields */
37331 pAbilities->instr_per_sec = pBDData->rDspSettings.uIps;
37332 pAbilities->data_size = pBDData->rDspSettings.uDStoreSize;
37333 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
37334 index 9df78e2..01ba9ae 100644
37335 --- a/drivers/char/nvram.c
37336 +++ b/drivers/char/nvram.c
37337 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
37338
37339 spin_unlock_irq(&rtc_lock);
37340
37341 - if (copy_to_user(buf, contents, tmp - contents))
37342 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
37343 return -EFAULT;
37344
37345 *ppos = i;
37346 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
37347 index 5c5cc00..ac9edb7 100644
37348 --- a/drivers/char/pcmcia/synclink_cs.c
37349 +++ b/drivers/char/pcmcia/synclink_cs.c
37350 @@ -2345,9 +2345,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
37351
37352 if (debug_level >= DEBUG_LEVEL_INFO)
37353 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
37354 - __FILE__, __LINE__, info->device_name, port->count);
37355 + __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
37356
37357 - WARN_ON(!port->count);
37358 + WARN_ON(!atomic_read(&port->count));
37359
37360 if (tty_port_close_start(port, tty, filp) == 0)
37361 goto cleanup;
37362 @@ -2365,7 +2365,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
37363 cleanup:
37364 if (debug_level >= DEBUG_LEVEL_INFO)
37365 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
37366 - tty->driver->name, port->count);
37367 + tty->driver->name, atomic_read(&port->count));
37368 }
37369
37370 /* Wait until the transmitter is empty.
37371 @@ -2507,7 +2507,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
37372
37373 if (debug_level >= DEBUG_LEVEL_INFO)
37374 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
37375 - __FILE__, __LINE__, tty->driver->name, port->count);
37376 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
37377
37378 /* If port is closing, signal caller to try again */
37379 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
37380 @@ -2527,11 +2527,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
37381 goto cleanup;
37382 }
37383 spin_lock(&port->lock);
37384 - port->count++;
37385 + atomic_inc(&port->count);
37386 spin_unlock(&port->lock);
37387 spin_unlock_irqrestore(&info->netlock, flags);
37388
37389 - if (port->count == 1) {
37390 + if (atomic_read(&port->count) == 1) {
37391 /* 1st open on this device, init hardware */
37392 retval = startup(info, tty);
37393 if (retval < 0)
37394 @@ -3920,7 +3920,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
37395 unsigned short new_crctype;
37396
37397 /* return error if TTY interface open */
37398 - if (info->port.count)
37399 + if (atomic_read(&info->port.count))
37400 return -EBUSY;
37401
37402 switch (encoding)
37403 @@ -4024,7 +4024,7 @@ static int hdlcdev_open(struct net_device *dev)
37404
37405 /* arbitrate between network and tty opens */
37406 spin_lock_irqsave(&info->netlock, flags);
37407 - if (info->port.count != 0 || info->netcount != 0) {
37408 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
37409 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
37410 spin_unlock_irqrestore(&info->netlock, flags);
37411 return -EBUSY;
37412 @@ -4114,7 +4114,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
37413 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
37414
37415 /* return error if TTY interface open */
37416 - if (info->port.count)
37417 + if (atomic_read(&info->port.count))
37418 return -EBUSY;
37419
37420 if (cmd != SIOCWANDEV)
37421 diff --git a/drivers/char/random.c b/drivers/char/random.c
37422 index 35487e8..dac8bd1 100644
37423 --- a/drivers/char/random.c
37424 +++ b/drivers/char/random.c
37425 @@ -272,8 +272,13 @@
37426 /*
37427 * Configuration information
37428 */
37429 +#ifdef CONFIG_GRKERNSEC_RANDNET
37430 +#define INPUT_POOL_WORDS 512
37431 +#define OUTPUT_POOL_WORDS 128
37432 +#else
37433 #define INPUT_POOL_WORDS 128
37434 #define OUTPUT_POOL_WORDS 32
37435 +#endif
37436 #define SEC_XFER_SIZE 512
37437 #define EXTRACT_SIZE 10
37438
37439 @@ -313,10 +318,17 @@ static struct poolinfo {
37440 int poolwords;
37441 int tap1, tap2, tap3, tap4, tap5;
37442 } poolinfo_table[] = {
37443 +#ifdef CONFIG_GRKERNSEC_RANDNET
37444 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
37445 + { 512, 411, 308, 208, 104, 1 },
37446 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
37447 + { 128, 103, 76, 51, 25, 1 },
37448 +#else
37449 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
37450 { 128, 103, 76, 51, 25, 1 },
37451 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
37452 { 32, 26, 20, 14, 7, 1 },
37453 +#endif
37454 #if 0
37455 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
37456 { 2048, 1638, 1231, 819, 411, 1 },
37457 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
37458 input_rotate += i ? 7 : 14;
37459 }
37460
37461 - ACCESS_ONCE(r->input_rotate) = input_rotate;
37462 - ACCESS_ONCE(r->add_ptr) = i;
37463 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
37464 + ACCESS_ONCE_RW(r->add_ptr) = i;
37465 smp_wmb();
37466
37467 if (out)
37468 @@ -1032,7 +1044,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
37469
37470 extract_buf(r, tmp);
37471 i = min_t(int, nbytes, EXTRACT_SIZE);
37472 - if (copy_to_user(buf, tmp, i)) {
37473 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
37474 ret = -EFAULT;
37475 break;
37476 }
37477 @@ -1368,7 +1380,7 @@ EXPORT_SYMBOL(generate_random_uuid);
37478 #include <linux/sysctl.h>
37479
37480 static int min_read_thresh = 8, min_write_thresh;
37481 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
37482 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
37483 static int max_write_thresh = INPUT_POOL_WORDS * 32;
37484 static char sysctl_bootid[16];
37485
37486 @@ -1384,7 +1396,7 @@ static char sysctl_bootid[16];
37487 static int proc_do_uuid(ctl_table *table, int write,
37488 void __user *buffer, size_t *lenp, loff_t *ppos)
37489 {
37490 - ctl_table fake_table;
37491 + ctl_table_no_const fake_table;
37492 unsigned char buf[64], tmp_uuid[16], *uuid;
37493
37494 uuid = table->data;
37495 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
37496 index bf2349db..5456d53 100644
37497 --- a/drivers/char/sonypi.c
37498 +++ b/drivers/char/sonypi.c
37499 @@ -54,6 +54,7 @@
37500
37501 #include <asm/uaccess.h>
37502 #include <asm/io.h>
37503 +#include <asm/local.h>
37504
37505 #include <linux/sonypi.h>
37506
37507 @@ -490,7 +491,7 @@ static struct sonypi_device {
37508 spinlock_t fifo_lock;
37509 wait_queue_head_t fifo_proc_list;
37510 struct fasync_struct *fifo_async;
37511 - int open_count;
37512 + local_t open_count;
37513 int model;
37514 struct input_dev *input_jog_dev;
37515 struct input_dev *input_key_dev;
37516 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
37517 static int sonypi_misc_release(struct inode *inode, struct file *file)
37518 {
37519 mutex_lock(&sonypi_device.lock);
37520 - sonypi_device.open_count--;
37521 + local_dec(&sonypi_device.open_count);
37522 mutex_unlock(&sonypi_device.lock);
37523 return 0;
37524 }
37525 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
37526 {
37527 mutex_lock(&sonypi_device.lock);
37528 /* Flush input queue on first open */
37529 - if (!sonypi_device.open_count)
37530 + if (!local_read(&sonypi_device.open_count))
37531 kfifo_reset(&sonypi_device.fifo);
37532 - sonypi_device.open_count++;
37533 + local_inc(&sonypi_device.open_count);
37534 mutex_unlock(&sonypi_device.lock);
37535
37536 return 0;
37537 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
37538 index 64420b3..5c40b56 100644
37539 --- a/drivers/char/tpm/tpm_acpi.c
37540 +++ b/drivers/char/tpm/tpm_acpi.c
37541 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
37542 virt = acpi_os_map_memory(start, len);
37543 if (!virt) {
37544 kfree(log->bios_event_log);
37545 + log->bios_event_log = NULL;
37546 printk("%s: ERROR - Unable to map memory\n", __func__);
37547 return -EIO;
37548 }
37549
37550 - memcpy_fromio(log->bios_event_log, virt, len);
37551 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
37552
37553 acpi_os_unmap_memory(virt, len);
37554 return 0;
37555 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
37556 index 84ddc55..1d32f1e 100644
37557 --- a/drivers/char/tpm/tpm_eventlog.c
37558 +++ b/drivers/char/tpm/tpm_eventlog.c
37559 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
37560 event = addr;
37561
37562 if ((event->event_type == 0 && event->event_size == 0) ||
37563 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
37564 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
37565 return NULL;
37566
37567 return addr;
37568 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
37569 return NULL;
37570
37571 if ((event->event_type == 0 && event->event_size == 0) ||
37572 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
37573 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
37574 return NULL;
37575
37576 (*pos)++;
37577 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
37578 int i;
37579
37580 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
37581 - seq_putc(m, data[i]);
37582 + if (!seq_putc(m, data[i]))
37583 + return -EFAULT;
37584
37585 return 0;
37586 }
37587 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
37588 index fc45567..fa2a590 100644
37589 --- a/drivers/char/virtio_console.c
37590 +++ b/drivers/char/virtio_console.c
37591 @@ -682,7 +682,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
37592 if (to_user) {
37593 ssize_t ret;
37594
37595 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
37596 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
37597 if (ret)
37598 return -EFAULT;
37599 } else {
37600 @@ -785,7 +785,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
37601 if (!port_has_data(port) && !port->host_connected)
37602 return 0;
37603
37604 - return fill_readbuf(port, ubuf, count, true);
37605 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
37606 }
37607
37608 static int wait_port_writable(struct port *port, bool nonblock)
37609 diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
37610 index a33f46f..a720eed 100644
37611 --- a/drivers/clk/clk-composite.c
37612 +++ b/drivers/clk/clk-composite.c
37613 @@ -122,7 +122,7 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
37614 struct clk *clk;
37615 struct clk_init_data init;
37616 struct clk_composite *composite;
37617 - struct clk_ops *clk_composite_ops;
37618 + clk_ops_no_const *clk_composite_ops;
37619
37620 composite = kzalloc(sizeof(*composite), GFP_KERNEL);
37621 if (!composite) {
37622 diff --git a/drivers/clk/socfpga/clk.c b/drivers/clk/socfpga/clk.c
37623 index bd11315..7f87098 100644
37624 --- a/drivers/clk/socfpga/clk.c
37625 +++ b/drivers/clk/socfpga/clk.c
37626 @@ -22,6 +22,7 @@
37627 #include <linux/clk-provider.h>
37628 #include <linux/io.h>
37629 #include <linux/of.h>
37630 +#include <asm/pgtable.h>
37631
37632 /* Clock Manager offsets */
37633 #define CLKMGR_CTRL 0x0
37634 @@ -135,8 +136,10 @@ static __init struct clk *socfpga_clk_init(struct device_node *node,
37635 if (strcmp(clk_name, "main_pll") || strcmp(clk_name, "periph_pll") ||
37636 strcmp(clk_name, "sdram_pll")) {
37637 socfpga_clk->hw.bit_idx = SOCFPGA_PLL_EXT_ENA;
37638 - clk_pll_ops.enable = clk_gate_ops.enable;
37639 - clk_pll_ops.disable = clk_gate_ops.disable;
37640 + pax_open_kernel();
37641 + *(void **)&clk_pll_ops.enable = clk_gate_ops.enable;
37642 + *(void **)&clk_pll_ops.disable = clk_gate_ops.disable;
37643 + pax_close_kernel();
37644 }
37645
37646 clk = clk_register(NULL, &socfpga_clk->hw.hw);
37647 diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
37648 index a2b2541..bc1e7ff 100644
37649 --- a/drivers/clocksource/arm_arch_timer.c
37650 +++ b/drivers/clocksource/arm_arch_timer.c
37651 @@ -264,7 +264,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
37652 return NOTIFY_OK;
37653 }
37654
37655 -static struct notifier_block arch_timer_cpu_nb __cpuinitdata = {
37656 +static struct notifier_block arch_timer_cpu_nb = {
37657 .notifier_call = arch_timer_cpu_notify,
37658 };
37659
37660 diff --git a/drivers/clocksource/bcm_kona_timer.c b/drivers/clocksource/bcm_kona_timer.c
37661 index 350f493..489479e 100644
37662 --- a/drivers/clocksource/bcm_kona_timer.c
37663 +++ b/drivers/clocksource/bcm_kona_timer.c
37664 @@ -199,7 +199,7 @@ static struct irqaction kona_timer_irq = {
37665 .handler = kona_timer_interrupt,
37666 };
37667
37668 -static void __init kona_timer_init(void)
37669 +static void __init kona_timer_init(struct device_node *np)
37670 {
37671 kona_timers_init();
37672 kona_timer_clockevents_init();
37673 diff --git a/drivers/clocksource/metag_generic.c b/drivers/clocksource/metag_generic.c
37674 index ade7513..069445f 100644
37675 --- a/drivers/clocksource/metag_generic.c
37676 +++ b/drivers/clocksource/metag_generic.c
37677 @@ -169,7 +169,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
37678 return NOTIFY_OK;
37679 }
37680
37681 -static struct notifier_block __cpuinitdata arch_timer_cpu_nb = {
37682 +static struct notifier_block arch_timer_cpu_nb = {
37683 .notifier_call = arch_timer_cpu_notify,
37684 };
37685
37686 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
37687 index edc089e..bc7c0bc 100644
37688 --- a/drivers/cpufreq/acpi-cpufreq.c
37689 +++ b/drivers/cpufreq/acpi-cpufreq.c
37690 @@ -172,7 +172,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
37691 return sprintf(buf, "%u\n", boost_enabled);
37692 }
37693
37694 -static struct global_attr global_boost = __ATTR(boost, 0644,
37695 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
37696 show_global_boost,
37697 store_global_boost);
37698
37699 @@ -705,8 +705,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37700 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
37701 per_cpu(acfreq_data, cpu) = data;
37702
37703 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
37704 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37705 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
37706 + pax_open_kernel();
37707 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37708 + pax_close_kernel();
37709 + }
37710
37711 result = acpi_processor_register_performance(data->acpi_data, cpu);
37712 if (result)
37713 @@ -832,7 +835,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37714 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
37715 break;
37716 case ACPI_ADR_SPACE_FIXED_HARDWARE:
37717 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37718 + pax_open_kernel();
37719 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37720 + pax_close_kernel();
37721 policy->cur = get_cur_freq_on_cpu(cpu);
37722 break;
37723 default:
37724 @@ -843,8 +848,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37725 acpi_processor_notify_smm(THIS_MODULE);
37726
37727 /* Check for APERF/MPERF support in hardware */
37728 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
37729 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
37730 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
37731 + pax_open_kernel();
37732 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
37733 + pax_close_kernel();
37734 + }
37735
37736 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
37737 for (i = 0; i < perf->state_count; i++)
37738 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
37739 index 6485547..477033e 100644
37740 --- a/drivers/cpufreq/cpufreq.c
37741 +++ b/drivers/cpufreq/cpufreq.c
37742 @@ -1854,7 +1854,7 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
37743 return NOTIFY_OK;
37744 }
37745
37746 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
37747 +static struct notifier_block cpufreq_cpu_notifier = {
37748 .notifier_call = cpufreq_cpu_callback,
37749 };
37750
37751 @@ -1886,8 +1886,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
37752
37753 pr_debug("trying to register driver %s\n", driver_data->name);
37754
37755 - if (driver_data->setpolicy)
37756 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
37757 + if (driver_data->setpolicy) {
37758 + pax_open_kernel();
37759 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
37760 + pax_close_kernel();
37761 + }
37762
37763 write_lock_irqsave(&cpufreq_driver_lock, flags);
37764 if (cpufreq_driver) {
37765 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
37766 index a86ff72..aad2b03 100644
37767 --- a/drivers/cpufreq/cpufreq_governor.c
37768 +++ b/drivers/cpufreq/cpufreq_governor.c
37769 @@ -235,7 +235,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37770 struct dbs_data *dbs_data;
37771 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
37772 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
37773 - struct od_ops *od_ops = NULL;
37774 + const struct od_ops *od_ops = NULL;
37775 struct od_dbs_tuners *od_tuners = NULL;
37776 struct cs_dbs_tuners *cs_tuners = NULL;
37777 struct cpu_dbs_common_info *cpu_cdbs;
37778 @@ -298,7 +298,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37779
37780 if ((cdata->governor == GOV_CONSERVATIVE) &&
37781 (!policy->governor->initialized)) {
37782 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37783 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37784
37785 cpufreq_register_notifier(cs_ops->notifier_block,
37786 CPUFREQ_TRANSITION_NOTIFIER);
37787 @@ -315,7 +315,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37788
37789 if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) &&
37790 (policy->governor->initialized == 1)) {
37791 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37792 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37793
37794 cpufreq_unregister_notifier(cs_ops->notifier_block,
37795 CPUFREQ_TRANSITION_NOTIFIER);
37796 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
37797 index 0d9e6be..461fd3b 100644
37798 --- a/drivers/cpufreq/cpufreq_governor.h
37799 +++ b/drivers/cpufreq/cpufreq_governor.h
37800 @@ -204,7 +204,7 @@ struct common_dbs_data {
37801 void (*exit)(struct dbs_data *dbs_data);
37802
37803 /* Governor specific ops, see below */
37804 - void *gov_ops;
37805 + const void *gov_ops;
37806 };
37807
37808 /* Governer Per policy data */
37809 diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
37810 index c087347..dad6268 100644
37811 --- a/drivers/cpufreq/cpufreq_ondemand.c
37812 +++ b/drivers/cpufreq/cpufreq_ondemand.c
37813 @@ -615,14 +615,18 @@ void od_register_powersave_bias_handler(unsigned int (*f)
37814 (struct cpufreq_policy *, unsigned int, unsigned int),
37815 unsigned int powersave_bias)
37816 {
37817 - od_ops.powersave_bias_target = f;
37818 + pax_open_kernel();
37819 + *(void **)&od_ops.powersave_bias_target = f;
37820 + pax_close_kernel();
37821 od_set_powersave_bias(powersave_bias);
37822 }
37823 EXPORT_SYMBOL_GPL(od_register_powersave_bias_handler);
37824
37825 void od_unregister_powersave_bias_handler(void)
37826 {
37827 - od_ops.powersave_bias_target = generic_powersave_bias_target;
37828 + pax_open_kernel();
37829 + *(void **)&od_ops.powersave_bias_target = generic_powersave_bias_target;
37830 + pax_close_kernel();
37831 od_set_powersave_bias(0);
37832 }
37833 EXPORT_SYMBOL_GPL(od_unregister_powersave_bias_handler);
37834 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
37835 index bfd6273..e39dd63 100644
37836 --- a/drivers/cpufreq/cpufreq_stats.c
37837 +++ b/drivers/cpufreq/cpufreq_stats.c
37838 @@ -365,7 +365,7 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
37839 }
37840
37841 /* priority=1 so this will get called before cpufreq_remove_dev */
37842 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
37843 +static struct notifier_block cpufreq_stat_cpu_notifier = {
37844 .notifier_call = cpufreq_stat_cpu_callback,
37845 .priority = 1,
37846 };
37847 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
37848 index 421ef37..e708530c 100644
37849 --- a/drivers/cpufreq/p4-clockmod.c
37850 +++ b/drivers/cpufreq/p4-clockmod.c
37851 @@ -160,10 +160,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
37852 case 0x0F: /* Core Duo */
37853 case 0x16: /* Celeron Core */
37854 case 0x1C: /* Atom */
37855 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37856 + pax_open_kernel();
37857 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37858 + pax_close_kernel();
37859 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
37860 case 0x0D: /* Pentium M (Dothan) */
37861 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37862 + pax_open_kernel();
37863 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37864 + pax_close_kernel();
37865 /* fall through */
37866 case 0x09: /* Pentium M (Banias) */
37867 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
37868 @@ -175,7 +179,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
37869
37870 /* on P-4s, the TSC runs with constant frequency independent whether
37871 * throttling is active or not. */
37872 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37873 + pax_open_kernel();
37874 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37875 + pax_close_kernel();
37876
37877 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
37878 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
37879 diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
37880 index c71ee14..7c2e183 100644
37881 --- a/drivers/cpufreq/sparc-us3-cpufreq.c
37882 +++ b/drivers/cpufreq/sparc-us3-cpufreq.c
37883 @@ -18,14 +18,12 @@
37884 #include <asm/head.h>
37885 #include <asm/timer.h>
37886
37887 -static struct cpufreq_driver *cpufreq_us3_driver;
37888 -
37889 struct us3_freq_percpu_info {
37890 struct cpufreq_frequency_table table[4];
37891 };
37892
37893 /* Indexed by cpu number. */
37894 -static struct us3_freq_percpu_info *us3_freq_table;
37895 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
37896
37897 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
37898 * in the Safari config register.
37899 @@ -186,12 +184,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
37900
37901 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
37902 {
37903 - if (cpufreq_us3_driver)
37904 - us3_set_cpu_divider_index(policy, 0);
37905 + us3_set_cpu_divider_index(policy->cpu, 0);
37906
37907 return 0;
37908 }
37909
37910 +static int __init us3_freq_init(void);
37911 +static void __exit us3_freq_exit(void);
37912 +
37913 +static struct cpufreq_driver cpufreq_us3_driver = {
37914 + .init = us3_freq_cpu_init,
37915 + .verify = us3_freq_verify,
37916 + .target = us3_freq_target,
37917 + .get = us3_freq_get,
37918 + .exit = us3_freq_cpu_exit,
37919 + .owner = THIS_MODULE,
37920 + .name = "UltraSPARC-III",
37921 +
37922 +};
37923 +
37924 static int __init us3_freq_init(void)
37925 {
37926 unsigned long manuf, impl, ver;
37927 @@ -208,57 +219,15 @@ static int __init us3_freq_init(void)
37928 (impl == CHEETAH_IMPL ||
37929 impl == CHEETAH_PLUS_IMPL ||
37930 impl == JAGUAR_IMPL ||
37931 - impl == PANTHER_IMPL)) {
37932 - struct cpufreq_driver *driver;
37933 -
37934 - ret = -ENOMEM;
37935 - driver = kzalloc(sizeof(struct cpufreq_driver), GFP_KERNEL);
37936 - if (!driver)
37937 - goto err_out;
37938 -
37939 - us3_freq_table = kzalloc(
37940 - (NR_CPUS * sizeof(struct us3_freq_percpu_info)),
37941 - GFP_KERNEL);
37942 - if (!us3_freq_table)
37943 - goto err_out;
37944 -
37945 - driver->init = us3_freq_cpu_init;
37946 - driver->verify = us3_freq_verify;
37947 - driver->target = us3_freq_target;
37948 - driver->get = us3_freq_get;
37949 - driver->exit = us3_freq_cpu_exit;
37950 - driver->owner = THIS_MODULE,
37951 - strcpy(driver->name, "UltraSPARC-III");
37952 -
37953 - cpufreq_us3_driver = driver;
37954 - ret = cpufreq_register_driver(driver);
37955 - if (ret)
37956 - goto err_out;
37957 -
37958 - return 0;
37959 -
37960 -err_out:
37961 - if (driver) {
37962 - kfree(driver);
37963 - cpufreq_us3_driver = NULL;
37964 - }
37965 - kfree(us3_freq_table);
37966 - us3_freq_table = NULL;
37967 - return ret;
37968 - }
37969 + impl == PANTHER_IMPL))
37970 + return cpufreq_register_driver(&cpufreq_us3_driver);
37971
37972 return -ENODEV;
37973 }
37974
37975 static void __exit us3_freq_exit(void)
37976 {
37977 - if (cpufreq_us3_driver) {
37978 - cpufreq_unregister_driver(cpufreq_us3_driver);
37979 - kfree(cpufreq_us3_driver);
37980 - cpufreq_us3_driver = NULL;
37981 - kfree(us3_freq_table);
37982 - us3_freq_table = NULL;
37983 - }
37984 + cpufreq_unregister_driver(&cpufreq_us3_driver);
37985 }
37986
37987 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
37988 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
37989 index 618e6f4..e89d915 100644
37990 --- a/drivers/cpufreq/speedstep-centrino.c
37991 +++ b/drivers/cpufreq/speedstep-centrino.c
37992 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
37993 !cpu_has(cpu, X86_FEATURE_EST))
37994 return -ENODEV;
37995
37996 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
37997 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
37998 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
37999 + pax_open_kernel();
38000 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
38001 + pax_close_kernel();
38002 + }
38003
38004 if (policy->cpu != 0)
38005 return -ENODEV;
38006 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
38007 index c3a93fe..e808f24 100644
38008 --- a/drivers/cpuidle/cpuidle.c
38009 +++ b/drivers/cpuidle/cpuidle.c
38010 @@ -254,7 +254,7 @@ static int poll_idle(struct cpuidle_device *dev,
38011
38012 static void poll_idle_init(struct cpuidle_driver *drv)
38013 {
38014 - struct cpuidle_state *state = &drv->states[0];
38015 + cpuidle_state_no_const *state = &drv->states[0];
38016
38017 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
38018 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
38019 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
38020 index ea2f8e7..70ac501 100644
38021 --- a/drivers/cpuidle/governor.c
38022 +++ b/drivers/cpuidle/governor.c
38023 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
38024 mutex_lock(&cpuidle_lock);
38025 if (__cpuidle_find_governor(gov->name) == NULL) {
38026 ret = 0;
38027 - list_add_tail(&gov->governor_list, &cpuidle_governors);
38028 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
38029 if (!cpuidle_curr_governor ||
38030 cpuidle_curr_governor->rating < gov->rating)
38031 cpuidle_switch_governor(gov);
38032 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
38033 new_gov = cpuidle_replace_governor(gov->rating);
38034 cpuidle_switch_governor(new_gov);
38035 }
38036 - list_del(&gov->governor_list);
38037 + pax_list_del((struct list_head *)&gov->governor_list);
38038 mutex_unlock(&cpuidle_lock);
38039 }
38040
38041 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
38042 index 428754a..8bdf9cc 100644
38043 --- a/drivers/cpuidle/sysfs.c
38044 +++ b/drivers/cpuidle/sysfs.c
38045 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
38046 NULL
38047 };
38048
38049 -static struct attribute_group cpuidle_attr_group = {
38050 +static attribute_group_no_const cpuidle_attr_group = {
38051 .attrs = cpuidle_default_attrs,
38052 .name = "cpuidle",
38053 };
38054 diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c
38055 index ebf130e..e32d8a9 100644
38056 --- a/drivers/crypto/hifn_795x.c
38057 +++ b/drivers/crypto/hifn_795x.c
38058 @@ -51,7 +51,7 @@ module_param_string(hifn_pll_ref, hifn_pll_ref, sizeof(hifn_pll_ref), 0444);
38059 MODULE_PARM_DESC(hifn_pll_ref,
38060 "PLL reference clock (pci[freq] or ext[freq], default ext)");
38061
38062 -static atomic_t hifn_dev_number;
38063 +static atomic_unchecked_t hifn_dev_number;
38064
38065 #define ACRYPTO_OP_DECRYPT 0
38066 #define ACRYPTO_OP_ENCRYPT 1
38067 @@ -2577,7 +2577,7 @@ static int hifn_probe(struct pci_dev *pdev, const struct pci_device_id *id)
38068 goto err_out_disable_pci_device;
38069
38070 snprintf(name, sizeof(name), "hifn%d",
38071 - atomic_inc_return(&hifn_dev_number)-1);
38072 + atomic_inc_return_unchecked(&hifn_dev_number)-1);
38073
38074 err = pci_request_regions(pdev, name);
38075 if (err)
38076 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
38077 index 3b36797..db0b0c0 100644
38078 --- a/drivers/devfreq/devfreq.c
38079 +++ b/drivers/devfreq/devfreq.c
38080 @@ -477,7 +477,7 @@ struct devfreq *devfreq_add_device(struct device *dev,
38081 GFP_KERNEL);
38082 devfreq->last_stat_updated = jiffies;
38083
38084 - dev_set_name(&devfreq->dev, dev_name(dev));
38085 + dev_set_name(&devfreq->dev, "%s", dev_name(dev));
38086 err = device_register(&devfreq->dev);
38087 if (err) {
38088 put_device(&devfreq->dev);
38089 @@ -588,7 +588,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
38090 goto err_out;
38091 }
38092
38093 - list_add(&governor->node, &devfreq_governor_list);
38094 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
38095
38096 list_for_each_entry(devfreq, &devfreq_list, node) {
38097 int ret = 0;
38098 @@ -676,7 +676,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
38099 }
38100 }
38101
38102 - list_del(&governor->node);
38103 + pax_list_del((struct list_head *)&governor->node);
38104 err_out:
38105 mutex_unlock(&devfreq_list_lock);
38106
38107 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
38108 index b70709b..1d8d02a 100644
38109 --- a/drivers/dma/sh/shdma.c
38110 +++ b/drivers/dma/sh/shdma.c
38111 @@ -476,7 +476,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
38112 return ret;
38113 }
38114
38115 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
38116 +static struct notifier_block sh_dmae_nmi_notifier = {
38117 .notifier_call = sh_dmae_nmi_handler,
38118
38119 /* Run before NMI debug handler and KGDB */
38120 diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c
38121 index 211021d..201d47f 100644
38122 --- a/drivers/edac/edac_device.c
38123 +++ b/drivers/edac/edac_device.c
38124 @@ -474,9 +474,9 @@ void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev,
38125 */
38126 int edac_device_alloc_index(void)
38127 {
38128 - static atomic_t device_indexes = ATOMIC_INIT(0);
38129 + static atomic_unchecked_t device_indexes = ATOMIC_INIT(0);
38130
38131 - return atomic_inc_return(&device_indexes) - 1;
38132 + return atomic_inc_return_unchecked(&device_indexes) - 1;
38133 }
38134 EXPORT_SYMBOL_GPL(edac_device_alloc_index);
38135
38136 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
38137 index c4d700a..0b57abd 100644
38138 --- a/drivers/edac/edac_mc_sysfs.c
38139 +++ b/drivers/edac/edac_mc_sysfs.c
38140 @@ -148,7 +148,7 @@ static const char * const edac_caps[] = {
38141 struct dev_ch_attribute {
38142 struct device_attribute attr;
38143 int channel;
38144 -};
38145 +} __do_const;
38146
38147 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
38148 struct dev_ch_attribute dev_attr_legacy_##_name = \
38149 @@ -1005,14 +1005,16 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
38150 }
38151
38152 if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) {
38153 + pax_open_kernel();
38154 if (mci->get_sdram_scrub_rate) {
38155 - dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
38156 - dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
38157 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
38158 + *(void **)&dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
38159 }
38160 if (mci->set_sdram_scrub_rate) {
38161 - dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
38162 - dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
38163 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
38164 + *(void **)&dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
38165 }
38166 + pax_close_kernel();
38167 err = device_create_file(&mci->dev,
38168 &dev_attr_sdram_scrub_rate);
38169 if (err) {
38170 diff --git a/drivers/edac/edac_pci.c b/drivers/edac/edac_pci.c
38171 index dd370f9..0281629 100644
38172 --- a/drivers/edac/edac_pci.c
38173 +++ b/drivers/edac/edac_pci.c
38174 @@ -29,7 +29,7 @@
38175
38176 static DEFINE_MUTEX(edac_pci_ctls_mutex);
38177 static LIST_HEAD(edac_pci_list);
38178 -static atomic_t pci_indexes = ATOMIC_INIT(0);
38179 +static atomic_unchecked_t pci_indexes = ATOMIC_INIT(0);
38180
38181 /*
38182 * edac_pci_alloc_ctl_info
38183 @@ -315,7 +315,7 @@ EXPORT_SYMBOL_GPL(edac_pci_reset_delay_period);
38184 */
38185 int edac_pci_alloc_index(void)
38186 {
38187 - return atomic_inc_return(&pci_indexes) - 1;
38188 + return atomic_inc_return_unchecked(&pci_indexes) - 1;
38189 }
38190 EXPORT_SYMBOL_GPL(edac_pci_alloc_index);
38191
38192 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
38193 index e8658e4..22746d6 100644
38194 --- a/drivers/edac/edac_pci_sysfs.c
38195 +++ b/drivers/edac/edac_pci_sysfs.c
38196 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
38197 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
38198 static int edac_pci_poll_msec = 1000; /* one second workq period */
38199
38200 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
38201 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
38202 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
38203 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
38204
38205 static struct kobject *edac_pci_top_main_kobj;
38206 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
38207 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
38208 void *value;
38209 ssize_t(*show) (void *, char *);
38210 ssize_t(*store) (void *, const char *, size_t);
38211 -};
38212 +} __do_const;
38213
38214 /* Set of show/store abstract level functions for PCI Parity object */
38215 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
38216 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
38217 edac_printk(KERN_CRIT, EDAC_PCI,
38218 "Signaled System Error on %s\n",
38219 pci_name(dev));
38220 - atomic_inc(&pci_nonparity_count);
38221 + atomic_inc_unchecked(&pci_nonparity_count);
38222 }
38223
38224 if (status & (PCI_STATUS_PARITY)) {
38225 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
38226 "Master Data Parity Error on %s\n",
38227 pci_name(dev));
38228
38229 - atomic_inc(&pci_parity_count);
38230 + atomic_inc_unchecked(&pci_parity_count);
38231 }
38232
38233 if (status & (PCI_STATUS_DETECTED_PARITY)) {
38234 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
38235 "Detected Parity Error on %s\n",
38236 pci_name(dev));
38237
38238 - atomic_inc(&pci_parity_count);
38239 + atomic_inc_unchecked(&pci_parity_count);
38240 }
38241 }
38242
38243 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
38244 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
38245 "Signaled System Error on %s\n",
38246 pci_name(dev));
38247 - atomic_inc(&pci_nonparity_count);
38248 + atomic_inc_unchecked(&pci_nonparity_count);
38249 }
38250
38251 if (status & (PCI_STATUS_PARITY)) {
38252 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
38253 "Master Data Parity Error on "
38254 "%s\n", pci_name(dev));
38255
38256 - atomic_inc(&pci_parity_count);
38257 + atomic_inc_unchecked(&pci_parity_count);
38258 }
38259
38260 if (status & (PCI_STATUS_DETECTED_PARITY)) {
38261 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
38262 "Detected Parity Error on %s\n",
38263 pci_name(dev));
38264
38265 - atomic_inc(&pci_parity_count);
38266 + atomic_inc_unchecked(&pci_parity_count);
38267 }
38268 }
38269 }
38270 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
38271 if (!check_pci_errors)
38272 return;
38273
38274 - before_count = atomic_read(&pci_parity_count);
38275 + before_count = atomic_read_unchecked(&pci_parity_count);
38276
38277 /* scan all PCI devices looking for a Parity Error on devices and
38278 * bridges.
38279 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
38280 /* Only if operator has selected panic on PCI Error */
38281 if (edac_pci_get_panic_on_pe()) {
38282 /* If the count is different 'after' from 'before' */
38283 - if (before_count != atomic_read(&pci_parity_count))
38284 + if (before_count != atomic_read_unchecked(&pci_parity_count))
38285 panic("EDAC: PCI Parity Error");
38286 }
38287 }
38288 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
38289 index 51b7e3a..aa8a3e8 100644
38290 --- a/drivers/edac/mce_amd.h
38291 +++ b/drivers/edac/mce_amd.h
38292 @@ -77,7 +77,7 @@ struct amd_decoder_ops {
38293 bool (*mc0_mce)(u16, u8);
38294 bool (*mc1_mce)(u16, u8);
38295 bool (*mc2_mce)(u16, u8);
38296 -};
38297 +} __no_const;
38298
38299 void amd_report_gart_errors(bool);
38300 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
38301 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
38302 index 57ea7f4..af06b76 100644
38303 --- a/drivers/firewire/core-card.c
38304 +++ b/drivers/firewire/core-card.c
38305 @@ -528,9 +528,9 @@ void fw_card_initialize(struct fw_card *card,
38306 const struct fw_card_driver *driver,
38307 struct device *device)
38308 {
38309 - static atomic_t index = ATOMIC_INIT(-1);
38310 + static atomic_unchecked_t index = ATOMIC_INIT(-1);
38311
38312 - card->index = atomic_inc_return(&index);
38313 + card->index = atomic_inc_return_unchecked(&index);
38314 card->driver = driver;
38315 card->device = device;
38316 card->current_tlabel = 0;
38317 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
38318
38319 void fw_core_remove_card(struct fw_card *card)
38320 {
38321 - struct fw_card_driver dummy_driver = dummy_driver_template;
38322 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
38323
38324 card->driver->update_phy_reg(card, 4,
38325 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
38326 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
38327 index 664a6ff..af13580 100644
38328 --- a/drivers/firewire/core-device.c
38329 +++ b/drivers/firewire/core-device.c
38330 @@ -232,7 +232,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
38331 struct config_rom_attribute {
38332 struct device_attribute attr;
38333 u32 key;
38334 -};
38335 +} __do_const;
38336
38337 static ssize_t show_immediate(struct device *dev,
38338 struct device_attribute *dattr, char *buf)
38339 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
38340 index 28a94c7..58da63a 100644
38341 --- a/drivers/firewire/core-transaction.c
38342 +++ b/drivers/firewire/core-transaction.c
38343 @@ -38,6 +38,7 @@
38344 #include <linux/timer.h>
38345 #include <linux/types.h>
38346 #include <linux/workqueue.h>
38347 +#include <linux/sched.h>
38348
38349 #include <asm/byteorder.h>
38350
38351 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
38352 index 515a42c..5ecf3ba 100644
38353 --- a/drivers/firewire/core.h
38354 +++ b/drivers/firewire/core.h
38355 @@ -111,6 +111,7 @@ struct fw_card_driver {
38356
38357 int (*stop_iso)(struct fw_iso_context *ctx);
38358 };
38359 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
38360
38361 void fw_card_initialize(struct fw_card *card,
38362 const struct fw_card_driver *driver, struct device *device);
38363 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
38364 index 94a58a0..f5eba42 100644
38365 --- a/drivers/firmware/dmi-id.c
38366 +++ b/drivers/firmware/dmi-id.c
38367 @@ -16,7 +16,7 @@
38368 struct dmi_device_attribute{
38369 struct device_attribute dev_attr;
38370 int field;
38371 -};
38372 +} __do_const;
38373 #define to_dmi_dev_attr(_dev_attr) \
38374 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
38375
38376 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
38377 index b95159b..841ae55 100644
38378 --- a/drivers/firmware/dmi_scan.c
38379 +++ b/drivers/firmware/dmi_scan.c
38380 @@ -497,11 +497,6 @@ void __init dmi_scan_machine(void)
38381 }
38382 }
38383 else {
38384 - /*
38385 - * no iounmap() for that ioremap(); it would be a no-op, but
38386 - * it's so early in setup that sucker gets confused into doing
38387 - * what it shouldn't if we actually call it.
38388 - */
38389 p = dmi_ioremap(0xF0000, 0x10000);
38390 if (p == NULL)
38391 goto error;
38392 @@ -786,7 +781,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
38393 if (buf == NULL)
38394 return -1;
38395
38396 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
38397 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
38398
38399 iounmap(buf);
38400 return 0;
38401 diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
38402 index 5145fa3..0d3babd 100644
38403 --- a/drivers/firmware/efi/efi.c
38404 +++ b/drivers/firmware/efi/efi.c
38405 @@ -65,14 +65,16 @@ static struct attribute_group efi_subsys_attr_group = {
38406 };
38407
38408 static struct efivars generic_efivars;
38409 -static struct efivar_operations generic_ops;
38410 +static efivar_operations_no_const generic_ops __read_only;
38411
38412 static int generic_ops_register(void)
38413 {
38414 - generic_ops.get_variable = efi.get_variable;
38415 - generic_ops.set_variable = efi.set_variable;
38416 - generic_ops.get_next_variable = efi.get_next_variable;
38417 - generic_ops.query_variable_store = efi_query_variable_store;
38418 + pax_open_kernel();
38419 + *(void **)&generic_ops.get_variable = efi.get_variable;
38420 + *(void **)&generic_ops.set_variable = efi.set_variable;
38421 + *(void **)&generic_ops.get_next_variable = efi.get_next_variable;
38422 + *(void **)&generic_ops.query_variable_store = efi_query_variable_store;
38423 + pax_close_kernel();
38424
38425 return efivars_register(&generic_efivars, &generic_ops, efi_kobj);
38426 }
38427 diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
38428 index 8bd1bb6..c48b0c6 100644
38429 --- a/drivers/firmware/efi/efivars.c
38430 +++ b/drivers/firmware/efi/efivars.c
38431 @@ -452,7 +452,7 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var)
38432 static int
38433 create_efivars_bin_attributes(void)
38434 {
38435 - struct bin_attribute *attr;
38436 + bin_attribute_no_const *attr;
38437 int error;
38438
38439 /* new_var */
38440 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
38441 index 2a90ba6..07f3733 100644
38442 --- a/drivers/firmware/google/memconsole.c
38443 +++ b/drivers/firmware/google/memconsole.c
38444 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
38445 if (!found_memconsole())
38446 return -ENODEV;
38447
38448 - memconsole_bin_attr.size = memconsole_length;
38449 + pax_open_kernel();
38450 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
38451 + pax_close_kernel();
38452
38453 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
38454
38455 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
38456 index e16d932..f0206ef 100644
38457 --- a/drivers/gpio/gpio-ich.c
38458 +++ b/drivers/gpio/gpio-ich.c
38459 @@ -69,7 +69,7 @@ struct ichx_desc {
38460 /* Some chipsets have quirks, let these use their own request/get */
38461 int (*request)(struct gpio_chip *chip, unsigned offset);
38462 int (*get)(struct gpio_chip *chip, unsigned offset);
38463 -};
38464 +} __do_const;
38465
38466 static struct {
38467 spinlock_t lock;
38468 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
38469 index 9902732..64b62dd 100644
38470 --- a/drivers/gpio/gpio-vr41xx.c
38471 +++ b/drivers/gpio/gpio-vr41xx.c
38472 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
38473 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
38474 maskl, pendl, maskh, pendh);
38475
38476 - atomic_inc(&irq_err_count);
38477 + atomic_inc_unchecked(&irq_err_count);
38478
38479 return -EINVAL;
38480 }
38481 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
38482 index ed1334e..ee0dd42 100644
38483 --- a/drivers/gpu/drm/drm_crtc_helper.c
38484 +++ b/drivers/gpu/drm/drm_crtc_helper.c
38485 @@ -321,7 +321,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
38486 struct drm_crtc *tmp;
38487 int crtc_mask = 1;
38488
38489 - WARN(!crtc, "checking null crtc?\n");
38490 + BUG_ON(!crtc);
38491
38492 dev = crtc->dev;
38493
38494 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
38495 index 9cc247f..36aa285 100644
38496 --- a/drivers/gpu/drm/drm_drv.c
38497 +++ b/drivers/gpu/drm/drm_drv.c
38498 @@ -306,7 +306,7 @@ module_exit(drm_core_exit);
38499 /**
38500 * Copy and IOCTL return string to user space
38501 */
38502 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
38503 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
38504 {
38505 int len;
38506
38507 @@ -376,7 +376,7 @@ long drm_ioctl(struct file *filp,
38508 struct drm_file *file_priv = filp->private_data;
38509 struct drm_device *dev;
38510 const struct drm_ioctl_desc *ioctl = NULL;
38511 - drm_ioctl_t *func;
38512 + drm_ioctl_no_const_t func;
38513 unsigned int nr = DRM_IOCTL_NR(cmd);
38514 int retcode = -EINVAL;
38515 char stack_kdata[128];
38516 @@ -389,7 +389,7 @@ long drm_ioctl(struct file *filp,
38517 return -ENODEV;
38518
38519 atomic_inc(&dev->ioctl_count);
38520 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
38521 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
38522 ++file_priv->ioctl_count;
38523
38524 if ((nr >= DRM_CORE_IOCTL_COUNT) &&
38525 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
38526 index 429e07d..e681a2c 100644
38527 --- a/drivers/gpu/drm/drm_fops.c
38528 +++ b/drivers/gpu/drm/drm_fops.c
38529 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
38530 }
38531
38532 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
38533 - atomic_set(&dev->counts[i], 0);
38534 + atomic_set_unchecked(&dev->counts[i], 0);
38535
38536 dev->sigdata.lock = NULL;
38537
38538 @@ -135,7 +135,7 @@ int drm_open(struct inode *inode, struct file *filp)
38539 if (drm_device_is_unplugged(dev))
38540 return -ENODEV;
38541
38542 - if (!dev->open_count++)
38543 + if (local_inc_return(&dev->open_count) == 1)
38544 need_setup = 1;
38545 mutex_lock(&dev->struct_mutex);
38546 old_imapping = inode->i_mapping;
38547 @@ -151,7 +151,7 @@ int drm_open(struct inode *inode, struct file *filp)
38548 retcode = drm_open_helper(inode, filp, dev);
38549 if (retcode)
38550 goto err_undo;
38551 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
38552 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
38553 if (need_setup) {
38554 retcode = drm_setup(dev);
38555 if (retcode)
38556 @@ -166,7 +166,7 @@ err_undo:
38557 iput(container_of(dev->dev_mapping, struct inode, i_data));
38558 dev->dev_mapping = old_mapping;
38559 mutex_unlock(&dev->struct_mutex);
38560 - dev->open_count--;
38561 + local_dec(&dev->open_count);
38562 return retcode;
38563 }
38564 EXPORT_SYMBOL(drm_open);
38565 @@ -441,7 +441,7 @@ int drm_release(struct inode *inode, struct file *filp)
38566
38567 mutex_lock(&drm_global_mutex);
38568
38569 - DRM_DEBUG("open_count = %d\n", dev->open_count);
38570 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
38571
38572 if (dev->driver->preclose)
38573 dev->driver->preclose(dev, file_priv);
38574 @@ -450,10 +450,10 @@ int drm_release(struct inode *inode, struct file *filp)
38575 * Begin inline drm_release
38576 */
38577
38578 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
38579 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
38580 task_pid_nr(current),
38581 (long)old_encode_dev(file_priv->minor->device),
38582 - dev->open_count);
38583 + local_read(&dev->open_count));
38584
38585 /* Release any auth tokens that might point to this file_priv,
38586 (do that under the drm_global_mutex) */
38587 @@ -550,8 +550,8 @@ int drm_release(struct inode *inode, struct file *filp)
38588 * End inline drm_release
38589 */
38590
38591 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
38592 - if (!--dev->open_count) {
38593 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
38594 + if (local_dec_and_test(&dev->open_count)) {
38595 if (atomic_read(&dev->ioctl_count)) {
38596 DRM_ERROR("Device busy: %d\n",
38597 atomic_read(&dev->ioctl_count));
38598 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
38599 index f731116..629842c 100644
38600 --- a/drivers/gpu/drm/drm_global.c
38601 +++ b/drivers/gpu/drm/drm_global.c
38602 @@ -36,7 +36,7 @@
38603 struct drm_global_item {
38604 struct mutex mutex;
38605 void *object;
38606 - int refcount;
38607 + atomic_t refcount;
38608 };
38609
38610 static struct drm_global_item glob[DRM_GLOBAL_NUM];
38611 @@ -49,7 +49,7 @@ void drm_global_init(void)
38612 struct drm_global_item *item = &glob[i];
38613 mutex_init(&item->mutex);
38614 item->object = NULL;
38615 - item->refcount = 0;
38616 + atomic_set(&item->refcount, 0);
38617 }
38618 }
38619
38620 @@ -59,7 +59,7 @@ void drm_global_release(void)
38621 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
38622 struct drm_global_item *item = &glob[i];
38623 BUG_ON(item->object != NULL);
38624 - BUG_ON(item->refcount != 0);
38625 + BUG_ON(atomic_read(&item->refcount) != 0);
38626 }
38627 }
38628
38629 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38630 void *object;
38631
38632 mutex_lock(&item->mutex);
38633 - if (item->refcount == 0) {
38634 + if (atomic_read(&item->refcount) == 0) {
38635 item->object = kzalloc(ref->size, GFP_KERNEL);
38636 if (unlikely(item->object == NULL)) {
38637 ret = -ENOMEM;
38638 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38639 goto out_err;
38640
38641 }
38642 - ++item->refcount;
38643 + atomic_inc(&item->refcount);
38644 ref->object = item->object;
38645 object = item->object;
38646 mutex_unlock(&item->mutex);
38647 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
38648 struct drm_global_item *item = &glob[ref->global_type];
38649
38650 mutex_lock(&item->mutex);
38651 - BUG_ON(item->refcount == 0);
38652 + BUG_ON(atomic_read(&item->refcount) == 0);
38653 BUG_ON(ref->object != item->object);
38654 - if (--item->refcount == 0) {
38655 + if (atomic_dec_and_test(&item->refcount)) {
38656 ref->release(ref);
38657 item->object = NULL;
38658 }
38659 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
38660 index d4b20ce..77a8d41 100644
38661 --- a/drivers/gpu/drm/drm_info.c
38662 +++ b/drivers/gpu/drm/drm_info.c
38663 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
38664 struct drm_local_map *map;
38665 struct drm_map_list *r_list;
38666
38667 - /* Hardcoded from _DRM_FRAME_BUFFER,
38668 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
38669 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
38670 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
38671 + static const char * const types[] = {
38672 + [_DRM_FRAME_BUFFER] = "FB",
38673 + [_DRM_REGISTERS] = "REG",
38674 + [_DRM_SHM] = "SHM",
38675 + [_DRM_AGP] = "AGP",
38676 + [_DRM_SCATTER_GATHER] = "SG",
38677 + [_DRM_CONSISTENT] = "PCI",
38678 + [_DRM_GEM] = "GEM" };
38679 const char *type;
38680 int i;
38681
38682 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
38683 map = r_list->map;
38684 if (!map)
38685 continue;
38686 - if (map->type < 0 || map->type > 5)
38687 + if (map->type >= ARRAY_SIZE(types))
38688 type = "??";
38689 else
38690 type = types[map->type];
38691 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
38692 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
38693 vma->vm_flags & VM_LOCKED ? 'l' : '-',
38694 vma->vm_flags & VM_IO ? 'i' : '-',
38695 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38696 + 0);
38697 +#else
38698 vma->vm_pgoff);
38699 +#endif
38700
38701 #if defined(__i386__)
38702 pgprot = pgprot_val(vma->vm_page_prot);
38703 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
38704 index 2f4c434..dd12cd2 100644
38705 --- a/drivers/gpu/drm/drm_ioc32.c
38706 +++ b/drivers/gpu/drm/drm_ioc32.c
38707 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
38708 request = compat_alloc_user_space(nbytes);
38709 if (!access_ok(VERIFY_WRITE, request, nbytes))
38710 return -EFAULT;
38711 - list = (struct drm_buf_desc *) (request + 1);
38712 + list = (struct drm_buf_desc __user *) (request + 1);
38713
38714 if (__put_user(count, &request->count)
38715 || __put_user(list, &request->list))
38716 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
38717 request = compat_alloc_user_space(nbytes);
38718 if (!access_ok(VERIFY_WRITE, request, nbytes))
38719 return -EFAULT;
38720 - list = (struct drm_buf_pub *) (request + 1);
38721 + list = (struct drm_buf_pub __user *) (request + 1);
38722
38723 if (__put_user(count, &request->count)
38724 || __put_user(list, &request->list))
38725 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
38726 return 0;
38727 }
38728
38729 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
38730 +drm_ioctl_compat_t drm_compat_ioctls[] = {
38731 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
38732 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
38733 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
38734 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
38735 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38736 {
38737 unsigned int nr = DRM_IOCTL_NR(cmd);
38738 - drm_ioctl_compat_t *fn;
38739 int ret;
38740
38741 /* Assume that ioctls without an explicit compat routine will just
38742 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38743 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
38744 return drm_ioctl(filp, cmd, arg);
38745
38746 - fn = drm_compat_ioctls[nr];
38747 -
38748 - if (fn != NULL)
38749 - ret = (*fn) (filp, cmd, arg);
38750 + if (drm_compat_ioctls[nr] != NULL)
38751 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
38752 else
38753 ret = drm_ioctl(filp, cmd, arg);
38754
38755 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
38756 index e77bd8b..1571b85 100644
38757 --- a/drivers/gpu/drm/drm_ioctl.c
38758 +++ b/drivers/gpu/drm/drm_ioctl.c
38759 @@ -252,7 +252,7 @@ int drm_getstats(struct drm_device *dev, void *data,
38760 stats->data[i].value =
38761 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
38762 else
38763 - stats->data[i].value = atomic_read(&dev->counts[i]);
38764 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
38765 stats->data[i].type = dev->types[i];
38766 }
38767
38768 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
38769 index d752c96..fe08455 100644
38770 --- a/drivers/gpu/drm/drm_lock.c
38771 +++ b/drivers/gpu/drm/drm_lock.c
38772 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38773 if (drm_lock_take(&master->lock, lock->context)) {
38774 master->lock.file_priv = file_priv;
38775 master->lock.lock_time = jiffies;
38776 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
38777 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
38778 break; /* Got lock */
38779 }
38780
38781 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38782 return -EINVAL;
38783 }
38784
38785 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
38786 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
38787
38788 if (drm_lock_free(&master->lock, lock->context)) {
38789 /* FIXME: Should really bail out here. */
38790 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
38791 index 16f3ec5..b28f9ca 100644
38792 --- a/drivers/gpu/drm/drm_stub.c
38793 +++ b/drivers/gpu/drm/drm_stub.c
38794 @@ -501,7 +501,7 @@ void drm_unplug_dev(struct drm_device *dev)
38795
38796 drm_device_set_unplugged(dev);
38797
38798 - if (dev->open_count == 0) {
38799 + if (local_read(&dev->open_count) == 0) {
38800 drm_put_dev(dev);
38801 }
38802 mutex_unlock(&drm_global_mutex);
38803 diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
38804 index 0229665..f61329c 100644
38805 --- a/drivers/gpu/drm/drm_sysfs.c
38806 +++ b/drivers/gpu/drm/drm_sysfs.c
38807 @@ -499,7 +499,7 @@ EXPORT_SYMBOL(drm_sysfs_hotplug_event);
38808 int drm_sysfs_device_add(struct drm_minor *minor)
38809 {
38810 int err;
38811 - char *minor_str;
38812 + const char *minor_str;
38813
38814 minor->kdev.parent = minor->dev->dev;
38815
38816 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
38817 index 004ecdf..db1f6e0 100644
38818 --- a/drivers/gpu/drm/i810/i810_dma.c
38819 +++ b/drivers/gpu/drm/i810/i810_dma.c
38820 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
38821 dma->buflist[vertex->idx],
38822 vertex->discard, vertex->used);
38823
38824 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
38825 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
38826 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
38827 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
38828 sarea_priv->last_enqueue = dev_priv->counter - 1;
38829 sarea_priv->last_dispatch = (int)hw_status[5];
38830
38831 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
38832 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
38833 mc->last_render);
38834
38835 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
38836 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
38837 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
38838 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
38839 sarea_priv->last_enqueue = dev_priv->counter - 1;
38840 sarea_priv->last_dispatch = (int)hw_status[5];
38841
38842 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
38843 index 6e0acad..93c8289 100644
38844 --- a/drivers/gpu/drm/i810/i810_drv.h
38845 +++ b/drivers/gpu/drm/i810/i810_drv.h
38846 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
38847 int page_flipping;
38848
38849 wait_queue_head_t irq_queue;
38850 - atomic_t irq_received;
38851 - atomic_t irq_emitted;
38852 + atomic_unchecked_t irq_received;
38853 + atomic_unchecked_t irq_emitted;
38854
38855 int front_offset;
38856 } drm_i810_private_t;
38857 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
38858 index e913d32..4d9b351 100644
38859 --- a/drivers/gpu/drm/i915/i915_debugfs.c
38860 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
38861 @@ -499,7 +499,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
38862 I915_READ(GTIMR));
38863 }
38864 seq_printf(m, "Interrupts received: %d\n",
38865 - atomic_read(&dev_priv->irq_received));
38866 + atomic_read_unchecked(&dev_priv->irq_received));
38867 for_each_ring(ring, dev_priv, i) {
38868 if (IS_GEN6(dev) || IS_GEN7(dev)) {
38869 seq_printf(m,
38870 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
38871 index 17d9b0b..860e6d9 100644
38872 --- a/drivers/gpu/drm/i915/i915_dma.c
38873 +++ b/drivers/gpu/drm/i915/i915_dma.c
38874 @@ -1259,7 +1259,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
38875 bool can_switch;
38876
38877 spin_lock(&dev->count_lock);
38878 - can_switch = (dev->open_count == 0);
38879 + can_switch = (local_read(&dev->open_count) == 0);
38880 spin_unlock(&dev->count_lock);
38881 return can_switch;
38882 }
38883 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
38884 index 47d8b68..52f5d8d 100644
38885 --- a/drivers/gpu/drm/i915/i915_drv.h
38886 +++ b/drivers/gpu/drm/i915/i915_drv.h
38887 @@ -916,7 +916,7 @@ typedef struct drm_i915_private {
38888 drm_dma_handle_t *status_page_dmah;
38889 struct resource mch_res;
38890
38891 - atomic_t irq_received;
38892 + atomic_unchecked_t irq_received;
38893
38894 /* protects the irq masks */
38895 spinlock_t irq_lock;
38896 @@ -1813,7 +1813,7 @@ extern struct i2c_adapter *intel_gmbus_get_adapter(
38897 struct drm_i915_private *dev_priv, unsigned port);
38898 extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
38899 extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
38900 -extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
38901 +static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
38902 {
38903 return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
38904 }
38905 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38906 index 117ce38..eefd237 100644
38907 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38908 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38909 @@ -727,9 +727,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
38910
38911 static int
38912 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
38913 - int count)
38914 + unsigned int count)
38915 {
38916 - int i;
38917 + unsigned int i;
38918 int relocs_total = 0;
38919 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
38920
38921 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
38922 index 3c59584..500f2e9 100644
38923 --- a/drivers/gpu/drm/i915/i915_ioc32.c
38924 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
38925 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
38926 (unsigned long)request);
38927 }
38928
38929 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
38930 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
38931 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
38932 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
38933 [DRM_I915_GETPARAM] = compat_i915_getparam,
38934 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
38935 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38936 {
38937 unsigned int nr = DRM_IOCTL_NR(cmd);
38938 - drm_ioctl_compat_t *fn = NULL;
38939 int ret;
38940
38941 if (nr < DRM_COMMAND_BASE)
38942 return drm_compat_ioctl(filp, cmd, arg);
38943
38944 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
38945 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
38946 -
38947 - if (fn != NULL)
38948 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
38949 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
38950 ret = (*fn) (filp, cmd, arg);
38951 - else
38952 + } else
38953 ret = drm_ioctl(filp, cmd, arg);
38954
38955 return ret;
38956 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
38957 index e5e32869..1678f36 100644
38958 --- a/drivers/gpu/drm/i915/i915_irq.c
38959 +++ b/drivers/gpu/drm/i915/i915_irq.c
38960 @@ -670,7 +670,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
38961 int pipe;
38962 u32 pipe_stats[I915_MAX_PIPES];
38963
38964 - atomic_inc(&dev_priv->irq_received);
38965 + atomic_inc_unchecked(&dev_priv->irq_received);
38966
38967 while (true) {
38968 iir = I915_READ(VLV_IIR);
38969 @@ -835,7 +835,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
38970 irqreturn_t ret = IRQ_NONE;
38971 int i;
38972
38973 - atomic_inc(&dev_priv->irq_received);
38974 + atomic_inc_unchecked(&dev_priv->irq_received);
38975
38976 /* disable master interrupt before clearing iir */
38977 de_ier = I915_READ(DEIER);
38978 @@ -925,7 +925,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
38979 int ret = IRQ_NONE;
38980 u32 de_iir, gt_iir, de_ier, pm_iir, sde_ier;
38981
38982 - atomic_inc(&dev_priv->irq_received);
38983 + atomic_inc_unchecked(&dev_priv->irq_received);
38984
38985 /* disable master interrupt before clearing iir */
38986 de_ier = I915_READ(DEIER);
38987 @@ -2089,7 +2089,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
38988 {
38989 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38990
38991 - atomic_set(&dev_priv->irq_received, 0);
38992 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38993
38994 I915_WRITE(HWSTAM, 0xeffe);
38995
38996 @@ -2124,7 +2124,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
38997 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38998 int pipe;
38999
39000 - atomic_set(&dev_priv->irq_received, 0);
39001 + atomic_set_unchecked(&dev_priv->irq_received, 0);
39002
39003 /* VLV magic */
39004 I915_WRITE(VLV_IMR, 0);
39005 @@ -2411,7 +2411,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
39006 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
39007 int pipe;
39008
39009 - atomic_set(&dev_priv->irq_received, 0);
39010 + atomic_set_unchecked(&dev_priv->irq_received, 0);
39011
39012 for_each_pipe(pipe)
39013 I915_WRITE(PIPESTAT(pipe), 0);
39014 @@ -2490,7 +2490,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
39015 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
39016 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
39017
39018 - atomic_inc(&dev_priv->irq_received);
39019 + atomic_inc_unchecked(&dev_priv->irq_received);
39020
39021 iir = I915_READ16(IIR);
39022 if (iir == 0)
39023 @@ -2565,7 +2565,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
39024 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
39025 int pipe;
39026
39027 - atomic_set(&dev_priv->irq_received, 0);
39028 + atomic_set_unchecked(&dev_priv->irq_received, 0);
39029
39030 if (I915_HAS_HOTPLUG(dev)) {
39031 I915_WRITE(PORT_HOTPLUG_EN, 0);
39032 @@ -2664,7 +2664,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
39033 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
39034 int pipe, ret = IRQ_NONE;
39035
39036 - atomic_inc(&dev_priv->irq_received);
39037 + atomic_inc_unchecked(&dev_priv->irq_received);
39038
39039 iir = I915_READ(IIR);
39040 do {
39041 @@ -2791,7 +2791,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
39042 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
39043 int pipe;
39044
39045 - atomic_set(&dev_priv->irq_received, 0);
39046 + atomic_set_unchecked(&dev_priv->irq_received, 0);
39047
39048 I915_WRITE(PORT_HOTPLUG_EN, 0);
39049 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
39050 @@ -2898,7 +2898,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
39051 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
39052 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
39053
39054 - atomic_inc(&dev_priv->irq_received);
39055 + atomic_inc_unchecked(&dev_priv->irq_received);
39056
39057 iir = I915_READ(IIR);
39058
39059 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
39060 index eea5982..eeef407 100644
39061 --- a/drivers/gpu/drm/i915/intel_display.c
39062 +++ b/drivers/gpu/drm/i915/intel_display.c
39063 @@ -8935,13 +8935,13 @@ struct intel_quirk {
39064 int subsystem_vendor;
39065 int subsystem_device;
39066 void (*hook)(struct drm_device *dev);
39067 -};
39068 +} __do_const;
39069
39070 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
39071 struct intel_dmi_quirk {
39072 void (*hook)(struct drm_device *dev);
39073 const struct dmi_system_id (*dmi_id_list)[];
39074 -};
39075 +} __do_const;
39076
39077 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
39078 {
39079 @@ -8949,18 +8949,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
39080 return 1;
39081 }
39082
39083 -static const struct intel_dmi_quirk intel_dmi_quirks[] = {
39084 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
39085 {
39086 - .dmi_id_list = &(const struct dmi_system_id[]) {
39087 - {
39088 - .callback = intel_dmi_reverse_brightness,
39089 - .ident = "NCR Corporation",
39090 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
39091 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
39092 - },
39093 - },
39094 - { } /* terminating entry */
39095 + .callback = intel_dmi_reverse_brightness,
39096 + .ident = "NCR Corporation",
39097 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
39098 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
39099 },
39100 + },
39101 + { } /* terminating entry */
39102 +};
39103 +
39104 +static const struct intel_dmi_quirk intel_dmi_quirks[] = {
39105 + {
39106 + .dmi_id_list = &intel_dmi_quirks_table,
39107 .hook = quirk_invert_brightness,
39108 },
39109 };
39110 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
39111 index 54558a0..2d97005 100644
39112 --- a/drivers/gpu/drm/mga/mga_drv.h
39113 +++ b/drivers/gpu/drm/mga/mga_drv.h
39114 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
39115 u32 clear_cmd;
39116 u32 maccess;
39117
39118 - atomic_t vbl_received; /**< Number of vblanks received. */
39119 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
39120 wait_queue_head_t fence_queue;
39121 - atomic_t last_fence_retired;
39122 + atomic_unchecked_t last_fence_retired;
39123 u32 next_fence_to_post;
39124
39125 unsigned int fb_cpp;
39126 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
39127 index 709e90d..89a1c0d 100644
39128 --- a/drivers/gpu/drm/mga/mga_ioc32.c
39129 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
39130 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
39131 return 0;
39132 }
39133
39134 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
39135 +drm_ioctl_compat_t mga_compat_ioctls[] = {
39136 [DRM_MGA_INIT] = compat_mga_init,
39137 [DRM_MGA_GETPARAM] = compat_mga_getparam,
39138 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
39139 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
39140 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
39141 {
39142 unsigned int nr = DRM_IOCTL_NR(cmd);
39143 - drm_ioctl_compat_t *fn = NULL;
39144 int ret;
39145
39146 if (nr < DRM_COMMAND_BASE)
39147 return drm_compat_ioctl(filp, cmd, arg);
39148
39149 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
39150 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
39151 -
39152 - if (fn != NULL)
39153 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
39154 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
39155 ret = (*fn) (filp, cmd, arg);
39156 - else
39157 + } else
39158 ret = drm_ioctl(filp, cmd, arg);
39159
39160 return ret;
39161 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
39162 index 598c281..60d590e 100644
39163 --- a/drivers/gpu/drm/mga/mga_irq.c
39164 +++ b/drivers/gpu/drm/mga/mga_irq.c
39165 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
39166 if (crtc != 0)
39167 return 0;
39168
39169 - return atomic_read(&dev_priv->vbl_received);
39170 + return atomic_read_unchecked(&dev_priv->vbl_received);
39171 }
39172
39173
39174 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
39175 /* VBLANK interrupt */
39176 if (status & MGA_VLINEPEN) {
39177 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
39178 - atomic_inc(&dev_priv->vbl_received);
39179 + atomic_inc_unchecked(&dev_priv->vbl_received);
39180 drm_handle_vblank(dev, 0);
39181 handled = 1;
39182 }
39183 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
39184 if ((prim_start & ~0x03) != (prim_end & ~0x03))
39185 MGA_WRITE(MGA_PRIMEND, prim_end);
39186
39187 - atomic_inc(&dev_priv->last_fence_retired);
39188 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
39189 DRM_WAKEUP(&dev_priv->fence_queue);
39190 handled = 1;
39191 }
39192 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
39193 * using fences.
39194 */
39195 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
39196 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
39197 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
39198 - *sequence) <= (1 << 23)));
39199
39200 *sequence = cur_fence;
39201 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
39202 index 6aa2137..fe8dc55 100644
39203 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
39204 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
39205 @@ -965,7 +965,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
39206 struct bit_table {
39207 const char id;
39208 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
39209 -};
39210 +} __no_const;
39211
39212 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
39213
39214 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
39215 index f2b30f8..d0f9a95 100644
39216 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
39217 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
39218 @@ -92,7 +92,7 @@ struct nouveau_drm {
39219 struct drm_global_reference mem_global_ref;
39220 struct ttm_bo_global_ref bo_global_ref;
39221 struct ttm_bo_device bdev;
39222 - atomic_t validate_sequence;
39223 + atomic_unchecked_t validate_sequence;
39224 int (*move)(struct nouveau_channel *,
39225 struct ttm_buffer_object *,
39226 struct ttm_mem_reg *, struct ttm_mem_reg *);
39227 diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
39228 index b4b4d0c..b7edc15 100644
39229 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
39230 +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
39231 @@ -322,7 +322,7 @@ validate_init(struct nouveau_channel *chan, struct drm_file *file_priv,
39232 int ret, i;
39233 struct nouveau_bo *res_bo = NULL;
39234
39235 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
39236 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
39237 retry:
39238 if (++trycnt > 100000) {
39239 NV_ERROR(cli, "%s failed and gave up.\n", __func__);
39240 @@ -359,7 +359,7 @@ retry:
39241 if (ret) {
39242 validate_fini(op, NULL);
39243 if (unlikely(ret == -EAGAIN)) {
39244 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
39245 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
39246 ret = ttm_bo_reserve_slowpath(&nvbo->bo, true,
39247 sequence);
39248 if (!ret)
39249 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
39250 index 08214bc..9208577 100644
39251 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
39252 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
39253 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
39254 unsigned long arg)
39255 {
39256 unsigned int nr = DRM_IOCTL_NR(cmd);
39257 - drm_ioctl_compat_t *fn = NULL;
39258 + drm_ioctl_compat_t fn = NULL;
39259 int ret;
39260
39261 if (nr < DRM_COMMAND_BASE)
39262 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
39263 index 25d3495..d81aaf6 100644
39264 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
39265 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
39266 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
39267 bool can_switch;
39268
39269 spin_lock(&dev->count_lock);
39270 - can_switch = (dev->open_count == 0);
39271 + can_switch = (local_read(&dev->open_count) == 0);
39272 spin_unlock(&dev->count_lock);
39273 return can_switch;
39274 }
39275 diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
39276 index 489cb8c..0b8d0d3 100644
39277 --- a/drivers/gpu/drm/qxl/qxl_ttm.c
39278 +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
39279 @@ -103,7 +103,7 @@ static void qxl_ttm_global_fini(struct qxl_device *qdev)
39280 }
39281 }
39282
39283 -static struct vm_operations_struct qxl_ttm_vm_ops;
39284 +static vm_operations_struct_no_const qxl_ttm_vm_ops __read_only;
39285 static const struct vm_operations_struct *ttm_vm_ops;
39286
39287 static int qxl_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
39288 @@ -147,8 +147,10 @@ int qxl_mmap(struct file *filp, struct vm_area_struct *vma)
39289 return r;
39290 if (unlikely(ttm_vm_ops == NULL)) {
39291 ttm_vm_ops = vma->vm_ops;
39292 + pax_open_kernel();
39293 qxl_ttm_vm_ops = *ttm_vm_ops;
39294 qxl_ttm_vm_ops.fault = &qxl_ttm_fault;
39295 + pax_close_kernel();
39296 }
39297 vma->vm_ops = &qxl_ttm_vm_ops;
39298 return 0;
39299 @@ -556,25 +558,23 @@ static int qxl_mm_dump_table(struct seq_file *m, void *data)
39300 static int qxl_ttm_debugfs_init(struct qxl_device *qdev)
39301 {
39302 #if defined(CONFIG_DEBUG_FS)
39303 - static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES];
39304 - static char qxl_mem_types_names[QXL_DEBUGFS_MEM_TYPES][32];
39305 - unsigned i;
39306 + static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES] = {
39307 + {
39308 + .name = "qxl_mem_mm",
39309 + .show = &qxl_mm_dump_table,
39310 + },
39311 + {
39312 + .name = "qxl_surf_mm",
39313 + .show = &qxl_mm_dump_table,
39314 + }
39315 + };
39316
39317 - for (i = 0; i < QXL_DEBUGFS_MEM_TYPES; i++) {
39318 - if (i == 0)
39319 - sprintf(qxl_mem_types_names[i], "qxl_mem_mm");
39320 - else
39321 - sprintf(qxl_mem_types_names[i], "qxl_surf_mm");
39322 - qxl_mem_types_list[i].name = qxl_mem_types_names[i];
39323 - qxl_mem_types_list[i].show = &qxl_mm_dump_table;
39324 - qxl_mem_types_list[i].driver_features = 0;
39325 - if (i == 0)
39326 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
39327 - else
39328 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
39329 + pax_open_kernel();
39330 + *(void **)&qxl_mem_types_list[0].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
39331 + *(void **)&qxl_mem_types_list[1].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
39332 + pax_close_kernel();
39333
39334 - }
39335 - return qxl_debugfs_add_files(qdev, qxl_mem_types_list, i);
39336 + return qxl_debugfs_add_files(qdev, qxl_mem_types_list, QXL_DEBUGFS_MEM_TYPES);
39337 #else
39338 return 0;
39339 #endif
39340 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
39341 index d4660cf..70dbe65 100644
39342 --- a/drivers/gpu/drm/r128/r128_cce.c
39343 +++ b/drivers/gpu/drm/r128/r128_cce.c
39344 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
39345
39346 /* GH: Simple idle check.
39347 */
39348 - atomic_set(&dev_priv->idle_count, 0);
39349 + atomic_set_unchecked(&dev_priv->idle_count, 0);
39350
39351 /* We don't support anything other than bus-mastering ring mode,
39352 * but the ring can be in either AGP or PCI space for the ring
39353 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
39354 index 930c71b..499aded 100644
39355 --- a/drivers/gpu/drm/r128/r128_drv.h
39356 +++ b/drivers/gpu/drm/r128/r128_drv.h
39357 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
39358 int is_pci;
39359 unsigned long cce_buffers_offset;
39360
39361 - atomic_t idle_count;
39362 + atomic_unchecked_t idle_count;
39363
39364 int page_flipping;
39365 int current_page;
39366 u32 crtc_offset;
39367 u32 crtc_offset_cntl;
39368
39369 - atomic_t vbl_received;
39370 + atomic_unchecked_t vbl_received;
39371
39372 u32 color_fmt;
39373 unsigned int front_offset;
39374 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
39375 index a954c54..9cc595c 100644
39376 --- a/drivers/gpu/drm/r128/r128_ioc32.c
39377 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
39378 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
39379 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
39380 }
39381
39382 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
39383 +drm_ioctl_compat_t r128_compat_ioctls[] = {
39384 [DRM_R128_INIT] = compat_r128_init,
39385 [DRM_R128_DEPTH] = compat_r128_depth,
39386 [DRM_R128_STIPPLE] = compat_r128_stipple,
39387 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
39388 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
39389 {
39390 unsigned int nr = DRM_IOCTL_NR(cmd);
39391 - drm_ioctl_compat_t *fn = NULL;
39392 int ret;
39393
39394 if (nr < DRM_COMMAND_BASE)
39395 return drm_compat_ioctl(filp, cmd, arg);
39396
39397 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
39398 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
39399 -
39400 - if (fn != NULL)
39401 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
39402 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
39403 ret = (*fn) (filp, cmd, arg);
39404 - else
39405 + } else
39406 ret = drm_ioctl(filp, cmd, arg);
39407
39408 return ret;
39409 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
39410 index 2ea4f09..d391371 100644
39411 --- a/drivers/gpu/drm/r128/r128_irq.c
39412 +++ b/drivers/gpu/drm/r128/r128_irq.c
39413 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
39414 if (crtc != 0)
39415 return 0;
39416
39417 - return atomic_read(&dev_priv->vbl_received);
39418 + return atomic_read_unchecked(&dev_priv->vbl_received);
39419 }
39420
39421 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
39422 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
39423 /* VBLANK interrupt */
39424 if (status & R128_CRTC_VBLANK_INT) {
39425 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
39426 - atomic_inc(&dev_priv->vbl_received);
39427 + atomic_inc_unchecked(&dev_priv->vbl_received);
39428 drm_handle_vblank(dev, 0);
39429 return IRQ_HANDLED;
39430 }
39431 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
39432 index 19bb7e6..de7e2a2 100644
39433 --- a/drivers/gpu/drm/r128/r128_state.c
39434 +++ b/drivers/gpu/drm/r128/r128_state.c
39435 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
39436
39437 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
39438 {
39439 - if (atomic_read(&dev_priv->idle_count) == 0)
39440 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
39441 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
39442 else
39443 - atomic_set(&dev_priv->idle_count, 0);
39444 + atomic_set_unchecked(&dev_priv->idle_count, 0);
39445 }
39446
39447 #endif
39448 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
39449 index 5a82b6b..9e69c73 100644
39450 --- a/drivers/gpu/drm/radeon/mkregtable.c
39451 +++ b/drivers/gpu/drm/radeon/mkregtable.c
39452 @@ -637,14 +637,14 @@ static int parser_auth(struct table *t, const char *filename)
39453 regex_t mask_rex;
39454 regmatch_t match[4];
39455 char buf[1024];
39456 - size_t end;
39457 + long end;
39458 int len;
39459 int done = 0;
39460 int r;
39461 unsigned o;
39462 struct offset *offset;
39463 char last_reg_s[10];
39464 - int last_reg;
39465 + unsigned long last_reg;
39466
39467 if (regcomp
39468 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
39469 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
39470 index b0dc0b6..a9bfe9c 100644
39471 --- a/drivers/gpu/drm/radeon/radeon_device.c
39472 +++ b/drivers/gpu/drm/radeon/radeon_device.c
39473 @@ -1014,7 +1014,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
39474 bool can_switch;
39475
39476 spin_lock(&dev->count_lock);
39477 - can_switch = (dev->open_count == 0);
39478 + can_switch = (local_read(&dev->open_count) == 0);
39479 spin_unlock(&dev->count_lock);
39480 return can_switch;
39481 }
39482 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
39483 index b369d42..8dd04eb 100644
39484 --- a/drivers/gpu/drm/radeon/radeon_drv.h
39485 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
39486 @@ -258,7 +258,7 @@ typedef struct drm_radeon_private {
39487
39488 /* SW interrupt */
39489 wait_queue_head_t swi_queue;
39490 - atomic_t swi_emitted;
39491 + atomic_unchecked_t swi_emitted;
39492 int vblank_crtc;
39493 uint32_t irq_enable_reg;
39494 uint32_t r500_disp_irq_reg;
39495 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
39496 index c180df8..5fd8186 100644
39497 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
39498 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
39499 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
39500 request = compat_alloc_user_space(sizeof(*request));
39501 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
39502 || __put_user(req32.param, &request->param)
39503 - || __put_user((void __user *)(unsigned long)req32.value,
39504 + || __put_user((unsigned long)req32.value,
39505 &request->value))
39506 return -EFAULT;
39507
39508 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
39509 #define compat_radeon_cp_setparam NULL
39510 #endif /* X86_64 || IA64 */
39511
39512 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
39513 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
39514 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
39515 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
39516 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
39517 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
39518 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
39519 {
39520 unsigned int nr = DRM_IOCTL_NR(cmd);
39521 - drm_ioctl_compat_t *fn = NULL;
39522 int ret;
39523
39524 if (nr < DRM_COMMAND_BASE)
39525 return drm_compat_ioctl(filp, cmd, arg);
39526
39527 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
39528 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
39529 -
39530 - if (fn != NULL)
39531 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
39532 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
39533 ret = (*fn) (filp, cmd, arg);
39534 - else
39535 + } else
39536 ret = drm_ioctl(filp, cmd, arg);
39537
39538 return ret;
39539 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
39540 index 8d68e97..9dcfed8 100644
39541 --- a/drivers/gpu/drm/radeon/radeon_irq.c
39542 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
39543 @@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
39544 unsigned int ret;
39545 RING_LOCALS;
39546
39547 - atomic_inc(&dev_priv->swi_emitted);
39548 - ret = atomic_read(&dev_priv->swi_emitted);
39549 + atomic_inc_unchecked(&dev_priv->swi_emitted);
39550 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
39551
39552 BEGIN_RING(4);
39553 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
39554 @@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
39555 drm_radeon_private_t *dev_priv =
39556 (drm_radeon_private_t *) dev->dev_private;
39557
39558 - atomic_set(&dev_priv->swi_emitted, 0);
39559 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
39560 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
39561
39562 dev->max_vblank_count = 0x001fffff;
39563 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
39564 index 4d20910..6726b6d 100644
39565 --- a/drivers/gpu/drm/radeon/radeon_state.c
39566 +++ b/drivers/gpu/drm/radeon/radeon_state.c
39567 @@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
39568 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
39569 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
39570
39571 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
39572 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
39573 sarea_priv->nbox * sizeof(depth_boxes[0])))
39574 return -EFAULT;
39575
39576 @@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
39577 {
39578 drm_radeon_private_t *dev_priv = dev->dev_private;
39579 drm_radeon_getparam_t *param = data;
39580 - int value;
39581 + int value = 0;
39582
39583 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
39584
39585 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
39586 index 6c0ce89..57a2529 100644
39587 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
39588 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
39589 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
39590 man->size = size >> PAGE_SHIFT;
39591 }
39592
39593 -static struct vm_operations_struct radeon_ttm_vm_ops;
39594 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
39595 static const struct vm_operations_struct *ttm_vm_ops = NULL;
39596
39597 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
39598 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
39599 }
39600 if (unlikely(ttm_vm_ops == NULL)) {
39601 ttm_vm_ops = vma->vm_ops;
39602 + pax_open_kernel();
39603 radeon_ttm_vm_ops = *ttm_vm_ops;
39604 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
39605 + pax_close_kernel();
39606 }
39607 vma->vm_ops = &radeon_ttm_vm_ops;
39608 return 0;
39609 @@ -853,38 +855,33 @@ static int radeon_mm_dump_table(struct seq_file *m, void *data)
39610 static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
39611 {
39612 #if defined(CONFIG_DEBUG_FS)
39613 - static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2];
39614 - static char radeon_mem_types_names[RADEON_DEBUGFS_MEM_TYPES+2][32];
39615 + static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2] = {
39616 + {
39617 + .name = "radeon_vram_mm",
39618 + .show = &radeon_mm_dump_table,
39619 + },
39620 + {
39621 + .name = "radeon_gtt_mm",
39622 + .show = &radeon_mm_dump_table,
39623 + },
39624 + {
39625 + .name = "ttm_page_pool",
39626 + .show = &ttm_page_alloc_debugfs,
39627 + },
39628 + {
39629 + .name = "ttm_dma_page_pool",
39630 + .show = &ttm_dma_page_alloc_debugfs,
39631 + },
39632 + };
39633 unsigned i;
39634
39635 - for (i = 0; i < RADEON_DEBUGFS_MEM_TYPES; i++) {
39636 - if (i == 0)
39637 - sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
39638 - else
39639 - sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
39640 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39641 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
39642 - radeon_mem_types_list[i].driver_features = 0;
39643 - if (i == 0)
39644 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39645 - else
39646 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39647 -
39648 - }
39649 - /* Add ttm page pool to debugfs */
39650 - sprintf(radeon_mem_types_names[i], "ttm_page_pool");
39651 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39652 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
39653 - radeon_mem_types_list[i].driver_features = 0;
39654 - radeon_mem_types_list[i++].data = NULL;
39655 + pax_open_kernel();
39656 + *(void **)&radeon_mem_types_list[0].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39657 + *(void **)&radeon_mem_types_list[1].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39658 + pax_close_kernel();
39659 #ifdef CONFIG_SWIOTLB
39660 - if (swiotlb_nr_tbl()) {
39661 - sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
39662 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39663 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
39664 - radeon_mem_types_list[i].driver_features = 0;
39665 - radeon_mem_types_list[i++].data = NULL;
39666 - }
39667 + if (swiotlb_nr_tbl())
39668 + i++;
39669 #endif
39670 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
39671
39672 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
39673 index 55880d5..9e95342 100644
39674 --- a/drivers/gpu/drm/radeon/rs690.c
39675 +++ b/drivers/gpu/drm/radeon/rs690.c
39676 @@ -327,9 +327,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
39677 if (rdev->pm.max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
39678 rdev->pm.sideport_bandwidth.full)
39679 rdev->pm.max_bandwidth = rdev->pm.sideport_bandwidth;
39680 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
39681 + read_delay_latency.full = dfixed_const(800 * 1000);
39682 read_delay_latency.full = dfixed_div(read_delay_latency,
39683 rdev->pm.igp_sideport_mclk);
39684 + a.full = dfixed_const(370);
39685 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
39686 } else {
39687 if (rdev->pm.max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
39688 rdev->pm.k8_bandwidth.full)
39689 diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
39690 index dbc2def..0a9f710 100644
39691 --- a/drivers/gpu/drm/ttm/ttm_memory.c
39692 +++ b/drivers/gpu/drm/ttm/ttm_memory.c
39693 @@ -264,7 +264,7 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
39694 zone->glob = glob;
39695 glob->zone_kernel = zone;
39696 ret = kobject_init_and_add(
39697 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39698 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39699 if (unlikely(ret != 0)) {
39700 kobject_put(&zone->kobj);
39701 return ret;
39702 @@ -347,7 +347,7 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
39703 zone->glob = glob;
39704 glob->zone_dma32 = zone;
39705 ret = kobject_init_and_add(
39706 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39707 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39708 if (unlikely(ret != 0)) {
39709 kobject_put(&zone->kobj);
39710 return ret;
39711 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
39712 index bd2a3b4..122d9ad 100644
39713 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
39714 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
39715 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
39716 static int ttm_pool_mm_shrink(struct shrinker *shrink,
39717 struct shrink_control *sc)
39718 {
39719 - static atomic_t start_pool = ATOMIC_INIT(0);
39720 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
39721 unsigned i;
39722 - unsigned pool_offset = atomic_add_return(1, &start_pool);
39723 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
39724 struct ttm_page_pool *pool;
39725 int shrink_pages = sc->nr_to_scan;
39726
39727 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
39728 index dc0c065..58a0782 100644
39729 --- a/drivers/gpu/drm/udl/udl_fb.c
39730 +++ b/drivers/gpu/drm/udl/udl_fb.c
39731 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
39732 fb_deferred_io_cleanup(info);
39733 kfree(info->fbdefio);
39734 info->fbdefio = NULL;
39735 - info->fbops->fb_mmap = udl_fb_mmap;
39736 }
39737
39738 pr_warn("released /dev/fb%d user=%d count=%d\n",
39739 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
39740 index 893a650..6190d3b 100644
39741 --- a/drivers/gpu/drm/via/via_drv.h
39742 +++ b/drivers/gpu/drm/via/via_drv.h
39743 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
39744 typedef uint32_t maskarray_t[5];
39745
39746 typedef struct drm_via_irq {
39747 - atomic_t irq_received;
39748 + atomic_unchecked_t irq_received;
39749 uint32_t pending_mask;
39750 uint32_t enable_mask;
39751 wait_queue_head_t irq_queue;
39752 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
39753 struct timeval last_vblank;
39754 int last_vblank_valid;
39755 unsigned usec_per_vblank;
39756 - atomic_t vbl_received;
39757 + atomic_unchecked_t vbl_received;
39758 drm_via_state_t hc_state;
39759 char pci_buf[VIA_PCI_BUF_SIZE];
39760 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
39761 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
39762 index ac98964..5dbf512 100644
39763 --- a/drivers/gpu/drm/via/via_irq.c
39764 +++ b/drivers/gpu/drm/via/via_irq.c
39765 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
39766 if (crtc != 0)
39767 return 0;
39768
39769 - return atomic_read(&dev_priv->vbl_received);
39770 + return atomic_read_unchecked(&dev_priv->vbl_received);
39771 }
39772
39773 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39774 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39775
39776 status = VIA_READ(VIA_REG_INTERRUPT);
39777 if (status & VIA_IRQ_VBLANK_PENDING) {
39778 - atomic_inc(&dev_priv->vbl_received);
39779 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
39780 + atomic_inc_unchecked(&dev_priv->vbl_received);
39781 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
39782 do_gettimeofday(&cur_vblank);
39783 if (dev_priv->last_vblank_valid) {
39784 dev_priv->usec_per_vblank =
39785 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39786 dev_priv->last_vblank = cur_vblank;
39787 dev_priv->last_vblank_valid = 1;
39788 }
39789 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
39790 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
39791 DRM_DEBUG("US per vblank is: %u\n",
39792 dev_priv->usec_per_vblank);
39793 }
39794 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39795
39796 for (i = 0; i < dev_priv->num_irqs; ++i) {
39797 if (status & cur_irq->pending_mask) {
39798 - atomic_inc(&cur_irq->irq_received);
39799 + atomic_inc_unchecked(&cur_irq->irq_received);
39800 DRM_WAKEUP(&cur_irq->irq_queue);
39801 handled = 1;
39802 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
39803 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
39804 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
39805 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
39806 masks[irq][4]));
39807 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
39808 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
39809 } else {
39810 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
39811 (((cur_irq_sequence =
39812 - atomic_read(&cur_irq->irq_received)) -
39813 + atomic_read_unchecked(&cur_irq->irq_received)) -
39814 *sequence) <= (1 << 23)));
39815 }
39816 *sequence = cur_irq_sequence;
39817 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
39818 }
39819
39820 for (i = 0; i < dev_priv->num_irqs; ++i) {
39821 - atomic_set(&cur_irq->irq_received, 0);
39822 + atomic_set_unchecked(&cur_irq->irq_received, 0);
39823 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
39824 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
39825 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
39826 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
39827 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
39828 case VIA_IRQ_RELATIVE:
39829 irqwait->request.sequence +=
39830 - atomic_read(&cur_irq->irq_received);
39831 + atomic_read_unchecked(&cur_irq->irq_received);
39832 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
39833 case VIA_IRQ_ABSOLUTE:
39834 break;
39835 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39836 index 13aeda7..4a952d1 100644
39837 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39838 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39839 @@ -290,7 +290,7 @@ struct vmw_private {
39840 * Fencing and IRQs.
39841 */
39842
39843 - atomic_t marker_seq;
39844 + atomic_unchecked_t marker_seq;
39845 wait_queue_head_t fence_queue;
39846 wait_queue_head_t fifo_queue;
39847 int fence_queue_waiters; /* Protected by hw_mutex */
39848 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39849 index 3eb1486..0a47ee9 100644
39850 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39851 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39852 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
39853 (unsigned int) min,
39854 (unsigned int) fifo->capabilities);
39855
39856 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
39857 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
39858 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
39859 vmw_marker_queue_init(&fifo->marker_queue);
39860 return vmw_fifo_send_fence(dev_priv, &dummy);
39861 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
39862 if (reserveable)
39863 iowrite32(bytes, fifo_mem +
39864 SVGA_FIFO_RESERVED);
39865 - return fifo_mem + (next_cmd >> 2);
39866 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
39867 } else {
39868 need_bounce = true;
39869 }
39870 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
39871
39872 fm = vmw_fifo_reserve(dev_priv, bytes);
39873 if (unlikely(fm == NULL)) {
39874 - *seqno = atomic_read(&dev_priv->marker_seq);
39875 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
39876 ret = -ENOMEM;
39877 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
39878 false, 3*HZ);
39879 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
39880 }
39881
39882 do {
39883 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
39884 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
39885 } while (*seqno == 0);
39886
39887 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
39888 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39889 index c509d40..3b640c3 100644
39890 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39891 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39892 @@ -138,7 +138,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
39893 int ret;
39894
39895 num_clips = arg->num_clips;
39896 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
39897 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
39898
39899 if (unlikely(num_clips == 0))
39900 return 0;
39901 @@ -222,7 +222,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
39902 int ret;
39903
39904 num_clips = arg->num_clips;
39905 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
39906 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
39907
39908 if (unlikely(num_clips == 0))
39909 return 0;
39910 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39911 index 4640adb..e1384ed 100644
39912 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39913 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39914 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
39915 * emitted. Then the fence is stale and signaled.
39916 */
39917
39918 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
39919 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
39920 > VMW_FENCE_WRAP);
39921
39922 return ret;
39923 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
39924
39925 if (fifo_idle)
39926 down_read(&fifo_state->rwsem);
39927 - signal_seq = atomic_read(&dev_priv->marker_seq);
39928 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
39929 ret = 0;
39930
39931 for (;;) {
39932 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39933 index 8a8725c2..afed796 100644
39934 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39935 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39936 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
39937 while (!vmw_lag_lt(queue, us)) {
39938 spin_lock(&queue->lock);
39939 if (list_empty(&queue->head))
39940 - seqno = atomic_read(&dev_priv->marker_seq);
39941 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
39942 else {
39943 marker = list_first_entry(&queue->head,
39944 struct vmw_marker, head);
39945 diff --git a/drivers/gpu/host1x/drm/dc.c b/drivers/gpu/host1x/drm/dc.c
39946 index 8c04943..4370ed9 100644
39947 --- a/drivers/gpu/host1x/drm/dc.c
39948 +++ b/drivers/gpu/host1x/drm/dc.c
39949 @@ -999,7 +999,7 @@ static int tegra_dc_debugfs_init(struct tegra_dc *dc, struct drm_minor *minor)
39950 }
39951
39952 for (i = 0; i < ARRAY_SIZE(debugfs_files); i++)
39953 - dc->debugfs_files[i].data = dc;
39954 + *(void **)&dc->debugfs_files[i].data = dc;
39955
39956 err = drm_debugfs_create_files(dc->debugfs_files,
39957 ARRAY_SIZE(debugfs_files),
39958 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
39959 index 402f486..5340852 100644
39960 --- a/drivers/hid/hid-core.c
39961 +++ b/drivers/hid/hid-core.c
39962 @@ -63,6 +63,8 @@ struct hid_report *hid_register_report(struct hid_device *device, unsigned type,
39963 struct hid_report_enum *report_enum = device->report_enum + type;
39964 struct hid_report *report;
39965
39966 + if (id >= HID_MAX_IDS)
39967 + return NULL;
39968 if (report_enum->report_id_hash[id])
39969 return report_enum->report_id_hash[id];
39970
39971 @@ -404,8 +406,10 @@ static int hid_parser_global(struct hid_parser *parser, struct hid_item *item)
39972
39973 case HID_GLOBAL_ITEM_TAG_REPORT_ID:
39974 parser->global.report_id = item_udata(item);
39975 - if (parser->global.report_id == 0) {
39976 - hid_err(parser->device, "report_id 0 is invalid\n");
39977 + if (parser->global.report_id == 0 ||
39978 + parser->global.report_id >= HID_MAX_IDS) {
39979 + hid_err(parser->device, "report_id %u is invalid\n",
39980 + parser->global.report_id);
39981 return -1;
39982 }
39983 return 0;
39984 @@ -575,7 +579,7 @@ static void hid_close_report(struct hid_device *device)
39985 for (i = 0; i < HID_REPORT_TYPES; i++) {
39986 struct hid_report_enum *report_enum = device->report_enum + i;
39987
39988 - for (j = 0; j < 256; j++) {
39989 + for (j = 0; j < HID_MAX_IDS; j++) {
39990 struct hid_report *report = report_enum->report_id_hash[j];
39991 if (report)
39992 hid_free_report(report);
39993 @@ -755,6 +759,56 @@ int hid_parse_report(struct hid_device *hid, __u8 *start, unsigned size)
39994 }
39995 EXPORT_SYMBOL_GPL(hid_parse_report);
39996
39997 +static const char * const hid_report_names[] = {
39998 + "HID_INPUT_REPORT",
39999 + "HID_OUTPUT_REPORT",
40000 + "HID_FEATURE_REPORT",
40001 +};
40002 +/**
40003 + * hid_validate_report - validate existing device report
40004 + *
40005 + * @device: hid device
40006 + * @type: which report type to examine
40007 + * @id: which report ID to examine (0 for first)
40008 + * @fields: expected number of fields
40009 + * @report_counts: expected number of values per field
40010 + *
40011 + * Validate the report details after parsing.
40012 + */
40013 +struct hid_report *hid_validate_report(struct hid_device *hid,
40014 + unsigned int type, unsigned int id,
40015 + unsigned int fields,
40016 + unsigned int report_counts)
40017 +{
40018 + struct hid_report *report;
40019 + unsigned int i;
40020 +
40021 + if (type > HID_FEATURE_REPORT) {
40022 + hid_err(hid, "invalid HID report %u\n", type);
40023 + return NULL;
40024 + }
40025 +
40026 + report = hid->report_enum[type].report_id_hash[id];
40027 + if (!report) {
40028 + hid_err(hid, "missing %s %u\n", hid_report_names[type], id);
40029 + return NULL;
40030 + }
40031 + if (report->maxfield < fields) {
40032 + hid_err(hid, "not enough fields in %s %u\n",
40033 + hid_report_names[type], id);
40034 + return NULL;
40035 + }
40036 + for (i = 0; i < fields; i++) {
40037 + if (report->field[i]->report_count < report_counts) {
40038 + hid_err(hid, "not enough values in %s %u fields\n",
40039 + hid_report_names[type], id);
40040 + return NULL;
40041 + }
40042 + }
40043 + return report;
40044 +}
40045 +EXPORT_SYMBOL_GPL(hid_validate_report);
40046 +
40047 /**
40048 * hid_open_report - open a driver-specific device report
40049 *
40050 @@ -1152,7 +1206,12 @@ EXPORT_SYMBOL_GPL(hid_output_report);
40051
40052 int hid_set_field(struct hid_field *field, unsigned offset, __s32 value)
40053 {
40054 - unsigned size = field->report_size;
40055 + unsigned size;
40056 +
40057 + if (!field)
40058 + return -1;
40059 +
40060 + size = field->report_size;
40061
40062 hid_dump_input(field->report->device, field->usage + offset, value);
40063
40064 @@ -2275,7 +2334,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
40065
40066 int hid_add_device(struct hid_device *hdev)
40067 {
40068 - static atomic_t id = ATOMIC_INIT(0);
40069 + static atomic_unchecked_t id = ATOMIC_INIT(0);
40070 int ret;
40071
40072 if (WARN_ON(hdev->status & HID_STAT_ADDED))
40073 @@ -2309,7 +2368,7 @@ int hid_add_device(struct hid_device *hdev)
40074 /* XXX hack, any other cleaner solution after the driver core
40075 * is converted to allow more than 20 bytes as the device name? */
40076 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
40077 - hdev->vendor, hdev->product, atomic_inc_return(&id));
40078 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
40079
40080 hid_debug_register(hdev, dev_name(&hdev->dev));
40081 ret = device_add(&hdev->dev);
40082 diff --git a/drivers/hid/hid-lenovo-tpkbd.c b/drivers/hid/hid-lenovo-tpkbd.c
40083 index 07837f5..b697ada 100644
40084 --- a/drivers/hid/hid-lenovo-tpkbd.c
40085 +++ b/drivers/hid/hid-lenovo-tpkbd.c
40086 @@ -341,6 +341,11 @@ static int tpkbd_probe_tp(struct hid_device *hdev)
40087 char *name_mute, *name_micmute;
40088 int ret;
40089
40090 + /* Validate required reports. */
40091 + if (!hid_validate_report(hdev, HID_OUTPUT_REPORT, 4, 4, 1) ||
40092 + !hid_validate_report(hdev, HID_OUTPUT_REPORT, 3, 1, 2))
40093 + return -ENODEV;
40094 +
40095 if (sysfs_create_group(&hdev->dev.kobj,
40096 &tpkbd_attr_group_pointer)) {
40097 hid_warn(hdev, "Could not create sysfs group\n");
40098 diff --git a/drivers/hid/hid-lg2ff.c b/drivers/hid/hid-lg2ff.c
40099 index b3cd150..9805197 100644
40100 --- a/drivers/hid/hid-lg2ff.c
40101 +++ b/drivers/hid/hid-lg2ff.c
40102 @@ -64,26 +64,13 @@ int lg2ff_init(struct hid_device *hid)
40103 struct hid_report *report;
40104 struct hid_input *hidinput = list_entry(hid->inputs.next,
40105 struct hid_input, list);
40106 - struct list_head *report_list =
40107 - &hid->report_enum[HID_OUTPUT_REPORT].report_list;
40108 struct input_dev *dev = hidinput->input;
40109 int error;
40110
40111 - if (list_empty(report_list)) {
40112 - hid_err(hid, "no output report found\n");
40113 + /* Check that the report looks ok */
40114 + report = hid_validate_report(hid, HID_OUTPUT_REPORT, 0, 1, 7);
40115 + if (!report)
40116 return -ENODEV;
40117 - }
40118 -
40119 - report = list_entry(report_list->next, struct hid_report, list);
40120 -
40121 - if (report->maxfield < 1) {
40122 - hid_err(hid, "output report is empty\n");
40123 - return -ENODEV;
40124 - }
40125 - if (report->field[0]->report_count < 7) {
40126 - hid_err(hid, "not enough values in the field\n");
40127 - return -ENODEV;
40128 - }
40129
40130 lg2ff = kmalloc(sizeof(struct lg2ff_device), GFP_KERNEL);
40131 if (!lg2ff)
40132 diff --git a/drivers/hid/hid-lg3ff.c b/drivers/hid/hid-lg3ff.c
40133 index e52f181..53ac79b 100644
40134 --- a/drivers/hid/hid-lg3ff.c
40135 +++ b/drivers/hid/hid-lg3ff.c
40136 @@ -66,10 +66,11 @@ static int hid_lg3ff_play(struct input_dev *dev, void *data,
40137 int x, y;
40138
40139 /*
40140 - * Maxusage should always be 63 (maximum fields)
40141 - * likely a better way to ensure this data is clean
40142 + * Available values in the field should always be 63, but we only use up to
40143 + * 35. Instead, clear the entire area, however big it is.
40144 */
40145 - memset(report->field[0]->value, 0, sizeof(__s32)*report->field[0]->maxusage);
40146 + memset(report->field[0]->value, 0,
40147 + sizeof(__s32) * report->field[0]->report_count);
40148
40149 switch (effect->type) {
40150 case FF_CONSTANT:
40151 @@ -129,32 +130,14 @@ static const signed short ff3_joystick_ac[] = {
40152 int lg3ff_init(struct hid_device *hid)
40153 {
40154 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
40155 - struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
40156 struct input_dev *dev = hidinput->input;
40157 - struct hid_report *report;
40158 - struct hid_field *field;
40159 const signed short *ff_bits = ff3_joystick_ac;
40160 int error;
40161 int i;
40162
40163 - /* Find the report to use */
40164 - if (list_empty(report_list)) {
40165 - hid_err(hid, "No output report found\n");
40166 - return -1;
40167 - }
40168 -
40169 /* Check that the report looks ok */
40170 - report = list_entry(report_list->next, struct hid_report, list);
40171 - if (!report) {
40172 - hid_err(hid, "NULL output report\n");
40173 - return -1;
40174 - }
40175 -
40176 - field = report->field[0];
40177 - if (!field) {
40178 - hid_err(hid, "NULL field\n");
40179 - return -1;
40180 - }
40181 + if (!hid_validate_report(hid, HID_OUTPUT_REPORT, 0, 1, 35))
40182 + return -ENODEV;
40183
40184 /* Assume single fixed device G940 */
40185 for (i = 0; ff_bits[i] >= 0; i++)
40186 diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
40187 index 0ddae2a..8b89f0f 100644
40188 --- a/drivers/hid/hid-lg4ff.c
40189 +++ b/drivers/hid/hid-lg4ff.c
40190 @@ -484,34 +484,16 @@ static enum led_brightness lg4ff_led_get_brightness(struct led_classdev *led_cde
40191 int lg4ff_init(struct hid_device *hid)
40192 {
40193 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
40194 - struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
40195 struct input_dev *dev = hidinput->input;
40196 - struct hid_report *report;
40197 - struct hid_field *field;
40198 struct lg4ff_device_entry *entry;
40199 struct lg_drv_data *drv_data;
40200 struct usb_device_descriptor *udesc;
40201 int error, i, j;
40202 __u16 bcdDevice, rev_maj, rev_min;
40203
40204 - /* Find the report to use */
40205 - if (list_empty(report_list)) {
40206 - hid_err(hid, "No output report found\n");
40207 - return -1;
40208 - }
40209 -
40210 /* Check that the report looks ok */
40211 - report = list_entry(report_list->next, struct hid_report, list);
40212 - if (!report) {
40213 - hid_err(hid, "NULL output report\n");
40214 + if (!hid_validate_report(hid, HID_OUTPUT_REPORT, 0, 1, 7))
40215 return -1;
40216 - }
40217 -
40218 - field = report->field[0];
40219 - if (!field) {
40220 - hid_err(hid, "NULL field\n");
40221 - return -1;
40222 - }
40223
40224 /* Check what wheel has been connected */
40225 for (i = 0; i < ARRAY_SIZE(lg4ff_devices); i++) {
40226 diff --git a/drivers/hid/hid-lgff.c b/drivers/hid/hid-lgff.c
40227 index d7ea8c8..a84fb40 100644
40228 --- a/drivers/hid/hid-lgff.c
40229 +++ b/drivers/hid/hid-lgff.c
40230 @@ -128,27 +128,14 @@ static void hid_lgff_set_autocenter(struct input_dev *dev, u16 magnitude)
40231 int lgff_init(struct hid_device* hid)
40232 {
40233 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
40234 - struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
40235 struct input_dev *dev = hidinput->input;
40236 - struct hid_report *report;
40237 - struct hid_field *field;
40238 const signed short *ff_bits = ff_joystick;
40239 int error;
40240 int i;
40241
40242 - /* Find the report to use */
40243 - if (list_empty(report_list)) {
40244 - hid_err(hid, "No output report found\n");
40245 - return -1;
40246 - }
40247 -
40248 /* Check that the report looks ok */
40249 - report = list_entry(report_list->next, struct hid_report, list);
40250 - field = report->field[0];
40251 - if (!field) {
40252 - hid_err(hid, "NULL field\n");
40253 - return -1;
40254 - }
40255 + if (!hid_validate_report(hid, HID_OUTPUT_REPORT, 0, 1, 7))
40256 + return -ENODEV;
40257
40258 for (i = 0; i < ARRAY_SIZE(devices); i++) {
40259 if (dev->id.vendor == devices[i].idVendor &&
40260 diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c
40261 index 5207591a..6c9197f 100644
40262 --- a/drivers/hid/hid-logitech-dj.c
40263 +++ b/drivers/hid/hid-logitech-dj.c
40264 @@ -421,7 +421,7 @@ static int logi_dj_recv_send_report(struct dj_receiver_dev *djrcv_dev,
40265 struct hid_report *report;
40266 struct hid_report_enum *output_report_enum;
40267 u8 *data = (u8 *)(&dj_report->device_index);
40268 - int i;
40269 + unsigned int i, length;
40270
40271 output_report_enum = &hdev->report_enum[HID_OUTPUT_REPORT];
40272 report = output_report_enum->report_id_hash[REPORT_ID_DJ_SHORT];
40273 @@ -431,7 +431,9 @@ static int logi_dj_recv_send_report(struct dj_receiver_dev *djrcv_dev,
40274 return -ENODEV;
40275 }
40276
40277 - for (i = 0; i < report->field[0]->report_count; i++)
40278 + length = min_t(size_t, sizeof(*dj_report) - 1,
40279 + report->field[0]->report_count);
40280 + for (i = 0; i < length; i++)
40281 report->field[0]->value[i] = data[i];
40282
40283 hid_hw_request(hdev, report, HID_REQ_SET_REPORT);
40284 @@ -738,6 +740,12 @@ static int logi_dj_probe(struct hid_device *hdev,
40285 goto hid_parse_fail;
40286 }
40287
40288 + if (!hid_validate_report(hdev, HID_OUTPUT_REPORT, REPORT_ID_DJ_SHORT,
40289 + 1, 3)) {
40290 + retval = -ENODEV;
40291 + goto hid_parse_fail;
40292 + }
40293 +
40294 /* Starts the usb device and connects to upper interfaces hiddev and
40295 * hidraw */
40296 retval = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
40297 diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
40298 index d39a5ce..4892dfc 100644
40299 --- a/drivers/hid/hid-multitouch.c
40300 +++ b/drivers/hid/hid-multitouch.c
40301 @@ -330,9 +330,18 @@ static void mt_feature_mapping(struct hid_device *hdev,
40302 break;
40303 }
40304 }
40305 + /* Ignore if value index is out of bounds. */
40306 + if (td->inputmode_index < 0 ||
40307 + td->inputmode_index >= field->report_count) {
40308 + dev_err(&hdev->dev, "HID_DG_INPUTMODE out of range\n");
40309 + td->inputmode = -1;
40310 + }
40311
40312 break;
40313 case HID_DG_CONTACTMAX:
40314 + /* Ignore if value count is out of bounds. */
40315 + if (field->report_count < 1)
40316 + break;
40317 td->maxcontact_report_id = field->report->id;
40318 td->maxcontacts = field->value[0];
40319 if (!td->maxcontacts &&
40320 @@ -743,15 +752,21 @@ static void mt_touch_report(struct hid_device *hid, struct hid_report *report)
40321 unsigned count;
40322 int r, n;
40323
40324 + if (report->maxfield == 0)
40325 + return;
40326 +
40327 /*
40328 * Includes multi-packet support where subsequent
40329 * packets are sent with zero contactcount.
40330 */
40331 - if (td->cc_index >= 0) {
40332 - struct hid_field *field = report->field[td->cc_index];
40333 - int value = field->value[td->cc_value_index];
40334 - if (value)
40335 - td->num_expected = value;
40336 + if (td->cc_index >= 0 && td->cc_index < report->maxfield) {
40337 + field = report->field[td->cc_index];
40338 + if (td->cc_value_index >= 0 &&
40339 + td->cc_value_index < field->report_count) {
40340 + int value = field->value[td->cc_value_index];
40341 + if (value)
40342 + td->num_expected = value;
40343 + }
40344 }
40345
40346 for (r = 0; r < report->maxfield; r++) {
40347 diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c
40348 index ef95102..5482156 100644
40349 --- a/drivers/hid/hid-ntrig.c
40350 +++ b/drivers/hid/hid-ntrig.c
40351 @@ -115,7 +115,8 @@ static inline int ntrig_get_mode(struct hid_device *hdev)
40352 struct hid_report *report = hdev->report_enum[HID_FEATURE_REPORT].
40353 report_id_hash[0x0d];
40354
40355 - if (!report)
40356 + if (!report || report->maxfield < 1 ||
40357 + report->field[0]->report_count < 1)
40358 return -EINVAL;
40359
40360 hid_hw_request(hdev, report, HID_REQ_GET_REPORT);
40361 diff --git a/drivers/hid/hid-picolcd_core.c b/drivers/hid/hid-picolcd_core.c
40362 index b48092d..72bba1e 100644
40363 --- a/drivers/hid/hid-picolcd_core.c
40364 +++ b/drivers/hid/hid-picolcd_core.c
40365 @@ -290,7 +290,7 @@ static ssize_t picolcd_operation_mode_store(struct device *dev,
40366 buf += 10;
40367 cnt -= 10;
40368 }
40369 - if (!report)
40370 + if (!report || report->maxfield < 1)
40371 return -EINVAL;
40372
40373 while (cnt > 0 && (buf[cnt-1] == '\n' || buf[cnt-1] == '\r'))
40374 diff --git a/drivers/hid/hid-pl.c b/drivers/hid/hid-pl.c
40375 index d29112f..2dcd7d9 100644
40376 --- a/drivers/hid/hid-pl.c
40377 +++ b/drivers/hid/hid-pl.c
40378 @@ -132,8 +132,14 @@ static int plff_init(struct hid_device *hid)
40379 strong = &report->field[0]->value[2];
40380 weak = &report->field[0]->value[3];
40381 debug("detected single-field device");
40382 - } else if (report->maxfield >= 4 && report->field[0]->maxusage == 1 &&
40383 - report->field[0]->usage[0].hid == (HID_UP_LED | 0x43)) {
40384 + } else if (report->field[0]->maxusage == 1 &&
40385 + report->field[0]->usage[0].hid ==
40386 + (HID_UP_LED | 0x43) &&
40387 + report->maxfield >= 4 &&
40388 + report->field[0]->report_count >= 1 &&
40389 + report->field[1]->report_count >= 1 &&
40390 + report->field[2]->report_count >= 1 &&
40391 + report->field[3]->report_count >= 1) {
40392 report->field[0]->value[0] = 0x00;
40393 report->field[1]->value[0] = 0x00;
40394 strong = &report->field[2]->value[0];
40395 diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
40396 index ca749810..aa34755 100644
40397 --- a/drivers/hid/hid-sensor-hub.c
40398 +++ b/drivers/hid/hid-sensor-hub.c
40399 @@ -221,7 +221,8 @@ int sensor_hub_get_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
40400
40401 mutex_lock(&data->mutex);
40402 report = sensor_hub_report(report_id, hsdev->hdev, HID_FEATURE_REPORT);
40403 - if (!report || (field_index >= report->maxfield)) {
40404 + if (!report || (field_index >= report->maxfield) ||
40405 + report->field[field_index]->report_count < 1) {
40406 ret = -EINVAL;
40407 goto done_proc;
40408 }
40409 diff --git a/drivers/hid/hid-steelseries.c b/drivers/hid/hid-steelseries.c
40410 index d164911..ef42e86 100644
40411 --- a/drivers/hid/hid-steelseries.c
40412 +++ b/drivers/hid/hid-steelseries.c
40413 @@ -249,6 +249,11 @@ static int steelseries_srws1_probe(struct hid_device *hdev,
40414 goto err_free;
40415 }
40416
40417 + if (!hid_validate_report(hdev, HID_OUTPUT_REPORT, 0, 1, 16)) {
40418 + ret = -ENODEV;
40419 + goto err_free;
40420 + }
40421 +
40422 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
40423 if (ret) {
40424 hid_err(hdev, "hw start failed\n");
40425 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
40426 index 90124ff..3761764 100644
40427 --- a/drivers/hid/hid-wiimote-debug.c
40428 +++ b/drivers/hid/hid-wiimote-debug.c
40429 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
40430 else if (size == 0)
40431 return -EIO;
40432
40433 - if (copy_to_user(u, buf, size))
40434 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
40435 return -EFAULT;
40436
40437 *off += size;
40438 diff --git a/drivers/hid/hid-zpff.c b/drivers/hid/hid-zpff.c
40439 index 6ec28a3..b124991 100644
40440 --- a/drivers/hid/hid-zpff.c
40441 +++ b/drivers/hid/hid-zpff.c
40442 @@ -68,22 +68,12 @@ static int zpff_init(struct hid_device *hid)
40443 struct hid_report *report;
40444 struct hid_input *hidinput = list_entry(hid->inputs.next,
40445 struct hid_input, list);
40446 - struct list_head *report_list =
40447 - &hid->report_enum[HID_OUTPUT_REPORT].report_list;
40448 struct input_dev *dev = hidinput->input;
40449 int error;
40450
40451 - if (list_empty(report_list)) {
40452 - hid_err(hid, "no output report found\n");
40453 + report = hid_validate_report(hid, HID_OUTPUT_REPORT, 0, 4, 1);
40454 + if (!report)
40455 return -ENODEV;
40456 - }
40457 -
40458 - report = list_entry(report_list->next, struct hid_report, list);
40459 -
40460 - if (report->maxfield < 4) {
40461 - hid_err(hid, "not enough fields in report\n");
40462 - return -ENODEV;
40463 - }
40464
40465 zpff = kzalloc(sizeof(struct zpff_device), GFP_KERNEL);
40466 if (!zpff)
40467 diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
40468 index fc307e0..2b255e8 100644
40469 --- a/drivers/hid/uhid.c
40470 +++ b/drivers/hid/uhid.c
40471 @@ -47,7 +47,7 @@ struct uhid_device {
40472 struct mutex report_lock;
40473 wait_queue_head_t report_wait;
40474 atomic_t report_done;
40475 - atomic_t report_id;
40476 + atomic_unchecked_t report_id;
40477 struct uhid_event report_buf;
40478 };
40479
40480 @@ -187,7 +187,7 @@ static int uhid_hid_get_raw(struct hid_device *hid, unsigned char rnum,
40481
40482 spin_lock_irqsave(&uhid->qlock, flags);
40483 ev->type = UHID_FEATURE;
40484 - ev->u.feature.id = atomic_inc_return(&uhid->report_id);
40485 + ev->u.feature.id = atomic_inc_return_unchecked(&uhid->report_id);
40486 ev->u.feature.rnum = rnum;
40487 ev->u.feature.rtype = report_type;
40488
40489 @@ -471,7 +471,7 @@ static int uhid_dev_feature_answer(struct uhid_device *uhid,
40490 spin_lock_irqsave(&uhid->qlock, flags);
40491
40492 /* id for old report; drop it silently */
40493 - if (atomic_read(&uhid->report_id) != ev->u.feature_answer.id)
40494 + if (atomic_read_unchecked(&uhid->report_id) != ev->u.feature_answer.id)
40495 goto unlock;
40496 if (atomic_read(&uhid->report_done))
40497 goto unlock;
40498 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
40499 index 0b122f8..b1d8160 100644
40500 --- a/drivers/hv/channel.c
40501 +++ b/drivers/hv/channel.c
40502 @@ -394,8 +394,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
40503 int ret = 0;
40504 int t;
40505
40506 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
40507 - atomic_inc(&vmbus_connection.next_gpadl_handle);
40508 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
40509 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
40510
40511 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
40512 if (ret)
40513 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
40514 index ae49237..380d4c9 100644
40515 --- a/drivers/hv/hv.c
40516 +++ b/drivers/hv/hv.c
40517 @@ -112,7 +112,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
40518 u64 output_address = (output) ? virt_to_phys(output) : 0;
40519 u32 output_address_hi = output_address >> 32;
40520 u32 output_address_lo = output_address & 0xFFFFFFFF;
40521 - void *hypercall_page = hv_context.hypercall_page;
40522 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
40523
40524 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
40525 "=a"(hv_status_lo) : "d" (control_hi),
40526 diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
40527 index deb5c25..ed2d4fd 100644
40528 --- a/drivers/hv/hv_balloon.c
40529 +++ b/drivers/hv/hv_balloon.c
40530 @@ -464,7 +464,7 @@ MODULE_PARM_DESC(hot_add, "If set attempt memory hot_add");
40531
40532 module_param(pressure_report_delay, uint, (S_IRUGO | S_IWUSR));
40533 MODULE_PARM_DESC(pressure_report_delay, "Delay in secs in reporting pressure");
40534 -static atomic_t trans_id = ATOMIC_INIT(0);
40535 +static atomic_unchecked_t trans_id = ATOMIC_INIT(0);
40536
40537 static int dm_ring_size = (5 * PAGE_SIZE);
40538
40539 @@ -825,7 +825,7 @@ static void hot_add_req(struct work_struct *dummy)
40540 memset(&resp, 0, sizeof(struct dm_hot_add_response));
40541 resp.hdr.type = DM_MEM_HOT_ADD_RESPONSE;
40542 resp.hdr.size = sizeof(struct dm_hot_add_response);
40543 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
40544 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40545
40546 #ifdef CONFIG_MEMORY_HOTPLUG
40547 pg_start = dm->ha_wrk.ha_page_range.finfo.start_page;
40548 @@ -960,7 +960,7 @@ static void post_status(struct hv_dynmem_device *dm)
40549 memset(&status, 0, sizeof(struct dm_status));
40550 status.hdr.type = DM_STATUS_REPORT;
40551 status.hdr.size = sizeof(struct dm_status);
40552 - status.hdr.trans_id = atomic_inc_return(&trans_id);
40553 + status.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40554
40555 /*
40556 * The host expects the guest to report free memory.
40557 @@ -980,7 +980,7 @@ static void post_status(struct hv_dynmem_device *dm)
40558 * send the status. This can happen if we were interrupted
40559 * after we picked our transaction ID.
40560 */
40561 - if (status.hdr.trans_id != atomic_read(&trans_id))
40562 + if (status.hdr.trans_id != atomic_read_unchecked(&trans_id))
40563 return;
40564
40565 vmbus_sendpacket(dm->dev->channel, &status,
40566 @@ -1081,7 +1081,7 @@ static void balloon_up(struct work_struct *dummy)
40567 bl_resp = (struct dm_balloon_response *)send_buffer;
40568 memset(send_buffer, 0, PAGE_SIZE);
40569 bl_resp->hdr.type = DM_BALLOON_RESPONSE;
40570 - bl_resp->hdr.trans_id = atomic_inc_return(&trans_id);
40571 + bl_resp->hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40572 bl_resp->hdr.size = sizeof(struct dm_balloon_response);
40573 bl_resp->more_pages = 1;
40574
40575 @@ -1152,7 +1152,7 @@ static void balloon_down(struct hv_dynmem_device *dm,
40576
40577 memset(&resp, 0, sizeof(struct dm_unballoon_response));
40578 resp.hdr.type = DM_UNBALLOON_RESPONSE;
40579 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
40580 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40581 resp.hdr.size = sizeof(struct dm_unballoon_response);
40582
40583 vmbus_sendpacket(dm_device.dev->channel, &resp,
40584 @@ -1215,7 +1215,7 @@ static void version_resp(struct hv_dynmem_device *dm,
40585 memset(&version_req, 0, sizeof(struct dm_version_request));
40586 version_req.hdr.type = DM_VERSION_REQUEST;
40587 version_req.hdr.size = sizeof(struct dm_version_request);
40588 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
40589 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40590 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN7;
40591 version_req.is_last_attempt = 1;
40592
40593 @@ -1385,7 +1385,7 @@ static int balloon_probe(struct hv_device *dev,
40594 memset(&version_req, 0, sizeof(struct dm_version_request));
40595 version_req.hdr.type = DM_VERSION_REQUEST;
40596 version_req.hdr.size = sizeof(struct dm_version_request);
40597 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
40598 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40599 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN8;
40600 version_req.is_last_attempt = 0;
40601
40602 @@ -1416,7 +1416,7 @@ static int balloon_probe(struct hv_device *dev,
40603 memset(&cap_msg, 0, sizeof(struct dm_capabilities));
40604 cap_msg.hdr.type = DM_CAPABILITIES_REPORT;
40605 cap_msg.hdr.size = sizeof(struct dm_capabilities);
40606 - cap_msg.hdr.trans_id = atomic_inc_return(&trans_id);
40607 + cap_msg.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40608
40609 cap_msg.caps.cap_bits.balloon = 1;
40610 cap_msg.caps.cap_bits.hot_add = 1;
40611 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
40612 index 12f2f9e..679603c 100644
40613 --- a/drivers/hv/hyperv_vmbus.h
40614 +++ b/drivers/hv/hyperv_vmbus.h
40615 @@ -591,7 +591,7 @@ enum vmbus_connect_state {
40616 struct vmbus_connection {
40617 enum vmbus_connect_state conn_state;
40618
40619 - atomic_t next_gpadl_handle;
40620 + atomic_unchecked_t next_gpadl_handle;
40621
40622 /*
40623 * Represents channel interrupts. Each bit position represents a
40624 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
40625 index 4004e54..c2de226 100644
40626 --- a/drivers/hv/vmbus_drv.c
40627 +++ b/drivers/hv/vmbus_drv.c
40628 @@ -668,10 +668,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
40629 {
40630 int ret = 0;
40631
40632 - static atomic_t device_num = ATOMIC_INIT(0);
40633 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
40634
40635 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
40636 - atomic_inc_return(&device_num));
40637 + atomic_inc_return_unchecked(&device_num));
40638
40639 child_device_obj->device.bus = &hv_bus;
40640 child_device_obj->device.parent = &hv_acpi_dev->dev;
40641 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
40642 index 6351aba..dc4aaf4 100644
40643 --- a/drivers/hwmon/acpi_power_meter.c
40644 +++ b/drivers/hwmon/acpi_power_meter.c
40645 @@ -117,7 +117,7 @@ struct sensor_template {
40646 struct device_attribute *devattr,
40647 const char *buf, size_t count);
40648 int index;
40649 -};
40650 +} __do_const;
40651
40652 /* Averaging interval */
40653 static int update_avg_interval(struct acpi_power_meter_resource *resource)
40654 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
40655 struct sensor_template *attrs)
40656 {
40657 struct device *dev = &resource->acpi_dev->dev;
40658 - struct sensor_device_attribute *sensors =
40659 + sensor_device_attribute_no_const *sensors =
40660 &resource->sensors[resource->num_sensors];
40661 int res = 0;
40662
40663 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
40664 index 62c2e32..8f2859a 100644
40665 --- a/drivers/hwmon/applesmc.c
40666 +++ b/drivers/hwmon/applesmc.c
40667 @@ -1084,7 +1084,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
40668 {
40669 struct applesmc_node_group *grp;
40670 struct applesmc_dev_attr *node;
40671 - struct attribute *attr;
40672 + attribute_no_const *attr;
40673 int ret, i;
40674
40675 for (grp = groups; grp->format; grp++) {
40676 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
40677 index b25c643..a13460d 100644
40678 --- a/drivers/hwmon/asus_atk0110.c
40679 +++ b/drivers/hwmon/asus_atk0110.c
40680 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
40681 struct atk_sensor_data {
40682 struct list_head list;
40683 struct atk_data *data;
40684 - struct device_attribute label_attr;
40685 - struct device_attribute input_attr;
40686 - struct device_attribute limit1_attr;
40687 - struct device_attribute limit2_attr;
40688 + device_attribute_no_const label_attr;
40689 + device_attribute_no_const input_attr;
40690 + device_attribute_no_const limit1_attr;
40691 + device_attribute_no_const limit2_attr;
40692 char label_attr_name[ATTR_NAME_SIZE];
40693 char input_attr_name[ATTR_NAME_SIZE];
40694 char limit1_attr_name[ATTR_NAME_SIZE];
40695 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
40696 static struct device_attribute atk_name_attr =
40697 __ATTR(name, 0444, atk_name_show, NULL);
40698
40699 -static void atk_init_attribute(struct device_attribute *attr, char *name,
40700 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
40701 sysfs_show_func show)
40702 {
40703 sysfs_attr_init(&attr->attr);
40704 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
40705 index 658ce3a..0d0c2f3 100644
40706 --- a/drivers/hwmon/coretemp.c
40707 +++ b/drivers/hwmon/coretemp.c
40708 @@ -790,7 +790,7 @@ static int __cpuinit coretemp_cpu_callback(struct notifier_block *nfb,
40709 return NOTIFY_OK;
40710 }
40711
40712 -static struct notifier_block coretemp_cpu_notifier __refdata = {
40713 +static struct notifier_block coretemp_cpu_notifier = {
40714 .notifier_call = coretemp_cpu_callback,
40715 };
40716
40717 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
40718 index 1429f6e..ee03d59 100644
40719 --- a/drivers/hwmon/ibmaem.c
40720 +++ b/drivers/hwmon/ibmaem.c
40721 @@ -926,7 +926,7 @@ static int aem_register_sensors(struct aem_data *data,
40722 struct aem_rw_sensor_template *rw)
40723 {
40724 struct device *dev = &data->pdev->dev;
40725 - struct sensor_device_attribute *sensors = data->sensors;
40726 + sensor_device_attribute_no_const *sensors = data->sensors;
40727 int err;
40728
40729 /* Set up read-only sensors */
40730 diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
40731 index 52b77af..aed1ddf 100644
40732 --- a/drivers/hwmon/iio_hwmon.c
40733 +++ b/drivers/hwmon/iio_hwmon.c
40734 @@ -73,7 +73,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
40735 {
40736 struct device *dev = &pdev->dev;
40737 struct iio_hwmon_state *st;
40738 - struct sensor_device_attribute *a;
40739 + sensor_device_attribute_no_const *a;
40740 int ret, i;
40741 int in_i = 1, temp_i = 1, curr_i = 1;
40742 enum iio_chan_type type;
40743 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
40744 index 9add6092..ee7ba3f 100644
40745 --- a/drivers/hwmon/pmbus/pmbus_core.c
40746 +++ b/drivers/hwmon/pmbus/pmbus_core.c
40747 @@ -781,7 +781,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
40748 return 0;
40749 }
40750
40751 -static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
40752 +static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
40753 const char *name,
40754 umode_t mode,
40755 ssize_t (*show)(struct device *dev,
40756 @@ -798,7 +798,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
40757 dev_attr->store = store;
40758 }
40759
40760 -static void pmbus_attr_init(struct sensor_device_attribute *a,
40761 +static void pmbus_attr_init(sensor_device_attribute_no_const *a,
40762 const char *name,
40763 umode_t mode,
40764 ssize_t (*show)(struct device *dev,
40765 @@ -820,7 +820,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
40766 u16 reg, u8 mask)
40767 {
40768 struct pmbus_boolean *boolean;
40769 - struct sensor_device_attribute *a;
40770 + sensor_device_attribute_no_const *a;
40771
40772 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
40773 if (!boolean)
40774 @@ -845,7 +845,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
40775 bool update, bool readonly)
40776 {
40777 struct pmbus_sensor *sensor;
40778 - struct device_attribute *a;
40779 + device_attribute_no_const *a;
40780
40781 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
40782 if (!sensor)
40783 @@ -876,7 +876,7 @@ static int pmbus_add_label(struct pmbus_data *data,
40784 const char *lstring, int index)
40785 {
40786 struct pmbus_label *label;
40787 - struct device_attribute *a;
40788 + device_attribute_no_const *a;
40789
40790 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
40791 if (!label)
40792 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
40793 index 2507f90..1645765 100644
40794 --- a/drivers/hwmon/sht15.c
40795 +++ b/drivers/hwmon/sht15.c
40796 @@ -169,7 +169,7 @@ struct sht15_data {
40797 int supply_uv;
40798 bool supply_uv_valid;
40799 struct work_struct update_supply_work;
40800 - atomic_t interrupt_handled;
40801 + atomic_unchecked_t interrupt_handled;
40802 };
40803
40804 /**
40805 @@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
40806 ret = gpio_direction_input(data->pdata->gpio_data);
40807 if (ret)
40808 return ret;
40809 - atomic_set(&data->interrupt_handled, 0);
40810 + atomic_set_unchecked(&data->interrupt_handled, 0);
40811
40812 enable_irq(gpio_to_irq(data->pdata->gpio_data));
40813 if (gpio_get_value(data->pdata->gpio_data) == 0) {
40814 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
40815 /* Only relevant if the interrupt hasn't occurred. */
40816 - if (!atomic_read(&data->interrupt_handled))
40817 + if (!atomic_read_unchecked(&data->interrupt_handled))
40818 schedule_work(&data->read_work);
40819 }
40820 ret = wait_event_timeout(data->wait_queue,
40821 @@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
40822
40823 /* First disable the interrupt */
40824 disable_irq_nosync(irq);
40825 - atomic_inc(&data->interrupt_handled);
40826 + atomic_inc_unchecked(&data->interrupt_handled);
40827 /* Then schedule a reading work struct */
40828 if (data->state != SHT15_READING_NOTHING)
40829 schedule_work(&data->read_work);
40830 @@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
40831 * If not, then start the interrupt again - care here as could
40832 * have gone low in meantime so verify it hasn't!
40833 */
40834 - atomic_set(&data->interrupt_handled, 0);
40835 + atomic_set_unchecked(&data->interrupt_handled, 0);
40836 enable_irq(gpio_to_irq(data->pdata->gpio_data));
40837 /* If still not occurred or another handler was scheduled */
40838 if (gpio_get_value(data->pdata->gpio_data)
40839 - || atomic_read(&data->interrupt_handled))
40840 + || atomic_read_unchecked(&data->interrupt_handled))
40841 return;
40842 }
40843
40844 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
40845 index 76f157b..9c0db1b 100644
40846 --- a/drivers/hwmon/via-cputemp.c
40847 +++ b/drivers/hwmon/via-cputemp.c
40848 @@ -296,7 +296,7 @@ static int __cpuinit via_cputemp_cpu_callback(struct notifier_block *nfb,
40849 return NOTIFY_OK;
40850 }
40851
40852 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
40853 +static struct notifier_block via_cputemp_cpu_notifier = {
40854 .notifier_call = via_cputemp_cpu_callback,
40855 };
40856
40857 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
40858 index 07f01ac..d79ad3d 100644
40859 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
40860 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
40861 @@ -43,7 +43,7 @@
40862 extern struct i2c_adapter amd756_smbus;
40863
40864 static struct i2c_adapter *s4882_adapter;
40865 -static struct i2c_algorithm *s4882_algo;
40866 +static i2c_algorithm_no_const *s4882_algo;
40867
40868 /* Wrapper access functions for multiplexed SMBus */
40869 static DEFINE_MUTEX(amd756_lock);
40870 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
40871 index 2ca268d..c6acbdf 100644
40872 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
40873 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
40874 @@ -41,7 +41,7 @@
40875 extern struct i2c_adapter *nforce2_smbus;
40876
40877 static struct i2c_adapter *s4985_adapter;
40878 -static struct i2c_algorithm *s4985_algo;
40879 +static i2c_algorithm_no_const *s4985_algo;
40880
40881 /* Wrapper access functions for multiplexed SMBus */
40882 static DEFINE_MUTEX(nforce2_lock);
40883 diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
40884 index c3ccdea..5b3dc1a 100644
40885 --- a/drivers/i2c/i2c-dev.c
40886 +++ b/drivers/i2c/i2c-dev.c
40887 @@ -271,7 +271,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
40888 break;
40889 }
40890
40891 - data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
40892 + data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
40893 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
40894 if (IS_ERR(rdwr_pa[i].buf)) {
40895 res = PTR_ERR(rdwr_pa[i].buf);
40896 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
40897 index 2ff6204..218c16e 100644
40898 --- a/drivers/ide/ide-cd.c
40899 +++ b/drivers/ide/ide-cd.c
40900 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
40901 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
40902 if ((unsigned long)buf & alignment
40903 || blk_rq_bytes(rq) & q->dma_pad_mask
40904 - || object_is_on_stack(buf))
40905 + || object_starts_on_stack(buf))
40906 drive->dma = 0;
40907 }
40908 }
40909 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
40910 index e145931..08bfc59 100644
40911 --- a/drivers/iio/industrialio-core.c
40912 +++ b/drivers/iio/industrialio-core.c
40913 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
40914 }
40915
40916 static
40917 -int __iio_device_attr_init(struct device_attribute *dev_attr,
40918 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
40919 const char *postfix,
40920 struct iio_chan_spec const *chan,
40921 ssize_t (*readfunc)(struct device *dev,
40922 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
40923 index 784b97c..c9ceadf 100644
40924 --- a/drivers/infiniband/core/cm.c
40925 +++ b/drivers/infiniband/core/cm.c
40926 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
40927
40928 struct cm_counter_group {
40929 struct kobject obj;
40930 - atomic_long_t counter[CM_ATTR_COUNT];
40931 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
40932 };
40933
40934 struct cm_counter_attribute {
40935 @@ -1395,7 +1395,7 @@ static void cm_dup_req_handler(struct cm_work *work,
40936 struct ib_mad_send_buf *msg = NULL;
40937 int ret;
40938
40939 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40940 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40941 counter[CM_REQ_COUNTER]);
40942
40943 /* Quick state check to discard duplicate REQs. */
40944 @@ -1779,7 +1779,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
40945 if (!cm_id_priv)
40946 return;
40947
40948 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40949 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40950 counter[CM_REP_COUNTER]);
40951 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
40952 if (ret)
40953 @@ -1946,7 +1946,7 @@ static int cm_rtu_handler(struct cm_work *work)
40954 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
40955 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
40956 spin_unlock_irq(&cm_id_priv->lock);
40957 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40958 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40959 counter[CM_RTU_COUNTER]);
40960 goto out;
40961 }
40962 @@ -2129,7 +2129,7 @@ static int cm_dreq_handler(struct cm_work *work)
40963 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
40964 dreq_msg->local_comm_id);
40965 if (!cm_id_priv) {
40966 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40967 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40968 counter[CM_DREQ_COUNTER]);
40969 cm_issue_drep(work->port, work->mad_recv_wc);
40970 return -EINVAL;
40971 @@ -2154,7 +2154,7 @@ static int cm_dreq_handler(struct cm_work *work)
40972 case IB_CM_MRA_REP_RCVD:
40973 break;
40974 case IB_CM_TIMEWAIT:
40975 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40976 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40977 counter[CM_DREQ_COUNTER]);
40978 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
40979 goto unlock;
40980 @@ -2168,7 +2168,7 @@ static int cm_dreq_handler(struct cm_work *work)
40981 cm_free_msg(msg);
40982 goto deref;
40983 case IB_CM_DREQ_RCVD:
40984 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40985 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40986 counter[CM_DREQ_COUNTER]);
40987 goto unlock;
40988 default:
40989 @@ -2535,7 +2535,7 @@ static int cm_mra_handler(struct cm_work *work)
40990 ib_modify_mad(cm_id_priv->av.port->mad_agent,
40991 cm_id_priv->msg, timeout)) {
40992 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
40993 - atomic_long_inc(&work->port->
40994 + atomic_long_inc_unchecked(&work->port->
40995 counter_group[CM_RECV_DUPLICATES].
40996 counter[CM_MRA_COUNTER]);
40997 goto out;
40998 @@ -2544,7 +2544,7 @@ static int cm_mra_handler(struct cm_work *work)
40999 break;
41000 case IB_CM_MRA_REQ_RCVD:
41001 case IB_CM_MRA_REP_RCVD:
41002 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
41003 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
41004 counter[CM_MRA_COUNTER]);
41005 /* fall through */
41006 default:
41007 @@ -2706,7 +2706,7 @@ static int cm_lap_handler(struct cm_work *work)
41008 case IB_CM_LAP_IDLE:
41009 break;
41010 case IB_CM_MRA_LAP_SENT:
41011 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
41012 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
41013 counter[CM_LAP_COUNTER]);
41014 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
41015 goto unlock;
41016 @@ -2722,7 +2722,7 @@ static int cm_lap_handler(struct cm_work *work)
41017 cm_free_msg(msg);
41018 goto deref;
41019 case IB_CM_LAP_RCVD:
41020 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
41021 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
41022 counter[CM_LAP_COUNTER]);
41023 goto unlock;
41024 default:
41025 @@ -3006,7 +3006,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
41026 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
41027 if (cur_cm_id_priv) {
41028 spin_unlock_irq(&cm.lock);
41029 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
41030 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
41031 counter[CM_SIDR_REQ_COUNTER]);
41032 goto out; /* Duplicate message. */
41033 }
41034 @@ -3218,10 +3218,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
41035 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
41036 msg->retries = 1;
41037
41038 - atomic_long_add(1 + msg->retries,
41039 + atomic_long_add_unchecked(1 + msg->retries,
41040 &port->counter_group[CM_XMIT].counter[attr_index]);
41041 if (msg->retries)
41042 - atomic_long_add(msg->retries,
41043 + atomic_long_add_unchecked(msg->retries,
41044 &port->counter_group[CM_XMIT_RETRIES].
41045 counter[attr_index]);
41046
41047 @@ -3431,7 +3431,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
41048 }
41049
41050 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
41051 - atomic_long_inc(&port->counter_group[CM_RECV].
41052 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
41053 counter[attr_id - CM_ATTR_ID_OFFSET]);
41054
41055 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
41056 @@ -3636,7 +3636,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
41057 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
41058
41059 return sprintf(buf, "%ld\n",
41060 - atomic_long_read(&group->counter[cm_attr->index]));
41061 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
41062 }
41063
41064 static const struct sysfs_ops cm_counter_ops = {
41065 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
41066 index 9f5ad7c..588cd84 100644
41067 --- a/drivers/infiniband/core/fmr_pool.c
41068 +++ b/drivers/infiniband/core/fmr_pool.c
41069 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
41070
41071 struct task_struct *thread;
41072
41073 - atomic_t req_ser;
41074 - atomic_t flush_ser;
41075 + atomic_unchecked_t req_ser;
41076 + atomic_unchecked_t flush_ser;
41077
41078 wait_queue_head_t force_wait;
41079 };
41080 @@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
41081 struct ib_fmr_pool *pool = pool_ptr;
41082
41083 do {
41084 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
41085 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
41086 ib_fmr_batch_release(pool);
41087
41088 - atomic_inc(&pool->flush_ser);
41089 + atomic_inc_unchecked(&pool->flush_ser);
41090 wake_up_interruptible(&pool->force_wait);
41091
41092 if (pool->flush_function)
41093 @@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
41094 }
41095
41096 set_current_state(TASK_INTERRUPTIBLE);
41097 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
41098 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
41099 !kthread_should_stop())
41100 schedule();
41101 __set_current_state(TASK_RUNNING);
41102 @@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
41103 pool->dirty_watermark = params->dirty_watermark;
41104 pool->dirty_len = 0;
41105 spin_lock_init(&pool->pool_lock);
41106 - atomic_set(&pool->req_ser, 0);
41107 - atomic_set(&pool->flush_ser, 0);
41108 + atomic_set_unchecked(&pool->req_ser, 0);
41109 + atomic_set_unchecked(&pool->flush_ser, 0);
41110 init_waitqueue_head(&pool->force_wait);
41111
41112 pool->thread = kthread_run(ib_fmr_cleanup_thread,
41113 @@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
41114 }
41115 spin_unlock_irq(&pool->pool_lock);
41116
41117 - serial = atomic_inc_return(&pool->req_ser);
41118 + serial = atomic_inc_return_unchecked(&pool->req_ser);
41119 wake_up_process(pool->thread);
41120
41121 if (wait_event_interruptible(pool->force_wait,
41122 - atomic_read(&pool->flush_ser) - serial >= 0))
41123 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
41124 return -EINTR;
41125
41126 return 0;
41127 @@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
41128 } else {
41129 list_add_tail(&fmr->list, &pool->dirty_list);
41130 if (++pool->dirty_len >= pool->dirty_watermark) {
41131 - atomic_inc(&pool->req_ser);
41132 + atomic_inc_unchecked(&pool->req_ser);
41133 wake_up_process(pool->thread);
41134 }
41135 }
41136 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
41137 index 4cb8eb2..146bf60 100644
41138 --- a/drivers/infiniband/hw/cxgb4/mem.c
41139 +++ b/drivers/infiniband/hw/cxgb4/mem.c
41140 @@ -249,7 +249,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
41141 int err;
41142 struct fw_ri_tpte tpt;
41143 u32 stag_idx;
41144 - static atomic_t key;
41145 + static atomic_unchecked_t key;
41146
41147 if (c4iw_fatal_error(rdev))
41148 return -EIO;
41149 @@ -266,7 +266,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
41150 if (rdev->stats.stag.cur > rdev->stats.stag.max)
41151 rdev->stats.stag.max = rdev->stats.stag.cur;
41152 mutex_unlock(&rdev->stats.lock);
41153 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
41154 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
41155 }
41156 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
41157 __func__, stag_state, type, pdid, stag_idx);
41158 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
41159 index 79b3dbc..96e5fcc 100644
41160 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
41161 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
41162 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
41163 struct ib_atomic_eth *ateth;
41164 struct ipath_ack_entry *e;
41165 u64 vaddr;
41166 - atomic64_t *maddr;
41167 + atomic64_unchecked_t *maddr;
41168 u64 sdata;
41169 u32 rkey;
41170 u8 next;
41171 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
41172 IB_ACCESS_REMOTE_ATOMIC)))
41173 goto nack_acc_unlck;
41174 /* Perform atomic OP and save result. */
41175 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
41176 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
41177 sdata = be64_to_cpu(ateth->swap_data);
41178 e = &qp->s_ack_queue[qp->r_head_ack_queue];
41179 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
41180 - (u64) atomic64_add_return(sdata, maddr) - sdata :
41181 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
41182 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
41183 be64_to_cpu(ateth->compare_data),
41184 sdata);
41185 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
41186 index 1f95bba..9530f87 100644
41187 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
41188 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
41189 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
41190 unsigned long flags;
41191 struct ib_wc wc;
41192 u64 sdata;
41193 - atomic64_t *maddr;
41194 + atomic64_unchecked_t *maddr;
41195 enum ib_wc_status send_status;
41196
41197 /*
41198 @@ -382,11 +382,11 @@ again:
41199 IB_ACCESS_REMOTE_ATOMIC)))
41200 goto acc_err;
41201 /* Perform atomic OP and save result. */
41202 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
41203 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
41204 sdata = wqe->wr.wr.atomic.compare_add;
41205 *(u64 *) sqp->s_sge.sge.vaddr =
41206 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
41207 - (u64) atomic64_add_return(sdata, maddr) - sdata :
41208 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
41209 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
41210 sdata, wqe->wr.wr.atomic.swap);
41211 goto send_comp;
41212 diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
41213 index 4d599ce..697b17f 100644
41214 --- a/drivers/infiniband/hw/mlx4/mad.c
41215 +++ b/drivers/infiniband/hw/mlx4/mad.c
41216 @@ -98,7 +98,7 @@ __be64 mlx4_ib_gen_node_guid(void)
41217
41218 __be64 mlx4_ib_get_new_demux_tid(struct mlx4_ib_demux_ctx *ctx)
41219 {
41220 - return cpu_to_be64(atomic_inc_return(&ctx->tid)) |
41221 + return cpu_to_be64(atomic_inc_return_unchecked(&ctx->tid)) |
41222 cpu_to_be64(0xff00000000000000LL);
41223 }
41224
41225 diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
41226 index f61ec26..ebf72cf 100644
41227 --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
41228 +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
41229 @@ -398,7 +398,7 @@ struct mlx4_ib_demux_ctx {
41230 struct list_head mcg_mgid0_list;
41231 struct workqueue_struct *mcg_wq;
41232 struct mlx4_ib_demux_pv_ctx **tun;
41233 - atomic_t tid;
41234 + atomic_unchecked_t tid;
41235 int flushing; /* flushing the work queue */
41236 };
41237
41238 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
41239 index 9d3e5c1..d9afe4a 100644
41240 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
41241 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
41242 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
41243 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
41244 }
41245
41246 -int mthca_QUERY_FW(struct mthca_dev *dev)
41247 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
41248 {
41249 struct mthca_mailbox *mailbox;
41250 u32 *outbox;
41251 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
41252 index ed9a989..e0c5871 100644
41253 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
41254 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
41255 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
41256 return key;
41257 }
41258
41259 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
41260 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
41261 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
41262 {
41263 struct mthca_mailbox *mailbox;
41264 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
41265 index 4291410..d2ab1fb 100644
41266 --- a/drivers/infiniband/hw/nes/nes.c
41267 +++ b/drivers/infiniband/hw/nes/nes.c
41268 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
41269 LIST_HEAD(nes_adapter_list);
41270 static LIST_HEAD(nes_dev_list);
41271
41272 -atomic_t qps_destroyed;
41273 +atomic_unchecked_t qps_destroyed;
41274
41275 static unsigned int ee_flsh_adapter;
41276 static unsigned int sysfs_nonidx_addr;
41277 @@ -269,7 +269,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
41278 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
41279 struct nes_adapter *nesadapter = nesdev->nesadapter;
41280
41281 - atomic_inc(&qps_destroyed);
41282 + atomic_inc_unchecked(&qps_destroyed);
41283
41284 /* Free the control structures */
41285
41286 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
41287 index 33cc589..3bd6538 100644
41288 --- a/drivers/infiniband/hw/nes/nes.h
41289 +++ b/drivers/infiniband/hw/nes/nes.h
41290 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
41291 extern unsigned int wqm_quanta;
41292 extern struct list_head nes_adapter_list;
41293
41294 -extern atomic_t cm_connects;
41295 -extern atomic_t cm_accepts;
41296 -extern atomic_t cm_disconnects;
41297 -extern atomic_t cm_closes;
41298 -extern atomic_t cm_connecteds;
41299 -extern atomic_t cm_connect_reqs;
41300 -extern atomic_t cm_rejects;
41301 -extern atomic_t mod_qp_timouts;
41302 -extern atomic_t qps_created;
41303 -extern atomic_t qps_destroyed;
41304 -extern atomic_t sw_qps_destroyed;
41305 +extern atomic_unchecked_t cm_connects;
41306 +extern atomic_unchecked_t cm_accepts;
41307 +extern atomic_unchecked_t cm_disconnects;
41308 +extern atomic_unchecked_t cm_closes;
41309 +extern atomic_unchecked_t cm_connecteds;
41310 +extern atomic_unchecked_t cm_connect_reqs;
41311 +extern atomic_unchecked_t cm_rejects;
41312 +extern atomic_unchecked_t mod_qp_timouts;
41313 +extern atomic_unchecked_t qps_created;
41314 +extern atomic_unchecked_t qps_destroyed;
41315 +extern atomic_unchecked_t sw_qps_destroyed;
41316 extern u32 mh_detected;
41317 extern u32 mh_pauses_sent;
41318 extern u32 cm_packets_sent;
41319 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
41320 extern u32 cm_packets_received;
41321 extern u32 cm_packets_dropped;
41322 extern u32 cm_packets_retrans;
41323 -extern atomic_t cm_listens_created;
41324 -extern atomic_t cm_listens_destroyed;
41325 +extern atomic_unchecked_t cm_listens_created;
41326 +extern atomic_unchecked_t cm_listens_destroyed;
41327 extern u32 cm_backlog_drops;
41328 -extern atomic_t cm_loopbacks;
41329 -extern atomic_t cm_nodes_created;
41330 -extern atomic_t cm_nodes_destroyed;
41331 -extern atomic_t cm_accel_dropped_pkts;
41332 -extern atomic_t cm_resets_recvd;
41333 -extern atomic_t pau_qps_created;
41334 -extern atomic_t pau_qps_destroyed;
41335 +extern atomic_unchecked_t cm_loopbacks;
41336 +extern atomic_unchecked_t cm_nodes_created;
41337 +extern atomic_unchecked_t cm_nodes_destroyed;
41338 +extern atomic_unchecked_t cm_accel_dropped_pkts;
41339 +extern atomic_unchecked_t cm_resets_recvd;
41340 +extern atomic_unchecked_t pau_qps_created;
41341 +extern atomic_unchecked_t pau_qps_destroyed;
41342
41343 extern u32 int_mod_timer_init;
41344 extern u32 int_mod_cq_depth_256;
41345 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
41346 index 24b9f1a..00fd004 100644
41347 --- a/drivers/infiniband/hw/nes/nes_cm.c
41348 +++ b/drivers/infiniband/hw/nes/nes_cm.c
41349 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
41350 u32 cm_packets_retrans;
41351 u32 cm_packets_created;
41352 u32 cm_packets_received;
41353 -atomic_t cm_listens_created;
41354 -atomic_t cm_listens_destroyed;
41355 +atomic_unchecked_t cm_listens_created;
41356 +atomic_unchecked_t cm_listens_destroyed;
41357 u32 cm_backlog_drops;
41358 -atomic_t cm_loopbacks;
41359 -atomic_t cm_nodes_created;
41360 -atomic_t cm_nodes_destroyed;
41361 -atomic_t cm_accel_dropped_pkts;
41362 -atomic_t cm_resets_recvd;
41363 +atomic_unchecked_t cm_loopbacks;
41364 +atomic_unchecked_t cm_nodes_created;
41365 +atomic_unchecked_t cm_nodes_destroyed;
41366 +atomic_unchecked_t cm_accel_dropped_pkts;
41367 +atomic_unchecked_t cm_resets_recvd;
41368
41369 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
41370 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
41371 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
41372
41373 static struct nes_cm_core *g_cm_core;
41374
41375 -atomic_t cm_connects;
41376 -atomic_t cm_accepts;
41377 -atomic_t cm_disconnects;
41378 -atomic_t cm_closes;
41379 -atomic_t cm_connecteds;
41380 -atomic_t cm_connect_reqs;
41381 -atomic_t cm_rejects;
41382 +atomic_unchecked_t cm_connects;
41383 +atomic_unchecked_t cm_accepts;
41384 +atomic_unchecked_t cm_disconnects;
41385 +atomic_unchecked_t cm_closes;
41386 +atomic_unchecked_t cm_connecteds;
41387 +atomic_unchecked_t cm_connect_reqs;
41388 +atomic_unchecked_t cm_rejects;
41389
41390 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
41391 {
41392 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
41393 kfree(listener);
41394 listener = NULL;
41395 ret = 0;
41396 - atomic_inc(&cm_listens_destroyed);
41397 + atomic_inc_unchecked(&cm_listens_destroyed);
41398 } else {
41399 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
41400 }
41401 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
41402 cm_node->rem_mac);
41403
41404 add_hte_node(cm_core, cm_node);
41405 - atomic_inc(&cm_nodes_created);
41406 + atomic_inc_unchecked(&cm_nodes_created);
41407
41408 return cm_node;
41409 }
41410 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
41411 }
41412
41413 atomic_dec(&cm_core->node_cnt);
41414 - atomic_inc(&cm_nodes_destroyed);
41415 + atomic_inc_unchecked(&cm_nodes_destroyed);
41416 nesqp = cm_node->nesqp;
41417 if (nesqp) {
41418 nesqp->cm_node = NULL;
41419 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
41420
41421 static void drop_packet(struct sk_buff *skb)
41422 {
41423 - atomic_inc(&cm_accel_dropped_pkts);
41424 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
41425 dev_kfree_skb_any(skb);
41426 }
41427
41428 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
41429 {
41430
41431 int reset = 0; /* whether to send reset in case of err.. */
41432 - atomic_inc(&cm_resets_recvd);
41433 + atomic_inc_unchecked(&cm_resets_recvd);
41434 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
41435 " refcnt=%d\n", cm_node, cm_node->state,
41436 atomic_read(&cm_node->ref_count));
41437 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
41438 rem_ref_cm_node(cm_node->cm_core, cm_node);
41439 return NULL;
41440 }
41441 - atomic_inc(&cm_loopbacks);
41442 + atomic_inc_unchecked(&cm_loopbacks);
41443 loopbackremotenode->loopbackpartner = cm_node;
41444 loopbackremotenode->tcp_cntxt.rcv_wscale =
41445 NES_CM_DEFAULT_RCV_WND_SCALE;
41446 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
41447 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
41448 else {
41449 rem_ref_cm_node(cm_core, cm_node);
41450 - atomic_inc(&cm_accel_dropped_pkts);
41451 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
41452 dev_kfree_skb_any(skb);
41453 }
41454 break;
41455 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
41456
41457 if ((cm_id) && (cm_id->event_handler)) {
41458 if (issue_disconn) {
41459 - atomic_inc(&cm_disconnects);
41460 + atomic_inc_unchecked(&cm_disconnects);
41461 cm_event.event = IW_CM_EVENT_DISCONNECT;
41462 cm_event.status = disconn_status;
41463 cm_event.local_addr = cm_id->local_addr;
41464 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
41465 }
41466
41467 if (issue_close) {
41468 - atomic_inc(&cm_closes);
41469 + atomic_inc_unchecked(&cm_closes);
41470 nes_disconnect(nesqp, 1);
41471
41472 cm_id->provider_data = nesqp;
41473 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
41474
41475 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
41476 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
41477 - atomic_inc(&cm_accepts);
41478 + atomic_inc_unchecked(&cm_accepts);
41479
41480 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
41481 netdev_refcnt_read(nesvnic->netdev));
41482 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
41483 struct nes_cm_core *cm_core;
41484 u8 *start_buff;
41485
41486 - atomic_inc(&cm_rejects);
41487 + atomic_inc_unchecked(&cm_rejects);
41488 cm_node = (struct nes_cm_node *)cm_id->provider_data;
41489 loopback = cm_node->loopbackpartner;
41490 cm_core = cm_node->cm_core;
41491 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
41492 ntohl(cm_id->local_addr.sin_addr.s_addr),
41493 ntohs(cm_id->local_addr.sin_port));
41494
41495 - atomic_inc(&cm_connects);
41496 + atomic_inc_unchecked(&cm_connects);
41497 nesqp->active_conn = 1;
41498
41499 /* cache the cm_id in the qp */
41500 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
41501 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
41502 return err;
41503 }
41504 - atomic_inc(&cm_listens_created);
41505 + atomic_inc_unchecked(&cm_listens_created);
41506 }
41507
41508 cm_id->add_ref(cm_id);
41509 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
41510
41511 if (nesqp->destroyed)
41512 return;
41513 - atomic_inc(&cm_connecteds);
41514 + atomic_inc_unchecked(&cm_connecteds);
41515 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
41516 " local port 0x%04X. jiffies = %lu.\n",
41517 nesqp->hwqp.qp_id,
41518 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
41519
41520 cm_id->add_ref(cm_id);
41521 ret = cm_id->event_handler(cm_id, &cm_event);
41522 - atomic_inc(&cm_closes);
41523 + atomic_inc_unchecked(&cm_closes);
41524 cm_event.event = IW_CM_EVENT_CLOSE;
41525 cm_event.status = 0;
41526 cm_event.provider_data = cm_id->provider_data;
41527 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
41528 return;
41529 cm_id = cm_node->cm_id;
41530
41531 - atomic_inc(&cm_connect_reqs);
41532 + atomic_inc_unchecked(&cm_connect_reqs);
41533 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
41534 cm_node, cm_id, jiffies);
41535
41536 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
41537 return;
41538 cm_id = cm_node->cm_id;
41539
41540 - atomic_inc(&cm_connect_reqs);
41541 + atomic_inc_unchecked(&cm_connect_reqs);
41542 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
41543 cm_node, cm_id, jiffies);
41544
41545 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
41546 index 4166452..fc952c3 100644
41547 --- a/drivers/infiniband/hw/nes/nes_mgt.c
41548 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
41549 @@ -40,8 +40,8 @@
41550 #include "nes.h"
41551 #include "nes_mgt.h"
41552
41553 -atomic_t pau_qps_created;
41554 -atomic_t pau_qps_destroyed;
41555 +atomic_unchecked_t pau_qps_created;
41556 +atomic_unchecked_t pau_qps_destroyed;
41557
41558 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
41559 {
41560 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
41561 {
41562 struct sk_buff *skb;
41563 unsigned long flags;
41564 - atomic_inc(&pau_qps_destroyed);
41565 + atomic_inc_unchecked(&pau_qps_destroyed);
41566
41567 /* Free packets that have not yet been forwarded */
41568 /* Lock is acquired by skb_dequeue when removing the skb */
41569 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
41570 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
41571 skb_queue_head_init(&nesqp->pau_list);
41572 spin_lock_init(&nesqp->pau_lock);
41573 - atomic_inc(&pau_qps_created);
41574 + atomic_inc_unchecked(&pau_qps_created);
41575 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
41576 }
41577
41578 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
41579 index 49eb511..a774366 100644
41580 --- a/drivers/infiniband/hw/nes/nes_nic.c
41581 +++ b/drivers/infiniband/hw/nes/nes_nic.c
41582 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
41583 target_stat_values[++index] = mh_detected;
41584 target_stat_values[++index] = mh_pauses_sent;
41585 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
41586 - target_stat_values[++index] = atomic_read(&cm_connects);
41587 - target_stat_values[++index] = atomic_read(&cm_accepts);
41588 - target_stat_values[++index] = atomic_read(&cm_disconnects);
41589 - target_stat_values[++index] = atomic_read(&cm_connecteds);
41590 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
41591 - target_stat_values[++index] = atomic_read(&cm_rejects);
41592 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
41593 - target_stat_values[++index] = atomic_read(&qps_created);
41594 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
41595 - target_stat_values[++index] = atomic_read(&qps_destroyed);
41596 - target_stat_values[++index] = atomic_read(&cm_closes);
41597 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
41598 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
41599 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
41600 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
41601 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
41602 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
41603 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
41604 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
41605 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
41606 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
41607 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
41608 target_stat_values[++index] = cm_packets_sent;
41609 target_stat_values[++index] = cm_packets_bounced;
41610 target_stat_values[++index] = cm_packets_created;
41611 target_stat_values[++index] = cm_packets_received;
41612 target_stat_values[++index] = cm_packets_dropped;
41613 target_stat_values[++index] = cm_packets_retrans;
41614 - target_stat_values[++index] = atomic_read(&cm_listens_created);
41615 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
41616 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
41617 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
41618 target_stat_values[++index] = cm_backlog_drops;
41619 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
41620 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
41621 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
41622 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
41623 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
41624 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
41625 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
41626 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
41627 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
41628 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
41629 target_stat_values[++index] = nesadapter->free_4kpbl;
41630 target_stat_values[++index] = nesadapter->free_256pbl;
41631 target_stat_values[++index] = int_mod_timer_init;
41632 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
41633 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
41634 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
41635 - target_stat_values[++index] = atomic_read(&pau_qps_created);
41636 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
41637 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
41638 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
41639 }
41640
41641 /**
41642 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
41643 index 8f67fe2..8960859 100644
41644 --- a/drivers/infiniband/hw/nes/nes_verbs.c
41645 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
41646 @@ -46,9 +46,9 @@
41647
41648 #include <rdma/ib_umem.h>
41649
41650 -atomic_t mod_qp_timouts;
41651 -atomic_t qps_created;
41652 -atomic_t sw_qps_destroyed;
41653 +atomic_unchecked_t mod_qp_timouts;
41654 +atomic_unchecked_t qps_created;
41655 +atomic_unchecked_t sw_qps_destroyed;
41656
41657 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
41658
41659 @@ -1134,7 +1134,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
41660 if (init_attr->create_flags)
41661 return ERR_PTR(-EINVAL);
41662
41663 - atomic_inc(&qps_created);
41664 + atomic_inc_unchecked(&qps_created);
41665 switch (init_attr->qp_type) {
41666 case IB_QPT_RC:
41667 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
41668 @@ -1465,7 +1465,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
41669 struct iw_cm_event cm_event;
41670 int ret = 0;
41671
41672 - atomic_inc(&sw_qps_destroyed);
41673 + atomic_inc_unchecked(&sw_qps_destroyed);
41674 nesqp->destroyed = 1;
41675
41676 /* Blow away the connection if it exists. */
41677 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
41678 index 4d11575..3e890e5 100644
41679 --- a/drivers/infiniband/hw/qib/qib.h
41680 +++ b/drivers/infiniband/hw/qib/qib.h
41681 @@ -51,6 +51,7 @@
41682 #include <linux/completion.h>
41683 #include <linux/kref.h>
41684 #include <linux/sched.h>
41685 +#include <linux/slab.h>
41686
41687 #include "qib_common.h"
41688 #include "qib_verbs.h"
41689 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
41690 index da739d9..da1c7f4 100644
41691 --- a/drivers/input/gameport/gameport.c
41692 +++ b/drivers/input/gameport/gameport.c
41693 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
41694 */
41695 static void gameport_init_port(struct gameport *gameport)
41696 {
41697 - static atomic_t gameport_no = ATOMIC_INIT(0);
41698 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
41699
41700 __module_get(THIS_MODULE);
41701
41702 mutex_init(&gameport->drv_mutex);
41703 device_initialize(&gameport->dev);
41704 dev_set_name(&gameport->dev, "gameport%lu",
41705 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
41706 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
41707 gameport->dev.bus = &gameport_bus;
41708 gameport->dev.release = gameport_release_port;
41709 if (gameport->parent)
41710 diff --git a/drivers/input/input.c b/drivers/input/input.c
41711 index c044699..174d71a 100644
41712 --- a/drivers/input/input.c
41713 +++ b/drivers/input/input.c
41714 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
41715 */
41716 int input_register_device(struct input_dev *dev)
41717 {
41718 - static atomic_t input_no = ATOMIC_INIT(0);
41719 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
41720 struct input_devres *devres = NULL;
41721 struct input_handler *handler;
41722 unsigned int packet_size;
41723 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
41724 dev->setkeycode = input_default_setkeycode;
41725
41726 dev_set_name(&dev->dev, "input%ld",
41727 - (unsigned long) atomic_inc_return(&input_no) - 1);
41728 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
41729
41730 error = device_add(&dev->dev);
41731 if (error)
41732 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
41733 index 04c69af..5f92d00 100644
41734 --- a/drivers/input/joystick/sidewinder.c
41735 +++ b/drivers/input/joystick/sidewinder.c
41736 @@ -30,6 +30,7 @@
41737 #include <linux/kernel.h>
41738 #include <linux/module.h>
41739 #include <linux/slab.h>
41740 +#include <linux/sched.h>
41741 #include <linux/init.h>
41742 #include <linux/input.h>
41743 #include <linux/gameport.h>
41744 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
41745 index fa061d4..4a6957c 100644
41746 --- a/drivers/input/joystick/xpad.c
41747 +++ b/drivers/input/joystick/xpad.c
41748 @@ -735,7 +735,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
41749
41750 static int xpad_led_probe(struct usb_xpad *xpad)
41751 {
41752 - static atomic_t led_seq = ATOMIC_INIT(0);
41753 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
41754 long led_no;
41755 struct xpad_led *led;
41756 struct led_classdev *led_cdev;
41757 @@ -748,7 +748,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
41758 if (!led)
41759 return -ENOMEM;
41760
41761 - led_no = (long)atomic_inc_return(&led_seq) - 1;
41762 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
41763
41764 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
41765 led->xpad = xpad;
41766 diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
41767 index e204f26..8459f15 100644
41768 --- a/drivers/input/misc/ims-pcu.c
41769 +++ b/drivers/input/misc/ims-pcu.c
41770 @@ -1621,7 +1621,7 @@ static int ims_pcu_identify_type(struct ims_pcu *pcu, u8 *device_id)
41771
41772 static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
41773 {
41774 - static atomic_t device_no = ATOMIC_INIT(0);
41775 + static atomic_unchecked_t device_no = ATOMIC_INIT(0);
41776
41777 const struct ims_pcu_device_info *info;
41778 u8 device_id;
41779 @@ -1653,7 +1653,7 @@ static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
41780 }
41781
41782 /* Device appears to be operable, complete initialization */
41783 - pcu->device_no = atomic_inc_return(&device_no) - 1;
41784 + pcu->device_no = atomic_inc_return_unchecked(&device_no) - 1;
41785
41786 error = ims_pcu_setup_backlight(pcu);
41787 if (error)
41788 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
41789 index 2f0b39d..7370f13 100644
41790 --- a/drivers/input/mouse/psmouse.h
41791 +++ b/drivers/input/mouse/psmouse.h
41792 @@ -116,7 +116,7 @@ struct psmouse_attribute {
41793 ssize_t (*set)(struct psmouse *psmouse, void *data,
41794 const char *buf, size_t count);
41795 bool protect;
41796 -};
41797 +} __do_const;
41798 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
41799
41800 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
41801 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
41802 index 4c842c3..590b0bf 100644
41803 --- a/drivers/input/mousedev.c
41804 +++ b/drivers/input/mousedev.c
41805 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
41806
41807 spin_unlock_irq(&client->packet_lock);
41808
41809 - if (copy_to_user(buffer, data, count))
41810 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
41811 return -EFAULT;
41812
41813 return count;
41814 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
41815 index 25fc597..558bf3b3 100644
41816 --- a/drivers/input/serio/serio.c
41817 +++ b/drivers/input/serio/serio.c
41818 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
41819 */
41820 static void serio_init_port(struct serio *serio)
41821 {
41822 - static atomic_t serio_no = ATOMIC_INIT(0);
41823 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
41824
41825 __module_get(THIS_MODULE);
41826
41827 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
41828 mutex_init(&serio->drv_mutex);
41829 device_initialize(&serio->dev);
41830 dev_set_name(&serio->dev, "serio%ld",
41831 - (long)atomic_inc_return(&serio_no) - 1);
41832 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
41833 serio->dev.bus = &serio_bus;
41834 serio->dev.release = serio_release_port;
41835 serio->dev.groups = serio_device_attr_groups;
41836 diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
41837 index 59df2e7..8f1cafb 100644
41838 --- a/drivers/input/serio/serio_raw.c
41839 +++ b/drivers/input/serio/serio_raw.c
41840 @@ -293,7 +293,7 @@ static irqreturn_t serio_raw_interrupt(struct serio *serio, unsigned char data,
41841
41842 static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
41843 {
41844 - static atomic_t serio_raw_no = ATOMIC_INIT(0);
41845 + static atomic_unchecked_t serio_raw_no = ATOMIC_INIT(0);
41846 struct serio_raw *serio_raw;
41847 int err;
41848
41849 @@ -304,7 +304,7 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
41850 }
41851
41852 snprintf(serio_raw->name, sizeof(serio_raw->name),
41853 - "serio_raw%ld", (long)atomic_inc_return(&serio_raw_no) - 1);
41854 + "serio_raw%ld", (long)atomic_inc_return_unchecked(&serio_raw_no) - 1);
41855 kref_init(&serio_raw->kref);
41856 INIT_LIST_HEAD(&serio_raw->client_list);
41857 init_waitqueue_head(&serio_raw->wait);
41858 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
41859 index d8f98b1..f62a640 100644
41860 --- a/drivers/iommu/iommu.c
41861 +++ b/drivers/iommu/iommu.c
41862 @@ -583,7 +583,7 @@ static struct notifier_block iommu_bus_nb = {
41863 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
41864 {
41865 bus_register_notifier(bus, &iommu_bus_nb);
41866 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
41867 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
41868 }
41869
41870 /**
41871 diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
41872 index dcfea4e..f4226b2 100644
41873 --- a/drivers/iommu/irq_remapping.c
41874 +++ b/drivers/iommu/irq_remapping.c
41875 @@ -354,7 +354,7 @@ int setup_hpet_msi_remapped(unsigned int irq, unsigned int id)
41876 void panic_if_irq_remap(const char *msg)
41877 {
41878 if (irq_remapping_enabled)
41879 - panic(msg);
41880 + panic("%s", msg);
41881 }
41882
41883 static void ir_ack_apic_edge(struct irq_data *data)
41884 @@ -375,10 +375,12 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
41885
41886 void irq_remap_modify_chip_defaults(struct irq_chip *chip)
41887 {
41888 - chip->irq_print_chip = ir_print_prefix;
41889 - chip->irq_ack = ir_ack_apic_edge;
41890 - chip->irq_eoi = ir_ack_apic_level;
41891 - chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
41892 + pax_open_kernel();
41893 + *(void **)&chip->irq_print_chip = ir_print_prefix;
41894 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
41895 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
41896 + *(void **)&chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
41897 + pax_close_kernel();
41898 }
41899
41900 bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip)
41901 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
41902 index 19ceaa6..3625818 100644
41903 --- a/drivers/irqchip/irq-gic.c
41904 +++ b/drivers/irqchip/irq-gic.c
41905 @@ -84,7 +84,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
41906 * Supported arch specific GIC irq extension.
41907 * Default make them NULL.
41908 */
41909 -struct irq_chip gic_arch_extn = {
41910 +irq_chip_no_const gic_arch_extn = {
41911 .irq_eoi = NULL,
41912 .irq_mask = NULL,
41913 .irq_unmask = NULL,
41914 @@ -333,7 +333,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
41915 chained_irq_exit(chip, desc);
41916 }
41917
41918 -static struct irq_chip gic_chip = {
41919 +static irq_chip_no_const gic_chip __read_only = {
41920 .name = "GIC",
41921 .irq_mask = gic_mask_irq,
41922 .irq_unmask = gic_unmask_irq,
41923 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
41924 index ac6f72b..81150f2 100644
41925 --- a/drivers/isdn/capi/capi.c
41926 +++ b/drivers/isdn/capi/capi.c
41927 @@ -81,8 +81,8 @@ struct capiminor {
41928
41929 struct capi20_appl *ap;
41930 u32 ncci;
41931 - atomic_t datahandle;
41932 - atomic_t msgid;
41933 + atomic_unchecked_t datahandle;
41934 + atomic_unchecked_t msgid;
41935
41936 struct tty_port port;
41937 int ttyinstop;
41938 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
41939 capimsg_setu16(s, 2, mp->ap->applid);
41940 capimsg_setu8 (s, 4, CAPI_DATA_B3);
41941 capimsg_setu8 (s, 5, CAPI_RESP);
41942 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
41943 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
41944 capimsg_setu32(s, 8, mp->ncci);
41945 capimsg_setu16(s, 12, datahandle);
41946 }
41947 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
41948 mp->outbytes -= len;
41949 spin_unlock_bh(&mp->outlock);
41950
41951 - datahandle = atomic_inc_return(&mp->datahandle);
41952 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
41953 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
41954 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
41955 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
41956 capimsg_setu16(skb->data, 2, mp->ap->applid);
41957 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
41958 capimsg_setu8 (skb->data, 5, CAPI_REQ);
41959 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
41960 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
41961 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
41962 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
41963 capimsg_setu16(skb->data, 16, len); /* Data length */
41964 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
41965 index 600c79b..3752bab 100644
41966 --- a/drivers/isdn/gigaset/interface.c
41967 +++ b/drivers/isdn/gigaset/interface.c
41968 @@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
41969 }
41970 tty->driver_data = cs;
41971
41972 - ++cs->port.count;
41973 + atomic_inc(&cs->port.count);
41974
41975 - if (cs->port.count == 1) {
41976 + if (atomic_read(&cs->port.count) == 1) {
41977 tty_port_tty_set(&cs->port, tty);
41978 cs->port.low_latency = 1;
41979 }
41980 @@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
41981
41982 if (!cs->connected)
41983 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
41984 - else if (!cs->port.count)
41985 + else if (!atomic_read(&cs->port.count))
41986 dev_warn(cs->dev, "%s: device not opened\n", __func__);
41987 - else if (!--cs->port.count)
41988 + else if (!atomic_dec_return(&cs->port.count))
41989 tty_port_tty_set(&cs->port, NULL);
41990
41991 mutex_unlock(&cs->mutex);
41992 diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
41993 index d0a41cb..f0cdb8c 100644
41994 --- a/drivers/isdn/gigaset/usb-gigaset.c
41995 +++ b/drivers/isdn/gigaset/usb-gigaset.c
41996 @@ -547,7 +547,7 @@ static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6])
41997 gigaset_dbg_buffer(DEBUG_USBREQ, "brkchars", 6, buf);
41998 memcpy(cs->hw.usb->bchars, buf, 6);
41999 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x19, 0x41,
42000 - 0, 0, &buf, 6, 2000);
42001 + 0, 0, buf, 6, 2000);
42002 }
42003
42004 static void gigaset_freebcshw(struct bc_state *bcs)
42005 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
42006 index 4d9b195..455075c 100644
42007 --- a/drivers/isdn/hardware/avm/b1.c
42008 +++ b/drivers/isdn/hardware/avm/b1.c
42009 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
42010 }
42011 if (left) {
42012 if (t4file->user) {
42013 - if (copy_from_user(buf, dp, left))
42014 + if (left > sizeof buf || copy_from_user(buf, dp, left))
42015 return -EFAULT;
42016 } else {
42017 memcpy(buf, dp, left);
42018 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
42019 }
42020 if (left) {
42021 if (config->user) {
42022 - if (copy_from_user(buf, dp, left))
42023 + if (left > sizeof buf || copy_from_user(buf, dp, left))
42024 return -EFAULT;
42025 } else {
42026 memcpy(buf, dp, left);
42027 diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
42028 index 9bb12ba..d4262f7 100644
42029 --- a/drivers/isdn/i4l/isdn_common.c
42030 +++ b/drivers/isdn/i4l/isdn_common.c
42031 @@ -1651,6 +1651,8 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
42032 } else
42033 return -EINVAL;
42034 case IIOCDBGVAR:
42035 + if (!capable(CAP_SYS_RAWIO))
42036 + return -EPERM;
42037 if (arg) {
42038 if (copy_to_user(argp, &dev, sizeof(ulong)))
42039 return -EFAULT;
42040 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
42041 index 3c5f249..5fac4d0 100644
42042 --- a/drivers/isdn/i4l/isdn_tty.c
42043 +++ b/drivers/isdn/i4l/isdn_tty.c
42044 @@ -1508,9 +1508,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
42045
42046 #ifdef ISDN_DEBUG_MODEM_OPEN
42047 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
42048 - port->count);
42049 + atomic_read(&port->count));
42050 #endif
42051 - port->count++;
42052 + atomic_inc(&port->count);
42053 port->tty = tty;
42054 /*
42055 * Start up serial port
42056 @@ -1554,7 +1554,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
42057 #endif
42058 return;
42059 }
42060 - if ((tty->count == 1) && (port->count != 1)) {
42061 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
42062 /*
42063 * Uh, oh. tty->count is 1, which means that the tty
42064 * structure will be freed. Info->count should always
42065 @@ -1563,15 +1563,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
42066 * serial port won't be shutdown.
42067 */
42068 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
42069 - "info->count is %d\n", port->count);
42070 - port->count = 1;
42071 + "info->count is %d\n", atomic_read(&port->count));
42072 + atomic_set(&port->count, 1);
42073 }
42074 - if (--port->count < 0) {
42075 + if (atomic_dec_return(&port->count) < 0) {
42076 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
42077 - info->line, port->count);
42078 - port->count = 0;
42079 + info->line, atomic_read(&port->count));
42080 + atomic_set(&port->count, 0);
42081 }
42082 - if (port->count) {
42083 + if (atomic_read(&port->count)) {
42084 #ifdef ISDN_DEBUG_MODEM_OPEN
42085 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
42086 #endif
42087 @@ -1625,7 +1625,7 @@ isdn_tty_hangup(struct tty_struct *tty)
42088 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
42089 return;
42090 isdn_tty_shutdown(info);
42091 - port->count = 0;
42092 + atomic_set(&port->count, 0);
42093 port->flags &= ~ASYNC_NORMAL_ACTIVE;
42094 port->tty = NULL;
42095 wake_up_interruptible(&port->open_wait);
42096 @@ -1970,7 +1970,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
42097 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
42098 modem_info *info = &dev->mdm.info[i];
42099
42100 - if (info->port.count == 0)
42101 + if (atomic_read(&info->port.count) == 0)
42102 continue;
42103 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
42104 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
42105 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
42106 index e74df7c..03a03ba 100644
42107 --- a/drivers/isdn/icn/icn.c
42108 +++ b/drivers/isdn/icn/icn.c
42109 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
42110 if (count > len)
42111 count = len;
42112 if (user) {
42113 - if (copy_from_user(msg, buf, count))
42114 + if (count > sizeof msg || copy_from_user(msg, buf, count))
42115 return -EFAULT;
42116 } else
42117 memcpy(msg, buf, count);
42118 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
42119 index 6a8405d..0bd1c7e 100644
42120 --- a/drivers/leds/leds-clevo-mail.c
42121 +++ b/drivers/leds/leds-clevo-mail.c
42122 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
42123 * detected as working, but in reality it is not) as low as
42124 * possible.
42125 */
42126 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
42127 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
42128 {
42129 .callback = clevo_mail_led_dmi_callback,
42130 .ident = "Clevo D410J",
42131 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
42132 index 64e204e..c6bf189 100644
42133 --- a/drivers/leds/leds-ss4200.c
42134 +++ b/drivers/leds/leds-ss4200.c
42135 @@ -91,7 +91,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
42136 * detected as working, but in reality it is not) as low as
42137 * possible.
42138 */
42139 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
42140 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
42141 {
42142 .callback = ss4200_led_dmi_callback,
42143 .ident = "Intel SS4200-E",
42144 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
42145 index 0bf1e4e..b4bf44e 100644
42146 --- a/drivers/lguest/core.c
42147 +++ b/drivers/lguest/core.c
42148 @@ -97,9 +97,17 @@ static __init int map_switcher(void)
42149 * The end address needs +1 because __get_vm_area allocates an
42150 * extra guard page, so we need space for that.
42151 */
42152 +
42153 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
42154 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
42155 + VM_ALLOC | VM_KERNEXEC, switcher_addr, switcher_addr
42156 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
42157 +#else
42158 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
42159 VM_ALLOC, switcher_addr, switcher_addr
42160 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
42161 +#endif
42162 +
42163 if (!switcher_vma) {
42164 err = -ENOMEM;
42165 printk("lguest: could not map switcher pages high\n");
42166 @@ -124,7 +132,7 @@ static __init int map_switcher(void)
42167 * Now the Switcher is mapped at the right address, we can't fail!
42168 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
42169 */
42170 - memcpy(switcher_vma->addr, start_switcher_text,
42171 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
42172 end_switcher_text - start_switcher_text);
42173
42174 printk(KERN_INFO "lguest: mapped switcher at %p\n",
42175 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
42176 index 5b9ac32..2ef4f26 100644
42177 --- a/drivers/lguest/page_tables.c
42178 +++ b/drivers/lguest/page_tables.c
42179 @@ -559,7 +559,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
42180 /*:*/
42181
42182 #ifdef CONFIG_X86_PAE
42183 -static void release_pmd(pmd_t *spmd)
42184 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
42185 {
42186 /* If the entry's not present, there's nothing to release. */
42187 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
42188 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
42189 index f0a3347..f6608b2 100644
42190 --- a/drivers/lguest/x86/core.c
42191 +++ b/drivers/lguest/x86/core.c
42192 @@ -59,7 +59,7 @@ static struct {
42193 /* Offset from where switcher.S was compiled to where we've copied it */
42194 static unsigned long switcher_offset(void)
42195 {
42196 - return switcher_addr - (unsigned long)start_switcher_text;
42197 + return switcher_addr - (unsigned long)ktla_ktva(start_switcher_text);
42198 }
42199
42200 /* This cpu's struct lguest_pages (after the Switcher text page) */
42201 @@ -99,7 +99,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
42202 * These copies are pretty cheap, so we do them unconditionally: */
42203 /* Save the current Host top-level page directory.
42204 */
42205 +
42206 +#ifdef CONFIG_PAX_PER_CPU_PGD
42207 + pages->state.host_cr3 = read_cr3();
42208 +#else
42209 pages->state.host_cr3 = __pa(current->mm->pgd);
42210 +#endif
42211 +
42212 /*
42213 * Set up the Guest's page tables to see this CPU's pages (and no
42214 * other CPU's pages).
42215 @@ -475,7 +481,7 @@ void __init lguest_arch_host_init(void)
42216 * compiled-in switcher code and the high-mapped copy we just made.
42217 */
42218 for (i = 0; i < IDT_ENTRIES; i++)
42219 - default_idt_entries[i] += switcher_offset();
42220 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
42221
42222 /*
42223 * Set up the Switcher's per-cpu areas.
42224 @@ -558,7 +564,7 @@ void __init lguest_arch_host_init(void)
42225 * it will be undisturbed when we switch. To change %cs and jump we
42226 * need this structure to feed to Intel's "lcall" instruction.
42227 */
42228 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
42229 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
42230 lguest_entry.segment = LGUEST_CS;
42231
42232 /*
42233 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
42234 index 40634b0..4f5855e 100644
42235 --- a/drivers/lguest/x86/switcher_32.S
42236 +++ b/drivers/lguest/x86/switcher_32.S
42237 @@ -87,6 +87,7 @@
42238 #include <asm/page.h>
42239 #include <asm/segment.h>
42240 #include <asm/lguest.h>
42241 +#include <asm/processor-flags.h>
42242
42243 // We mark the start of the code to copy
42244 // It's placed in .text tho it's never run here
42245 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
42246 // Changes type when we load it: damn Intel!
42247 // For after we switch over our page tables
42248 // That entry will be read-only: we'd crash.
42249 +
42250 +#ifdef CONFIG_PAX_KERNEXEC
42251 + mov %cr0, %edx
42252 + xor $X86_CR0_WP, %edx
42253 + mov %edx, %cr0
42254 +#endif
42255 +
42256 movl $(GDT_ENTRY_TSS*8), %edx
42257 ltr %dx
42258
42259 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
42260 // Let's clear it again for our return.
42261 // The GDT descriptor of the Host
42262 // Points to the table after two "size" bytes
42263 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
42264 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
42265 // Clear "used" from type field (byte 5, bit 2)
42266 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
42267 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
42268 +
42269 +#ifdef CONFIG_PAX_KERNEXEC
42270 + mov %cr0, %eax
42271 + xor $X86_CR0_WP, %eax
42272 + mov %eax, %cr0
42273 +#endif
42274
42275 // Once our page table's switched, the Guest is live!
42276 // The Host fades as we run this final step.
42277 @@ -295,13 +309,12 @@ deliver_to_host:
42278 // I consulted gcc, and it gave
42279 // These instructions, which I gladly credit:
42280 leal (%edx,%ebx,8), %eax
42281 - movzwl (%eax),%edx
42282 - movl 4(%eax), %eax
42283 - xorw %ax, %ax
42284 - orl %eax, %edx
42285 + movl 4(%eax), %edx
42286 + movw (%eax), %dx
42287 // Now the address of the handler's in %edx
42288 // We call it now: its "iret" drops us home.
42289 - jmp *%edx
42290 + ljmp $__KERNEL_CS, $1f
42291 +1: jmp *%edx
42292
42293 // Every interrupt can come to us here
42294 // But we must truly tell each apart.
42295 diff --git a/drivers/md/bcache/closure.h b/drivers/md/bcache/closure.h
42296 index 0003992..854bbce 100644
42297 --- a/drivers/md/bcache/closure.h
42298 +++ b/drivers/md/bcache/closure.h
42299 @@ -622,7 +622,7 @@ static inline void closure_wake_up(struct closure_waitlist *list)
42300 static inline void set_closure_fn(struct closure *cl, closure_fn *fn,
42301 struct workqueue_struct *wq)
42302 {
42303 - BUG_ON(object_is_on_stack(cl));
42304 + BUG_ON(object_starts_on_stack(cl));
42305 closure_set_ip(cl);
42306 cl->fn = fn;
42307 cl->wq = wq;
42308 diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
42309 index b4713ce..b30139b 100644
42310 --- a/drivers/md/bcache/super.c
42311 +++ b/drivers/md/bcache/super.c
42312 @@ -1603,7 +1603,7 @@ err_unlock_gc:
42313 err:
42314 closure_sync(&op.cl);
42315 /* XXX: test this, it's broken */
42316 - bch_cache_set_error(c, err);
42317 + bch_cache_set_error(c, "%s", err);
42318 }
42319
42320 static bool can_attach_cache(struct cache *ca, struct cache_set *c)
42321 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
42322 index 5a2c754..0fa55db 100644
42323 --- a/drivers/md/bitmap.c
42324 +++ b/drivers/md/bitmap.c
42325 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
42326 chunk_kb ? "KB" : "B");
42327 if (bitmap->storage.file) {
42328 seq_printf(seq, ", file: ");
42329 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
42330 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
42331 }
42332
42333 seq_printf(seq, "\n");
42334 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
42335 index 81a79b7..87a0f73 100644
42336 --- a/drivers/md/dm-ioctl.c
42337 +++ b/drivers/md/dm-ioctl.c
42338 @@ -1697,7 +1697,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
42339 cmd == DM_LIST_VERSIONS_CMD)
42340 return 0;
42341
42342 - if ((cmd == DM_DEV_CREATE_CMD)) {
42343 + if (cmd == DM_DEV_CREATE_CMD) {
42344 if (!*param->name) {
42345 DMWARN("name not supplied when creating device");
42346 return -EINVAL;
42347 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
42348 index 699b5be..eac0a15 100644
42349 --- a/drivers/md/dm-raid1.c
42350 +++ b/drivers/md/dm-raid1.c
42351 @@ -40,7 +40,7 @@ enum dm_raid1_error {
42352
42353 struct mirror {
42354 struct mirror_set *ms;
42355 - atomic_t error_count;
42356 + atomic_unchecked_t error_count;
42357 unsigned long error_type;
42358 struct dm_dev *dev;
42359 sector_t offset;
42360 @@ -186,7 +186,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
42361 struct mirror *m;
42362
42363 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
42364 - if (!atomic_read(&m->error_count))
42365 + if (!atomic_read_unchecked(&m->error_count))
42366 return m;
42367
42368 return NULL;
42369 @@ -218,7 +218,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
42370 * simple way to tell if a device has encountered
42371 * errors.
42372 */
42373 - atomic_inc(&m->error_count);
42374 + atomic_inc_unchecked(&m->error_count);
42375
42376 if (test_and_set_bit(error_type, &m->error_type))
42377 return;
42378 @@ -409,7 +409,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
42379 struct mirror *m = get_default_mirror(ms);
42380
42381 do {
42382 - if (likely(!atomic_read(&m->error_count)))
42383 + if (likely(!atomic_read_unchecked(&m->error_count)))
42384 return m;
42385
42386 if (m-- == ms->mirror)
42387 @@ -423,7 +423,7 @@ static int default_ok(struct mirror *m)
42388 {
42389 struct mirror *default_mirror = get_default_mirror(m->ms);
42390
42391 - return !atomic_read(&default_mirror->error_count);
42392 + return !atomic_read_unchecked(&default_mirror->error_count);
42393 }
42394
42395 static int mirror_available(struct mirror_set *ms, struct bio *bio)
42396 @@ -560,7 +560,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
42397 */
42398 if (likely(region_in_sync(ms, region, 1)))
42399 m = choose_mirror(ms, bio->bi_sector);
42400 - else if (m && atomic_read(&m->error_count))
42401 + else if (m && atomic_read_unchecked(&m->error_count))
42402 m = NULL;
42403
42404 if (likely(m))
42405 @@ -927,7 +927,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
42406 }
42407
42408 ms->mirror[mirror].ms = ms;
42409 - atomic_set(&(ms->mirror[mirror].error_count), 0);
42410 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
42411 ms->mirror[mirror].error_type = 0;
42412 ms->mirror[mirror].offset = offset;
42413
42414 @@ -1340,7 +1340,7 @@ static void mirror_resume(struct dm_target *ti)
42415 */
42416 static char device_status_char(struct mirror *m)
42417 {
42418 - if (!atomic_read(&(m->error_count)))
42419 + if (!atomic_read_unchecked(&(m->error_count)))
42420 return 'A';
42421
42422 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
42423 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
42424 index d907ca6..cfb8384 100644
42425 --- a/drivers/md/dm-stripe.c
42426 +++ b/drivers/md/dm-stripe.c
42427 @@ -20,7 +20,7 @@ struct stripe {
42428 struct dm_dev *dev;
42429 sector_t physical_start;
42430
42431 - atomic_t error_count;
42432 + atomic_unchecked_t error_count;
42433 };
42434
42435 struct stripe_c {
42436 @@ -185,7 +185,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
42437 kfree(sc);
42438 return r;
42439 }
42440 - atomic_set(&(sc->stripe[i].error_count), 0);
42441 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
42442 }
42443
42444 ti->private = sc;
42445 @@ -326,7 +326,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
42446 DMEMIT("%d ", sc->stripes);
42447 for (i = 0; i < sc->stripes; i++) {
42448 DMEMIT("%s ", sc->stripe[i].dev->name);
42449 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
42450 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
42451 'D' : 'A';
42452 }
42453 buffer[i] = '\0';
42454 @@ -371,8 +371,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
42455 */
42456 for (i = 0; i < sc->stripes; i++)
42457 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
42458 - atomic_inc(&(sc->stripe[i].error_count));
42459 - if (atomic_read(&(sc->stripe[i].error_count)) <
42460 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
42461 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
42462 DM_IO_ERROR_THRESHOLD)
42463 schedule_work(&sc->trigger_event);
42464 }
42465 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
42466 index 1ff252a..ee384c1 100644
42467 --- a/drivers/md/dm-table.c
42468 +++ b/drivers/md/dm-table.c
42469 @@ -389,7 +389,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
42470 if (!dev_size)
42471 return 0;
42472
42473 - if ((start >= dev_size) || (start + len > dev_size)) {
42474 + if ((start >= dev_size) || (len > dev_size - start)) {
42475 DMWARN("%s: %s too small for target: "
42476 "start=%llu, len=%llu, dev_size=%llu",
42477 dm_device_name(ti->table->md), bdevname(bdev, b),
42478 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
42479 index 60bce43..9b997d0 100644
42480 --- a/drivers/md/dm-thin-metadata.c
42481 +++ b/drivers/md/dm-thin-metadata.c
42482 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
42483 {
42484 pmd->info.tm = pmd->tm;
42485 pmd->info.levels = 2;
42486 - pmd->info.value_type.context = pmd->data_sm;
42487 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
42488 pmd->info.value_type.size = sizeof(__le64);
42489 pmd->info.value_type.inc = data_block_inc;
42490 pmd->info.value_type.dec = data_block_dec;
42491 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
42492
42493 pmd->bl_info.tm = pmd->tm;
42494 pmd->bl_info.levels = 1;
42495 - pmd->bl_info.value_type.context = pmd->data_sm;
42496 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
42497 pmd->bl_info.value_type.size = sizeof(__le64);
42498 pmd->bl_info.value_type.inc = data_block_inc;
42499 pmd->bl_info.value_type.dec = data_block_dec;
42500 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
42501 index 33f2010..23fb84c 100644
42502 --- a/drivers/md/dm.c
42503 +++ b/drivers/md/dm.c
42504 @@ -169,9 +169,9 @@ struct mapped_device {
42505 /*
42506 * Event handling.
42507 */
42508 - atomic_t event_nr;
42509 + atomic_unchecked_t event_nr;
42510 wait_queue_head_t eventq;
42511 - atomic_t uevent_seq;
42512 + atomic_unchecked_t uevent_seq;
42513 struct list_head uevent_list;
42514 spinlock_t uevent_lock; /* Protect access to uevent_list */
42515
42516 @@ -1884,8 +1884,8 @@ static struct mapped_device *alloc_dev(int minor)
42517 rwlock_init(&md->map_lock);
42518 atomic_set(&md->holders, 1);
42519 atomic_set(&md->open_count, 0);
42520 - atomic_set(&md->event_nr, 0);
42521 - atomic_set(&md->uevent_seq, 0);
42522 + atomic_set_unchecked(&md->event_nr, 0);
42523 + atomic_set_unchecked(&md->uevent_seq, 0);
42524 INIT_LIST_HEAD(&md->uevent_list);
42525 spin_lock_init(&md->uevent_lock);
42526
42527 @@ -2033,7 +2033,7 @@ static void event_callback(void *context)
42528
42529 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
42530
42531 - atomic_inc(&md->event_nr);
42532 + atomic_inc_unchecked(&md->event_nr);
42533 wake_up(&md->eventq);
42534 }
42535
42536 @@ -2690,18 +2690,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
42537
42538 uint32_t dm_next_uevent_seq(struct mapped_device *md)
42539 {
42540 - return atomic_add_return(1, &md->uevent_seq);
42541 + return atomic_add_return_unchecked(1, &md->uevent_seq);
42542 }
42543
42544 uint32_t dm_get_event_nr(struct mapped_device *md)
42545 {
42546 - return atomic_read(&md->event_nr);
42547 + return atomic_read_unchecked(&md->event_nr);
42548 }
42549
42550 int dm_wait_event(struct mapped_device *md, int event_nr)
42551 {
42552 return wait_event_interruptible(md->eventq,
42553 - (event_nr != atomic_read(&md->event_nr)));
42554 + (event_nr != atomic_read_unchecked(&md->event_nr)));
42555 }
42556
42557 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
42558 diff --git a/drivers/md/md.c b/drivers/md/md.c
42559 index 51f0345..c77810e 100644
42560 --- a/drivers/md/md.c
42561 +++ b/drivers/md/md.c
42562 @@ -234,10 +234,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
42563 * start build, activate spare
42564 */
42565 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
42566 -static atomic_t md_event_count;
42567 +static atomic_unchecked_t md_event_count;
42568 void md_new_event(struct mddev *mddev)
42569 {
42570 - atomic_inc(&md_event_count);
42571 + atomic_inc_unchecked(&md_event_count);
42572 wake_up(&md_event_waiters);
42573 }
42574 EXPORT_SYMBOL_GPL(md_new_event);
42575 @@ -247,7 +247,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
42576 */
42577 static void md_new_event_inintr(struct mddev *mddev)
42578 {
42579 - atomic_inc(&md_event_count);
42580 + atomic_inc_unchecked(&md_event_count);
42581 wake_up(&md_event_waiters);
42582 }
42583
42584 @@ -1501,7 +1501,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
42585 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
42586 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
42587 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
42588 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
42589 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
42590
42591 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
42592 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
42593 @@ -1745,7 +1745,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
42594 else
42595 sb->resync_offset = cpu_to_le64(0);
42596
42597 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
42598 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
42599
42600 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
42601 sb->size = cpu_to_le64(mddev->dev_sectors);
42602 @@ -2750,7 +2750,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
42603 static ssize_t
42604 errors_show(struct md_rdev *rdev, char *page)
42605 {
42606 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
42607 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
42608 }
42609
42610 static ssize_t
42611 @@ -2759,7 +2759,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
42612 char *e;
42613 unsigned long n = simple_strtoul(buf, &e, 10);
42614 if (*buf && (*e == 0 || *e == '\n')) {
42615 - atomic_set(&rdev->corrected_errors, n);
42616 + atomic_set_unchecked(&rdev->corrected_errors, n);
42617 return len;
42618 }
42619 return -EINVAL;
42620 @@ -3207,8 +3207,8 @@ int md_rdev_init(struct md_rdev *rdev)
42621 rdev->sb_loaded = 0;
42622 rdev->bb_page = NULL;
42623 atomic_set(&rdev->nr_pending, 0);
42624 - atomic_set(&rdev->read_errors, 0);
42625 - atomic_set(&rdev->corrected_errors, 0);
42626 + atomic_set_unchecked(&rdev->read_errors, 0);
42627 + atomic_set_unchecked(&rdev->corrected_errors, 0);
42628
42629 INIT_LIST_HEAD(&rdev->same_set);
42630 init_waitqueue_head(&rdev->blocked_wait);
42631 @@ -7009,7 +7009,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
42632
42633 spin_unlock(&pers_lock);
42634 seq_printf(seq, "\n");
42635 - seq->poll_event = atomic_read(&md_event_count);
42636 + seq->poll_event = atomic_read_unchecked(&md_event_count);
42637 return 0;
42638 }
42639 if (v == (void*)2) {
42640 @@ -7112,7 +7112,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
42641 return error;
42642
42643 seq = file->private_data;
42644 - seq->poll_event = atomic_read(&md_event_count);
42645 + seq->poll_event = atomic_read_unchecked(&md_event_count);
42646 return error;
42647 }
42648
42649 @@ -7126,7 +7126,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
42650 /* always allow read */
42651 mask = POLLIN | POLLRDNORM;
42652
42653 - if (seq->poll_event != atomic_read(&md_event_count))
42654 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
42655 mask |= POLLERR | POLLPRI;
42656 return mask;
42657 }
42658 @@ -7170,7 +7170,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
42659 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
42660 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
42661 (int)part_stat_read(&disk->part0, sectors[1]) -
42662 - atomic_read(&disk->sync_io);
42663 + atomic_read_unchecked(&disk->sync_io);
42664 /* sync IO will cause sync_io to increase before the disk_stats
42665 * as sync_io is counted when a request starts, and
42666 * disk_stats is counted when it completes.
42667 diff --git a/drivers/md/md.h b/drivers/md/md.h
42668 index 653f992b6..6af6c40 100644
42669 --- a/drivers/md/md.h
42670 +++ b/drivers/md/md.h
42671 @@ -94,13 +94,13 @@ struct md_rdev {
42672 * only maintained for arrays that
42673 * support hot removal
42674 */
42675 - atomic_t read_errors; /* number of consecutive read errors that
42676 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
42677 * we have tried to ignore.
42678 */
42679 struct timespec last_read_error; /* monotonic time since our
42680 * last read error
42681 */
42682 - atomic_t corrected_errors; /* number of corrected read errors,
42683 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
42684 * for reporting to userspace and storing
42685 * in superblock.
42686 */
42687 @@ -434,7 +434,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
42688
42689 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
42690 {
42691 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
42692 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
42693 }
42694
42695 struct md_personality
42696 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
42697 index 3e6d115..ffecdeb 100644
42698 --- a/drivers/md/persistent-data/dm-space-map.h
42699 +++ b/drivers/md/persistent-data/dm-space-map.h
42700 @@ -71,6 +71,7 @@ struct dm_space_map {
42701 dm_sm_threshold_fn fn,
42702 void *context);
42703 };
42704 +typedef struct dm_space_map __no_const dm_space_map_no_const;
42705
42706 /*----------------------------------------------------------------*/
42707
42708 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
42709 index 6f48244..7d29145 100644
42710 --- a/drivers/md/raid1.c
42711 +++ b/drivers/md/raid1.c
42712 @@ -1822,7 +1822,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
42713 if (r1_sync_page_io(rdev, sect, s,
42714 bio->bi_io_vec[idx].bv_page,
42715 READ) != 0)
42716 - atomic_add(s, &rdev->corrected_errors);
42717 + atomic_add_unchecked(s, &rdev->corrected_errors);
42718 }
42719 sectors -= s;
42720 sect += s;
42721 @@ -2049,7 +2049,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
42722 test_bit(In_sync, &rdev->flags)) {
42723 if (r1_sync_page_io(rdev, sect, s,
42724 conf->tmppage, READ)) {
42725 - atomic_add(s, &rdev->corrected_errors);
42726 + atomic_add_unchecked(s, &rdev->corrected_errors);
42727 printk(KERN_INFO
42728 "md/raid1:%s: read error corrected "
42729 "(%d sectors at %llu on %s)\n",
42730 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
42731 index 081bb33..3c4b287 100644
42732 --- a/drivers/md/raid10.c
42733 +++ b/drivers/md/raid10.c
42734 @@ -1940,7 +1940,7 @@ static void end_sync_read(struct bio *bio, int error)
42735 /* The write handler will notice the lack of
42736 * R10BIO_Uptodate and record any errors etc
42737 */
42738 - atomic_add(r10_bio->sectors,
42739 + atomic_add_unchecked(r10_bio->sectors,
42740 &conf->mirrors[d].rdev->corrected_errors);
42741
42742 /* for reconstruct, we always reschedule after a read.
42743 @@ -2298,7 +2298,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42744 {
42745 struct timespec cur_time_mon;
42746 unsigned long hours_since_last;
42747 - unsigned int read_errors = atomic_read(&rdev->read_errors);
42748 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
42749
42750 ktime_get_ts(&cur_time_mon);
42751
42752 @@ -2320,9 +2320,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42753 * overflowing the shift of read_errors by hours_since_last.
42754 */
42755 if (hours_since_last >= 8 * sizeof(read_errors))
42756 - atomic_set(&rdev->read_errors, 0);
42757 + atomic_set_unchecked(&rdev->read_errors, 0);
42758 else
42759 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
42760 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
42761 }
42762
42763 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
42764 @@ -2376,8 +2376,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42765 return;
42766
42767 check_decay_read_errors(mddev, rdev);
42768 - atomic_inc(&rdev->read_errors);
42769 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
42770 + atomic_inc_unchecked(&rdev->read_errors);
42771 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
42772 char b[BDEVNAME_SIZE];
42773 bdevname(rdev->bdev, b);
42774
42775 @@ -2385,7 +2385,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42776 "md/raid10:%s: %s: Raid device exceeded "
42777 "read_error threshold [cur %d:max %d]\n",
42778 mdname(mddev), b,
42779 - atomic_read(&rdev->read_errors), max_read_errors);
42780 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
42781 printk(KERN_NOTICE
42782 "md/raid10:%s: %s: Failing raid device\n",
42783 mdname(mddev), b);
42784 @@ -2540,7 +2540,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42785 sect +
42786 choose_data_offset(r10_bio, rdev)),
42787 bdevname(rdev->bdev, b));
42788 - atomic_add(s, &rdev->corrected_errors);
42789 + atomic_add_unchecked(s, &rdev->corrected_errors);
42790 }
42791
42792 rdev_dec_pending(rdev, mddev);
42793 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
42794 index a35b846..e295c6d 100644
42795 --- a/drivers/md/raid5.c
42796 +++ b/drivers/md/raid5.c
42797 @@ -1764,21 +1764,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
42798 mdname(conf->mddev), STRIPE_SECTORS,
42799 (unsigned long long)s,
42800 bdevname(rdev->bdev, b));
42801 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
42802 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
42803 clear_bit(R5_ReadError, &sh->dev[i].flags);
42804 clear_bit(R5_ReWrite, &sh->dev[i].flags);
42805 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
42806 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
42807
42808 - if (atomic_read(&rdev->read_errors))
42809 - atomic_set(&rdev->read_errors, 0);
42810 + if (atomic_read_unchecked(&rdev->read_errors))
42811 + atomic_set_unchecked(&rdev->read_errors, 0);
42812 } else {
42813 const char *bdn = bdevname(rdev->bdev, b);
42814 int retry = 0;
42815 int set_bad = 0;
42816
42817 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
42818 - atomic_inc(&rdev->read_errors);
42819 + atomic_inc_unchecked(&rdev->read_errors);
42820 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
42821 printk_ratelimited(
42822 KERN_WARNING
42823 @@ -1806,7 +1806,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
42824 mdname(conf->mddev),
42825 (unsigned long long)s,
42826 bdn);
42827 - } else if (atomic_read(&rdev->read_errors)
42828 + } else if (atomic_read_unchecked(&rdev->read_errors)
42829 > conf->max_nr_stripes)
42830 printk(KERN_WARNING
42831 "md/raid:%s: Too many read errors, failing device %s.\n",
42832 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
42833 index 401ef64..836e563 100644
42834 --- a/drivers/media/dvb-core/dvbdev.c
42835 +++ b/drivers/media/dvb-core/dvbdev.c
42836 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
42837 const struct dvb_device *template, void *priv, int type)
42838 {
42839 struct dvb_device *dvbdev;
42840 - struct file_operations *dvbdevfops;
42841 + file_operations_no_const *dvbdevfops;
42842 struct device *clsdev;
42843 int minor;
42844 int id;
42845 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
42846 index 9b6c3bb..baeb5c7 100644
42847 --- a/drivers/media/dvb-frontends/dib3000.h
42848 +++ b/drivers/media/dvb-frontends/dib3000.h
42849 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
42850 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
42851 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
42852 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
42853 -};
42854 +} __no_const;
42855
42856 #if IS_ENABLED(CONFIG_DVB_DIB3000MB)
42857 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
42858 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
42859 index c7a9be1..683f6f8 100644
42860 --- a/drivers/media/pci/cx88/cx88-video.c
42861 +++ b/drivers/media/pci/cx88/cx88-video.c
42862 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
42863
42864 /* ------------------------------------------------------------------ */
42865
42866 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42867 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42868 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42869 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42870 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42871 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42872
42873 module_param_array(video_nr, int, NULL, 0444);
42874 module_param_array(vbi_nr, int, NULL, 0444);
42875 diff --git a/drivers/media/pci/ivtv/ivtv-driver.c b/drivers/media/pci/ivtv/ivtv-driver.c
42876 index 07b8460..e6d7265 100644
42877 --- a/drivers/media/pci/ivtv/ivtv-driver.c
42878 +++ b/drivers/media/pci/ivtv/ivtv-driver.c
42879 @@ -84,7 +84,7 @@ static struct pci_device_id ivtv_pci_tbl[] = {
42880 MODULE_DEVICE_TABLE(pci,ivtv_pci_tbl);
42881
42882 /* ivtv instance counter */
42883 -static atomic_t ivtv_instance = ATOMIC_INIT(0);
42884 +static atomic_unchecked_t ivtv_instance = ATOMIC_INIT(0);
42885
42886 /* Parameter declarations */
42887 static int cardtype[IVTV_MAX_CARDS];
42888 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
42889 index d338b19..aae4f9e 100644
42890 --- a/drivers/media/platform/omap/omap_vout.c
42891 +++ b/drivers/media/platform/omap/omap_vout.c
42892 @@ -63,7 +63,6 @@ enum omap_vout_channels {
42893 OMAP_VIDEO2,
42894 };
42895
42896 -static struct videobuf_queue_ops video_vbq_ops;
42897 /* Variables configurable through module params*/
42898 static u32 video1_numbuffers = 3;
42899 static u32 video2_numbuffers = 3;
42900 @@ -1015,6 +1014,12 @@ static int omap_vout_open(struct file *file)
42901 {
42902 struct videobuf_queue *q;
42903 struct omap_vout_device *vout = NULL;
42904 + static struct videobuf_queue_ops video_vbq_ops = {
42905 + .buf_setup = omap_vout_buffer_setup,
42906 + .buf_prepare = omap_vout_buffer_prepare,
42907 + .buf_release = omap_vout_buffer_release,
42908 + .buf_queue = omap_vout_buffer_queue,
42909 + };
42910
42911 vout = video_drvdata(file);
42912 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
42913 @@ -1032,10 +1037,6 @@ static int omap_vout_open(struct file *file)
42914 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
42915
42916 q = &vout->vbq;
42917 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
42918 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
42919 - video_vbq_ops.buf_release = omap_vout_buffer_release;
42920 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
42921 spin_lock_init(&vout->vbq_lock);
42922
42923 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
42924 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
42925 index 04e6490..2df65bf 100644
42926 --- a/drivers/media/platform/s5p-tv/mixer.h
42927 +++ b/drivers/media/platform/s5p-tv/mixer.h
42928 @@ -156,7 +156,7 @@ struct mxr_layer {
42929 /** layer index (unique identifier) */
42930 int idx;
42931 /** callbacks for layer methods */
42932 - struct mxr_layer_ops ops;
42933 + struct mxr_layer_ops *ops;
42934 /** format array */
42935 const struct mxr_format **fmt_array;
42936 /** size of format array */
42937 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42938 index b93a21f..2535195 100644
42939 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42940 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42941 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
42942 {
42943 struct mxr_layer *layer;
42944 int ret;
42945 - struct mxr_layer_ops ops = {
42946 + static struct mxr_layer_ops ops = {
42947 .release = mxr_graph_layer_release,
42948 .buffer_set = mxr_graph_buffer_set,
42949 .stream_set = mxr_graph_stream_set,
42950 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
42951 index b713403..53cb5ad 100644
42952 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
42953 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
42954 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
42955 layer->update_buf = next;
42956 }
42957
42958 - layer->ops.buffer_set(layer, layer->update_buf);
42959 + layer->ops->buffer_set(layer, layer->update_buf);
42960
42961 if (done && done != layer->shadow_buf)
42962 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
42963 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
42964 index ef0efdf..8c78eb6 100644
42965 --- a/drivers/media/platform/s5p-tv/mixer_video.c
42966 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
42967 @@ -209,7 +209,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
42968 layer->geo.src.height = layer->geo.src.full_height;
42969
42970 mxr_geometry_dump(mdev, &layer->geo);
42971 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42972 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42973 mxr_geometry_dump(mdev, &layer->geo);
42974 }
42975
42976 @@ -227,7 +227,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
42977 layer->geo.dst.full_width = mbus_fmt.width;
42978 layer->geo.dst.full_height = mbus_fmt.height;
42979 layer->geo.dst.field = mbus_fmt.field;
42980 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42981 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42982
42983 mxr_geometry_dump(mdev, &layer->geo);
42984 }
42985 @@ -333,7 +333,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
42986 /* set source size to highest accepted value */
42987 geo->src.full_width = max(geo->dst.full_width, pix->width);
42988 geo->src.full_height = max(geo->dst.full_height, pix->height);
42989 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42990 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42991 mxr_geometry_dump(mdev, &layer->geo);
42992 /* set cropping to total visible screen */
42993 geo->src.width = pix->width;
42994 @@ -341,12 +341,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
42995 geo->src.x_offset = 0;
42996 geo->src.y_offset = 0;
42997 /* assure consistency of geometry */
42998 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
42999 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
43000 mxr_geometry_dump(mdev, &layer->geo);
43001 /* set full size to lowest possible value */
43002 geo->src.full_width = 0;
43003 geo->src.full_height = 0;
43004 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
43005 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
43006 mxr_geometry_dump(mdev, &layer->geo);
43007
43008 /* returning results */
43009 @@ -473,7 +473,7 @@ static int mxr_s_selection(struct file *file, void *fh,
43010 target->width = s->r.width;
43011 target->height = s->r.height;
43012
43013 - layer->ops.fix_geometry(layer, stage, s->flags);
43014 + layer->ops->fix_geometry(layer, stage, s->flags);
43015
43016 /* retrieve update selection rectangle */
43017 res.left = target->x_offset;
43018 @@ -954,13 +954,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
43019 mxr_output_get(mdev);
43020
43021 mxr_layer_update_output(layer);
43022 - layer->ops.format_set(layer);
43023 + layer->ops->format_set(layer);
43024 /* enabling layer in hardware */
43025 spin_lock_irqsave(&layer->enq_slock, flags);
43026 layer->state = MXR_LAYER_STREAMING;
43027 spin_unlock_irqrestore(&layer->enq_slock, flags);
43028
43029 - layer->ops.stream_set(layer, MXR_ENABLE);
43030 + layer->ops->stream_set(layer, MXR_ENABLE);
43031 mxr_streamer_get(mdev);
43032
43033 return 0;
43034 @@ -1030,7 +1030,7 @@ static int stop_streaming(struct vb2_queue *vq)
43035 spin_unlock_irqrestore(&layer->enq_slock, flags);
43036
43037 /* disabling layer in hardware */
43038 - layer->ops.stream_set(layer, MXR_DISABLE);
43039 + layer->ops->stream_set(layer, MXR_DISABLE);
43040 /* remove one streamer */
43041 mxr_streamer_put(mdev);
43042 /* allow changes in output configuration */
43043 @@ -1069,8 +1069,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
43044
43045 void mxr_layer_release(struct mxr_layer *layer)
43046 {
43047 - if (layer->ops.release)
43048 - layer->ops.release(layer);
43049 + if (layer->ops->release)
43050 + layer->ops->release(layer);
43051 }
43052
43053 void mxr_base_layer_release(struct mxr_layer *layer)
43054 @@ -1096,7 +1096,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
43055
43056 layer->mdev = mdev;
43057 layer->idx = idx;
43058 - layer->ops = *ops;
43059 + layer->ops = ops;
43060
43061 spin_lock_init(&layer->enq_slock);
43062 INIT_LIST_HEAD(&layer->enq_list);
43063 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
43064 index 3d13a63..da31bf1 100644
43065 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
43066 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
43067 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
43068 {
43069 struct mxr_layer *layer;
43070 int ret;
43071 - struct mxr_layer_ops ops = {
43072 + static struct mxr_layer_ops ops = {
43073 .release = mxr_vp_layer_release,
43074 .buffer_set = mxr_vp_buffer_set,
43075 .stream_set = mxr_vp_stream_set,
43076 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
43077 index 545c04c..a14bded 100644
43078 --- a/drivers/media/radio/radio-cadet.c
43079 +++ b/drivers/media/radio/radio-cadet.c
43080 @@ -324,6 +324,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
43081 unsigned char readbuf[RDS_BUFFER];
43082 int i = 0;
43083
43084 + if (count > RDS_BUFFER)
43085 + return -EFAULT;
43086 mutex_lock(&dev->lock);
43087 if (dev->rdsstat == 0)
43088 cadet_start_rds(dev);
43089 @@ -339,7 +341,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
43090 while (i < count && dev->rdsin != dev->rdsout)
43091 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
43092
43093 - if (i && copy_to_user(data, readbuf, i))
43094 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
43095 i = -EFAULT;
43096 unlock:
43097 mutex_unlock(&dev->lock);
43098 diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
43099 index bd4d3a7..ffc0b9d 100644
43100 --- a/drivers/media/radio/radio-maxiradio.c
43101 +++ b/drivers/media/radio/radio-maxiradio.c
43102 @@ -61,7 +61,7 @@ MODULE_PARM_DESC(radio_nr, "Radio device number");
43103 /* TEA5757 pin mappings */
43104 static const int clk = 1, data = 2, wren = 4, mo_st = 8, power = 16;
43105
43106 -static atomic_t maxiradio_instance = ATOMIC_INIT(0);
43107 +static atomic_unchecked_t maxiradio_instance = ATOMIC_INIT(0);
43108
43109 #define PCI_VENDOR_ID_GUILLEMOT 0x5046
43110 #define PCI_DEVICE_ID_GUILLEMOT_MAXIRADIO 0x1001
43111 diff --git a/drivers/media/radio/radio-shark.c b/drivers/media/radio/radio-shark.c
43112 index 8fa18ab..caee70f 100644
43113 --- a/drivers/media/radio/radio-shark.c
43114 +++ b/drivers/media/radio/radio-shark.c
43115 @@ -79,7 +79,7 @@ struct shark_device {
43116 u32 last_val;
43117 };
43118
43119 -static atomic_t shark_instance = ATOMIC_INIT(0);
43120 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
43121
43122 static void shark_write_val(struct snd_tea575x *tea, u32 val)
43123 {
43124 diff --git a/drivers/media/radio/radio-shark2.c b/drivers/media/radio/radio-shark2.c
43125 index 9fb6697..f167415 100644
43126 --- a/drivers/media/radio/radio-shark2.c
43127 +++ b/drivers/media/radio/radio-shark2.c
43128 @@ -74,7 +74,7 @@ struct shark_device {
43129 u8 *transfer_buffer;
43130 };
43131
43132 -static atomic_t shark_instance = ATOMIC_INIT(0);
43133 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
43134
43135 static int shark_write_reg(struct radio_tea5777 *tea, u64 reg)
43136 {
43137 diff --git a/drivers/media/radio/radio-si476x.c b/drivers/media/radio/radio-si476x.c
43138 index 9dc8baf..796d52f 100644
43139 --- a/drivers/media/radio/radio-si476x.c
43140 +++ b/drivers/media/radio/radio-si476x.c
43141 @@ -1456,7 +1456,7 @@ static int si476x_radio_probe(struct platform_device *pdev)
43142 struct si476x_radio *radio;
43143 struct v4l2_ctrl *ctrl;
43144
43145 - static atomic_t instance = ATOMIC_INIT(0);
43146 + static atomic_unchecked_t instance = ATOMIC_INIT(0);
43147
43148 radio = devm_kzalloc(&pdev->dev, sizeof(*radio), GFP_KERNEL);
43149 if (!radio)
43150 diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
43151 index 1cf382a..c22998c 100644
43152 --- a/drivers/media/rc/rc-main.c
43153 +++ b/drivers/media/rc/rc-main.c
43154 @@ -1030,7 +1030,7 @@ EXPORT_SYMBOL_GPL(rc_free_device);
43155 int rc_register_device(struct rc_dev *dev)
43156 {
43157 static bool raw_init = false; /* raw decoders loaded? */
43158 - static atomic_t devno = ATOMIC_INIT(0);
43159 + static atomic_unchecked_t devno = ATOMIC_INIT(0);
43160 struct rc_map *rc_map;
43161 const char *path;
43162 int rc;
43163 @@ -1061,7 +1061,7 @@ int rc_register_device(struct rc_dev *dev)
43164 */
43165 mutex_lock(&dev->lock);
43166
43167 - dev->devno = (unsigned long)(atomic_inc_return(&devno) - 1);
43168 + dev->devno = (unsigned long)(atomic_inc_return_unchecked(&devno) - 1);
43169 dev_set_name(&dev->dev, "rc%ld", dev->devno);
43170 dev_set_drvdata(&dev->dev, dev);
43171 rc = device_add(&dev->dev);
43172 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
43173 index 3940bb0..fb3952a 100644
43174 --- a/drivers/media/usb/dvb-usb/cxusb.c
43175 +++ b/drivers/media/usb/dvb-usb/cxusb.c
43176 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
43177
43178 struct dib0700_adapter_state {
43179 int (*set_param_save) (struct dvb_frontend *);
43180 -};
43181 +} __no_const;
43182
43183 static int dib7070_set_param_override(struct dvb_frontend *fe)
43184 {
43185 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
43186 index 6e237b6..dc25556 100644
43187 --- a/drivers/media/usb/dvb-usb/dw2102.c
43188 +++ b/drivers/media/usb/dvb-usb/dw2102.c
43189 @@ -118,7 +118,7 @@ struct su3000_state {
43190
43191 struct s6x0_state {
43192 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
43193 -};
43194 +} __no_const;
43195
43196 /* debug */
43197 static int dvb_usb_dw2102_debug;
43198 diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
43199 index f129551..ecf6514 100644
43200 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
43201 +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
43202 @@ -326,7 +326,7 @@ struct v4l2_buffer32 {
43203 __u32 reserved;
43204 };
43205
43206 -static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
43207 +static int get_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
43208 enum v4l2_memory memory)
43209 {
43210 void __user *up_pln;
43211 @@ -355,7 +355,7 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
43212 return 0;
43213 }
43214
43215 -static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
43216 +static int put_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
43217 enum v4l2_memory memory)
43218 {
43219 if (copy_in_user(up32, up, 2 * sizeof(__u32)) ||
43220 @@ -772,7 +772,7 @@ static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subde
43221 put_user(kp->start_block, &up->start_block) ||
43222 put_user(kp->blocks, &up->blocks) ||
43223 put_user(tmp, &up->edid) ||
43224 - copy_to_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
43225 + copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved)))
43226 return -EFAULT;
43227 return 0;
43228 }
43229 diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
43230 index 8ed5da2..47fee46 100644
43231 --- a/drivers/media/v4l2-core/v4l2-device.c
43232 +++ b/drivers/media/v4l2-core/v4l2-device.c
43233 @@ -74,9 +74,9 @@ int v4l2_device_put(struct v4l2_device *v4l2_dev)
43234 EXPORT_SYMBOL_GPL(v4l2_device_put);
43235
43236 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
43237 - atomic_t *instance)
43238 + atomic_unchecked_t *instance)
43239 {
43240 - int num = atomic_inc_return(instance) - 1;
43241 + int num = atomic_inc_return_unchecked(instance) - 1;
43242 int len = strlen(basename);
43243
43244 if (basename[len - 1] >= '0' && basename[len - 1] <= '9')
43245 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
43246 index 7658586..1079260 100644
43247 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
43248 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
43249 @@ -1995,7 +1995,8 @@ struct v4l2_ioctl_info {
43250 struct file *file, void *fh, void *p);
43251 } u;
43252 void (*debug)(const void *arg, bool write_only);
43253 -};
43254 +} __do_const;
43255 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
43256
43257 /* This control needs a priority check */
43258 #define INFO_FL_PRIO (1 << 0)
43259 @@ -2177,7 +2178,7 @@ static long __video_do_ioctl(struct file *file,
43260 struct video_device *vfd = video_devdata(file);
43261 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
43262 bool write_only = false;
43263 - struct v4l2_ioctl_info default_info;
43264 + v4l2_ioctl_info_no_const default_info;
43265 const struct v4l2_ioctl_info *info;
43266 void *fh = file->private_data;
43267 struct v4l2_fh *vfh = NULL;
43268 @@ -2251,7 +2252,7 @@ done:
43269 }
43270
43271 static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
43272 - void * __user *user_ptr, void ***kernel_ptr)
43273 + void __user **user_ptr, void ***kernel_ptr)
43274 {
43275 int ret = 0;
43276
43277 @@ -2267,7 +2268,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
43278 ret = -EINVAL;
43279 break;
43280 }
43281 - *user_ptr = (void __user *)buf->m.planes;
43282 + *user_ptr = (void __force_user *)buf->m.planes;
43283 *kernel_ptr = (void *)&buf->m.planes;
43284 *array_size = sizeof(struct v4l2_plane) * buf->length;
43285 ret = 1;
43286 @@ -2302,7 +2303,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
43287 ret = -EINVAL;
43288 break;
43289 }
43290 - *user_ptr = (void __user *)ctrls->controls;
43291 + *user_ptr = (void __force_user *)ctrls->controls;
43292 *kernel_ptr = (void *)&ctrls->controls;
43293 *array_size = sizeof(struct v4l2_ext_control)
43294 * ctrls->count;
43295 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
43296 index 767ff4d..c69d259 100644
43297 --- a/drivers/message/fusion/mptbase.c
43298 +++ b/drivers/message/fusion/mptbase.c
43299 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
43300 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
43301 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
43302
43303 +#ifdef CONFIG_GRKERNSEC_HIDESYM
43304 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
43305 +#else
43306 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
43307 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
43308 +#endif
43309 +
43310 /*
43311 * Rounding UP to nearest 4-kB boundary here...
43312 */
43313 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
43314 ioc->facts.GlobalCredits);
43315
43316 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
43317 +#ifdef CONFIG_GRKERNSEC_HIDESYM
43318 + NULL, NULL);
43319 +#else
43320 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
43321 +#endif
43322 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
43323 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
43324 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
43325 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
43326 index dd239bd..689c4f7 100644
43327 --- a/drivers/message/fusion/mptsas.c
43328 +++ b/drivers/message/fusion/mptsas.c
43329 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
43330 return 0;
43331 }
43332
43333 +static inline void
43334 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
43335 +{
43336 + if (phy_info->port_details) {
43337 + phy_info->port_details->rphy = rphy;
43338 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
43339 + ioc->name, rphy));
43340 + }
43341 +
43342 + if (rphy) {
43343 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
43344 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
43345 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
43346 + ioc->name, rphy, rphy->dev.release));
43347 + }
43348 +}
43349 +
43350 /* no mutex */
43351 static void
43352 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
43353 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
43354 return NULL;
43355 }
43356
43357 -static inline void
43358 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
43359 -{
43360 - if (phy_info->port_details) {
43361 - phy_info->port_details->rphy = rphy;
43362 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
43363 - ioc->name, rphy));
43364 - }
43365 -
43366 - if (rphy) {
43367 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
43368 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
43369 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
43370 - ioc->name, rphy, rphy->dev.release));
43371 - }
43372 -}
43373 -
43374 static inline struct sas_port *
43375 mptsas_get_port(struct mptsas_phyinfo *phy_info)
43376 {
43377 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
43378 index 727819c..ad74694 100644
43379 --- a/drivers/message/fusion/mptscsih.c
43380 +++ b/drivers/message/fusion/mptscsih.c
43381 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
43382
43383 h = shost_priv(SChost);
43384
43385 - if (h) {
43386 - if (h->info_kbuf == NULL)
43387 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
43388 - return h->info_kbuf;
43389 - h->info_kbuf[0] = '\0';
43390 + if (!h)
43391 + return NULL;
43392
43393 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
43394 - h->info_kbuf[size-1] = '\0';
43395 - }
43396 + if (h->info_kbuf == NULL)
43397 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
43398 + return h->info_kbuf;
43399 + h->info_kbuf[0] = '\0';
43400 +
43401 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
43402 + h->info_kbuf[size-1] = '\0';
43403
43404 return h->info_kbuf;
43405 }
43406 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
43407 index b7d87cd..9890039 100644
43408 --- a/drivers/message/i2o/i2o_proc.c
43409 +++ b/drivers/message/i2o/i2o_proc.c
43410 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
43411 "Array Controller Device"
43412 };
43413
43414 -static char *chtostr(char *tmp, u8 *chars, int n)
43415 -{
43416 - tmp[0] = 0;
43417 - return strncat(tmp, (char *)chars, n);
43418 -}
43419 -
43420 static int i2o_report_query_status(struct seq_file *seq, int block_status,
43421 char *group)
43422 {
43423 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
43424 } *result;
43425
43426 i2o_exec_execute_ddm_table ddm_table;
43427 - char tmp[28 + 1];
43428
43429 result = kmalloc(sizeof(*result), GFP_KERNEL);
43430 if (!result)
43431 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
43432
43433 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
43434 seq_printf(seq, "%-#8x", ddm_table.module_id);
43435 - seq_printf(seq, "%-29s",
43436 - chtostr(tmp, ddm_table.module_name_version, 28));
43437 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
43438 seq_printf(seq, "%9d ", ddm_table.data_size);
43439 seq_printf(seq, "%8d", ddm_table.code_size);
43440
43441 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
43442
43443 i2o_driver_result_table *result;
43444 i2o_driver_store_table *dst;
43445 - char tmp[28 + 1];
43446
43447 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
43448 if (result == NULL)
43449 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
43450
43451 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
43452 seq_printf(seq, "%-#8x", dst->module_id);
43453 - seq_printf(seq, "%-29s",
43454 - chtostr(tmp, dst->module_name_version, 28));
43455 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
43456 + seq_printf(seq, "%-.28s", dst->module_name_version);
43457 + seq_printf(seq, "%-.8s", dst->date);
43458 seq_printf(seq, "%8d ", dst->module_size);
43459 seq_printf(seq, "%8d ", dst->mpb_size);
43460 seq_printf(seq, "0x%04x", dst->module_flags);
43461 @@ -1250,7 +1240,6 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
43462 // == (allow) 512d bytes (max)
43463 static u16 *work16 = (u16 *) work32;
43464 int token;
43465 - char tmp[16 + 1];
43466
43467 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
43468
43469 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
43470 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
43471 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
43472 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
43473 - seq_printf(seq, "Vendor info : %s\n",
43474 - chtostr(tmp, (u8 *) (work32 + 2), 16));
43475 - seq_printf(seq, "Product info : %s\n",
43476 - chtostr(tmp, (u8 *) (work32 + 6), 16));
43477 - seq_printf(seq, "Description : %s\n",
43478 - chtostr(tmp, (u8 *) (work32 + 10), 16));
43479 - seq_printf(seq, "Product rev. : %s\n",
43480 - chtostr(tmp, (u8 *) (work32 + 14), 8));
43481 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
43482 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
43483 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
43484 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
43485
43486 seq_printf(seq, "Serial number : ");
43487 print_serial_number(seq, (u8 *) (work32 + 16),
43488 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
43489 u8 pad[256]; // allow up to 256 byte (max) serial number
43490 } result;
43491
43492 - char tmp[24 + 1];
43493 -
43494 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
43495
43496 if (token < 0) {
43497 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
43498 }
43499
43500 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
43501 - seq_printf(seq, "Module name : %s\n",
43502 - chtostr(tmp, result.module_name, 24));
43503 - seq_printf(seq, "Module revision : %s\n",
43504 - chtostr(tmp, result.module_rev, 8));
43505 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
43506 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
43507
43508 seq_printf(seq, "Serial number : ");
43509 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
43510 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43511 u8 instance_number[4];
43512 } result;
43513
43514 - char tmp[64 + 1];
43515 -
43516 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
43517
43518 if (token < 0) {
43519 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43520 return 0;
43521 }
43522
43523 - seq_printf(seq, "Device name : %s\n",
43524 - chtostr(tmp, result.device_name, 64));
43525 - seq_printf(seq, "Service name : %s\n",
43526 - chtostr(tmp, result.service_name, 64));
43527 - seq_printf(seq, "Physical name : %s\n",
43528 - chtostr(tmp, result.physical_location, 64));
43529 - seq_printf(seq, "Instance number : %s\n",
43530 - chtostr(tmp, result.instance_number, 4));
43531 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
43532 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
43533 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
43534 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
43535
43536 return 0;
43537 }
43538 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
43539 index a8c08f3..155fe3d 100644
43540 --- a/drivers/message/i2o/iop.c
43541 +++ b/drivers/message/i2o/iop.c
43542 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
43543
43544 spin_lock_irqsave(&c->context_list_lock, flags);
43545
43546 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
43547 - atomic_inc(&c->context_list_counter);
43548 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
43549 + atomic_inc_unchecked(&c->context_list_counter);
43550
43551 - entry->context = atomic_read(&c->context_list_counter);
43552 + entry->context = atomic_read_unchecked(&c->context_list_counter);
43553
43554 list_add(&entry->list, &c->context_list);
43555
43556 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
43557
43558 #if BITS_PER_LONG == 64
43559 spin_lock_init(&c->context_list_lock);
43560 - atomic_set(&c->context_list_counter, 0);
43561 + atomic_set_unchecked(&c->context_list_counter, 0);
43562 INIT_LIST_HEAD(&c->context_list);
43563 #endif
43564
43565 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
43566 index 45ece11..8efa218 100644
43567 --- a/drivers/mfd/janz-cmodio.c
43568 +++ b/drivers/mfd/janz-cmodio.c
43569 @@ -13,6 +13,7 @@
43570
43571 #include <linux/kernel.h>
43572 #include <linux/module.h>
43573 +#include <linux/slab.h>
43574 #include <linux/init.h>
43575 #include <linux/pci.h>
43576 #include <linux/interrupt.h>
43577 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
43578 index a5f9888..1c0ed56 100644
43579 --- a/drivers/mfd/twl4030-irq.c
43580 +++ b/drivers/mfd/twl4030-irq.c
43581 @@ -35,6 +35,7 @@
43582 #include <linux/of.h>
43583 #include <linux/irqdomain.h>
43584 #include <linux/i2c/twl.h>
43585 +#include <asm/pgtable.h>
43586
43587 #include "twl-core.h"
43588
43589 @@ -728,10 +729,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
43590 * Install an irq handler for each of the SIH modules;
43591 * clone dummy irq_chip since PIH can't *do* anything
43592 */
43593 - twl4030_irq_chip = dummy_irq_chip;
43594 - twl4030_irq_chip.name = "twl4030";
43595 + pax_open_kernel();
43596 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
43597 + *(const char **)&twl4030_irq_chip.name = "twl4030";
43598
43599 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
43600 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
43601 + pax_close_kernel();
43602
43603 for (i = irq_base; i < irq_end; i++) {
43604 irq_set_chip_and_handler(i, &twl4030_irq_chip,
43605 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
43606 index 277a8db..0e0b754 100644
43607 --- a/drivers/mfd/twl6030-irq.c
43608 +++ b/drivers/mfd/twl6030-irq.c
43609 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
43610 * install an irq handler for each of the modules;
43611 * clone dummy irq_chip since PIH can't *do* anything
43612 */
43613 - twl6030_irq_chip = dummy_irq_chip;
43614 - twl6030_irq_chip.name = "twl6030";
43615 - twl6030_irq_chip.irq_set_type = NULL;
43616 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
43617 + pax_open_kernel();
43618 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
43619 + *(const char **)&twl6030_irq_chip.name = "twl6030";
43620 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
43621 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
43622 + pax_close_kernel();
43623
43624 for (i = irq_base; i < irq_end; i++) {
43625 irq_set_chip_and_handler(i, &twl6030_irq_chip,
43626 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
43627 index f32550a..e3e52a2 100644
43628 --- a/drivers/misc/c2port/core.c
43629 +++ b/drivers/misc/c2port/core.c
43630 @@ -920,7 +920,9 @@ struct c2port_device *c2port_device_register(char *name,
43631 mutex_init(&c2dev->mutex);
43632
43633 /* Create binary file */
43634 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
43635 + pax_open_kernel();
43636 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
43637 + pax_close_kernel();
43638 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
43639 if (unlikely(ret))
43640 goto error_device_create_bin_file;
43641 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
43642 index 36f5d52..32311c3 100644
43643 --- a/drivers/misc/kgdbts.c
43644 +++ b/drivers/misc/kgdbts.c
43645 @@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
43646 char before[BREAK_INSTR_SIZE];
43647 char after[BREAK_INSTR_SIZE];
43648
43649 - probe_kernel_read(before, (char *)kgdbts_break_test,
43650 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
43651 BREAK_INSTR_SIZE);
43652 init_simple_test();
43653 ts.tst = plant_and_detach_test;
43654 @@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
43655 /* Activate test with initial breakpoint */
43656 if (!is_early)
43657 kgdb_breakpoint();
43658 - probe_kernel_read(after, (char *)kgdbts_break_test,
43659 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
43660 BREAK_INSTR_SIZE);
43661 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
43662 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
43663 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
43664 index 4cd4a3d..b48cbc7 100644
43665 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
43666 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
43667 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
43668 * the lid is closed. This leads to interrupts as soon as a little move
43669 * is done.
43670 */
43671 - atomic_inc(&lis3->count);
43672 + atomic_inc_unchecked(&lis3->count);
43673
43674 wake_up_interruptible(&lis3->misc_wait);
43675 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
43676 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
43677 if (lis3->pm_dev)
43678 pm_runtime_get_sync(lis3->pm_dev);
43679
43680 - atomic_set(&lis3->count, 0);
43681 + atomic_set_unchecked(&lis3->count, 0);
43682 return 0;
43683 }
43684
43685 @@ -616,7 +616,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
43686 add_wait_queue(&lis3->misc_wait, &wait);
43687 while (true) {
43688 set_current_state(TASK_INTERRUPTIBLE);
43689 - data = atomic_xchg(&lis3->count, 0);
43690 + data = atomic_xchg_unchecked(&lis3->count, 0);
43691 if (data)
43692 break;
43693
43694 @@ -657,7 +657,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
43695 struct lis3lv02d, miscdev);
43696
43697 poll_wait(file, &lis3->misc_wait, wait);
43698 - if (atomic_read(&lis3->count))
43699 + if (atomic_read_unchecked(&lis3->count))
43700 return POLLIN | POLLRDNORM;
43701 return 0;
43702 }
43703 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
43704 index c439c82..1f20f57 100644
43705 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
43706 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
43707 @@ -297,7 +297,7 @@ struct lis3lv02d {
43708 struct input_polled_dev *idev; /* input device */
43709 struct platform_device *pdev; /* platform device */
43710 struct regulator_bulk_data regulators[2];
43711 - atomic_t count; /* interrupt count after last read */
43712 + atomic_unchecked_t count; /* interrupt count after last read */
43713 union axis_conversion ac; /* hw -> logical axis */
43714 int mapped_btns[3];
43715
43716 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
43717 index 2f30bad..c4c13d0 100644
43718 --- a/drivers/misc/sgi-gru/gruhandles.c
43719 +++ b/drivers/misc/sgi-gru/gruhandles.c
43720 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
43721 unsigned long nsec;
43722
43723 nsec = CLKS2NSEC(clks);
43724 - atomic_long_inc(&mcs_op_statistics[op].count);
43725 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
43726 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
43727 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
43728 if (mcs_op_statistics[op].max < nsec)
43729 mcs_op_statistics[op].max = nsec;
43730 }
43731 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
43732 index 797d796..ae8f01e 100644
43733 --- a/drivers/misc/sgi-gru/gruprocfs.c
43734 +++ b/drivers/misc/sgi-gru/gruprocfs.c
43735 @@ -32,9 +32,9 @@
43736
43737 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
43738
43739 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
43740 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
43741 {
43742 - unsigned long val = atomic_long_read(v);
43743 + unsigned long val = atomic_long_read_unchecked(v);
43744
43745 seq_printf(s, "%16lu %s\n", val, id);
43746 }
43747 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
43748
43749 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
43750 for (op = 0; op < mcsop_last; op++) {
43751 - count = atomic_long_read(&mcs_op_statistics[op].count);
43752 - total = atomic_long_read(&mcs_op_statistics[op].total);
43753 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
43754 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
43755 max = mcs_op_statistics[op].max;
43756 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
43757 count ? total / count : 0, max);
43758 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
43759 index 5c3ce24..4915ccb 100644
43760 --- a/drivers/misc/sgi-gru/grutables.h
43761 +++ b/drivers/misc/sgi-gru/grutables.h
43762 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
43763 * GRU statistics.
43764 */
43765 struct gru_stats_s {
43766 - atomic_long_t vdata_alloc;
43767 - atomic_long_t vdata_free;
43768 - atomic_long_t gts_alloc;
43769 - atomic_long_t gts_free;
43770 - atomic_long_t gms_alloc;
43771 - atomic_long_t gms_free;
43772 - atomic_long_t gts_double_allocate;
43773 - atomic_long_t assign_context;
43774 - atomic_long_t assign_context_failed;
43775 - atomic_long_t free_context;
43776 - atomic_long_t load_user_context;
43777 - atomic_long_t load_kernel_context;
43778 - atomic_long_t lock_kernel_context;
43779 - atomic_long_t unlock_kernel_context;
43780 - atomic_long_t steal_user_context;
43781 - atomic_long_t steal_kernel_context;
43782 - atomic_long_t steal_context_failed;
43783 - atomic_long_t nopfn;
43784 - atomic_long_t asid_new;
43785 - atomic_long_t asid_next;
43786 - atomic_long_t asid_wrap;
43787 - atomic_long_t asid_reuse;
43788 - atomic_long_t intr;
43789 - atomic_long_t intr_cbr;
43790 - atomic_long_t intr_tfh;
43791 - atomic_long_t intr_spurious;
43792 - atomic_long_t intr_mm_lock_failed;
43793 - atomic_long_t call_os;
43794 - atomic_long_t call_os_wait_queue;
43795 - atomic_long_t user_flush_tlb;
43796 - atomic_long_t user_unload_context;
43797 - atomic_long_t user_exception;
43798 - atomic_long_t set_context_option;
43799 - atomic_long_t check_context_retarget_intr;
43800 - atomic_long_t check_context_unload;
43801 - atomic_long_t tlb_dropin;
43802 - atomic_long_t tlb_preload_page;
43803 - atomic_long_t tlb_dropin_fail_no_asid;
43804 - atomic_long_t tlb_dropin_fail_upm;
43805 - atomic_long_t tlb_dropin_fail_invalid;
43806 - atomic_long_t tlb_dropin_fail_range_active;
43807 - atomic_long_t tlb_dropin_fail_idle;
43808 - atomic_long_t tlb_dropin_fail_fmm;
43809 - atomic_long_t tlb_dropin_fail_no_exception;
43810 - atomic_long_t tfh_stale_on_fault;
43811 - atomic_long_t mmu_invalidate_range;
43812 - atomic_long_t mmu_invalidate_page;
43813 - atomic_long_t flush_tlb;
43814 - atomic_long_t flush_tlb_gru;
43815 - atomic_long_t flush_tlb_gru_tgh;
43816 - atomic_long_t flush_tlb_gru_zero_asid;
43817 + atomic_long_unchecked_t vdata_alloc;
43818 + atomic_long_unchecked_t vdata_free;
43819 + atomic_long_unchecked_t gts_alloc;
43820 + atomic_long_unchecked_t gts_free;
43821 + atomic_long_unchecked_t gms_alloc;
43822 + atomic_long_unchecked_t gms_free;
43823 + atomic_long_unchecked_t gts_double_allocate;
43824 + atomic_long_unchecked_t assign_context;
43825 + atomic_long_unchecked_t assign_context_failed;
43826 + atomic_long_unchecked_t free_context;
43827 + atomic_long_unchecked_t load_user_context;
43828 + atomic_long_unchecked_t load_kernel_context;
43829 + atomic_long_unchecked_t lock_kernel_context;
43830 + atomic_long_unchecked_t unlock_kernel_context;
43831 + atomic_long_unchecked_t steal_user_context;
43832 + atomic_long_unchecked_t steal_kernel_context;
43833 + atomic_long_unchecked_t steal_context_failed;
43834 + atomic_long_unchecked_t nopfn;
43835 + atomic_long_unchecked_t asid_new;
43836 + atomic_long_unchecked_t asid_next;
43837 + atomic_long_unchecked_t asid_wrap;
43838 + atomic_long_unchecked_t asid_reuse;
43839 + atomic_long_unchecked_t intr;
43840 + atomic_long_unchecked_t intr_cbr;
43841 + atomic_long_unchecked_t intr_tfh;
43842 + atomic_long_unchecked_t intr_spurious;
43843 + atomic_long_unchecked_t intr_mm_lock_failed;
43844 + atomic_long_unchecked_t call_os;
43845 + atomic_long_unchecked_t call_os_wait_queue;
43846 + atomic_long_unchecked_t user_flush_tlb;
43847 + atomic_long_unchecked_t user_unload_context;
43848 + atomic_long_unchecked_t user_exception;
43849 + atomic_long_unchecked_t set_context_option;
43850 + atomic_long_unchecked_t check_context_retarget_intr;
43851 + atomic_long_unchecked_t check_context_unload;
43852 + atomic_long_unchecked_t tlb_dropin;
43853 + atomic_long_unchecked_t tlb_preload_page;
43854 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
43855 + atomic_long_unchecked_t tlb_dropin_fail_upm;
43856 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
43857 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
43858 + atomic_long_unchecked_t tlb_dropin_fail_idle;
43859 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
43860 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
43861 + atomic_long_unchecked_t tfh_stale_on_fault;
43862 + atomic_long_unchecked_t mmu_invalidate_range;
43863 + atomic_long_unchecked_t mmu_invalidate_page;
43864 + atomic_long_unchecked_t flush_tlb;
43865 + atomic_long_unchecked_t flush_tlb_gru;
43866 + atomic_long_unchecked_t flush_tlb_gru_tgh;
43867 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
43868
43869 - atomic_long_t copy_gpa;
43870 - atomic_long_t read_gpa;
43871 + atomic_long_unchecked_t copy_gpa;
43872 + atomic_long_unchecked_t read_gpa;
43873
43874 - atomic_long_t mesq_receive;
43875 - atomic_long_t mesq_receive_none;
43876 - atomic_long_t mesq_send;
43877 - atomic_long_t mesq_send_failed;
43878 - atomic_long_t mesq_noop;
43879 - atomic_long_t mesq_send_unexpected_error;
43880 - atomic_long_t mesq_send_lb_overflow;
43881 - atomic_long_t mesq_send_qlimit_reached;
43882 - atomic_long_t mesq_send_amo_nacked;
43883 - atomic_long_t mesq_send_put_nacked;
43884 - atomic_long_t mesq_page_overflow;
43885 - atomic_long_t mesq_qf_locked;
43886 - atomic_long_t mesq_qf_noop_not_full;
43887 - atomic_long_t mesq_qf_switch_head_failed;
43888 - atomic_long_t mesq_qf_unexpected_error;
43889 - atomic_long_t mesq_noop_unexpected_error;
43890 - atomic_long_t mesq_noop_lb_overflow;
43891 - atomic_long_t mesq_noop_qlimit_reached;
43892 - atomic_long_t mesq_noop_amo_nacked;
43893 - atomic_long_t mesq_noop_put_nacked;
43894 - atomic_long_t mesq_noop_page_overflow;
43895 + atomic_long_unchecked_t mesq_receive;
43896 + atomic_long_unchecked_t mesq_receive_none;
43897 + atomic_long_unchecked_t mesq_send;
43898 + atomic_long_unchecked_t mesq_send_failed;
43899 + atomic_long_unchecked_t mesq_noop;
43900 + atomic_long_unchecked_t mesq_send_unexpected_error;
43901 + atomic_long_unchecked_t mesq_send_lb_overflow;
43902 + atomic_long_unchecked_t mesq_send_qlimit_reached;
43903 + atomic_long_unchecked_t mesq_send_amo_nacked;
43904 + atomic_long_unchecked_t mesq_send_put_nacked;
43905 + atomic_long_unchecked_t mesq_page_overflow;
43906 + atomic_long_unchecked_t mesq_qf_locked;
43907 + atomic_long_unchecked_t mesq_qf_noop_not_full;
43908 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
43909 + atomic_long_unchecked_t mesq_qf_unexpected_error;
43910 + atomic_long_unchecked_t mesq_noop_unexpected_error;
43911 + atomic_long_unchecked_t mesq_noop_lb_overflow;
43912 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
43913 + atomic_long_unchecked_t mesq_noop_amo_nacked;
43914 + atomic_long_unchecked_t mesq_noop_put_nacked;
43915 + atomic_long_unchecked_t mesq_noop_page_overflow;
43916
43917 };
43918
43919 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
43920 tghop_invalidate, mcsop_last};
43921
43922 struct mcs_op_statistic {
43923 - atomic_long_t count;
43924 - atomic_long_t total;
43925 + atomic_long_unchecked_t count;
43926 + atomic_long_unchecked_t total;
43927 unsigned long max;
43928 };
43929
43930 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
43931
43932 #define STAT(id) do { \
43933 if (gru_options & OPT_STATS) \
43934 - atomic_long_inc(&gru_stats.id); \
43935 + atomic_long_inc_unchecked(&gru_stats.id); \
43936 } while (0)
43937
43938 #ifdef CONFIG_SGI_GRU_DEBUG
43939 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
43940 index c862cd4..0d176fe 100644
43941 --- a/drivers/misc/sgi-xp/xp.h
43942 +++ b/drivers/misc/sgi-xp/xp.h
43943 @@ -288,7 +288,7 @@ struct xpc_interface {
43944 xpc_notify_func, void *);
43945 void (*received) (short, int, void *);
43946 enum xp_retval (*partid_to_nasids) (short, void *);
43947 -};
43948 +} __no_const;
43949
43950 extern struct xpc_interface xpc_interface;
43951
43952 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
43953 index b94d5f7..7f494c5 100644
43954 --- a/drivers/misc/sgi-xp/xpc.h
43955 +++ b/drivers/misc/sgi-xp/xpc.h
43956 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
43957 void (*received_payload) (struct xpc_channel *, void *);
43958 void (*notify_senders_of_disconnect) (struct xpc_channel *);
43959 };
43960 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
43961
43962 /* struct xpc_partition act_state values (for XPC HB) */
43963
43964 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
43965 /* found in xpc_main.c */
43966 extern struct device *xpc_part;
43967 extern struct device *xpc_chan;
43968 -extern struct xpc_arch_operations xpc_arch_ops;
43969 +extern xpc_arch_operations_no_const xpc_arch_ops;
43970 extern int xpc_disengage_timelimit;
43971 extern int xpc_disengage_timedout;
43972 extern int xpc_activate_IRQ_rcvd;
43973 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
43974 index d971817..33bdca5 100644
43975 --- a/drivers/misc/sgi-xp/xpc_main.c
43976 +++ b/drivers/misc/sgi-xp/xpc_main.c
43977 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
43978 .notifier_call = xpc_system_die,
43979 };
43980
43981 -struct xpc_arch_operations xpc_arch_ops;
43982 +xpc_arch_operations_no_const xpc_arch_ops;
43983
43984 /*
43985 * Timer function to enforce the timelimit on the partition disengage.
43986 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
43987
43988 if (((die_args->trapnr == X86_TRAP_MF) ||
43989 (die_args->trapnr == X86_TRAP_XF)) &&
43990 - !user_mode_vm(die_args->regs))
43991 + !user_mode(die_args->regs))
43992 xpc_die_deactivate();
43993
43994 break;
43995 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
43996 index 49f04bc..65660c2 100644
43997 --- a/drivers/mmc/core/mmc_ops.c
43998 +++ b/drivers/mmc/core/mmc_ops.c
43999 @@ -247,7 +247,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
44000 void *data_buf;
44001 int is_on_stack;
44002
44003 - is_on_stack = object_is_on_stack(buf);
44004 + is_on_stack = object_starts_on_stack(buf);
44005 if (is_on_stack) {
44006 /*
44007 * dma onto stack is unsafe/nonportable, but callers to this
44008 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
44009 index 0b74189..818358f 100644
44010 --- a/drivers/mmc/host/dw_mmc.h
44011 +++ b/drivers/mmc/host/dw_mmc.h
44012 @@ -202,5 +202,5 @@ struct dw_mci_drv_data {
44013 void (*prepare_command)(struct dw_mci *host, u32 *cmdr);
44014 void (*set_ios)(struct dw_mci *host, struct mmc_ios *ios);
44015 int (*parse_dt)(struct dw_mci *host);
44016 -};
44017 +} __do_const;
44018 #endif /* _DW_MMC_H_ */
44019 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
44020 index c6f6246..60760a8 100644
44021 --- a/drivers/mmc/host/sdhci-s3c.c
44022 +++ b/drivers/mmc/host/sdhci-s3c.c
44023 @@ -664,9 +664,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
44024 * we can use overriding functions instead of default.
44025 */
44026 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
44027 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
44028 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
44029 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
44030 + pax_open_kernel();
44031 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
44032 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
44033 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
44034 + pax_close_kernel();
44035 }
44036
44037 /* It supports additional host capabilities if needed */
44038 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
44039 index 0c8bb6b..6f35deb 100644
44040 --- a/drivers/mtd/nand/denali.c
44041 +++ b/drivers/mtd/nand/denali.c
44042 @@ -24,6 +24,7 @@
44043 #include <linux/slab.h>
44044 #include <linux/mtd/mtd.h>
44045 #include <linux/module.h>
44046 +#include <linux/slab.h>
44047
44048 #include "denali.h"
44049
44050 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
44051 index 51b9d6a..52af9a7 100644
44052 --- a/drivers/mtd/nftlmount.c
44053 +++ b/drivers/mtd/nftlmount.c
44054 @@ -24,6 +24,7 @@
44055 #include <asm/errno.h>
44056 #include <linux/delay.h>
44057 #include <linux/slab.h>
44058 +#include <linux/sched.h>
44059 #include <linux/mtd/mtd.h>
44060 #include <linux/mtd/nand.h>
44061 #include <linux/mtd/nftl.h>
44062 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
44063 index f9d5615..99dd95f 100644
44064 --- a/drivers/mtd/sm_ftl.c
44065 +++ b/drivers/mtd/sm_ftl.c
44066 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
44067 #define SM_CIS_VENDOR_OFFSET 0x59
44068 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
44069 {
44070 - struct attribute_group *attr_group;
44071 + attribute_group_no_const *attr_group;
44072 struct attribute **attributes;
44073 struct sm_sysfs_attribute *vendor_attribute;
44074
44075 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
44076 index f975696..4597e21 100644
44077 --- a/drivers/net/bonding/bond_main.c
44078 +++ b/drivers/net/bonding/bond_main.c
44079 @@ -4870,7 +4870,7 @@ static unsigned int bond_get_num_tx_queues(void)
44080 return tx_queues;
44081 }
44082
44083 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
44084 +static struct rtnl_link_ops bond_link_ops = {
44085 .kind = "bond",
44086 .priv_size = sizeof(struct bonding),
44087 .setup = bond_setup,
44088 @@ -4995,8 +4995,8 @@ static void __exit bonding_exit(void)
44089
44090 bond_destroy_debugfs();
44091
44092 - rtnl_link_unregister(&bond_link_ops);
44093 unregister_pernet_subsys(&bond_net_ops);
44094 + rtnl_link_unregister(&bond_link_ops);
44095
44096 #ifdef CONFIG_NET_POLL_CONTROLLER
44097 /*
44098 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
44099 index e1d2643..7f4133b 100644
44100 --- a/drivers/net/ethernet/8390/ax88796.c
44101 +++ b/drivers/net/ethernet/8390/ax88796.c
44102 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
44103 if (ax->plat->reg_offsets)
44104 ei_local->reg_offset = ax->plat->reg_offsets;
44105 else {
44106 + resource_size_t _mem_size = mem_size;
44107 + do_div(_mem_size, 0x18);
44108 ei_local->reg_offset = ax->reg_offsets;
44109 for (ret = 0; ret < 0x18; ret++)
44110 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
44111 + ax->reg_offsets[ret] = _mem_size * ret;
44112 }
44113
44114 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
44115 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
44116 index 151675d..0139a9d 100644
44117 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
44118 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
44119 @@ -1112,7 +1112,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
44120 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
44121 {
44122 /* RX_MODE controlling object */
44123 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
44124 + bnx2x_init_rx_mode_obj(bp);
44125
44126 /* multicast configuration controlling object */
44127 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
44128 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
44129 index ce1a916..10b52b0 100644
44130 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
44131 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
44132 @@ -960,6 +960,9 @@ static int bnx2x_set_dump(struct net_device *dev, struct ethtool_dump *val)
44133 struct bnx2x *bp = netdev_priv(dev);
44134
44135 /* Use the ethtool_dump "flag" field as the dump preset index */
44136 + if (val->flag < 1 || val->flag > DUMP_MAX_PRESETS)
44137 + return -EINVAL;
44138 +
44139 bp->dump_preset_idx = val->flag;
44140 return 0;
44141 }
44142 @@ -986,8 +989,6 @@ static int bnx2x_get_dump_data(struct net_device *dev,
44143 struct bnx2x *bp = netdev_priv(dev);
44144 struct dump_header dump_hdr = {0};
44145
44146 - memset(p, 0, dump->len);
44147 -
44148 /* Disable parity attentions as long as following dump may
44149 * cause false alarms by reading never written registers. We
44150 * will re-enable parity attentions right after the dump.
44151 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
44152 index b4c9dea..2a9927f 100644
44153 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
44154 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
44155 @@ -11497,6 +11497,8 @@ static int bnx2x_init_bp(struct bnx2x *bp)
44156 bp->min_msix_vec_cnt = 2;
44157 BNX2X_DEV_INFO("bp->min_msix_vec_cnt %d", bp->min_msix_vec_cnt);
44158
44159 + bp->dump_preset_idx = 1;
44160 +
44161 return rc;
44162 }
44163
44164 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
44165 index 32a9609..0b1c53a 100644
44166 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
44167 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
44168 @@ -2387,15 +2387,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
44169 return rc;
44170 }
44171
44172 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
44173 - struct bnx2x_rx_mode_obj *o)
44174 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
44175 {
44176 if (CHIP_IS_E1x(bp)) {
44177 - o->wait_comp = bnx2x_empty_rx_mode_wait;
44178 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
44179 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
44180 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
44181 } else {
44182 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
44183 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
44184 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
44185 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
44186 }
44187 }
44188
44189 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
44190 index 43c00bc..dd1d03d 100644
44191 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
44192 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
44193 @@ -1321,8 +1321,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
44194
44195 /********************* RX MODE ****************/
44196
44197 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
44198 - struct bnx2x_rx_mode_obj *o);
44199 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
44200
44201 /**
44202 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
44203 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
44204 index ff6e30e..87e8452 100644
44205 --- a/drivers/net/ethernet/broadcom/tg3.h
44206 +++ b/drivers/net/ethernet/broadcom/tg3.h
44207 @@ -147,6 +147,7 @@
44208 #define CHIPREV_ID_5750_A0 0x4000
44209 #define CHIPREV_ID_5750_A1 0x4001
44210 #define CHIPREV_ID_5750_A3 0x4003
44211 +#define CHIPREV_ID_5750_C1 0x4201
44212 #define CHIPREV_ID_5750_C2 0x4202
44213 #define CHIPREV_ID_5752_A0_HW 0x5000
44214 #define CHIPREV_ID_5752_A0 0x6000
44215 diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
44216 index 71497e8..b650951 100644
44217 --- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
44218 +++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
44219 @@ -3037,7 +3037,9 @@ static void t3_io_resume(struct pci_dev *pdev)
44220 CH_ALERT(adapter, "adapter recovering, PEX ERR 0x%x\n",
44221 t3_read_reg(adapter, A_PCIE_PEX_ERR));
44222
44223 + rtnl_lock();
44224 t3_resume_ports(adapter);
44225 + rtnl_unlock();
44226 }
44227
44228 static const struct pci_error_handlers t3_err_handler = {
44229 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
44230 index 8cffcdf..aadf043 100644
44231 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
44232 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
44233 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
44234 */
44235 struct l2t_skb_cb {
44236 arp_failure_handler_func arp_failure_handler;
44237 -};
44238 +} __no_const;
44239
44240 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
44241
44242 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
44243 index 4c83003..2a2a5b9 100644
44244 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
44245 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
44246 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
44247 for (i=0; i<ETH_ALEN; i++) {
44248 tmp.addr[i] = dev->dev_addr[i];
44249 }
44250 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
44251 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
44252 break;
44253
44254 case DE4X5_SET_HWADDR: /* Set the hardware address */
44255 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
44256 spin_lock_irqsave(&lp->lock, flags);
44257 memcpy(&statbuf, &lp->pktStats, ioc->len);
44258 spin_unlock_irqrestore(&lp->lock, flags);
44259 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
44260 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
44261 return -EFAULT;
44262 break;
44263 }
44264 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
44265 index 6e43426..1bd8365 100644
44266 --- a/drivers/net/ethernet/emulex/benet/be_main.c
44267 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
44268 @@ -469,7 +469,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
44269
44270 if (wrapped)
44271 newacc += 65536;
44272 - ACCESS_ONCE(*acc) = newacc;
44273 + ACCESS_ONCE_RW(*acc) = newacc;
44274 }
44275
44276 void populate_erx_stats(struct be_adapter *adapter,
44277 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
44278 index 21b85fb..b49e5fc 100644
44279 --- a/drivers/net/ethernet/faraday/ftgmac100.c
44280 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
44281 @@ -31,6 +31,8 @@
44282 #include <linux/netdevice.h>
44283 #include <linux/phy.h>
44284 #include <linux/platform_device.h>
44285 +#include <linux/interrupt.h>
44286 +#include <linux/irqreturn.h>
44287 #include <net/ip.h>
44288
44289 #include "ftgmac100.h"
44290 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
44291 index a6eda8d..935d273 100644
44292 --- a/drivers/net/ethernet/faraday/ftmac100.c
44293 +++ b/drivers/net/ethernet/faraday/ftmac100.c
44294 @@ -31,6 +31,8 @@
44295 #include <linux/module.h>
44296 #include <linux/netdevice.h>
44297 #include <linux/platform_device.h>
44298 +#include <linux/interrupt.h>
44299 +#include <linux/irqreturn.h>
44300
44301 #include "ftmac100.h"
44302
44303 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
44304 index 331987d..3be1135 100644
44305 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
44306 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
44307 @@ -776,7 +776,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
44308 }
44309
44310 /* update the base incval used to calculate frequency adjustment */
44311 - ACCESS_ONCE(adapter->base_incval) = incval;
44312 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
44313 smp_mb();
44314
44315 /* need lock to prevent incorrect read while modifying cyclecounter */
44316 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
44317 index fbe5363..266b4e3 100644
44318 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
44319 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
44320 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
44321 struct __vxge_hw_fifo *fifo;
44322 struct vxge_hw_fifo_config *config;
44323 u32 txdl_size, txdl_per_memblock;
44324 - struct vxge_hw_mempool_cbs fifo_mp_callback;
44325 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
44326 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
44327 + };
44328 +
44329 struct __vxge_hw_virtualpath *vpath;
44330
44331 if ((vp == NULL) || (attr == NULL)) {
44332 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
44333 goto exit;
44334 }
44335
44336 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
44337 -
44338 fifo->mempool =
44339 __vxge_hw_mempool_create(vpath->hldev,
44340 fifo->config->memblock_size,
44341 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44342 index 5e7fb1d..f8d1810 100644
44343 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44344 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44345 @@ -1948,7 +1948,9 @@ int qlcnic_83xx_config_default_opmode(struct qlcnic_adapter *adapter)
44346 op_mode = QLC_83XX_DEFAULT_OPMODE;
44347
44348 if (op_mode == QLC_83XX_DEFAULT_OPMODE) {
44349 - adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
44350 + pax_open_kernel();
44351 + *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
44352 + pax_close_kernel();
44353 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44354 } else {
44355 return -EIO;
44356 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44357 index b0c3de9..fc5857e 100644
44358 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44359 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44360 @@ -200,15 +200,21 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
44361 if (priv_level == QLCNIC_NON_PRIV_FUNC) {
44362 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
44363 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44364 - nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
44365 + pax_open_kernel();
44366 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
44367 + pax_close_kernel();
44368 } else if (priv_level == QLCNIC_PRIV_FUNC) {
44369 ahw->op_mode = QLCNIC_PRIV_FUNC;
44370 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
44371 - nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
44372 + pax_open_kernel();
44373 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
44374 + pax_close_kernel();
44375 } else if (priv_level == QLCNIC_MGMT_FUNC) {
44376 ahw->op_mode = QLCNIC_MGMT_FUNC;
44377 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44378 - nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
44379 + pax_open_kernel();
44380 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
44381 + pax_close_kernel();
44382 } else {
44383 return -EIO;
44384 }
44385 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c
44386 index 6acf82b..14b097e 100644
44387 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c
44388 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c
44389 @@ -206,10 +206,10 @@ int qlcnic_fw_cmd_set_drv_version(struct qlcnic_adapter *adapter)
44390 if (err) {
44391 dev_info(&adapter->pdev->dev,
44392 "Failed to set driver version in firmware\n");
44393 - return -EIO;
44394 + err = -EIO;
44395 }
44396 -
44397 - return 0;
44398 + qlcnic_free_mbx_args(&cmd);
44399 + return err;
44400 }
44401
44402 int
44403 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
44404 index d3f8797..82a03d3 100644
44405 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
44406 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
44407 @@ -262,7 +262,7 @@ void qlcnic_82xx_change_filter(struct qlcnic_adapter *adapter, u64 *uaddr,
44408
44409 mac_req = (struct qlcnic_mac_req *)&(req->words[0]);
44410 mac_req->op = vlan_id ? QLCNIC_MAC_VLAN_ADD : QLCNIC_MAC_ADD;
44411 - memcpy(mac_req->mac_addr, &uaddr, ETH_ALEN);
44412 + memcpy(mac_req->mac_addr, uaddr, ETH_ALEN);
44413
44414 vlan_req = (struct qlcnic_vlan_req *)&req->words[1];
44415 vlan_req->vlan_id = cpu_to_le16(vlan_id);
44416 diff --git a/drivers/net/ethernet/realtek/8139cp.c b/drivers/net/ethernet/realtek/8139cp.c
44417 index 887aebe..9095ff9 100644
44418 --- a/drivers/net/ethernet/realtek/8139cp.c
44419 +++ b/drivers/net/ethernet/realtek/8139cp.c
44420 @@ -524,6 +524,7 @@ rx_status_loop:
44421 PCI_DMA_FROMDEVICE);
44422 if (dma_mapping_error(&cp->pdev->dev, new_mapping)) {
44423 dev->stats.rx_dropped++;
44424 + kfree_skb(new_skb);
44425 goto rx_next;
44426 }
44427
44428 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
44429 index 393f961..d343034 100644
44430 --- a/drivers/net/ethernet/realtek/r8169.c
44431 +++ b/drivers/net/ethernet/realtek/r8169.c
44432 @@ -753,22 +753,22 @@ struct rtl8169_private {
44433 struct mdio_ops {
44434 void (*write)(struct rtl8169_private *, int, int);
44435 int (*read)(struct rtl8169_private *, int);
44436 - } mdio_ops;
44437 + } __no_const mdio_ops;
44438
44439 struct pll_power_ops {
44440 void (*down)(struct rtl8169_private *);
44441 void (*up)(struct rtl8169_private *);
44442 - } pll_power_ops;
44443 + } __no_const pll_power_ops;
44444
44445 struct jumbo_ops {
44446 void (*enable)(struct rtl8169_private *);
44447 void (*disable)(struct rtl8169_private *);
44448 - } jumbo_ops;
44449 + } __no_const jumbo_ops;
44450
44451 struct csi_ops {
44452 void (*write)(struct rtl8169_private *, int, int);
44453 u32 (*read)(struct rtl8169_private *, int);
44454 - } csi_ops;
44455 + } __no_const csi_ops;
44456
44457 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
44458 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
44459 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
44460 index 9a95abf..36df7f9 100644
44461 --- a/drivers/net/ethernet/sfc/ptp.c
44462 +++ b/drivers/net/ethernet/sfc/ptp.c
44463 @@ -535,7 +535,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
44464 (u32)((u64)ptp->start.dma_addr >> 32));
44465
44466 /* Clear flag that signals MC ready */
44467 - ACCESS_ONCE(*start) = 0;
44468 + ACCESS_ONCE_RW(*start) = 0;
44469 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
44470 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
44471
44472 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44473 index 50617c5..b13724c 100644
44474 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44475 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44476 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
44477
44478 writel(value, ioaddr + MMC_CNTRL);
44479
44480 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
44481 - MMC_CNTRL, value);
44482 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
44483 +// MMC_CNTRL, value);
44484 }
44485
44486 /* To mask all all interrupts.*/
44487 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
44488 index e6fe0d8..2b7d752 100644
44489 --- a/drivers/net/hyperv/hyperv_net.h
44490 +++ b/drivers/net/hyperv/hyperv_net.h
44491 @@ -101,7 +101,7 @@ struct rndis_device {
44492
44493 enum rndis_device_state state;
44494 bool link_state;
44495 - atomic_t new_req_id;
44496 + atomic_unchecked_t new_req_id;
44497
44498 spinlock_t request_lock;
44499 struct list_head req_list;
44500 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
44501 index 0775f0a..d4fb316 100644
44502 --- a/drivers/net/hyperv/rndis_filter.c
44503 +++ b/drivers/net/hyperv/rndis_filter.c
44504 @@ -104,7 +104,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
44505 * template
44506 */
44507 set = &rndis_msg->msg.set_req;
44508 - set->req_id = atomic_inc_return(&dev->new_req_id);
44509 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
44510
44511 /* Add to the request list */
44512 spin_lock_irqsave(&dev->request_lock, flags);
44513 @@ -752,7 +752,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
44514
44515 /* Setup the rndis set */
44516 halt = &request->request_msg.msg.halt_req;
44517 - halt->req_id = atomic_inc_return(&dev->new_req_id);
44518 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
44519
44520 /* Ignore return since this msg is optional. */
44521 rndis_filter_send_request(dev, request);
44522 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
44523 index bf0d55e..82bcfbd1 100644
44524 --- a/drivers/net/ieee802154/fakehard.c
44525 +++ b/drivers/net/ieee802154/fakehard.c
44526 @@ -364,7 +364,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
44527 phy->transmit_power = 0xbf;
44528
44529 dev->netdev_ops = &fake_ops;
44530 - dev->ml_priv = &fake_mlme;
44531 + dev->ml_priv = (void *)&fake_mlme;
44532
44533 priv = netdev_priv(dev);
44534 priv->phy = phy;
44535 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
44536 index 6e91931..2b0ebe7 100644
44537 --- a/drivers/net/macvlan.c
44538 +++ b/drivers/net/macvlan.c
44539 @@ -905,13 +905,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
44540 int macvlan_link_register(struct rtnl_link_ops *ops)
44541 {
44542 /* common fields */
44543 - ops->priv_size = sizeof(struct macvlan_dev);
44544 - ops->validate = macvlan_validate;
44545 - ops->maxtype = IFLA_MACVLAN_MAX;
44546 - ops->policy = macvlan_policy;
44547 - ops->changelink = macvlan_changelink;
44548 - ops->get_size = macvlan_get_size;
44549 - ops->fill_info = macvlan_fill_info;
44550 + pax_open_kernel();
44551 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
44552 + *(void **)&ops->validate = macvlan_validate;
44553 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
44554 + *(const void **)&ops->policy = macvlan_policy;
44555 + *(void **)&ops->changelink = macvlan_changelink;
44556 + *(void **)&ops->get_size = macvlan_get_size;
44557 + *(void **)&ops->fill_info = macvlan_fill_info;
44558 + pax_close_kernel();
44559
44560 return rtnl_link_register(ops);
44561 };
44562 @@ -967,7 +969,7 @@ static int macvlan_device_event(struct notifier_block *unused,
44563 return NOTIFY_DONE;
44564 }
44565
44566 -static struct notifier_block macvlan_notifier_block __read_mostly = {
44567 +static struct notifier_block macvlan_notifier_block = {
44568 .notifier_call = macvlan_device_event,
44569 };
44570
44571 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
44572 index 523d6b2..5e16aa1 100644
44573 --- a/drivers/net/macvtap.c
44574 +++ b/drivers/net/macvtap.c
44575 @@ -1110,7 +1110,7 @@ static int macvtap_device_event(struct notifier_block *unused,
44576 return NOTIFY_DONE;
44577 }
44578
44579 -static struct notifier_block macvtap_notifier_block __read_mostly = {
44580 +static struct notifier_block macvtap_notifier_block = {
44581 .notifier_call = macvtap_device_event,
44582 };
44583
44584 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
44585 index daec9b0..6428fcb 100644
44586 --- a/drivers/net/phy/mdio-bitbang.c
44587 +++ b/drivers/net/phy/mdio-bitbang.c
44588 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
44589 struct mdiobb_ctrl *ctrl = bus->priv;
44590
44591 module_put(ctrl->ops->owner);
44592 + mdiobus_unregister(bus);
44593 mdiobus_free(bus);
44594 }
44595 EXPORT_SYMBOL(free_mdio_bitbang);
44596 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
44597 index 72ff14b..11d442d 100644
44598 --- a/drivers/net/ppp/ppp_generic.c
44599 +++ b/drivers/net/ppp/ppp_generic.c
44600 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44601 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
44602 struct ppp_stats stats;
44603 struct ppp_comp_stats cstats;
44604 - char *vers;
44605
44606 switch (cmd) {
44607 case SIOCGPPPSTATS:
44608 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44609 break;
44610
44611 case SIOCGPPPVER:
44612 - vers = PPP_VERSION;
44613 - if (copy_to_user(addr, vers, strlen(vers) + 1))
44614 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
44615 break;
44616 err = 0;
44617 break;
44618 diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
44619 index 1252d9c..80e660b 100644
44620 --- a/drivers/net/slip/slhc.c
44621 +++ b/drivers/net/slip/slhc.c
44622 @@ -488,7 +488,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
44623 register struct tcphdr *thp;
44624 register struct iphdr *ip;
44625 register struct cstate *cs;
44626 - int len, hdrlen;
44627 + long len, hdrlen;
44628 unsigned char *cp = icp;
44629
44630 /* We've got a compressed packet; read the change byte */
44631 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
44632 index b305105..8ead6df 100644
44633 --- a/drivers/net/team/team.c
44634 +++ b/drivers/net/team/team.c
44635 @@ -2682,7 +2682,7 @@ static int team_device_event(struct notifier_block *unused,
44636 return NOTIFY_DONE;
44637 }
44638
44639 -static struct notifier_block team_notifier_block __read_mostly = {
44640 +static struct notifier_block team_notifier_block = {
44641 .notifier_call = team_device_event,
44642 };
44643
44644 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
44645 index 2491eb2..1a453eb 100644
44646 --- a/drivers/net/tun.c
44647 +++ b/drivers/net/tun.c
44648 @@ -1076,8 +1076,9 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
44649 u32 rxhash;
44650
44651 if (!(tun->flags & TUN_NO_PI)) {
44652 - if ((len -= sizeof(pi)) > total_len)
44653 + if (len < sizeof(pi))
44654 return -EINVAL;
44655 + len -= sizeof(pi);
44656
44657 if (memcpy_fromiovecend((void *)&pi, iv, 0, sizeof(pi)))
44658 return -EFAULT;
44659 @@ -1085,8 +1086,9 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
44660 }
44661
44662 if (tun->flags & TUN_VNET_HDR) {
44663 - if ((len -= tun->vnet_hdr_sz) > total_len)
44664 + if (len < tun->vnet_hdr_sz)
44665 return -EINVAL;
44666 + len -= tun->vnet_hdr_sz;
44667
44668 if (memcpy_fromiovecend((void *)&gso, iv, offset, sizeof(gso)))
44669 return -EFAULT;
44670 @@ -1869,7 +1871,7 @@ unlock:
44671 }
44672
44673 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
44674 - unsigned long arg, int ifreq_len)
44675 + unsigned long arg, size_t ifreq_len)
44676 {
44677 struct tun_file *tfile = file->private_data;
44678 struct tun_struct *tun;
44679 @@ -1881,6 +1883,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
44680 int vnet_hdr_sz;
44681 int ret;
44682
44683 + if (ifreq_len > sizeof ifr)
44684 + return -EFAULT;
44685 +
44686 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
44687 if (copy_from_user(&ifr, argp, ifreq_len))
44688 return -EFAULT;
44689 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
44690 index cba1d46..f703766 100644
44691 --- a/drivers/net/usb/hso.c
44692 +++ b/drivers/net/usb/hso.c
44693 @@ -71,7 +71,7 @@
44694 #include <asm/byteorder.h>
44695 #include <linux/serial_core.h>
44696 #include <linux/serial.h>
44697 -
44698 +#include <asm/local.h>
44699
44700 #define MOD_AUTHOR "Option Wireless"
44701 #define MOD_DESCRIPTION "USB High Speed Option driver"
44702 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
44703 struct urb *urb;
44704
44705 urb = serial->rx_urb[0];
44706 - if (serial->port.count > 0) {
44707 + if (atomic_read(&serial->port.count) > 0) {
44708 count = put_rxbuf_data(urb, serial);
44709 if (count == -1)
44710 return;
44711 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
44712 DUMP1(urb->transfer_buffer, urb->actual_length);
44713
44714 /* Anyone listening? */
44715 - if (serial->port.count == 0)
44716 + if (atomic_read(&serial->port.count) == 0)
44717 return;
44718
44719 if (status == 0) {
44720 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
44721 tty_port_tty_set(&serial->port, tty);
44722
44723 /* check for port already opened, if not set the termios */
44724 - serial->port.count++;
44725 - if (serial->port.count == 1) {
44726 + if (atomic_inc_return(&serial->port.count) == 1) {
44727 serial->rx_state = RX_IDLE;
44728 /* Force default termio settings */
44729 _hso_serial_set_termios(tty, NULL);
44730 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
44731 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
44732 if (result) {
44733 hso_stop_serial_device(serial->parent);
44734 - serial->port.count--;
44735 + atomic_dec(&serial->port.count);
44736 kref_put(&serial->parent->ref, hso_serial_ref_free);
44737 }
44738 } else {
44739 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
44740
44741 /* reset the rts and dtr */
44742 /* do the actual close */
44743 - serial->port.count--;
44744 + atomic_dec(&serial->port.count);
44745
44746 - if (serial->port.count <= 0) {
44747 - serial->port.count = 0;
44748 + if (atomic_read(&serial->port.count) <= 0) {
44749 + atomic_set(&serial->port.count, 0);
44750 tty_port_tty_set(&serial->port, NULL);
44751 if (!usb_gone)
44752 hso_stop_serial_device(serial->parent);
44753 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
44754
44755 /* the actual setup */
44756 spin_lock_irqsave(&serial->serial_lock, flags);
44757 - if (serial->port.count)
44758 + if (atomic_read(&serial->port.count))
44759 _hso_serial_set_termios(tty, old);
44760 else
44761 tty->termios = *old;
44762 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
44763 D1("Pending read interrupt on port %d\n", i);
44764 spin_lock(&serial->serial_lock);
44765 if (serial->rx_state == RX_IDLE &&
44766 - serial->port.count > 0) {
44767 + atomic_read(&serial->port.count) > 0) {
44768 /* Setup and send a ctrl req read on
44769 * port i */
44770 if (!serial->rx_urb_filled[0]) {
44771 @@ -3057,7 +3056,7 @@ static int hso_resume(struct usb_interface *iface)
44772 /* Start all serial ports */
44773 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
44774 if (serial_table[i] && (serial_table[i]->interface == iface)) {
44775 - if (dev2ser(serial_table[i])->port.count) {
44776 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
44777 result =
44778 hso_start_serial_device(serial_table[i], GFP_NOIO);
44779 hso_kick_transmit(dev2ser(serial_table[i]));
44780 diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
44781 index a79e9d3..78cd4fa 100644
44782 --- a/drivers/net/usb/sierra_net.c
44783 +++ b/drivers/net/usb/sierra_net.c
44784 @@ -52,7 +52,7 @@ static const char driver_name[] = "sierra_net";
44785 /* atomic counter partially included in MAC address to make sure 2 devices
44786 * do not end up with the same MAC - concept breaks in case of > 255 ifaces
44787 */
44788 -static atomic_t iface_counter = ATOMIC_INIT(0);
44789 +static atomic_unchecked_t iface_counter = ATOMIC_INIT(0);
44790
44791 /*
44792 * SYNC Timer Delay definition used to set the expiry time
44793 @@ -698,7 +698,7 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
44794 dev->net->netdev_ops = &sierra_net_device_ops;
44795
44796 /* change MAC addr to include, ifacenum, and to be unique */
44797 - dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return(&iface_counter);
44798 + dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return_unchecked(&iface_counter);
44799 dev->net->dev_addr[ETH_ALEN-1] = ifacenum;
44800
44801 /* we will have to manufacture ethernet headers, prepare template */
44802 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
44803 index 57325f3..36b181f 100644
44804 --- a/drivers/net/vxlan.c
44805 +++ b/drivers/net/vxlan.c
44806 @@ -1579,7 +1579,7 @@ nla_put_failure:
44807 return -EMSGSIZE;
44808 }
44809
44810 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
44811 +static struct rtnl_link_ops vxlan_link_ops = {
44812 .kind = "vxlan",
44813 .maxtype = IFLA_VXLAN_MAX,
44814 .policy = vxlan_policy,
44815 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
44816 index 34c8a33..3261fdc 100644
44817 --- a/drivers/net/wireless/at76c50x-usb.c
44818 +++ b/drivers/net/wireless/at76c50x-usb.c
44819 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
44820 }
44821
44822 /* Convert timeout from the DFU status to jiffies */
44823 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
44824 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
44825 {
44826 return msecs_to_jiffies((s->poll_timeout[2] << 16)
44827 | (s->poll_timeout[1] << 8)
44828 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44829 index 8d78253..bebbb68 100644
44830 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44831 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44832 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44833 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
44834 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
44835
44836 - ACCESS_ONCE(ads->ds_link) = i->link;
44837 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
44838 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
44839 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
44840
44841 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
44842 ctl6 = SM(i->keytype, AR_EncrType);
44843 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44844
44845 if ((i->is_first || i->is_last) &&
44846 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
44847 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
44848 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
44849 | set11nTries(i->rates, 1)
44850 | set11nTries(i->rates, 2)
44851 | set11nTries(i->rates, 3)
44852 | (i->dur_update ? AR_DurUpdateEna : 0)
44853 | SM(0, AR_BurstDur);
44854
44855 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
44856 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
44857 | set11nRate(i->rates, 1)
44858 | set11nRate(i->rates, 2)
44859 | set11nRate(i->rates, 3);
44860 } else {
44861 - ACCESS_ONCE(ads->ds_ctl2) = 0;
44862 - ACCESS_ONCE(ads->ds_ctl3) = 0;
44863 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
44864 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
44865 }
44866
44867 if (!i->is_first) {
44868 - ACCESS_ONCE(ads->ds_ctl0) = 0;
44869 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44870 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44871 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
44872 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44873 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44874 return;
44875 }
44876
44877 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44878 break;
44879 }
44880
44881 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44882 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44883 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
44884 | SM(i->txpower, AR_XmitPower)
44885 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
44886 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44887 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
44888 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
44889
44890 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44891 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44892 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44893 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44894
44895 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
44896 return;
44897
44898 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
44899 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
44900 | set11nPktDurRTSCTS(i->rates, 1);
44901
44902 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
44903 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
44904 | set11nPktDurRTSCTS(i->rates, 3);
44905
44906 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
44907 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
44908 | set11nRateFlags(i->rates, 1)
44909 | set11nRateFlags(i->rates, 2)
44910 | set11nRateFlags(i->rates, 3)
44911 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44912 index 301bf72..3f5654f 100644
44913 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44914 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44915 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44916 (i->qcu << AR_TxQcuNum_S) | desc_len;
44917
44918 checksum += val;
44919 - ACCESS_ONCE(ads->info) = val;
44920 + ACCESS_ONCE_RW(ads->info) = val;
44921
44922 checksum += i->link;
44923 - ACCESS_ONCE(ads->link) = i->link;
44924 + ACCESS_ONCE_RW(ads->link) = i->link;
44925
44926 checksum += i->buf_addr[0];
44927 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
44928 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
44929 checksum += i->buf_addr[1];
44930 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
44931 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
44932 checksum += i->buf_addr[2];
44933 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
44934 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
44935 checksum += i->buf_addr[3];
44936 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
44937 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
44938
44939 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
44940 - ACCESS_ONCE(ads->ctl3) = val;
44941 + ACCESS_ONCE_RW(ads->ctl3) = val;
44942 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
44943 - ACCESS_ONCE(ads->ctl5) = val;
44944 + ACCESS_ONCE_RW(ads->ctl5) = val;
44945 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
44946 - ACCESS_ONCE(ads->ctl7) = val;
44947 + ACCESS_ONCE_RW(ads->ctl7) = val;
44948 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
44949 - ACCESS_ONCE(ads->ctl9) = val;
44950 + ACCESS_ONCE_RW(ads->ctl9) = val;
44951
44952 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
44953 - ACCESS_ONCE(ads->ctl10) = checksum;
44954 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
44955
44956 if (i->is_first || i->is_last) {
44957 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
44958 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
44959 | set11nTries(i->rates, 1)
44960 | set11nTries(i->rates, 2)
44961 | set11nTries(i->rates, 3)
44962 | (i->dur_update ? AR_DurUpdateEna : 0)
44963 | SM(0, AR_BurstDur);
44964
44965 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
44966 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
44967 | set11nRate(i->rates, 1)
44968 | set11nRate(i->rates, 2)
44969 | set11nRate(i->rates, 3);
44970 } else {
44971 - ACCESS_ONCE(ads->ctl13) = 0;
44972 - ACCESS_ONCE(ads->ctl14) = 0;
44973 + ACCESS_ONCE_RW(ads->ctl13) = 0;
44974 + ACCESS_ONCE_RW(ads->ctl14) = 0;
44975 }
44976
44977 ads->ctl20 = 0;
44978 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44979
44980 ctl17 = SM(i->keytype, AR_EncrType);
44981 if (!i->is_first) {
44982 - ACCESS_ONCE(ads->ctl11) = 0;
44983 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
44984 - ACCESS_ONCE(ads->ctl15) = 0;
44985 - ACCESS_ONCE(ads->ctl16) = 0;
44986 - ACCESS_ONCE(ads->ctl17) = ctl17;
44987 - ACCESS_ONCE(ads->ctl18) = 0;
44988 - ACCESS_ONCE(ads->ctl19) = 0;
44989 + ACCESS_ONCE_RW(ads->ctl11) = 0;
44990 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
44991 + ACCESS_ONCE_RW(ads->ctl15) = 0;
44992 + ACCESS_ONCE_RW(ads->ctl16) = 0;
44993 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
44994 + ACCESS_ONCE_RW(ads->ctl18) = 0;
44995 + ACCESS_ONCE_RW(ads->ctl19) = 0;
44996 return;
44997 }
44998
44999 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
45000 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
45001 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
45002 | SM(i->txpower, AR_XmitPower)
45003 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
45004 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
45005 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
45006 ctl12 |= SM(val, AR_PAPRDChainMask);
45007
45008 - ACCESS_ONCE(ads->ctl12) = ctl12;
45009 - ACCESS_ONCE(ads->ctl17) = ctl17;
45010 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
45011 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
45012
45013 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
45014 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
45015 | set11nPktDurRTSCTS(i->rates, 1);
45016
45017 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
45018 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
45019 | set11nPktDurRTSCTS(i->rates, 3);
45020
45021 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
45022 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
45023 | set11nRateFlags(i->rates, 1)
45024 | set11nRateFlags(i->rates, 2)
45025 | set11nRateFlags(i->rates, 3)
45026 | SM(i->rtscts_rate, AR_RTSCTSRate);
45027
45028 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
45029 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
45030 }
45031
45032 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
45033 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
45034 index ae30343..a117806 100644
45035 --- a/drivers/net/wireless/ath/ath9k/hw.h
45036 +++ b/drivers/net/wireless/ath/ath9k/hw.h
45037 @@ -652,7 +652,7 @@ struct ath_hw_private_ops {
45038
45039 /* ANI */
45040 void (*ani_cache_ini_regs)(struct ath_hw *ah);
45041 -};
45042 +} __no_const;
45043
45044 /**
45045 * struct ath_spec_scan - parameters for Atheros spectral scan
45046 @@ -721,7 +721,7 @@ struct ath_hw_ops {
45047 struct ath_spec_scan *param);
45048 void (*spectral_scan_trigger)(struct ath_hw *ah);
45049 void (*spectral_scan_wait)(struct ath_hw *ah);
45050 -};
45051 +} __no_const;
45052
45053 struct ath_nf_limits {
45054 s16 max;
45055 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
45056 index b37a582..680835d 100644
45057 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
45058 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
45059 @@ -3639,7 +3639,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
45060 */
45061 if (il3945_mod_params.disable_hw_scan) {
45062 D_INFO("Disabling hw_scan\n");
45063 - il3945_mac_ops.hw_scan = NULL;
45064 + pax_open_kernel();
45065 + *(void **)&il3945_mac_ops.hw_scan = NULL;
45066 + pax_close_kernel();
45067 }
45068
45069 D_INFO("*** LOAD DRIVER ***\n");
45070 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
45071 index d532948..e0d8bb1 100644
45072 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
45073 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
45074 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
45075 {
45076 struct iwl_priv *priv = file->private_data;
45077 char buf[64];
45078 - int buf_size;
45079 + size_t buf_size;
45080 u32 offset, len;
45081
45082 memset(buf, 0, sizeof(buf));
45083 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
45084 struct iwl_priv *priv = file->private_data;
45085
45086 char buf[8];
45087 - int buf_size;
45088 + size_t buf_size;
45089 u32 reset_flag;
45090
45091 memset(buf, 0, sizeof(buf));
45092 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
45093 {
45094 struct iwl_priv *priv = file->private_data;
45095 char buf[8];
45096 - int buf_size;
45097 + size_t buf_size;
45098 int ht40;
45099
45100 memset(buf, 0, sizeof(buf));
45101 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
45102 {
45103 struct iwl_priv *priv = file->private_data;
45104 char buf[8];
45105 - int buf_size;
45106 + size_t buf_size;
45107 int value;
45108
45109 memset(buf, 0, sizeof(buf));
45110 @@ -698,10 +698,10 @@ DEBUGFS_READ_FILE_OPS(temperature);
45111 DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
45112 DEBUGFS_READ_FILE_OPS(current_sleep_command);
45113
45114 -static const char *fmt_value = " %-30s %10u\n";
45115 -static const char *fmt_hex = " %-30s 0x%02X\n";
45116 -static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
45117 -static const char *fmt_header =
45118 +static const char fmt_value[] = " %-30s %10u\n";
45119 +static const char fmt_hex[] = " %-30s 0x%02X\n";
45120 +static const char fmt_table[] = " %-30s %10u %10u %10u %10u\n";
45121 +static const char fmt_header[] =
45122 "%-32s current cumulative delta max\n";
45123
45124 static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
45125 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
45126 {
45127 struct iwl_priv *priv = file->private_data;
45128 char buf[8];
45129 - int buf_size;
45130 + size_t buf_size;
45131 int clear;
45132
45133 memset(buf, 0, sizeof(buf));
45134 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
45135 {
45136 struct iwl_priv *priv = file->private_data;
45137 char buf[8];
45138 - int buf_size;
45139 + size_t buf_size;
45140 int trace;
45141
45142 memset(buf, 0, sizeof(buf));
45143 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
45144 {
45145 struct iwl_priv *priv = file->private_data;
45146 char buf[8];
45147 - int buf_size;
45148 + size_t buf_size;
45149 int missed;
45150
45151 memset(buf, 0, sizeof(buf));
45152 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
45153
45154 struct iwl_priv *priv = file->private_data;
45155 char buf[8];
45156 - int buf_size;
45157 + size_t buf_size;
45158 int plcp;
45159
45160 memset(buf, 0, sizeof(buf));
45161 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
45162
45163 struct iwl_priv *priv = file->private_data;
45164 char buf[8];
45165 - int buf_size;
45166 + size_t buf_size;
45167 int flush;
45168
45169 memset(buf, 0, sizeof(buf));
45170 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
45171
45172 struct iwl_priv *priv = file->private_data;
45173 char buf[8];
45174 - int buf_size;
45175 + size_t buf_size;
45176 int rts;
45177
45178 if (!priv->cfg->ht_params)
45179 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
45180 {
45181 struct iwl_priv *priv = file->private_data;
45182 char buf[8];
45183 - int buf_size;
45184 + size_t buf_size;
45185
45186 memset(buf, 0, sizeof(buf));
45187 buf_size = min(count, sizeof(buf) - 1);
45188 @@ -2254,7 +2254,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
45189 struct iwl_priv *priv = file->private_data;
45190 u32 event_log_flag;
45191 char buf[8];
45192 - int buf_size;
45193 + size_t buf_size;
45194
45195 /* check that the interface is up */
45196 if (!iwl_is_ready(priv))
45197 @@ -2308,7 +2308,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
45198 struct iwl_priv *priv = file->private_data;
45199 char buf[8];
45200 u32 calib_disabled;
45201 - int buf_size;
45202 + size_t buf_size;
45203
45204 memset(buf, 0, sizeof(buf));
45205 buf_size = min(count, sizeof(buf) - 1);
45206 diff --git a/drivers/net/wireless/iwlwifi/dvm/main.c b/drivers/net/wireless/iwlwifi/dvm/main.c
45207 index a8afc7b..de058b2 100644
45208 --- a/drivers/net/wireless/iwlwifi/dvm/main.c
45209 +++ b/drivers/net/wireless/iwlwifi/dvm/main.c
45210 @@ -1189,7 +1189,7 @@ static void iwl_option_config(struct iwl_priv *priv)
45211 static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
45212 {
45213 struct iwl_nvm_data *data = priv->nvm_data;
45214 - char *debug_msg;
45215 + static const char debug_msg[] = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
45216
45217 if (data->sku_cap_11n_enable &&
45218 !priv->cfg->ht_params) {
45219 @@ -1203,7 +1203,6 @@ static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
45220 return -EINVAL;
45221 }
45222
45223 - debug_msg = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
45224 IWL_DEBUG_INFO(priv, debug_msg,
45225 data->sku_cap_band_24GHz_enable ? "" : "NOT", "enabled",
45226 data->sku_cap_band_52GHz_enable ? "" : "NOT", "enabled",
45227 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
45228 index aeb70e1..d7b5bb5 100644
45229 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
45230 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
45231 @@ -1329,7 +1329,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
45232 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
45233
45234 char buf[8];
45235 - int buf_size;
45236 + size_t buf_size;
45237 u32 reset_flag;
45238
45239 memset(buf, 0, sizeof(buf));
45240 @@ -1350,7 +1350,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
45241 {
45242 struct iwl_trans *trans = file->private_data;
45243 char buf[8];
45244 - int buf_size;
45245 + size_t buf_size;
45246 int csr;
45247
45248 memset(buf, 0, sizeof(buf));
45249 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
45250 index cb34c78..9fec0dc 100644
45251 --- a/drivers/net/wireless/mac80211_hwsim.c
45252 +++ b/drivers/net/wireless/mac80211_hwsim.c
45253 @@ -2195,25 +2195,19 @@ static int __init init_mac80211_hwsim(void)
45254
45255 if (channels > 1) {
45256 hwsim_if_comb.num_different_channels = channels;
45257 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
45258 - mac80211_hwsim_ops.cancel_hw_scan =
45259 - mac80211_hwsim_cancel_hw_scan;
45260 - mac80211_hwsim_ops.sw_scan_start = NULL;
45261 - mac80211_hwsim_ops.sw_scan_complete = NULL;
45262 - mac80211_hwsim_ops.remain_on_channel =
45263 - mac80211_hwsim_roc;
45264 - mac80211_hwsim_ops.cancel_remain_on_channel =
45265 - mac80211_hwsim_croc;
45266 - mac80211_hwsim_ops.add_chanctx =
45267 - mac80211_hwsim_add_chanctx;
45268 - mac80211_hwsim_ops.remove_chanctx =
45269 - mac80211_hwsim_remove_chanctx;
45270 - mac80211_hwsim_ops.change_chanctx =
45271 - mac80211_hwsim_change_chanctx;
45272 - mac80211_hwsim_ops.assign_vif_chanctx =
45273 - mac80211_hwsim_assign_vif_chanctx;
45274 - mac80211_hwsim_ops.unassign_vif_chanctx =
45275 - mac80211_hwsim_unassign_vif_chanctx;
45276 + pax_open_kernel();
45277 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
45278 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
45279 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
45280 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
45281 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
45282 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
45283 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
45284 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
45285 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
45286 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
45287 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
45288 + pax_close_kernel();
45289 }
45290
45291 spin_lock_init(&hwsim_radio_lock);
45292 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
45293 index 8169a85..7fa3b47 100644
45294 --- a/drivers/net/wireless/rndis_wlan.c
45295 +++ b/drivers/net/wireless/rndis_wlan.c
45296 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
45297
45298 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
45299
45300 - if (rts_threshold < 0 || rts_threshold > 2347)
45301 + if (rts_threshold > 2347)
45302 rts_threshold = 2347;
45303
45304 tmp = cpu_to_le32(rts_threshold);
45305 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
45306 index 7510723..5ba37f5 100644
45307 --- a/drivers/net/wireless/rt2x00/rt2x00.h
45308 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
45309 @@ -386,7 +386,7 @@ struct rt2x00_intf {
45310 * for hardware which doesn't support hardware
45311 * sequence counting.
45312 */
45313 - atomic_t seqno;
45314 + atomic_unchecked_t seqno;
45315 };
45316
45317 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
45318 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
45319 index d955741..8730748 100644
45320 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
45321 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
45322 @@ -252,9 +252,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
45323 * sequence counter given by mac80211.
45324 */
45325 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
45326 - seqno = atomic_add_return(0x10, &intf->seqno);
45327 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
45328 else
45329 - seqno = atomic_read(&intf->seqno);
45330 + seqno = atomic_read_unchecked(&intf->seqno);
45331
45332 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
45333 hdr->seq_ctrl |= cpu_to_le16(seqno);
45334 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
45335 index e2b3d9c..67a5184 100644
45336 --- a/drivers/net/wireless/ti/wl1251/sdio.c
45337 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
45338 @@ -271,13 +271,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
45339
45340 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
45341
45342 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
45343 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
45344 + pax_open_kernel();
45345 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
45346 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
45347 + pax_close_kernel();
45348
45349 wl1251_info("using dedicated interrupt line");
45350 } else {
45351 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
45352 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
45353 + pax_open_kernel();
45354 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
45355 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
45356 + pax_close_kernel();
45357
45358 wl1251_info("using SDIO interrupt");
45359 }
45360 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
45361 index 1c627da..69f7d17 100644
45362 --- a/drivers/net/wireless/ti/wl12xx/main.c
45363 +++ b/drivers/net/wireless/ti/wl12xx/main.c
45364 @@ -656,7 +656,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
45365 sizeof(wl->conf.mem));
45366
45367 /* read data preparation is only needed by wl127x */
45368 - wl->ops->prepare_read = wl127x_prepare_read;
45369 + pax_open_kernel();
45370 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
45371 + pax_close_kernel();
45372
45373 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
45374 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
45375 @@ -681,7 +683,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
45376 sizeof(wl->conf.mem));
45377
45378 /* read data preparation is only needed by wl127x */
45379 - wl->ops->prepare_read = wl127x_prepare_read;
45380 + pax_open_kernel();
45381 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
45382 + pax_close_kernel();
45383
45384 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
45385 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
45386 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
45387 index 9fa692d..b31fee0 100644
45388 --- a/drivers/net/wireless/ti/wl18xx/main.c
45389 +++ b/drivers/net/wireless/ti/wl18xx/main.c
45390 @@ -1687,8 +1687,10 @@ static int wl18xx_setup(struct wl1271 *wl)
45391 }
45392
45393 if (!checksum_param) {
45394 - wl18xx_ops.set_rx_csum = NULL;
45395 - wl18xx_ops.init_vif = NULL;
45396 + pax_open_kernel();
45397 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
45398 + *(void **)&wl18xx_ops.init_vif = NULL;
45399 + pax_close_kernel();
45400 }
45401
45402 /* Enable 11a Band only if we have 5G antennas */
45403 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
45404 index 7ef0b4a..ff65c28 100644
45405 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
45406 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
45407 @@ -386,7 +386,7 @@ static inline void handle_regs_int(struct urb *urb)
45408 {
45409 struct zd_usb *usb = urb->context;
45410 struct zd_usb_interrupt *intr = &usb->intr;
45411 - int len;
45412 + unsigned int len;
45413 u16 int_num;
45414
45415 ZD_ASSERT(in_interrupt());
45416 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
45417 index d93b2b6..ae50401 100644
45418 --- a/drivers/oprofile/buffer_sync.c
45419 +++ b/drivers/oprofile/buffer_sync.c
45420 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
45421 if (cookie == NO_COOKIE)
45422 offset = pc;
45423 if (cookie == INVALID_COOKIE) {
45424 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
45425 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
45426 offset = pc;
45427 }
45428 if (cookie != last_cookie) {
45429 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
45430 /* add userspace sample */
45431
45432 if (!mm) {
45433 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
45434 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
45435 return 0;
45436 }
45437
45438 cookie = lookup_dcookie(mm, s->eip, &offset);
45439
45440 if (cookie == INVALID_COOKIE) {
45441 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
45442 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
45443 return 0;
45444 }
45445
45446 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
45447 /* ignore backtraces if failed to add a sample */
45448 if (state == sb_bt_start) {
45449 state = sb_bt_ignore;
45450 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
45451 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
45452 }
45453 }
45454 release_mm(mm);
45455 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
45456 index c0cc4e7..44d4e54 100644
45457 --- a/drivers/oprofile/event_buffer.c
45458 +++ b/drivers/oprofile/event_buffer.c
45459 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
45460 }
45461
45462 if (buffer_pos == buffer_size) {
45463 - atomic_inc(&oprofile_stats.event_lost_overflow);
45464 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
45465 return;
45466 }
45467
45468 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
45469 index ed2c3ec..deda85a 100644
45470 --- a/drivers/oprofile/oprof.c
45471 +++ b/drivers/oprofile/oprof.c
45472 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
45473 if (oprofile_ops.switch_events())
45474 return;
45475
45476 - atomic_inc(&oprofile_stats.multiplex_counter);
45477 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
45478 start_switch_worker();
45479 }
45480
45481 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
45482 index 84a208d..d61b0a1 100644
45483 --- a/drivers/oprofile/oprofile_files.c
45484 +++ b/drivers/oprofile/oprofile_files.c
45485 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
45486
45487 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
45488
45489 -static ssize_t timeout_read(struct file *file, char __user *buf,
45490 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
45491 size_t count, loff_t *offset)
45492 {
45493 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
45494 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
45495 index 917d28e..d62d981 100644
45496 --- a/drivers/oprofile/oprofile_stats.c
45497 +++ b/drivers/oprofile/oprofile_stats.c
45498 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
45499 cpu_buf->sample_invalid_eip = 0;
45500 }
45501
45502 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
45503 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
45504 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
45505 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
45506 - atomic_set(&oprofile_stats.multiplex_counter, 0);
45507 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
45508 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
45509 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
45510 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
45511 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
45512 }
45513
45514
45515 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
45516 index 38b6fc0..b5cbfce 100644
45517 --- a/drivers/oprofile/oprofile_stats.h
45518 +++ b/drivers/oprofile/oprofile_stats.h
45519 @@ -13,11 +13,11 @@
45520 #include <linux/atomic.h>
45521
45522 struct oprofile_stat_struct {
45523 - atomic_t sample_lost_no_mm;
45524 - atomic_t sample_lost_no_mapping;
45525 - atomic_t bt_lost_no_mapping;
45526 - atomic_t event_lost_overflow;
45527 - atomic_t multiplex_counter;
45528 + atomic_unchecked_t sample_lost_no_mm;
45529 + atomic_unchecked_t sample_lost_no_mapping;
45530 + atomic_unchecked_t bt_lost_no_mapping;
45531 + atomic_unchecked_t event_lost_overflow;
45532 + atomic_unchecked_t multiplex_counter;
45533 };
45534
45535 extern struct oprofile_stat_struct oprofile_stats;
45536 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
45537 index 7c12d9c..558bf3bb 100644
45538 --- a/drivers/oprofile/oprofilefs.c
45539 +++ b/drivers/oprofile/oprofilefs.c
45540 @@ -190,7 +190,7 @@ static const struct file_operations atomic_ro_fops = {
45541
45542
45543 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
45544 - char const *name, atomic_t *val)
45545 + char const *name, atomic_unchecked_t *val)
45546 {
45547 return __oprofilefs_create_file(sb, root, name,
45548 &atomic_ro_fops, 0444, val);
45549 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
45550 index 93404f7..4a313d8 100644
45551 --- a/drivers/oprofile/timer_int.c
45552 +++ b/drivers/oprofile/timer_int.c
45553 @@ -93,7 +93,7 @@ static int __cpuinit oprofile_cpu_notify(struct notifier_block *self,
45554 return NOTIFY_OK;
45555 }
45556
45557 -static struct notifier_block __refdata oprofile_cpu_notifier = {
45558 +static struct notifier_block oprofile_cpu_notifier = {
45559 .notifier_call = oprofile_cpu_notify,
45560 };
45561
45562 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
45563 index 92ed045..62d39bd7 100644
45564 --- a/drivers/parport/procfs.c
45565 +++ b/drivers/parport/procfs.c
45566 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
45567
45568 *ppos += len;
45569
45570 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
45571 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
45572 }
45573
45574 #ifdef CONFIG_PARPORT_1284
45575 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
45576
45577 *ppos += len;
45578
45579 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
45580 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
45581 }
45582 #endif /* IEEE1284.3 support. */
45583
45584 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
45585 index c35e8ad..fc33beb 100644
45586 --- a/drivers/pci/hotplug/acpiphp_ibm.c
45587 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
45588 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
45589 goto init_cleanup;
45590 }
45591
45592 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
45593 + pax_open_kernel();
45594 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
45595 + pax_close_kernel();
45596 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
45597
45598 return retval;
45599 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
45600 index a6a71c4..c91097b 100644
45601 --- a/drivers/pci/hotplug/cpcihp_generic.c
45602 +++ b/drivers/pci/hotplug/cpcihp_generic.c
45603 @@ -73,7 +73,6 @@ static u16 port;
45604 static unsigned int enum_bit;
45605 static u8 enum_mask;
45606
45607 -static struct cpci_hp_controller_ops generic_hpc_ops;
45608 static struct cpci_hp_controller generic_hpc;
45609
45610 static int __init validate_parameters(void)
45611 @@ -139,6 +138,10 @@ static int query_enum(void)
45612 return ((value & enum_mask) == enum_mask);
45613 }
45614
45615 +static struct cpci_hp_controller_ops generic_hpc_ops = {
45616 + .query_enum = query_enum,
45617 +};
45618 +
45619 static int __init cpcihp_generic_init(void)
45620 {
45621 int status;
45622 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
45623 pci_dev_put(dev);
45624
45625 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
45626 - generic_hpc_ops.query_enum = query_enum;
45627 generic_hpc.ops = &generic_hpc_ops;
45628
45629 status = cpci_hp_register_controller(&generic_hpc);
45630 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
45631 index 449b4bb..257e2e8 100644
45632 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
45633 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
45634 @@ -59,7 +59,6 @@
45635 /* local variables */
45636 static bool debug;
45637 static bool poll;
45638 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
45639 static struct cpci_hp_controller zt5550_hpc;
45640
45641 /* Primary cPCI bus bridge device */
45642 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
45643 return 0;
45644 }
45645
45646 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
45647 + .query_enum = zt5550_hc_query_enum,
45648 +};
45649 +
45650 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
45651 {
45652 int status;
45653 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
45654 dbg("returned from zt5550_hc_config");
45655
45656 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
45657 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
45658 zt5550_hpc.ops = &zt5550_hpc_ops;
45659 if(!poll) {
45660 zt5550_hpc.irq = hc_dev->irq;
45661 zt5550_hpc.irq_flags = IRQF_SHARED;
45662 zt5550_hpc.dev_id = hc_dev;
45663
45664 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45665 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45666 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45667 + pax_open_kernel();
45668 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45669 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45670 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45671 + pax_open_kernel();
45672 } else {
45673 info("using ENUM# polling mode");
45674 }
45675 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
45676 index 76ba8a1..20ca857 100644
45677 --- a/drivers/pci/hotplug/cpqphp_nvram.c
45678 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
45679 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
45680
45681 void compaq_nvram_init (void __iomem *rom_start)
45682 {
45683 +
45684 +#ifndef CONFIG_PAX_KERNEXEC
45685 if (rom_start) {
45686 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
45687 }
45688 +#endif
45689 +
45690 dbg("int15 entry = %p\n", compaq_int15_entry_point);
45691
45692 /* initialize our int15 lock */
45693 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
45694 index ec20f74..c1d961e 100644
45695 --- a/drivers/pci/hotplug/pci_hotplug_core.c
45696 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
45697 @@ -441,8 +441,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
45698 return -EINVAL;
45699 }
45700
45701 - slot->ops->owner = owner;
45702 - slot->ops->mod_name = mod_name;
45703 + pax_open_kernel();
45704 + *(struct module **)&slot->ops->owner = owner;
45705 + *(const char **)&slot->ops->mod_name = mod_name;
45706 + pax_close_kernel();
45707
45708 mutex_lock(&pci_hp_mutex);
45709 /*
45710 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
45711 index 7d72c5e..edce02c 100644
45712 --- a/drivers/pci/hotplug/pciehp_core.c
45713 +++ b/drivers/pci/hotplug/pciehp_core.c
45714 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
45715 struct slot *slot = ctrl->slot;
45716 struct hotplug_slot *hotplug = NULL;
45717 struct hotplug_slot_info *info = NULL;
45718 - struct hotplug_slot_ops *ops = NULL;
45719 + hotplug_slot_ops_no_const *ops = NULL;
45720 char name[SLOT_NAME_SIZE];
45721 int retval = -ENOMEM;
45722
45723 diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
45724 index 5127f3f..b225573 100644
45725 --- a/drivers/pci/hotplug/pciehp_hpc.c
45726 +++ b/drivers/pci/hotplug/pciehp_hpc.c
45727 @@ -773,14 +773,12 @@ static void pcie_shutdown_notification(struct controller *ctrl)
45728 static int pcie_init_slot(struct controller *ctrl)
45729 {
45730 struct slot *slot;
45731 - char name[32];
45732
45733 slot = kzalloc(sizeof(*slot), GFP_KERNEL);
45734 if (!slot)
45735 return -ENOMEM;
45736
45737 - snprintf(name, sizeof(name), "pciehp-%u", PSN(ctrl));
45738 - slot->wq = alloc_workqueue(name, 0, 0);
45739 + slot->wq = alloc_workqueue("pciehp-%u", 0, 0, PSN(ctrl));
45740 if (!slot->wq)
45741 goto abort;
45742
45743 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
45744 index 5b4a9d9..cd5ac1f 100644
45745 --- a/drivers/pci/pci-sysfs.c
45746 +++ b/drivers/pci/pci-sysfs.c
45747 @@ -1071,7 +1071,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
45748 {
45749 /* allocate attribute structure, piggyback attribute name */
45750 int name_len = write_combine ? 13 : 10;
45751 - struct bin_attribute *res_attr;
45752 + bin_attribute_no_const *res_attr;
45753 int retval;
45754
45755 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
45756 @@ -1256,7 +1256,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
45757 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
45758 {
45759 int retval;
45760 - struct bin_attribute *attr;
45761 + bin_attribute_no_const *attr;
45762
45763 /* If the device has VPD, try to expose it in sysfs. */
45764 if (dev->vpd) {
45765 @@ -1303,7 +1303,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
45766 {
45767 int retval;
45768 int rom_size = 0;
45769 - struct bin_attribute *attr;
45770 + bin_attribute_no_const *attr;
45771
45772 if (!sysfs_initialized)
45773 return -EACCES;
45774 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
45775 index d1182c4..2a138ec 100644
45776 --- a/drivers/pci/pci.h
45777 +++ b/drivers/pci/pci.h
45778 @@ -92,7 +92,7 @@ struct pci_vpd_ops {
45779 struct pci_vpd {
45780 unsigned int len;
45781 const struct pci_vpd_ops *ops;
45782 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
45783 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
45784 };
45785
45786 int pci_vpd_pci22_init(struct pci_dev *dev);
45787 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
45788 index d320df6..ca9a8f6 100644
45789 --- a/drivers/pci/pcie/aspm.c
45790 +++ b/drivers/pci/pcie/aspm.c
45791 @@ -27,9 +27,9 @@
45792 #define MODULE_PARAM_PREFIX "pcie_aspm."
45793
45794 /* Note: those are not register definitions */
45795 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
45796 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
45797 -#define ASPM_STATE_L1 (4) /* L1 state */
45798 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
45799 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
45800 +#define ASPM_STATE_L1 (4U) /* L1 state */
45801 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
45802 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
45803
45804 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
45805 index ea37072..10e58e56 100644
45806 --- a/drivers/pci/probe.c
45807 +++ b/drivers/pci/probe.c
45808 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
45809 struct pci_bus_region region;
45810 bool bar_too_big = false, bar_disabled = false;
45811
45812 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
45813 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
45814
45815 /* No printks while decoding is disabled! */
45816 if (!dev->mmio_always_on) {
45817 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
45818 index 0812608..b04018c4 100644
45819 --- a/drivers/pci/proc.c
45820 +++ b/drivers/pci/proc.c
45821 @@ -453,7 +453,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
45822 static int __init pci_proc_init(void)
45823 {
45824 struct pci_dev *dev = NULL;
45825 +
45826 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
45827 +#ifdef CONFIG_GRKERNSEC_PROC_USER
45828 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
45829 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
45830 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
45831 +#endif
45832 +#else
45833 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
45834 +#endif
45835 proc_create("devices", 0, proc_bus_pci_dir,
45836 &proc_bus_pci_dev_operations);
45837 proc_initialized = 1;
45838 diff --git a/drivers/platform/x86/chromeos_laptop.c b/drivers/platform/x86/chromeos_laptop.c
45839 index 3e5b4497..dcdfb70 100644
45840 --- a/drivers/platform/x86/chromeos_laptop.c
45841 +++ b/drivers/platform/x86/chromeos_laptop.c
45842 @@ -301,7 +301,7 @@ static int __init setup_tsl2563_als(const struct dmi_system_id *id)
45843 return 0;
45844 }
45845
45846 -static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = {
45847 +static struct dmi_system_id __initconst chromeos_laptop_dmi_table[] = {
45848 {
45849 .ident = "Samsung Series 5 550 - Touchpad",
45850 .matches = {
45851 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
45852 index 6b22938..bc9700e 100644
45853 --- a/drivers/platform/x86/msi-laptop.c
45854 +++ b/drivers/platform/x86/msi-laptop.c
45855 @@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
45856
45857 if (!quirks->ec_read_only) {
45858 /* allow userland write sysfs file */
45859 - dev_attr_bluetooth.store = store_bluetooth;
45860 - dev_attr_wlan.store = store_wlan;
45861 - dev_attr_threeg.store = store_threeg;
45862 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
45863 - dev_attr_wlan.attr.mode |= S_IWUSR;
45864 - dev_attr_threeg.attr.mode |= S_IWUSR;
45865 + pax_open_kernel();
45866 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
45867 + *(void **)&dev_attr_wlan.store = store_wlan;
45868 + *(void **)&dev_attr_threeg.store = store_threeg;
45869 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
45870 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
45871 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
45872 + pax_close_kernel();
45873 }
45874
45875 /* disable hardware control by fn key */
45876 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
45877 index 2ac045f..39c443d 100644
45878 --- a/drivers/platform/x86/sony-laptop.c
45879 +++ b/drivers/platform/x86/sony-laptop.c
45880 @@ -2483,7 +2483,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
45881 }
45882
45883 /* High speed charging function */
45884 -static struct device_attribute *hsc_handle;
45885 +static device_attribute_no_const *hsc_handle;
45886
45887 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
45888 struct device_attribute *attr,
45889 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
45890 index 54d31c0..3f896d3 100644
45891 --- a/drivers/platform/x86/thinkpad_acpi.c
45892 +++ b/drivers/platform/x86/thinkpad_acpi.c
45893 @@ -2093,7 +2093,7 @@ static int hotkey_mask_get(void)
45894 return 0;
45895 }
45896
45897 -void static hotkey_mask_warn_incomplete_mask(void)
45898 +static void hotkey_mask_warn_incomplete_mask(void)
45899 {
45900 /* log only what the user can fix... */
45901 const u32 wantedmask = hotkey_driver_mask &
45902 @@ -2324,11 +2324,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
45903 }
45904 }
45905
45906 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45907 - struct tp_nvram_state *newn,
45908 - const u32 event_mask)
45909 -{
45910 -
45911 #define TPACPI_COMPARE_KEY(__scancode, __member) \
45912 do { \
45913 if ((event_mask & (1 << __scancode)) && \
45914 @@ -2342,36 +2337,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45915 tpacpi_hotkey_send_key(__scancode); \
45916 } while (0)
45917
45918 - void issue_volchange(const unsigned int oldvol,
45919 - const unsigned int newvol)
45920 - {
45921 - unsigned int i = oldvol;
45922 +static void issue_volchange(const unsigned int oldvol,
45923 + const unsigned int newvol,
45924 + const u32 event_mask)
45925 +{
45926 + unsigned int i = oldvol;
45927
45928 - while (i > newvol) {
45929 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
45930 - i--;
45931 - }
45932 - while (i < newvol) {
45933 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45934 - i++;
45935 - }
45936 + while (i > newvol) {
45937 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
45938 + i--;
45939 }
45940 + while (i < newvol) {
45941 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45942 + i++;
45943 + }
45944 +}
45945
45946 - void issue_brightnesschange(const unsigned int oldbrt,
45947 - const unsigned int newbrt)
45948 - {
45949 - unsigned int i = oldbrt;
45950 +static void issue_brightnesschange(const unsigned int oldbrt,
45951 + const unsigned int newbrt,
45952 + const u32 event_mask)
45953 +{
45954 + unsigned int i = oldbrt;
45955
45956 - while (i > newbrt) {
45957 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
45958 - i--;
45959 - }
45960 - while (i < newbrt) {
45961 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45962 - i++;
45963 - }
45964 + while (i > newbrt) {
45965 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
45966 + i--;
45967 + }
45968 + while (i < newbrt) {
45969 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45970 + i++;
45971 }
45972 +}
45973
45974 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45975 + struct tp_nvram_state *newn,
45976 + const u32 event_mask)
45977 +{
45978 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
45979 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
45980 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
45981 @@ -2405,7 +2406,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45982 oldn->volume_level != newn->volume_level) {
45983 /* recently muted, or repeated mute keypress, or
45984 * multiple presses ending in mute */
45985 - issue_volchange(oldn->volume_level, newn->volume_level);
45986 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
45987 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
45988 }
45989 } else {
45990 @@ -2415,7 +2416,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45991 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45992 }
45993 if (oldn->volume_level != newn->volume_level) {
45994 - issue_volchange(oldn->volume_level, newn->volume_level);
45995 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
45996 } else if (oldn->volume_toggle != newn->volume_toggle) {
45997 /* repeated vol up/down keypress at end of scale ? */
45998 if (newn->volume_level == 0)
45999 @@ -2428,7 +2429,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
46000 /* handle brightness */
46001 if (oldn->brightness_level != newn->brightness_level) {
46002 issue_brightnesschange(oldn->brightness_level,
46003 - newn->brightness_level);
46004 + newn->brightness_level,
46005 + event_mask);
46006 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
46007 /* repeated key presses that didn't change state */
46008 if (newn->brightness_level == 0)
46009 @@ -2437,10 +2439,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
46010 && !tp_features.bright_unkfw)
46011 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
46012 }
46013 +}
46014
46015 #undef TPACPI_COMPARE_KEY
46016 #undef TPACPI_MAY_SEND_KEY
46017 -}
46018
46019 /*
46020 * Polling driver
46021 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
46022 index e4ac38a..b13344c 100644
46023 --- a/drivers/platform/x86/wmi.c
46024 +++ b/drivers/platform/x86/wmi.c
46025 @@ -743,7 +743,7 @@ static int wmi_create_device(const struct guid_block *gblock,
46026 wblock->dev.class = &wmi_class;
46027
46028 wmi_gtoa(gblock->guid, guid_string);
46029 - dev_set_name(&wblock->dev, guid_string);
46030 + dev_set_name(&wblock->dev, "%s", guid_string);
46031
46032 dev_set_drvdata(&wblock->dev, wblock);
46033
46034 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
46035 index 769d265..a3a05ca 100644
46036 --- a/drivers/pnp/pnpbios/bioscalls.c
46037 +++ b/drivers/pnp/pnpbios/bioscalls.c
46038 @@ -58,7 +58,7 @@ do { \
46039 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
46040 } while(0)
46041
46042 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
46043 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
46044 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
46045
46046 /*
46047 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
46048
46049 cpu = get_cpu();
46050 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
46051 +
46052 + pax_open_kernel();
46053 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
46054 + pax_close_kernel();
46055
46056 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
46057 spin_lock_irqsave(&pnp_bios_lock, flags);
46058 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
46059 :"memory");
46060 spin_unlock_irqrestore(&pnp_bios_lock, flags);
46061
46062 + pax_open_kernel();
46063 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
46064 + pax_close_kernel();
46065 +
46066 put_cpu();
46067
46068 /* If we get here and this is set then the PnP BIOS faulted on us. */
46069 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
46070 return status;
46071 }
46072
46073 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
46074 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
46075 {
46076 int i;
46077
46078 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
46079 pnp_bios_callpoint.offset = header->fields.pm16offset;
46080 pnp_bios_callpoint.segment = PNP_CS16;
46081
46082 + pax_open_kernel();
46083 +
46084 for_each_possible_cpu(i) {
46085 struct desc_struct *gdt = get_cpu_gdt_table(i);
46086 if (!gdt)
46087 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
46088 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
46089 (unsigned long)__va(header->fields.pm16dseg));
46090 }
46091 +
46092 + pax_close_kernel();
46093 }
46094 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
46095 index 3e6db1c..1fbbdae 100644
46096 --- a/drivers/pnp/resource.c
46097 +++ b/drivers/pnp/resource.c
46098 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
46099 return 1;
46100
46101 /* check if the resource is valid */
46102 - if (*irq < 0 || *irq > 15)
46103 + if (*irq > 15)
46104 return 0;
46105
46106 /* check if the resource is reserved */
46107 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
46108 return 1;
46109
46110 /* check if the resource is valid */
46111 - if (*dma < 0 || *dma == 4 || *dma > 7)
46112 + if (*dma == 4 || *dma > 7)
46113 return 0;
46114
46115 /* check if the resource is reserved */
46116 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
46117 index 0c52e2a..3421ab7 100644
46118 --- a/drivers/power/pda_power.c
46119 +++ b/drivers/power/pda_power.c
46120 @@ -37,7 +37,11 @@ static int polling;
46121
46122 #if IS_ENABLED(CONFIG_USB_PHY)
46123 static struct usb_phy *transceiver;
46124 -static struct notifier_block otg_nb;
46125 +static int otg_handle_notification(struct notifier_block *nb,
46126 + unsigned long event, void *unused);
46127 +static struct notifier_block otg_nb = {
46128 + .notifier_call = otg_handle_notification
46129 +};
46130 #endif
46131
46132 static struct regulator *ac_draw;
46133 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
46134
46135 #if IS_ENABLED(CONFIG_USB_PHY)
46136 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
46137 - otg_nb.notifier_call = otg_handle_notification;
46138 ret = usb_register_notifier(transceiver, &otg_nb);
46139 if (ret) {
46140 dev_err(dev, "failure to register otg notifier\n");
46141 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
46142 index cc439fd..8fa30df 100644
46143 --- a/drivers/power/power_supply.h
46144 +++ b/drivers/power/power_supply.h
46145 @@ -16,12 +16,12 @@ struct power_supply;
46146
46147 #ifdef CONFIG_SYSFS
46148
46149 -extern void power_supply_init_attrs(struct device_type *dev_type);
46150 +extern void power_supply_init_attrs(void);
46151 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
46152
46153 #else
46154
46155 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
46156 +static inline void power_supply_init_attrs(void) {}
46157 #define power_supply_uevent NULL
46158
46159 #endif /* CONFIG_SYSFS */
46160 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
46161 index 1c517c3..ffa2f17 100644
46162 --- a/drivers/power/power_supply_core.c
46163 +++ b/drivers/power/power_supply_core.c
46164 @@ -24,7 +24,10 @@
46165 struct class *power_supply_class;
46166 EXPORT_SYMBOL_GPL(power_supply_class);
46167
46168 -static struct device_type power_supply_dev_type;
46169 +extern const struct attribute_group *power_supply_attr_groups[];
46170 +static struct device_type power_supply_dev_type = {
46171 + .groups = power_supply_attr_groups,
46172 +};
46173
46174 static bool __power_supply_is_supplied_by(struct power_supply *supplier,
46175 struct power_supply *supply)
46176 @@ -554,7 +557,7 @@ static int __init power_supply_class_init(void)
46177 return PTR_ERR(power_supply_class);
46178
46179 power_supply_class->dev_uevent = power_supply_uevent;
46180 - power_supply_init_attrs(&power_supply_dev_type);
46181 + power_supply_init_attrs();
46182
46183 return 0;
46184 }
46185 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
46186 index 29178f7..c65f324 100644
46187 --- a/drivers/power/power_supply_sysfs.c
46188 +++ b/drivers/power/power_supply_sysfs.c
46189 @@ -230,17 +230,15 @@ static struct attribute_group power_supply_attr_group = {
46190 .is_visible = power_supply_attr_is_visible,
46191 };
46192
46193 -static const struct attribute_group *power_supply_attr_groups[] = {
46194 +const struct attribute_group *power_supply_attr_groups[] = {
46195 &power_supply_attr_group,
46196 NULL,
46197 };
46198
46199 -void power_supply_init_attrs(struct device_type *dev_type)
46200 +void power_supply_init_attrs(void)
46201 {
46202 int i;
46203
46204 - dev_type->groups = power_supply_attr_groups;
46205 -
46206 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
46207 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
46208 }
46209 diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
46210 index 815d6df..811633a 100644
46211 --- a/drivers/regulator/core.c
46212 +++ b/drivers/regulator/core.c
46213 @@ -3529,7 +3529,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
46214 {
46215 const struct regulation_constraints *constraints = NULL;
46216 const struct regulator_init_data *init_data;
46217 - static atomic_t regulator_no = ATOMIC_INIT(0);
46218 + static atomic_unchecked_t regulator_no = ATOMIC_INIT(0);
46219 struct regulator_dev *rdev;
46220 struct device *dev;
46221 int ret, i;
46222 @@ -3599,7 +3599,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
46223 rdev->dev.of_node = config->of_node;
46224 rdev->dev.parent = dev;
46225 dev_set_name(&rdev->dev, "regulator.%d",
46226 - atomic_inc_return(&regulator_no) - 1);
46227 + atomic_inc_return_unchecked(&regulator_no) - 1);
46228 ret = device_register(&rdev->dev);
46229 if (ret != 0) {
46230 put_device(&rdev->dev);
46231 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
46232 index d428ef9..fdc0357 100644
46233 --- a/drivers/regulator/max8660.c
46234 +++ b/drivers/regulator/max8660.c
46235 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
46236 max8660->shadow_regs[MAX8660_OVER1] = 5;
46237 } else {
46238 /* Otherwise devices can be toggled via software */
46239 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
46240 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
46241 + pax_open_kernel();
46242 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
46243 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
46244 + pax_close_kernel();
46245 }
46246
46247 /*
46248 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
46249 index adb1414..c13e0ce 100644
46250 --- a/drivers/regulator/max8973-regulator.c
46251 +++ b/drivers/regulator/max8973-regulator.c
46252 @@ -401,9 +401,11 @@ static int max8973_probe(struct i2c_client *client,
46253 if (!pdata->enable_ext_control) {
46254 max->desc.enable_reg = MAX8973_VOUT;
46255 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
46256 - max8973_dcdc_ops.enable = regulator_enable_regmap;
46257 - max8973_dcdc_ops.disable = regulator_disable_regmap;
46258 - max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
46259 + pax_open_kernel();
46260 + *(void **)&max8973_dcdc_ops.enable = regulator_enable_regmap;
46261 + *(void **)&max8973_dcdc_ops.disable = regulator_disable_regmap;
46262 + *(void **)&max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
46263 + pax_close_kernel();
46264 }
46265
46266 max->enable_external_control = pdata->enable_ext_control;
46267 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
46268 index b716283..3cc4349 100644
46269 --- a/drivers/regulator/mc13892-regulator.c
46270 +++ b/drivers/regulator/mc13892-regulator.c
46271 @@ -582,10 +582,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
46272 }
46273 mc13xxx_unlock(mc13892);
46274
46275 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
46276 + pax_open_kernel();
46277 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
46278 = mc13892_vcam_set_mode;
46279 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
46280 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
46281 = mc13892_vcam_get_mode;
46282 + pax_close_kernel();
46283
46284 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
46285 ARRAY_SIZE(mc13892_regulators));
46286 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
46287 index f1cb706..4c7832a 100644
46288 --- a/drivers/rtc/rtc-cmos.c
46289 +++ b/drivers/rtc/rtc-cmos.c
46290 @@ -724,7 +724,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
46291 hpet_rtc_timer_init();
46292
46293 /* export at least the first block of NVRAM */
46294 - nvram.size = address_space - NVRAM_OFFSET;
46295 + pax_open_kernel();
46296 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
46297 + pax_close_kernel();
46298 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
46299 if (retval < 0) {
46300 dev_dbg(dev, "can't create nvram file? %d\n", retval);
46301 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
46302 index d049393..bb20be0 100644
46303 --- a/drivers/rtc/rtc-dev.c
46304 +++ b/drivers/rtc/rtc-dev.c
46305 @@ -16,6 +16,7 @@
46306 #include <linux/module.h>
46307 #include <linux/rtc.h>
46308 #include <linux/sched.h>
46309 +#include <linux/grsecurity.h>
46310 #include "rtc-core.h"
46311
46312 static dev_t rtc_devt;
46313 @@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
46314 if (copy_from_user(&tm, uarg, sizeof(tm)))
46315 return -EFAULT;
46316
46317 + gr_log_timechange();
46318 +
46319 return rtc_set_time(rtc, &tm);
46320
46321 case RTC_PIE_ON:
46322 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
46323 index b53992a..776df84 100644
46324 --- a/drivers/rtc/rtc-ds1307.c
46325 +++ b/drivers/rtc/rtc-ds1307.c
46326 @@ -107,7 +107,7 @@ struct ds1307 {
46327 u8 offset; /* register's offset */
46328 u8 regs[11];
46329 u16 nvram_offset;
46330 - struct bin_attribute *nvram;
46331 + bin_attribute_no_const *nvram;
46332 enum ds_type type;
46333 unsigned long flags;
46334 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
46335 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
46336 index 130f29a..6179d03 100644
46337 --- a/drivers/rtc/rtc-m48t59.c
46338 +++ b/drivers/rtc/rtc-m48t59.c
46339 @@ -482,7 +482,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
46340 goto out;
46341 }
46342
46343 - m48t59_nvram_attr.size = pdata->offset;
46344 + pax_open_kernel();
46345 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
46346 + pax_close_kernel();
46347
46348 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
46349 if (ret) {
46350 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
46351 index e693af6..2e525b6 100644
46352 --- a/drivers/scsi/bfa/bfa_fcpim.h
46353 +++ b/drivers/scsi/bfa/bfa_fcpim.h
46354 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
46355
46356 struct bfa_itn_s {
46357 bfa_isr_func_t isr;
46358 -};
46359 +} __no_const;
46360
46361 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
46362 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
46363 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
46364 index 23a90e7..9cf04ee 100644
46365 --- a/drivers/scsi/bfa/bfa_ioc.h
46366 +++ b/drivers/scsi/bfa/bfa_ioc.h
46367 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
46368 bfa_ioc_disable_cbfn_t disable_cbfn;
46369 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
46370 bfa_ioc_reset_cbfn_t reset_cbfn;
46371 -};
46372 +} __no_const;
46373
46374 /*
46375 * IOC event notification mechanism.
46376 @@ -346,7 +346,7 @@ struct bfa_ioc_hwif_s {
46377 void (*ioc_sync_ack) (struct bfa_ioc_s *ioc);
46378 bfa_boolean_t (*ioc_sync_complete) (struct bfa_ioc_s *ioc);
46379 bfa_boolean_t (*ioc_lpu_read_stat) (struct bfa_ioc_s *ioc);
46380 -};
46381 +} __no_const;
46382
46383 /*
46384 * Queue element to wait for room in request queue. FIFO order is
46385 diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c
46386 index 8c05ae01..b2cf224 100644
46387 --- a/drivers/scsi/fcoe/fcoe_sysfs.c
46388 +++ b/drivers/scsi/fcoe/fcoe_sysfs.c
46389 @@ -33,8 +33,8 @@
46390 */
46391 #include "libfcoe.h"
46392
46393 -static atomic_t ctlr_num;
46394 -static atomic_t fcf_num;
46395 +static atomic_unchecked_t ctlr_num;
46396 +static atomic_unchecked_t fcf_num;
46397
46398 /*
46399 * fcoe_fcf_dev_loss_tmo: the default number of seconds that fcoe sysfs
46400 @@ -681,7 +681,7 @@ struct fcoe_ctlr_device *fcoe_ctlr_device_add(struct device *parent,
46401 if (!ctlr)
46402 goto out;
46403
46404 - ctlr->id = atomic_inc_return(&ctlr_num) - 1;
46405 + ctlr->id = atomic_inc_return_unchecked(&ctlr_num) - 1;
46406 ctlr->f = f;
46407 ctlr->mode = FIP_CONN_TYPE_FABRIC;
46408 INIT_LIST_HEAD(&ctlr->fcfs);
46409 @@ -898,7 +898,7 @@ struct fcoe_fcf_device *fcoe_fcf_device_add(struct fcoe_ctlr_device *ctlr,
46410 fcf->dev.parent = &ctlr->dev;
46411 fcf->dev.bus = &fcoe_bus_type;
46412 fcf->dev.type = &fcoe_fcf_device_type;
46413 - fcf->id = atomic_inc_return(&fcf_num) - 1;
46414 + fcf->id = atomic_inc_return_unchecked(&fcf_num) - 1;
46415 fcf->state = FCOE_FCF_STATE_UNKNOWN;
46416
46417 fcf->dev_loss_tmo = ctlr->fcf_dev_loss_tmo;
46418 @@ -934,8 +934,8 @@ int __init fcoe_sysfs_setup(void)
46419 {
46420 int error;
46421
46422 - atomic_set(&ctlr_num, 0);
46423 - atomic_set(&fcf_num, 0);
46424 + atomic_set_unchecked(&ctlr_num, 0);
46425 + atomic_set_unchecked(&fcf_num, 0);
46426
46427 error = bus_register(&fcoe_bus_type);
46428 if (error)
46429 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
46430 index df0c3c7..b00e1d0 100644
46431 --- a/drivers/scsi/hosts.c
46432 +++ b/drivers/scsi/hosts.c
46433 @@ -42,7 +42,7 @@
46434 #include "scsi_logging.h"
46435
46436
46437 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
46438 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
46439
46440
46441 static void scsi_host_cls_release(struct device *dev)
46442 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
46443 * subtract one because we increment first then return, but we need to
46444 * know what the next host number was before increment
46445 */
46446 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
46447 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
46448 shost->dma_channel = 0xff;
46449
46450 /* These three are default values which can be overridden */
46451 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
46452 index 7f4f790..b75b92a 100644
46453 --- a/drivers/scsi/hpsa.c
46454 +++ b/drivers/scsi/hpsa.c
46455 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
46456 unsigned long flags;
46457
46458 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
46459 - return h->access.command_completed(h, q);
46460 + return h->access->command_completed(h, q);
46461
46462 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
46463 a = rq->head[rq->current_entry];
46464 @@ -3422,7 +3422,7 @@ static void start_io(struct ctlr_info *h)
46465 while (!list_empty(&h->reqQ)) {
46466 c = list_entry(h->reqQ.next, struct CommandList, list);
46467 /* can't do anything if fifo is full */
46468 - if ((h->access.fifo_full(h))) {
46469 + if ((h->access->fifo_full(h))) {
46470 dev_warn(&h->pdev->dev, "fifo full\n");
46471 break;
46472 }
46473 @@ -3444,7 +3444,7 @@ static void start_io(struct ctlr_info *h)
46474
46475 /* Tell the controller execute command */
46476 spin_unlock_irqrestore(&h->lock, flags);
46477 - h->access.submit_command(h, c);
46478 + h->access->submit_command(h, c);
46479 spin_lock_irqsave(&h->lock, flags);
46480 }
46481 spin_unlock_irqrestore(&h->lock, flags);
46482 @@ -3452,17 +3452,17 @@ static void start_io(struct ctlr_info *h)
46483
46484 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
46485 {
46486 - return h->access.command_completed(h, q);
46487 + return h->access->command_completed(h, q);
46488 }
46489
46490 static inline bool interrupt_pending(struct ctlr_info *h)
46491 {
46492 - return h->access.intr_pending(h);
46493 + return h->access->intr_pending(h);
46494 }
46495
46496 static inline long interrupt_not_for_us(struct ctlr_info *h)
46497 {
46498 - return (h->access.intr_pending(h) == 0) ||
46499 + return (h->access->intr_pending(h) == 0) ||
46500 (h->interrupts_enabled == 0);
46501 }
46502
46503 @@ -4364,7 +4364,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
46504 if (prod_index < 0)
46505 return -ENODEV;
46506 h->product_name = products[prod_index].product_name;
46507 - h->access = *(products[prod_index].access);
46508 + h->access = products[prod_index].access;
46509
46510 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
46511 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
46512 @@ -4646,7 +4646,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
46513
46514 assert_spin_locked(&lockup_detector_lock);
46515 remove_ctlr_from_lockup_detector_list(h);
46516 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46517 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46518 spin_lock_irqsave(&h->lock, flags);
46519 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
46520 spin_unlock_irqrestore(&h->lock, flags);
46521 @@ -4823,7 +4823,7 @@ reinit_after_soft_reset:
46522 }
46523
46524 /* make sure the board interrupts are off */
46525 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46526 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46527
46528 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
46529 goto clean2;
46530 @@ -4857,7 +4857,7 @@ reinit_after_soft_reset:
46531 * fake ones to scoop up any residual completions.
46532 */
46533 spin_lock_irqsave(&h->lock, flags);
46534 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46535 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46536 spin_unlock_irqrestore(&h->lock, flags);
46537 free_irqs(h);
46538 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
46539 @@ -4876,9 +4876,9 @@ reinit_after_soft_reset:
46540 dev_info(&h->pdev->dev, "Board READY.\n");
46541 dev_info(&h->pdev->dev,
46542 "Waiting for stale completions to drain.\n");
46543 - h->access.set_intr_mask(h, HPSA_INTR_ON);
46544 + h->access->set_intr_mask(h, HPSA_INTR_ON);
46545 msleep(10000);
46546 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46547 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46548
46549 rc = controller_reset_failed(h->cfgtable);
46550 if (rc)
46551 @@ -4899,7 +4899,7 @@ reinit_after_soft_reset:
46552 }
46553
46554 /* Turn the interrupts on so we can service requests */
46555 - h->access.set_intr_mask(h, HPSA_INTR_ON);
46556 + h->access->set_intr_mask(h, HPSA_INTR_ON);
46557
46558 hpsa_hba_inquiry(h);
46559 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
46560 @@ -4954,7 +4954,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
46561 * To write all data in the battery backed cache to disks
46562 */
46563 hpsa_flush_cache(h);
46564 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46565 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46566 hpsa_free_irqs_and_disable_msix(h);
46567 }
46568
46569 @@ -5122,7 +5122,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
46570 return;
46571 }
46572 /* Change the access methods to the performant access methods */
46573 - h->access = SA5_performant_access;
46574 + h->access = &SA5_performant_access;
46575 h->transMethod = CFGTBL_Trans_Performant;
46576 }
46577
46578 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
46579 index 9816479..c5d4e97 100644
46580 --- a/drivers/scsi/hpsa.h
46581 +++ b/drivers/scsi/hpsa.h
46582 @@ -79,7 +79,7 @@ struct ctlr_info {
46583 unsigned int msix_vector;
46584 unsigned int msi_vector;
46585 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
46586 - struct access_method access;
46587 + struct access_method *access;
46588
46589 /* queue and queue Info */
46590 struct list_head reqQ;
46591 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
46592 index 8b928c6..9c76300 100644
46593 --- a/drivers/scsi/libfc/fc_exch.c
46594 +++ b/drivers/scsi/libfc/fc_exch.c
46595 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
46596 u16 pool_max_index;
46597
46598 struct {
46599 - atomic_t no_free_exch;
46600 - atomic_t no_free_exch_xid;
46601 - atomic_t xid_not_found;
46602 - atomic_t xid_busy;
46603 - atomic_t seq_not_found;
46604 - atomic_t non_bls_resp;
46605 + atomic_unchecked_t no_free_exch;
46606 + atomic_unchecked_t no_free_exch_xid;
46607 + atomic_unchecked_t xid_not_found;
46608 + atomic_unchecked_t xid_busy;
46609 + atomic_unchecked_t seq_not_found;
46610 + atomic_unchecked_t non_bls_resp;
46611 } stats;
46612 };
46613
46614 @@ -736,7 +736,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
46615 /* allocate memory for exchange */
46616 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
46617 if (!ep) {
46618 - atomic_inc(&mp->stats.no_free_exch);
46619 + atomic_inc_unchecked(&mp->stats.no_free_exch);
46620 goto out;
46621 }
46622 memset(ep, 0, sizeof(*ep));
46623 @@ -797,7 +797,7 @@ out:
46624 return ep;
46625 err:
46626 spin_unlock_bh(&pool->lock);
46627 - atomic_inc(&mp->stats.no_free_exch_xid);
46628 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
46629 mempool_free(ep, mp->ep_pool);
46630 return NULL;
46631 }
46632 @@ -940,7 +940,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46633 xid = ntohs(fh->fh_ox_id); /* we originated exch */
46634 ep = fc_exch_find(mp, xid);
46635 if (!ep) {
46636 - atomic_inc(&mp->stats.xid_not_found);
46637 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46638 reject = FC_RJT_OX_ID;
46639 goto out;
46640 }
46641 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46642 ep = fc_exch_find(mp, xid);
46643 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
46644 if (ep) {
46645 - atomic_inc(&mp->stats.xid_busy);
46646 + atomic_inc_unchecked(&mp->stats.xid_busy);
46647 reject = FC_RJT_RX_ID;
46648 goto rel;
46649 }
46650 @@ -981,7 +981,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46651 }
46652 xid = ep->xid; /* get our XID */
46653 } else if (!ep) {
46654 - atomic_inc(&mp->stats.xid_not_found);
46655 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46656 reject = FC_RJT_RX_ID; /* XID not found */
46657 goto out;
46658 }
46659 @@ -998,7 +998,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46660 } else {
46661 sp = &ep->seq;
46662 if (sp->id != fh->fh_seq_id) {
46663 - atomic_inc(&mp->stats.seq_not_found);
46664 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46665 if (f_ctl & FC_FC_END_SEQ) {
46666 /*
46667 * Update sequence_id based on incoming last
46668 @@ -1448,22 +1448,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46669
46670 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
46671 if (!ep) {
46672 - atomic_inc(&mp->stats.xid_not_found);
46673 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46674 goto out;
46675 }
46676 if (ep->esb_stat & ESB_ST_COMPLETE) {
46677 - atomic_inc(&mp->stats.xid_not_found);
46678 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46679 goto rel;
46680 }
46681 if (ep->rxid == FC_XID_UNKNOWN)
46682 ep->rxid = ntohs(fh->fh_rx_id);
46683 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
46684 - atomic_inc(&mp->stats.xid_not_found);
46685 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46686 goto rel;
46687 }
46688 if (ep->did != ntoh24(fh->fh_s_id) &&
46689 ep->did != FC_FID_FLOGI) {
46690 - atomic_inc(&mp->stats.xid_not_found);
46691 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46692 goto rel;
46693 }
46694 sof = fr_sof(fp);
46695 @@ -1472,7 +1472,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46696 sp->ssb_stat |= SSB_ST_RESP;
46697 sp->id = fh->fh_seq_id;
46698 } else if (sp->id != fh->fh_seq_id) {
46699 - atomic_inc(&mp->stats.seq_not_found);
46700 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46701 goto rel;
46702 }
46703
46704 @@ -1536,9 +1536,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46705 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
46706
46707 if (!sp)
46708 - atomic_inc(&mp->stats.xid_not_found);
46709 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46710 else
46711 - atomic_inc(&mp->stats.non_bls_resp);
46712 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
46713
46714 fc_frame_free(fp);
46715 }
46716 @@ -2185,13 +2185,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
46717
46718 list_for_each_entry(ema, &lport->ema_list, ema_list) {
46719 mp = ema->mp;
46720 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
46721 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
46722 st->fc_no_free_exch_xid +=
46723 - atomic_read(&mp->stats.no_free_exch_xid);
46724 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
46725 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
46726 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
46727 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
46728 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
46729 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
46730 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
46731 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
46732 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
46733 }
46734 }
46735 EXPORT_SYMBOL(fc_exch_update_stats);
46736 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
46737 index 161c98e..6d563b3 100644
46738 --- a/drivers/scsi/libsas/sas_ata.c
46739 +++ b/drivers/scsi/libsas/sas_ata.c
46740 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
46741 .postreset = ata_std_postreset,
46742 .error_handler = ata_std_error_handler,
46743 .post_internal_cmd = sas_ata_post_internal,
46744 - .qc_defer = ata_std_qc_defer,
46745 + .qc_defer = ata_std_qc_defer,
46746 .qc_prep = ata_noop_qc_prep,
46747 .qc_issue = sas_ata_qc_issue,
46748 .qc_fill_rtf = sas_ata_qc_fill_rtf,
46749 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
46750 index bcc56ca..6f4174a 100644
46751 --- a/drivers/scsi/lpfc/lpfc.h
46752 +++ b/drivers/scsi/lpfc/lpfc.h
46753 @@ -431,7 +431,7 @@ struct lpfc_vport {
46754 struct dentry *debug_nodelist;
46755 struct dentry *vport_debugfs_root;
46756 struct lpfc_debugfs_trc *disc_trc;
46757 - atomic_t disc_trc_cnt;
46758 + atomic_unchecked_t disc_trc_cnt;
46759 #endif
46760 uint8_t stat_data_enabled;
46761 uint8_t stat_data_blocked;
46762 @@ -865,8 +865,8 @@ struct lpfc_hba {
46763 struct timer_list fabric_block_timer;
46764 unsigned long bit_flags;
46765 #define FABRIC_COMANDS_BLOCKED 0
46766 - atomic_t num_rsrc_err;
46767 - atomic_t num_cmd_success;
46768 + atomic_unchecked_t num_rsrc_err;
46769 + atomic_unchecked_t num_cmd_success;
46770 unsigned long last_rsrc_error_time;
46771 unsigned long last_ramp_down_time;
46772 unsigned long last_ramp_up_time;
46773 @@ -902,7 +902,7 @@ struct lpfc_hba {
46774
46775 struct dentry *debug_slow_ring_trc;
46776 struct lpfc_debugfs_trc *slow_ring_trc;
46777 - atomic_t slow_ring_trc_cnt;
46778 + atomic_unchecked_t slow_ring_trc_cnt;
46779 /* iDiag debugfs sub-directory */
46780 struct dentry *idiag_root;
46781 struct dentry *idiag_pci_cfg;
46782 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
46783 index f525ecb..32549a4 100644
46784 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
46785 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
46786 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
46787
46788 #include <linux/debugfs.h>
46789
46790 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
46791 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
46792 static unsigned long lpfc_debugfs_start_time = 0L;
46793
46794 /* iDiag */
46795 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
46796 lpfc_debugfs_enable = 0;
46797
46798 len = 0;
46799 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
46800 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
46801 (lpfc_debugfs_max_disc_trc - 1);
46802 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
46803 dtp = vport->disc_trc + i;
46804 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
46805 lpfc_debugfs_enable = 0;
46806
46807 len = 0;
46808 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
46809 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
46810 (lpfc_debugfs_max_slow_ring_trc - 1);
46811 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
46812 dtp = phba->slow_ring_trc + i;
46813 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
46814 !vport || !vport->disc_trc)
46815 return;
46816
46817 - index = atomic_inc_return(&vport->disc_trc_cnt) &
46818 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
46819 (lpfc_debugfs_max_disc_trc - 1);
46820 dtp = vport->disc_trc + index;
46821 dtp->fmt = fmt;
46822 dtp->data1 = data1;
46823 dtp->data2 = data2;
46824 dtp->data3 = data3;
46825 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
46826 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
46827 dtp->jif = jiffies;
46828 #endif
46829 return;
46830 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
46831 !phba || !phba->slow_ring_trc)
46832 return;
46833
46834 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
46835 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
46836 (lpfc_debugfs_max_slow_ring_trc - 1);
46837 dtp = phba->slow_ring_trc + index;
46838 dtp->fmt = fmt;
46839 dtp->data1 = data1;
46840 dtp->data2 = data2;
46841 dtp->data3 = data3;
46842 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
46843 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
46844 dtp->jif = jiffies;
46845 #endif
46846 return;
46847 @@ -4182,7 +4182,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
46848 "slow_ring buffer\n");
46849 goto debug_failed;
46850 }
46851 - atomic_set(&phba->slow_ring_trc_cnt, 0);
46852 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
46853 memset(phba->slow_ring_trc, 0,
46854 (sizeof(struct lpfc_debugfs_trc) *
46855 lpfc_debugfs_max_slow_ring_trc));
46856 @@ -4228,7 +4228,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
46857 "buffer\n");
46858 goto debug_failed;
46859 }
46860 - atomic_set(&vport->disc_trc_cnt, 0);
46861 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
46862
46863 snprintf(name, sizeof(name), "discovery_trace");
46864 vport->debug_disc_trc =
46865 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
46866 index cb465b2..2e7b25f 100644
46867 --- a/drivers/scsi/lpfc/lpfc_init.c
46868 +++ b/drivers/scsi/lpfc/lpfc_init.c
46869 @@ -10950,8 +10950,10 @@ lpfc_init(void)
46870 "misc_register returned with status %d", error);
46871
46872 if (lpfc_enable_npiv) {
46873 - lpfc_transport_functions.vport_create = lpfc_vport_create;
46874 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
46875 + pax_open_kernel();
46876 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
46877 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
46878 + pax_close_kernel();
46879 }
46880 lpfc_transport_template =
46881 fc_attach_transport(&lpfc_transport_functions);
46882 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
46883 index 8523b278e..ce1d812 100644
46884 --- a/drivers/scsi/lpfc/lpfc_scsi.c
46885 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
46886 @@ -331,7 +331,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
46887 uint32_t evt_posted;
46888
46889 spin_lock_irqsave(&phba->hbalock, flags);
46890 - atomic_inc(&phba->num_rsrc_err);
46891 + atomic_inc_unchecked(&phba->num_rsrc_err);
46892 phba->last_rsrc_error_time = jiffies;
46893
46894 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
46895 @@ -372,7 +372,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
46896 unsigned long flags;
46897 struct lpfc_hba *phba = vport->phba;
46898 uint32_t evt_posted;
46899 - atomic_inc(&phba->num_cmd_success);
46900 + atomic_inc_unchecked(&phba->num_cmd_success);
46901
46902 if (vport->cfg_lun_queue_depth <= queue_depth)
46903 return;
46904 @@ -416,8 +416,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
46905 unsigned long num_rsrc_err, num_cmd_success;
46906 int i;
46907
46908 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
46909 - num_cmd_success = atomic_read(&phba->num_cmd_success);
46910 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
46911 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
46912
46913 /*
46914 * The error and success command counters are global per
46915 @@ -445,8 +445,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
46916 }
46917 }
46918 lpfc_destroy_vport_work_array(phba, vports);
46919 - atomic_set(&phba->num_rsrc_err, 0);
46920 - atomic_set(&phba->num_cmd_success, 0);
46921 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
46922 + atomic_set_unchecked(&phba->num_cmd_success, 0);
46923 }
46924
46925 /**
46926 @@ -480,8 +480,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
46927 }
46928 }
46929 lpfc_destroy_vport_work_array(phba, vports);
46930 - atomic_set(&phba->num_rsrc_err, 0);
46931 - atomic_set(&phba->num_cmd_success, 0);
46932 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
46933 + atomic_set_unchecked(&phba->num_cmd_success, 0);
46934 }
46935
46936 /**
46937 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
46938 index 8e1b737..50ff510 100644
46939 --- a/drivers/scsi/pmcraid.c
46940 +++ b/drivers/scsi/pmcraid.c
46941 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
46942 res->scsi_dev = scsi_dev;
46943 scsi_dev->hostdata = res;
46944 res->change_detected = 0;
46945 - atomic_set(&res->read_failures, 0);
46946 - atomic_set(&res->write_failures, 0);
46947 + atomic_set_unchecked(&res->read_failures, 0);
46948 + atomic_set_unchecked(&res->write_failures, 0);
46949 rc = 0;
46950 }
46951 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
46952 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
46953
46954 /* If this was a SCSI read/write command keep count of errors */
46955 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
46956 - atomic_inc(&res->read_failures);
46957 + atomic_inc_unchecked(&res->read_failures);
46958 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
46959 - atomic_inc(&res->write_failures);
46960 + atomic_inc_unchecked(&res->write_failures);
46961
46962 if (!RES_IS_GSCSI(res->cfg_entry) &&
46963 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
46964 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
46965 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
46966 * hrrq_id assigned here in queuecommand
46967 */
46968 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
46969 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
46970 pinstance->num_hrrq;
46971 cmd->cmd_done = pmcraid_io_done;
46972
46973 @@ -3846,7 +3846,7 @@ static long pmcraid_ioctl_passthrough(
46974 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
46975 * hrrq_id assigned here in queuecommand
46976 */
46977 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
46978 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
46979 pinstance->num_hrrq;
46980
46981 if (request_size) {
46982 @@ -4483,7 +4483,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
46983
46984 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
46985 /* add resources only after host is added into system */
46986 - if (!atomic_read(&pinstance->expose_resources))
46987 + if (!atomic_read_unchecked(&pinstance->expose_resources))
46988 return;
46989
46990 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
46991 @@ -5310,8 +5310,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
46992 init_waitqueue_head(&pinstance->reset_wait_q);
46993
46994 atomic_set(&pinstance->outstanding_cmds, 0);
46995 - atomic_set(&pinstance->last_message_id, 0);
46996 - atomic_set(&pinstance->expose_resources, 0);
46997 + atomic_set_unchecked(&pinstance->last_message_id, 0);
46998 + atomic_set_unchecked(&pinstance->expose_resources, 0);
46999
47000 INIT_LIST_HEAD(&pinstance->free_res_q);
47001 INIT_LIST_HEAD(&pinstance->used_res_q);
47002 @@ -6024,7 +6024,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
47003 /* Schedule worker thread to handle CCN and take care of adding and
47004 * removing devices to OS
47005 */
47006 - atomic_set(&pinstance->expose_resources, 1);
47007 + atomic_set_unchecked(&pinstance->expose_resources, 1);
47008 schedule_work(&pinstance->worker_q);
47009 return rc;
47010
47011 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
47012 index e1d150f..6c6df44 100644
47013 --- a/drivers/scsi/pmcraid.h
47014 +++ b/drivers/scsi/pmcraid.h
47015 @@ -748,7 +748,7 @@ struct pmcraid_instance {
47016 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
47017
47018 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
47019 - atomic_t last_message_id;
47020 + atomic_unchecked_t last_message_id;
47021
47022 /* configuration table */
47023 struct pmcraid_config_table *cfg_table;
47024 @@ -777,7 +777,7 @@ struct pmcraid_instance {
47025 atomic_t outstanding_cmds;
47026
47027 /* should add/delete resources to mid-layer now ?*/
47028 - atomic_t expose_resources;
47029 + atomic_unchecked_t expose_resources;
47030
47031
47032
47033 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
47034 struct pmcraid_config_table_entry_ext cfg_entry_ext;
47035 };
47036 struct scsi_device *scsi_dev; /* Link scsi_device structure */
47037 - atomic_t read_failures; /* count of failed READ commands */
47038 - atomic_t write_failures; /* count of failed WRITE commands */
47039 + atomic_unchecked_t read_failures; /* count of failed READ commands */
47040 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
47041
47042 /* To indicate add/delete/modify during CCN */
47043 u8 change_detected;
47044 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
47045 index bf60c63..74d4dce 100644
47046 --- a/drivers/scsi/qla2xxx/qla_attr.c
47047 +++ b/drivers/scsi/qla2xxx/qla_attr.c
47048 @@ -2001,7 +2001,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
47049 return 0;
47050 }
47051
47052 -struct fc_function_template qla2xxx_transport_functions = {
47053 +fc_function_template_no_const qla2xxx_transport_functions = {
47054
47055 .show_host_node_name = 1,
47056 .show_host_port_name = 1,
47057 @@ -2048,7 +2048,7 @@ struct fc_function_template qla2xxx_transport_functions = {
47058 .bsg_timeout = qla24xx_bsg_timeout,
47059 };
47060
47061 -struct fc_function_template qla2xxx_transport_vport_functions = {
47062 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
47063
47064 .show_host_node_name = 1,
47065 .show_host_port_name = 1,
47066 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
47067 index 026bfde..90c4018 100644
47068 --- a/drivers/scsi/qla2xxx/qla_gbl.h
47069 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
47070 @@ -528,8 +528,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
47071 struct device_attribute;
47072 extern struct device_attribute *qla2x00_host_attrs[];
47073 struct fc_function_template;
47074 -extern struct fc_function_template qla2xxx_transport_functions;
47075 -extern struct fc_function_template qla2xxx_transport_vport_functions;
47076 +extern fc_function_template_no_const qla2xxx_transport_functions;
47077 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
47078 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
47079 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
47080 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
47081 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
47082 index ad72c1d..afc9a98 100644
47083 --- a/drivers/scsi/qla2xxx/qla_os.c
47084 +++ b/drivers/scsi/qla2xxx/qla_os.c
47085 @@ -1571,8 +1571,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
47086 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
47087 /* Ok, a 64bit DMA mask is applicable. */
47088 ha->flags.enable_64bit_addressing = 1;
47089 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
47090 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
47091 + pax_open_kernel();
47092 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
47093 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
47094 + pax_close_kernel();
47095 return;
47096 }
47097 }
47098 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
47099 index ddf16a8..80f4dd0 100644
47100 --- a/drivers/scsi/qla4xxx/ql4_def.h
47101 +++ b/drivers/scsi/qla4xxx/ql4_def.h
47102 @@ -291,7 +291,7 @@ struct ddb_entry {
47103 * (4000 only) */
47104 atomic_t relogin_timer; /* Max Time to wait for
47105 * relogin to complete */
47106 - atomic_t relogin_retry_count; /* Num of times relogin has been
47107 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
47108 * retried */
47109 uint32_t default_time2wait; /* Default Min time between
47110 * relogins (+aens) */
47111 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
47112 index 4d231c1..2892c37 100644
47113 --- a/drivers/scsi/qla4xxx/ql4_os.c
47114 +++ b/drivers/scsi/qla4xxx/ql4_os.c
47115 @@ -2971,12 +2971,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
47116 */
47117 if (!iscsi_is_session_online(cls_sess)) {
47118 /* Reset retry relogin timer */
47119 - atomic_inc(&ddb_entry->relogin_retry_count);
47120 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
47121 DEBUG2(ql4_printk(KERN_INFO, ha,
47122 "%s: index[%d] relogin timed out-retrying"
47123 " relogin (%d), retry (%d)\n", __func__,
47124 ddb_entry->fw_ddb_index,
47125 - atomic_read(&ddb_entry->relogin_retry_count),
47126 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
47127 ddb_entry->default_time2wait + 4));
47128 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
47129 atomic_set(&ddb_entry->retry_relogin_timer,
47130 @@ -5081,7 +5081,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
47131
47132 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
47133 atomic_set(&ddb_entry->relogin_timer, 0);
47134 - atomic_set(&ddb_entry->relogin_retry_count, 0);
47135 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
47136 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
47137 ddb_entry->default_relogin_timeout =
47138 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
47139 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
47140 index eaa808e..95f8841 100644
47141 --- a/drivers/scsi/scsi.c
47142 +++ b/drivers/scsi/scsi.c
47143 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
47144 unsigned long timeout;
47145 int rtn = 0;
47146
47147 - atomic_inc(&cmd->device->iorequest_cnt);
47148 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
47149
47150 /* check if the device is still usable */
47151 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
47152 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
47153 index 86d5220..f22c51a 100644
47154 --- a/drivers/scsi/scsi_lib.c
47155 +++ b/drivers/scsi/scsi_lib.c
47156 @@ -1458,7 +1458,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
47157 shost = sdev->host;
47158 scsi_init_cmd_errh(cmd);
47159 cmd->result = DID_NO_CONNECT << 16;
47160 - atomic_inc(&cmd->device->iorequest_cnt);
47161 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
47162
47163 /*
47164 * SCSI request completion path will do scsi_device_unbusy(),
47165 @@ -1484,9 +1484,9 @@ static void scsi_softirq_done(struct request *rq)
47166
47167 INIT_LIST_HEAD(&cmd->eh_entry);
47168
47169 - atomic_inc(&cmd->device->iodone_cnt);
47170 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
47171 if (cmd->result)
47172 - atomic_inc(&cmd->device->ioerr_cnt);
47173 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
47174
47175 disposition = scsi_decide_disposition(cmd);
47176 if (disposition != SUCCESS &&
47177 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
47178 index 931a7d9..0c2a754 100644
47179 --- a/drivers/scsi/scsi_sysfs.c
47180 +++ b/drivers/scsi/scsi_sysfs.c
47181 @@ -658,7 +658,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
47182 char *buf) \
47183 { \
47184 struct scsi_device *sdev = to_scsi_device(dev); \
47185 - unsigned long long count = atomic_read(&sdev->field); \
47186 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
47187 return snprintf(buf, 20, "0x%llx\n", count); \
47188 } \
47189 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
47190 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
47191 index 84a1fdf..693b0d6 100644
47192 --- a/drivers/scsi/scsi_tgt_lib.c
47193 +++ b/drivers/scsi/scsi_tgt_lib.c
47194 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
47195 int err;
47196
47197 dprintk("%lx %u\n", uaddr, len);
47198 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
47199 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
47200 if (err) {
47201 /*
47202 * TODO: need to fixup sg_tablesize, max_segment_size,
47203 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
47204 index e106c27..11a380e 100644
47205 --- a/drivers/scsi/scsi_transport_fc.c
47206 +++ b/drivers/scsi/scsi_transport_fc.c
47207 @@ -497,7 +497,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
47208 * Netlink Infrastructure
47209 */
47210
47211 -static atomic_t fc_event_seq;
47212 +static atomic_unchecked_t fc_event_seq;
47213
47214 /**
47215 * fc_get_event_number - Obtain the next sequential FC event number
47216 @@ -510,7 +510,7 @@ static atomic_t fc_event_seq;
47217 u32
47218 fc_get_event_number(void)
47219 {
47220 - return atomic_add_return(1, &fc_event_seq);
47221 + return atomic_add_return_unchecked(1, &fc_event_seq);
47222 }
47223 EXPORT_SYMBOL(fc_get_event_number);
47224
47225 @@ -654,7 +654,7 @@ static __init int fc_transport_init(void)
47226 {
47227 int error;
47228
47229 - atomic_set(&fc_event_seq, 0);
47230 + atomic_set_unchecked(&fc_event_seq, 0);
47231
47232 error = transport_class_register(&fc_host_class);
47233 if (error)
47234 @@ -844,7 +844,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
47235 char *cp;
47236
47237 *val = simple_strtoul(buf, &cp, 0);
47238 - if ((*cp && (*cp != '\n')) || (*val < 0))
47239 + if (*cp && (*cp != '\n'))
47240 return -EINVAL;
47241 /*
47242 * Check for overflow; dev_loss_tmo is u32
47243 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
47244 index 133926b..903000d 100644
47245 --- a/drivers/scsi/scsi_transport_iscsi.c
47246 +++ b/drivers/scsi/scsi_transport_iscsi.c
47247 @@ -80,7 +80,7 @@ struct iscsi_internal {
47248 struct transport_container session_cont;
47249 };
47250
47251 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
47252 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
47253 static struct workqueue_struct *iscsi_eh_timer_workq;
47254
47255 static DEFINE_IDA(iscsi_sess_ida);
47256 @@ -1738,7 +1738,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
47257 int err;
47258
47259 ihost = shost->shost_data;
47260 - session->sid = atomic_add_return(1, &iscsi_session_nr);
47261 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
47262
47263 if (target_id == ISCSI_MAX_TARGET) {
47264 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
47265 @@ -3944,7 +3944,7 @@ static __init int iscsi_transport_init(void)
47266 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
47267 ISCSI_TRANSPORT_VERSION);
47268
47269 - atomic_set(&iscsi_session_nr, 0);
47270 + atomic_set_unchecked(&iscsi_session_nr, 0);
47271
47272 err = class_register(&iscsi_transport_class);
47273 if (err)
47274 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
47275 index f379c7f..e8fc69c 100644
47276 --- a/drivers/scsi/scsi_transport_srp.c
47277 +++ b/drivers/scsi/scsi_transport_srp.c
47278 @@ -33,7 +33,7 @@
47279 #include "scsi_transport_srp_internal.h"
47280
47281 struct srp_host_attrs {
47282 - atomic_t next_port_id;
47283 + atomic_unchecked_t next_port_id;
47284 };
47285 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
47286
47287 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
47288 struct Scsi_Host *shost = dev_to_shost(dev);
47289 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
47290
47291 - atomic_set(&srp_host->next_port_id, 0);
47292 + atomic_set_unchecked(&srp_host->next_port_id, 0);
47293 return 0;
47294 }
47295
47296 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
47297 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
47298 rport->roles = ids->roles;
47299
47300 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
47301 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
47302 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
47303
47304 transport_setup_device(&rport->dev);
47305 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
47306 index 610417e..167c46c 100644
47307 --- a/drivers/scsi/sd.c
47308 +++ b/drivers/scsi/sd.c
47309 @@ -2928,7 +2928,7 @@ static int sd_probe(struct device *dev)
47310 sdkp->disk = gd;
47311 sdkp->index = index;
47312 atomic_set(&sdkp->openers, 0);
47313 - atomic_set(&sdkp->device->ioerr_cnt, 0);
47314 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
47315
47316 if (!sdp->request_queue->rq_timeout) {
47317 if (sdp->type != TYPE_MOD)
47318 @@ -2941,7 +2941,7 @@ static int sd_probe(struct device *dev)
47319 device_initialize(&sdkp->dev);
47320 sdkp->dev.parent = dev;
47321 sdkp->dev.class = &sd_disk_class;
47322 - dev_set_name(&sdkp->dev, dev_name(dev));
47323 + dev_set_name(&sdkp->dev, "%s", dev_name(dev));
47324
47325 if (device_add(&sdkp->dev))
47326 goto out_free_index;
47327 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
47328 index df5e961..df6b97f 100644
47329 --- a/drivers/scsi/sg.c
47330 +++ b/drivers/scsi/sg.c
47331 @@ -1102,7 +1102,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
47332 sdp->disk->disk_name,
47333 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
47334 NULL,
47335 - (char *)arg);
47336 + (char __user *)arg);
47337 case BLKTRACESTART:
47338 return blk_trace_startstop(sdp->device->request_queue, 1);
47339 case BLKTRACESTOP:
47340 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
47341 index 32b7bb1..2f1c4bd 100644
47342 --- a/drivers/spi/spi.c
47343 +++ b/drivers/spi/spi.c
47344 @@ -1631,7 +1631,7 @@ int spi_bus_unlock(struct spi_master *master)
47345 EXPORT_SYMBOL_GPL(spi_bus_unlock);
47346
47347 /* portable code must never pass more than 32 bytes */
47348 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
47349 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
47350
47351 static u8 *buf;
47352
47353 diff --git a/drivers/staging/android/timed_output.c b/drivers/staging/android/timed_output.c
47354 index ec9e2ae..cd15d67 100644
47355 --- a/drivers/staging/android/timed_output.c
47356 +++ b/drivers/staging/android/timed_output.c
47357 @@ -25,7 +25,7 @@
47358 #include "timed_output.h"
47359
47360 static struct class *timed_output_class;
47361 -static atomic_t device_count;
47362 +static atomic_unchecked_t device_count;
47363
47364 static ssize_t enable_show(struct device *dev, struct device_attribute *attr,
47365 char *buf)
47366 @@ -59,7 +59,7 @@ static int create_timed_output_class(void)
47367 timed_output_class = class_create(THIS_MODULE, "timed_output");
47368 if (IS_ERR(timed_output_class))
47369 return PTR_ERR(timed_output_class);
47370 - atomic_set(&device_count, 0);
47371 + atomic_set_unchecked(&device_count, 0);
47372 }
47373
47374 return 0;
47375 @@ -76,7 +76,7 @@ int timed_output_dev_register(struct timed_output_dev *tdev)
47376 if (ret < 0)
47377 return ret;
47378
47379 - tdev->index = atomic_inc_return(&device_count);
47380 + tdev->index = atomic_inc_return_unchecked(&device_count);
47381 tdev->dev = device_create(timed_output_class, NULL,
47382 MKDEV(0, tdev->index), NULL, tdev->name);
47383 if (IS_ERR(tdev->dev))
47384 diff --git a/drivers/staging/media/solo6x10/solo6x10-core.c b/drivers/staging/media/solo6x10/solo6x10-core.c
47385 index 3675020..e80d92c 100644
47386 --- a/drivers/staging/media/solo6x10/solo6x10-core.c
47387 +++ b/drivers/staging/media/solo6x10/solo6x10-core.c
47388 @@ -434,7 +434,7 @@ static void solo_device_release(struct device *dev)
47389
47390 static int solo_sysfs_init(struct solo_dev *solo_dev)
47391 {
47392 - struct bin_attribute *sdram_attr = &solo_dev->sdram_attr;
47393 + bin_attribute_no_const *sdram_attr = &solo_dev->sdram_attr;
47394 struct device *dev = &solo_dev->dev;
47395 const char *driver;
47396 int i;
47397 diff --git a/drivers/staging/media/solo6x10/solo6x10-p2m.c b/drivers/staging/media/solo6x10/solo6x10-p2m.c
47398 index 3335941..2b26186 100644
47399 --- a/drivers/staging/media/solo6x10/solo6x10-p2m.c
47400 +++ b/drivers/staging/media/solo6x10/solo6x10-p2m.c
47401 @@ -77,7 +77,7 @@ int solo_p2m_dma_desc(struct solo_dev *solo_dev,
47402
47403 /* Get next ID. According to Softlogic, 6110 has problems on !=0 P2M */
47404 if (solo_dev->type != SOLO_DEV_6110 && multi_p2m) {
47405 - p2m_id = atomic_inc_return(&solo_dev->p2m_count) % SOLO_NR_P2M;
47406 + p2m_id = atomic_inc_return_unchecked(&solo_dev->p2m_count) % SOLO_NR_P2M;
47407 if (p2m_id < 0)
47408 p2m_id = -p2m_id;
47409 }
47410 diff --git a/drivers/staging/media/solo6x10/solo6x10.h b/drivers/staging/media/solo6x10/solo6x10.h
47411 index 6f91d2e..3f011d2 100644
47412 --- a/drivers/staging/media/solo6x10/solo6x10.h
47413 +++ b/drivers/staging/media/solo6x10/solo6x10.h
47414 @@ -238,7 +238,7 @@ struct solo_dev {
47415
47416 /* P2M DMA Engine */
47417 struct solo_p2m_dev p2m_dev[SOLO_NR_P2M];
47418 - atomic_t p2m_count;
47419 + atomic_unchecked_t p2m_count;
47420 int p2m_jiffies;
47421 unsigned int p2m_timeouts;
47422
47423 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
47424 index 34afc16..ffe44dd 100644
47425 --- a/drivers/staging/octeon/ethernet-rx.c
47426 +++ b/drivers/staging/octeon/ethernet-rx.c
47427 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
47428 /* Increment RX stats for virtual ports */
47429 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
47430 #ifdef CONFIG_64BIT
47431 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
47432 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
47433 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
47434 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
47435 #else
47436 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
47437 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
47438 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
47439 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
47440 #endif
47441 }
47442 netif_receive_skb(skb);
47443 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
47444 dev->name);
47445 */
47446 #ifdef CONFIG_64BIT
47447 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
47448 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
47449 #else
47450 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
47451 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
47452 #endif
47453 dev_kfree_skb_irq(skb);
47454 }
47455 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
47456 index c3a90e7..023619a 100644
47457 --- a/drivers/staging/octeon/ethernet.c
47458 +++ b/drivers/staging/octeon/ethernet.c
47459 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
47460 * since the RX tasklet also increments it.
47461 */
47462 #ifdef CONFIG_64BIT
47463 - atomic64_add(rx_status.dropped_packets,
47464 - (atomic64_t *)&priv->stats.rx_dropped);
47465 + atomic64_add_unchecked(rx_status.dropped_packets,
47466 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
47467 #else
47468 - atomic_add(rx_status.dropped_packets,
47469 - (atomic_t *)&priv->stats.rx_dropped);
47470 + atomic_add_unchecked(rx_status.dropped_packets,
47471 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
47472 #endif
47473 }
47474
47475 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
47476 index dc23395..cf7e9b1 100644
47477 --- a/drivers/staging/rtl8712/rtl871x_io.h
47478 +++ b/drivers/staging/rtl8712/rtl871x_io.h
47479 @@ -108,7 +108,7 @@ struct _io_ops {
47480 u8 *pmem);
47481 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
47482 u8 *pmem);
47483 -};
47484 +} __no_const;
47485
47486 struct io_req {
47487 struct list_head list;
47488 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
47489 index 1f5088b..0e59820 100644
47490 --- a/drivers/staging/sbe-2t3e3/netdev.c
47491 +++ b/drivers/staging/sbe-2t3e3/netdev.c
47492 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
47493 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
47494
47495 if (rlen)
47496 - if (copy_to_user(data, &resp, rlen))
47497 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
47498 return -EFAULT;
47499
47500 return 0;
47501 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
47502 index a863a98..d272795 100644
47503 --- a/drivers/staging/usbip/vhci.h
47504 +++ b/drivers/staging/usbip/vhci.h
47505 @@ -83,7 +83,7 @@ struct vhci_hcd {
47506 unsigned resuming:1;
47507 unsigned long re_timeout;
47508
47509 - atomic_t seqnum;
47510 + atomic_unchecked_t seqnum;
47511
47512 /*
47513 * NOTE:
47514 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
47515 index d7974cb..d78076b 100644
47516 --- a/drivers/staging/usbip/vhci_hcd.c
47517 +++ b/drivers/staging/usbip/vhci_hcd.c
47518 @@ -441,7 +441,7 @@ static void vhci_tx_urb(struct urb *urb)
47519
47520 spin_lock(&vdev->priv_lock);
47521
47522 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
47523 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47524 if (priv->seqnum == 0xffff)
47525 dev_info(&urb->dev->dev, "seqnum max\n");
47526
47527 @@ -687,7 +687,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
47528 return -ENOMEM;
47529 }
47530
47531 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
47532 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47533 if (unlink->seqnum == 0xffff)
47534 pr_info("seqnum max\n");
47535
47536 @@ -891,7 +891,7 @@ static int vhci_start(struct usb_hcd *hcd)
47537 vdev->rhport = rhport;
47538 }
47539
47540 - atomic_set(&vhci->seqnum, 0);
47541 + atomic_set_unchecked(&vhci->seqnum, 0);
47542 spin_lock_init(&vhci->lock);
47543
47544 hcd->power_budget = 0; /* no limit */
47545 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
47546 index d07fcb5..358e1e1 100644
47547 --- a/drivers/staging/usbip/vhci_rx.c
47548 +++ b/drivers/staging/usbip/vhci_rx.c
47549 @@ -80,7 +80,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
47550 if (!urb) {
47551 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
47552 pr_info("max seqnum %d\n",
47553 - atomic_read(&the_controller->seqnum));
47554 + atomic_read_unchecked(&the_controller->seqnum));
47555 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
47556 return;
47557 }
47558 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
47559 index 8417c2f..ef5ebd6 100644
47560 --- a/drivers/staging/vt6655/hostap.c
47561 +++ b/drivers/staging/vt6655/hostap.c
47562 @@ -69,14 +69,13 @@ static int msglevel = MSG_LEVEL_INFO;
47563 *
47564 */
47565
47566 +static net_device_ops_no_const apdev_netdev_ops;
47567 +
47568 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47569 {
47570 PSDevice apdev_priv;
47571 struct net_device *dev = pDevice->dev;
47572 int ret;
47573 - const struct net_device_ops apdev_netdev_ops = {
47574 - .ndo_start_xmit = pDevice->tx_80211,
47575 - };
47576
47577 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47578
47579 @@ -88,6 +87,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47580 *apdev_priv = *pDevice;
47581 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
47582
47583 + /* only half broken now */
47584 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47585 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47586
47587 pDevice->apdev->type = ARPHRD_IEEE80211;
47588 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
47589 index c699a30..b90a5fd 100644
47590 --- a/drivers/staging/vt6656/hostap.c
47591 +++ b/drivers/staging/vt6656/hostap.c
47592 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
47593 *
47594 */
47595
47596 +static net_device_ops_no_const apdev_netdev_ops;
47597 +
47598 static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47599 {
47600 struct vnt_private *apdev_priv;
47601 struct net_device *dev = pDevice->dev;
47602 int ret;
47603 - const struct net_device_ops apdev_netdev_ops = {
47604 - .ndo_start_xmit = pDevice->tx_80211,
47605 - };
47606
47607 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47608
47609 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47610 *apdev_priv = *pDevice;
47611 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
47612
47613 + /* only half broken now */
47614 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47615 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47616
47617 pDevice->apdev->type = ARPHRD_IEEE80211;
47618 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
47619 index d128ce2..fc1f9a1 100644
47620 --- a/drivers/staging/zcache/tmem.h
47621 +++ b/drivers/staging/zcache/tmem.h
47622 @@ -225,7 +225,7 @@ struct tmem_pamops {
47623 bool (*is_remote)(void *);
47624 int (*replace_in_obj)(void *, struct tmem_obj *);
47625 #endif
47626 -};
47627 +} __no_const;
47628 extern void tmem_register_pamops(struct tmem_pamops *m);
47629
47630 /* memory allocation methods provided by the host implementation */
47631 @@ -234,7 +234,7 @@ struct tmem_hostops {
47632 void (*obj_free)(struct tmem_obj *, struct tmem_pool *);
47633 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
47634 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
47635 -};
47636 +} __no_const;
47637 extern void tmem_register_hostops(struct tmem_hostops *m);
47638
47639 /* core tmem accessor functions */
47640 diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
47641 index d3536f5..a0c2ce9 100644
47642 --- a/drivers/target/sbp/sbp_target.c
47643 +++ b/drivers/target/sbp/sbp_target.c
47644 @@ -62,7 +62,7 @@ static const u32 sbp_unit_directory_template[] = {
47645
47646 #define SESSION_MAINTENANCE_INTERVAL HZ
47647
47648 -static atomic_t login_id = ATOMIC_INIT(0);
47649 +static atomic_unchecked_t login_id = ATOMIC_INIT(0);
47650
47651 static void session_maintenance_work(struct work_struct *);
47652 static int sbp_run_transaction(struct fw_card *, int, int, int, int,
47653 @@ -444,7 +444,7 @@ static void sbp_management_request_login(
47654 login->lun = se_lun;
47655 login->status_fifo_addr = sbp2_pointer_to_addr(&req->orb.status_fifo);
47656 login->exclusive = LOGIN_ORB_EXCLUSIVE(be32_to_cpu(req->orb.misc));
47657 - login->login_id = atomic_inc_return(&login_id);
47658 + login->login_id = atomic_inc_return_unchecked(&login_id);
47659
47660 login->tgt_agt = sbp_target_agent_register(login);
47661 if (IS_ERR(login->tgt_agt)) {
47662 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
47663 index 4630481..c26782a 100644
47664 --- a/drivers/target/target_core_device.c
47665 +++ b/drivers/target/target_core_device.c
47666 @@ -1400,7 +1400,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
47667 spin_lock_init(&dev->se_port_lock);
47668 spin_lock_init(&dev->se_tmr_lock);
47669 spin_lock_init(&dev->qf_cmd_lock);
47670 - atomic_set(&dev->dev_ordered_id, 0);
47671 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
47672 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
47673 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
47674 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
47675 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
47676 index 21e3158..43c6004 100644
47677 --- a/drivers/target/target_core_transport.c
47678 +++ b/drivers/target/target_core_transport.c
47679 @@ -1080,7 +1080,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
47680 * Used to determine when ORDERED commands should go from
47681 * Dormant to Active status.
47682 */
47683 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
47684 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
47685 smp_mb__after_atomic_inc();
47686 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
47687 cmd->se_ordered_id, cmd->sam_task_attr,
47688 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
47689 index 33f83fe..d80f8e1 100644
47690 --- a/drivers/tty/cyclades.c
47691 +++ b/drivers/tty/cyclades.c
47692 @@ -1570,10 +1570,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
47693 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
47694 info->port.count);
47695 #endif
47696 - info->port.count++;
47697 + atomic_inc(&info->port.count);
47698 #ifdef CY_DEBUG_COUNT
47699 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
47700 - current->pid, info->port.count);
47701 + current->pid, atomic_read(&info->port.count));
47702 #endif
47703
47704 /*
47705 @@ -3972,7 +3972,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
47706 for (j = 0; j < cy_card[i].nports; j++) {
47707 info = &cy_card[i].ports[j];
47708
47709 - if (info->port.count) {
47710 + if (atomic_read(&info->port.count)) {
47711 /* XXX is the ldisc num worth this? */
47712 struct tty_struct *tty;
47713 struct tty_ldisc *ld;
47714 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
47715 index eb255e8..f637a57 100644
47716 --- a/drivers/tty/hvc/hvc_console.c
47717 +++ b/drivers/tty/hvc/hvc_console.c
47718 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
47719
47720 spin_lock_irqsave(&hp->port.lock, flags);
47721 /* Check and then increment for fast path open. */
47722 - if (hp->port.count++ > 0) {
47723 + if (atomic_inc_return(&hp->port.count) > 1) {
47724 spin_unlock_irqrestore(&hp->port.lock, flags);
47725 hvc_kick();
47726 return 0;
47727 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47728
47729 spin_lock_irqsave(&hp->port.lock, flags);
47730
47731 - if (--hp->port.count == 0) {
47732 + if (atomic_dec_return(&hp->port.count) == 0) {
47733 spin_unlock_irqrestore(&hp->port.lock, flags);
47734 /* We are done with the tty pointer now. */
47735 tty_port_tty_set(&hp->port, NULL);
47736 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47737 */
47738 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
47739 } else {
47740 - if (hp->port.count < 0)
47741 + if (atomic_read(&hp->port.count) < 0)
47742 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
47743 - hp->vtermno, hp->port.count);
47744 + hp->vtermno, atomic_read(&hp->port.count));
47745 spin_unlock_irqrestore(&hp->port.lock, flags);
47746 }
47747 }
47748 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
47749 * open->hangup case this can be called after the final close so prevent
47750 * that from happening for now.
47751 */
47752 - if (hp->port.count <= 0) {
47753 + if (atomic_read(&hp->port.count) <= 0) {
47754 spin_unlock_irqrestore(&hp->port.lock, flags);
47755 return;
47756 }
47757
47758 - hp->port.count = 0;
47759 + atomic_set(&hp->port.count, 0);
47760 spin_unlock_irqrestore(&hp->port.lock, flags);
47761 tty_port_tty_set(&hp->port, NULL);
47762
47763 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
47764 return -EPIPE;
47765
47766 /* FIXME what's this (unprotected) check for? */
47767 - if (hp->port.count <= 0)
47768 + if (atomic_read(&hp->port.count) <= 0)
47769 return -EIO;
47770
47771 spin_lock_irqsave(&hp->lock, flags);
47772 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
47773 index 81e939e..95ead10 100644
47774 --- a/drivers/tty/hvc/hvcs.c
47775 +++ b/drivers/tty/hvc/hvcs.c
47776 @@ -83,6 +83,7 @@
47777 #include <asm/hvcserver.h>
47778 #include <asm/uaccess.h>
47779 #include <asm/vio.h>
47780 +#include <asm/local.h>
47781
47782 /*
47783 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
47784 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
47785
47786 spin_lock_irqsave(&hvcsd->lock, flags);
47787
47788 - if (hvcsd->port.count > 0) {
47789 + if (atomic_read(&hvcsd->port.count) > 0) {
47790 spin_unlock_irqrestore(&hvcsd->lock, flags);
47791 printk(KERN_INFO "HVCS: vterm state unchanged. "
47792 "The hvcs device node is still in use.\n");
47793 @@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
47794 }
47795 }
47796
47797 - hvcsd->port.count = 0;
47798 + atomic_set(&hvcsd->port.count, 0);
47799 hvcsd->port.tty = tty;
47800 tty->driver_data = hvcsd;
47801
47802 @@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
47803 unsigned long flags;
47804
47805 spin_lock_irqsave(&hvcsd->lock, flags);
47806 - hvcsd->port.count++;
47807 + atomic_inc(&hvcsd->port.count);
47808 hvcsd->todo_mask |= HVCS_SCHED_READ;
47809 spin_unlock_irqrestore(&hvcsd->lock, flags);
47810
47811 @@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
47812 hvcsd = tty->driver_data;
47813
47814 spin_lock_irqsave(&hvcsd->lock, flags);
47815 - if (--hvcsd->port.count == 0) {
47816 + if (atomic_dec_and_test(&hvcsd->port.count)) {
47817
47818 vio_disable_interrupts(hvcsd->vdev);
47819
47820 @@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
47821
47822 free_irq(irq, hvcsd);
47823 return;
47824 - } else if (hvcsd->port.count < 0) {
47825 + } else if (atomic_read(&hvcsd->port.count) < 0) {
47826 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
47827 " is missmanaged.\n",
47828 - hvcsd->vdev->unit_address, hvcsd->port.count);
47829 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
47830 }
47831
47832 spin_unlock_irqrestore(&hvcsd->lock, flags);
47833 @@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
47834
47835 spin_lock_irqsave(&hvcsd->lock, flags);
47836 /* Preserve this so that we know how many kref refs to put */
47837 - temp_open_count = hvcsd->port.count;
47838 + temp_open_count = atomic_read(&hvcsd->port.count);
47839
47840 /*
47841 * Don't kref put inside the spinlock because the destruction
47842 @@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
47843 tty->driver_data = NULL;
47844 hvcsd->port.tty = NULL;
47845
47846 - hvcsd->port.count = 0;
47847 + atomic_set(&hvcsd->port.count, 0);
47848
47849 /* This will drop any buffered data on the floor which is OK in a hangup
47850 * scenario. */
47851 @@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
47852 * the middle of a write operation? This is a crummy place to do this
47853 * but we want to keep it all in the spinlock.
47854 */
47855 - if (hvcsd->port.count <= 0) {
47856 + if (atomic_read(&hvcsd->port.count) <= 0) {
47857 spin_unlock_irqrestore(&hvcsd->lock, flags);
47858 return -ENODEV;
47859 }
47860 @@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
47861 {
47862 struct hvcs_struct *hvcsd = tty->driver_data;
47863
47864 - if (!hvcsd || hvcsd->port.count <= 0)
47865 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
47866 return 0;
47867
47868 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
47869 diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
47870 index 4190199..48f2920 100644
47871 --- a/drivers/tty/hvc/hvsi.c
47872 +++ b/drivers/tty/hvc/hvsi.c
47873 @@ -85,7 +85,7 @@ struct hvsi_struct {
47874 int n_outbuf;
47875 uint32_t vtermno;
47876 uint32_t virq;
47877 - atomic_t seqno; /* HVSI packet sequence number */
47878 + atomic_unchecked_t seqno; /* HVSI packet sequence number */
47879 uint16_t mctrl;
47880 uint8_t state; /* HVSI protocol state */
47881 uint8_t flags;
47882 @@ -295,7 +295,7 @@ static int hvsi_version_respond(struct hvsi_struct *hp, uint16_t query_seqno)
47883
47884 packet.hdr.type = VS_QUERY_RESPONSE_PACKET_HEADER;
47885 packet.hdr.len = sizeof(struct hvsi_query_response);
47886 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47887 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47888 packet.verb = VSV_SEND_VERSION_NUMBER;
47889 packet.u.version = HVSI_VERSION;
47890 packet.query_seqno = query_seqno+1;
47891 @@ -555,7 +555,7 @@ static int hvsi_query(struct hvsi_struct *hp, uint16_t verb)
47892
47893 packet.hdr.type = VS_QUERY_PACKET_HEADER;
47894 packet.hdr.len = sizeof(struct hvsi_query);
47895 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47896 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47897 packet.verb = verb;
47898
47899 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len);
47900 @@ -597,7 +597,7 @@ static int hvsi_set_mctrl(struct hvsi_struct *hp, uint16_t mctrl)
47901 int wrote;
47902
47903 packet.hdr.type = VS_CONTROL_PACKET_HEADER,
47904 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47905 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47906 packet.hdr.len = sizeof(struct hvsi_control);
47907 packet.verb = VSV_SET_MODEM_CTL;
47908 packet.mask = HVSI_TSDTR;
47909 @@ -680,7 +680,7 @@ static int hvsi_put_chars(struct hvsi_struct *hp, const char *buf, int count)
47910 BUG_ON(count > HVSI_MAX_OUTGOING_DATA);
47911
47912 packet.hdr.type = VS_DATA_PACKET_HEADER;
47913 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47914 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47915 packet.hdr.len = count + sizeof(struct hvsi_header);
47916 memcpy(&packet.data, buf, count);
47917
47918 @@ -697,7 +697,7 @@ static void hvsi_close_protocol(struct hvsi_struct *hp)
47919 struct hvsi_control packet __ALIGNED__;
47920
47921 packet.hdr.type = VS_CONTROL_PACKET_HEADER;
47922 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47923 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47924 packet.hdr.len = 6;
47925 packet.verb = VSV_CLOSE_PROTOCOL;
47926
47927 diff --git a/drivers/tty/hvc/hvsi_lib.c b/drivers/tty/hvc/hvsi_lib.c
47928 index 3396eb9..6d3d540 100644
47929 --- a/drivers/tty/hvc/hvsi_lib.c
47930 +++ b/drivers/tty/hvc/hvsi_lib.c
47931 @@ -9,7 +9,7 @@
47932
47933 static int hvsi_send_packet(struct hvsi_priv *pv, struct hvsi_header *packet)
47934 {
47935 - packet->seqno = atomic_inc_return(&pv->seqno);
47936 + packet->seqno = atomic_inc_return_unchecked(&pv->seqno);
47937
47938 /* Assumes that always succeeds, works in practice */
47939 return pv->put_chars(pv->termno, (char *)packet, packet->len);
47940 @@ -21,7 +21,7 @@ static void hvsi_start_handshake(struct hvsi_priv *pv)
47941
47942 /* Reset state */
47943 pv->established = 0;
47944 - atomic_set(&pv->seqno, 0);
47945 + atomic_set_unchecked(&pv->seqno, 0);
47946
47947 pr_devel("HVSI@%x: Handshaking started\n", pv->termno);
47948
47949 @@ -265,7 +265,7 @@ int hvsilib_read_mctrl(struct hvsi_priv *pv)
47950 pv->mctrl_update = 0;
47951 q.hdr.type = VS_QUERY_PACKET_HEADER;
47952 q.hdr.len = sizeof(struct hvsi_query);
47953 - q.hdr.seqno = atomic_inc_return(&pv->seqno);
47954 + q.hdr.seqno = atomic_inc_return_unchecked(&pv->seqno);
47955 q.verb = VSV_SEND_MODEM_CTL_STATUS;
47956 rc = hvsi_send_packet(pv, &q.hdr);
47957 if (rc <= 0) {
47958 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
47959 index 8fd72ff..34a0bed 100644
47960 --- a/drivers/tty/ipwireless/tty.c
47961 +++ b/drivers/tty/ipwireless/tty.c
47962 @@ -29,6 +29,7 @@
47963 #include <linux/tty_driver.h>
47964 #include <linux/tty_flip.h>
47965 #include <linux/uaccess.h>
47966 +#include <asm/local.h>
47967
47968 #include "tty.h"
47969 #include "network.h"
47970 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
47971 mutex_unlock(&tty->ipw_tty_mutex);
47972 return -ENODEV;
47973 }
47974 - if (tty->port.count == 0)
47975 + if (atomic_read(&tty->port.count) == 0)
47976 tty->tx_bytes_queued = 0;
47977
47978 - tty->port.count++;
47979 + atomic_inc(&tty->port.count);
47980
47981 tty->port.tty = linux_tty;
47982 linux_tty->driver_data = tty;
47983 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
47984
47985 static void do_ipw_close(struct ipw_tty *tty)
47986 {
47987 - tty->port.count--;
47988 -
47989 - if (tty->port.count == 0) {
47990 + if (atomic_dec_return(&tty->port.count) == 0) {
47991 struct tty_struct *linux_tty = tty->port.tty;
47992
47993 if (linux_tty != NULL) {
47994 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
47995 return;
47996
47997 mutex_lock(&tty->ipw_tty_mutex);
47998 - if (tty->port.count == 0) {
47999 + if (atomic_read(&tty->port.count) == 0) {
48000 mutex_unlock(&tty->ipw_tty_mutex);
48001 return;
48002 }
48003 @@ -164,7 +163,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
48004
48005 mutex_lock(&tty->ipw_tty_mutex);
48006
48007 - if (!tty->port.count) {
48008 + if (!atomic_read(&tty->port.count)) {
48009 mutex_unlock(&tty->ipw_tty_mutex);
48010 return;
48011 }
48012 @@ -206,7 +205,7 @@ static int ipw_write(struct tty_struct *linux_tty,
48013 return -ENODEV;
48014
48015 mutex_lock(&tty->ipw_tty_mutex);
48016 - if (!tty->port.count) {
48017 + if (!atomic_read(&tty->port.count)) {
48018 mutex_unlock(&tty->ipw_tty_mutex);
48019 return -EINVAL;
48020 }
48021 @@ -246,7 +245,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
48022 if (!tty)
48023 return -ENODEV;
48024
48025 - if (!tty->port.count)
48026 + if (!atomic_read(&tty->port.count))
48027 return -EINVAL;
48028
48029 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
48030 @@ -288,7 +287,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
48031 if (!tty)
48032 return 0;
48033
48034 - if (!tty->port.count)
48035 + if (!atomic_read(&tty->port.count))
48036 return 0;
48037
48038 return tty->tx_bytes_queued;
48039 @@ -369,7 +368,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
48040 if (!tty)
48041 return -ENODEV;
48042
48043 - if (!tty->port.count)
48044 + if (!atomic_read(&tty->port.count))
48045 return -EINVAL;
48046
48047 return get_control_lines(tty);
48048 @@ -385,7 +384,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
48049 if (!tty)
48050 return -ENODEV;
48051
48052 - if (!tty->port.count)
48053 + if (!atomic_read(&tty->port.count))
48054 return -EINVAL;
48055
48056 return set_control_lines(tty, set, clear);
48057 @@ -399,7 +398,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
48058 if (!tty)
48059 return -ENODEV;
48060
48061 - if (!tty->port.count)
48062 + if (!atomic_read(&tty->port.count))
48063 return -EINVAL;
48064
48065 /* FIXME: Exactly how is the tty object locked here .. */
48066 @@ -555,7 +554,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
48067 * are gone */
48068 mutex_lock(&ttyj->ipw_tty_mutex);
48069 }
48070 - while (ttyj->port.count)
48071 + while (atomic_read(&ttyj->port.count))
48072 do_ipw_close(ttyj);
48073 ipwireless_disassociate_network_ttys(network,
48074 ttyj->channel_idx);
48075 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
48076 index 1deaca4..c8582d4 100644
48077 --- a/drivers/tty/moxa.c
48078 +++ b/drivers/tty/moxa.c
48079 @@ -1189,7 +1189,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
48080 }
48081
48082 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
48083 - ch->port.count++;
48084 + atomic_inc(&ch->port.count);
48085 tty->driver_data = ch;
48086 tty_port_tty_set(&ch->port, tty);
48087 mutex_lock(&ch->port.mutex);
48088 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
48089 index 6422390..49003ac8 100644
48090 --- a/drivers/tty/n_gsm.c
48091 +++ b/drivers/tty/n_gsm.c
48092 @@ -1632,7 +1632,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
48093 spin_lock_init(&dlci->lock);
48094 mutex_init(&dlci->mutex);
48095 dlci->fifo = &dlci->_fifo;
48096 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
48097 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
48098 kfree(dlci);
48099 return NULL;
48100 }
48101 @@ -2932,7 +2932,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
48102 struct gsm_dlci *dlci = tty->driver_data;
48103 struct tty_port *port = &dlci->port;
48104
48105 - port->count++;
48106 + atomic_inc(&port->count);
48107 dlci_get(dlci);
48108 dlci_get(dlci->gsm->dlci[0]);
48109 mux_get(dlci->gsm);
48110 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
48111 index 6c7fe90..9241dab 100644
48112 --- a/drivers/tty/n_tty.c
48113 +++ b/drivers/tty/n_tty.c
48114 @@ -2203,6 +2203,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
48115 {
48116 *ops = tty_ldisc_N_TTY;
48117 ops->owner = NULL;
48118 - ops->refcount = ops->flags = 0;
48119 + atomic_set(&ops->refcount, 0);
48120 + ops->flags = 0;
48121 }
48122 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
48123 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
48124 index abfd990..5ab5da9 100644
48125 --- a/drivers/tty/pty.c
48126 +++ b/drivers/tty/pty.c
48127 @@ -796,8 +796,10 @@ static void __init unix98_pty_init(void)
48128 panic("Couldn't register Unix98 pts driver");
48129
48130 /* Now create the /dev/ptmx special device */
48131 + pax_open_kernel();
48132 tty_default_fops(&ptmx_fops);
48133 - ptmx_fops.open = ptmx_open;
48134 + *(void **)&ptmx_fops.open = ptmx_open;
48135 + pax_close_kernel();
48136
48137 cdev_init(&ptmx_cdev, &ptmx_fops);
48138 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
48139 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
48140 index 354564e..fe50d9a 100644
48141 --- a/drivers/tty/rocket.c
48142 +++ b/drivers/tty/rocket.c
48143 @@ -914,7 +914,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
48144 tty->driver_data = info;
48145 tty_port_tty_set(port, tty);
48146
48147 - if (port->count++ == 0) {
48148 + if (atomic_inc_return(&port->count) == 1) {
48149 atomic_inc(&rp_num_ports_open);
48150
48151 #ifdef ROCKET_DEBUG_OPEN
48152 @@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
48153 #endif
48154 }
48155 #ifdef ROCKET_DEBUG_OPEN
48156 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
48157 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
48158 #endif
48159
48160 /*
48161 @@ -1515,7 +1515,7 @@ static void rp_hangup(struct tty_struct *tty)
48162 spin_unlock_irqrestore(&info->port.lock, flags);
48163 return;
48164 }
48165 - if (info->port.count)
48166 + if (atomic_read(&info->port.count))
48167 atomic_dec(&rp_num_ports_open);
48168 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
48169 spin_unlock_irqrestore(&info->port.lock, flags);
48170 diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
48171 index e2520ab..034e20b 100644
48172 --- a/drivers/tty/serial/ioc4_serial.c
48173 +++ b/drivers/tty/serial/ioc4_serial.c
48174 @@ -437,7 +437,7 @@ struct ioc4_soft {
48175 } is_intr_info[MAX_IOC4_INTR_ENTS];
48176
48177 /* Number of entries active in the above array */
48178 - atomic_t is_num_intrs;
48179 + atomic_unchecked_t is_num_intrs;
48180 } is_intr_type[IOC4_NUM_INTR_TYPES];
48181
48182 /* is_ir_lock must be held while
48183 @@ -974,7 +974,7 @@ intr_connect(struct ioc4_soft *soft, int type,
48184 BUG_ON(!((type == IOC4_SIO_INTR_TYPE)
48185 || (type == IOC4_OTHER_INTR_TYPE)));
48186
48187 - i = atomic_inc_return(&soft-> is_intr_type[type].is_num_intrs) - 1;
48188 + i = atomic_inc_return_unchecked(&soft-> is_intr_type[type].is_num_intrs) - 1;
48189 BUG_ON(!(i < MAX_IOC4_INTR_ENTS || (printk("i %d\n", i), 0)));
48190
48191 /* Save off the lower level interrupt handler */
48192 @@ -1001,7 +1001,7 @@ static irqreturn_t ioc4_intr(int irq, void *arg)
48193
48194 soft = arg;
48195 for (intr_type = 0; intr_type < IOC4_NUM_INTR_TYPES; intr_type++) {
48196 - num_intrs = (int)atomic_read(
48197 + num_intrs = (int)atomic_read_unchecked(
48198 &soft->is_intr_type[intr_type].is_num_intrs);
48199
48200 this_mir = this_ir = pending_intrs(soft, intr_type);
48201 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
48202 index 1002054..dd644a8 100644
48203 --- a/drivers/tty/serial/kgdboc.c
48204 +++ b/drivers/tty/serial/kgdboc.c
48205 @@ -24,8 +24,9 @@
48206 #define MAX_CONFIG_LEN 40
48207
48208 static struct kgdb_io kgdboc_io_ops;
48209 +static struct kgdb_io kgdboc_io_ops_console;
48210
48211 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
48212 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
48213 static int configured = -1;
48214
48215 static char config[MAX_CONFIG_LEN];
48216 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
48217 kgdboc_unregister_kbd();
48218 if (configured == 1)
48219 kgdb_unregister_io_module(&kgdboc_io_ops);
48220 + else if (configured == 2)
48221 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
48222 }
48223
48224 static int configure_kgdboc(void)
48225 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
48226 int err;
48227 char *cptr = config;
48228 struct console *cons;
48229 + int is_console = 0;
48230
48231 err = kgdboc_option_setup(config);
48232 if (err || !strlen(config) || isspace(config[0]))
48233 goto noconfig;
48234
48235 err = -ENODEV;
48236 - kgdboc_io_ops.is_console = 0;
48237 kgdb_tty_driver = NULL;
48238
48239 kgdboc_use_kms = 0;
48240 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
48241 int idx;
48242 if (cons->device && cons->device(cons, &idx) == p &&
48243 idx == tty_line) {
48244 - kgdboc_io_ops.is_console = 1;
48245 + is_console = 1;
48246 break;
48247 }
48248 cons = cons->next;
48249 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
48250 kgdb_tty_line = tty_line;
48251
48252 do_register:
48253 - err = kgdb_register_io_module(&kgdboc_io_ops);
48254 + if (is_console) {
48255 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
48256 + configured = 2;
48257 + } else {
48258 + err = kgdb_register_io_module(&kgdboc_io_ops);
48259 + configured = 1;
48260 + }
48261 if (err)
48262 goto noconfig;
48263
48264 @@ -205,8 +214,6 @@ do_register:
48265 if (err)
48266 goto nmi_con_failed;
48267
48268 - configured = 1;
48269 -
48270 return 0;
48271
48272 nmi_con_failed:
48273 @@ -223,7 +230,7 @@ noconfig:
48274 static int __init init_kgdboc(void)
48275 {
48276 /* Already configured? */
48277 - if (configured == 1)
48278 + if (configured >= 1)
48279 return 0;
48280
48281 return configure_kgdboc();
48282 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
48283 if (config[len - 1] == '\n')
48284 config[len - 1] = '\0';
48285
48286 - if (configured == 1)
48287 + if (configured >= 1)
48288 cleanup_kgdboc();
48289
48290 /* Go and configure with the new params. */
48291 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
48292 .post_exception = kgdboc_post_exp_handler,
48293 };
48294
48295 +static struct kgdb_io kgdboc_io_ops_console = {
48296 + .name = "kgdboc",
48297 + .read_char = kgdboc_get_char,
48298 + .write_char = kgdboc_put_char,
48299 + .pre_exception = kgdboc_pre_exp_handler,
48300 + .post_exception = kgdboc_post_exp_handler,
48301 + .is_console = 1
48302 +};
48303 +
48304 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
48305 /* This is only available if kgdboc is a built in for early debugging */
48306 static int __init kgdboc_early_init(char *opt)
48307 diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
48308 index b11e997..6d25a3b 100644
48309 --- a/drivers/tty/serial/msm_serial.c
48310 +++ b/drivers/tty/serial/msm_serial.c
48311 @@ -857,7 +857,7 @@ static struct uart_driver msm_uart_driver = {
48312 .cons = MSM_CONSOLE,
48313 };
48314
48315 -static atomic_t msm_uart_next_id = ATOMIC_INIT(0);
48316 +static atomic_unchecked_t msm_uart_next_id = ATOMIC_INIT(0);
48317
48318 static int __init msm_serial_probe(struct platform_device *pdev)
48319 {
48320 @@ -867,7 +867,7 @@ static int __init msm_serial_probe(struct platform_device *pdev)
48321 int irq;
48322
48323 if (pdev->id == -1)
48324 - pdev->id = atomic_inc_return(&msm_uart_next_id) - 1;
48325 + pdev->id = atomic_inc_return_unchecked(&msm_uart_next_id) - 1;
48326
48327 if (unlikely(pdev->id < 0 || pdev->id >= UART_NR))
48328 return -ENXIO;
48329 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
48330 index 0c8a9fa..234a95f 100644
48331 --- a/drivers/tty/serial/samsung.c
48332 +++ b/drivers/tty/serial/samsung.c
48333 @@ -453,11 +453,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
48334 }
48335 }
48336
48337 +static int s3c64xx_serial_startup(struct uart_port *port);
48338 static int s3c24xx_serial_startup(struct uart_port *port)
48339 {
48340 struct s3c24xx_uart_port *ourport = to_ourport(port);
48341 int ret;
48342
48343 + /* Startup sequence is different for s3c64xx and higher SoC's */
48344 + if (s3c24xx_serial_has_interrupt_mask(port))
48345 + return s3c64xx_serial_startup(port);
48346 +
48347 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
48348 port->mapbase, port->membase);
48349
48350 @@ -1124,10 +1129,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
48351 /* setup info for port */
48352 port->dev = &platdev->dev;
48353
48354 - /* Startup sequence is different for s3c64xx and higher SoC's */
48355 - if (s3c24xx_serial_has_interrupt_mask(port))
48356 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
48357 -
48358 port->uartclk = 1;
48359
48360 if (cfg->uart_flags & UPF_CONS_FLOW) {
48361 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
48362 index f87dbfd..42ad4b1 100644
48363 --- a/drivers/tty/serial/serial_core.c
48364 +++ b/drivers/tty/serial/serial_core.c
48365 @@ -1454,7 +1454,7 @@ static void uart_hangup(struct tty_struct *tty)
48366 uart_flush_buffer(tty);
48367 uart_shutdown(tty, state);
48368 spin_lock_irqsave(&port->lock, flags);
48369 - port->count = 0;
48370 + atomic_set(&port->count, 0);
48371 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
48372 spin_unlock_irqrestore(&port->lock, flags);
48373 tty_port_tty_set(port, NULL);
48374 @@ -1550,7 +1550,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48375 goto end;
48376 }
48377
48378 - port->count++;
48379 + atomic_inc(&port->count);
48380 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
48381 retval = -ENXIO;
48382 goto err_dec_count;
48383 @@ -1578,7 +1578,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48384 /*
48385 * Make sure the device is in D0 state.
48386 */
48387 - if (port->count == 1)
48388 + if (atomic_read(&port->count) == 1)
48389 uart_change_pm(state, UART_PM_STATE_ON);
48390
48391 /*
48392 @@ -1596,7 +1596,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48393 end:
48394 return retval;
48395 err_dec_count:
48396 - port->count--;
48397 + atomic_inc(&port->count);
48398 mutex_unlock(&port->mutex);
48399 goto end;
48400 }
48401 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
48402 index 8eaf1ab..85c030d 100644
48403 --- a/drivers/tty/synclink.c
48404 +++ b/drivers/tty/synclink.c
48405 @@ -3090,7 +3090,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
48406
48407 if (debug_level >= DEBUG_LEVEL_INFO)
48408 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
48409 - __FILE__,__LINE__, info->device_name, info->port.count);
48410 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
48411
48412 if (tty_port_close_start(&info->port, tty, filp) == 0)
48413 goto cleanup;
48414 @@ -3108,7 +3108,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
48415 cleanup:
48416 if (debug_level >= DEBUG_LEVEL_INFO)
48417 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
48418 - tty->driver->name, info->port.count);
48419 + tty->driver->name, atomic_read(&info->port.count));
48420
48421 } /* end of mgsl_close() */
48422
48423 @@ -3207,8 +3207,8 @@ static void mgsl_hangup(struct tty_struct *tty)
48424
48425 mgsl_flush_buffer(tty);
48426 shutdown(info);
48427 -
48428 - info->port.count = 0;
48429 +
48430 + atomic_set(&info->port.count, 0);
48431 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48432 info->port.tty = NULL;
48433
48434 @@ -3297,12 +3297,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48435
48436 if (debug_level >= DEBUG_LEVEL_INFO)
48437 printk("%s(%d):block_til_ready before block on %s count=%d\n",
48438 - __FILE__,__LINE__, tty->driver->name, port->count );
48439 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48440
48441 spin_lock_irqsave(&info->irq_spinlock, flags);
48442 if (!tty_hung_up_p(filp)) {
48443 extra_count = true;
48444 - port->count--;
48445 + atomic_dec(&port->count);
48446 }
48447 spin_unlock_irqrestore(&info->irq_spinlock, flags);
48448 port->blocked_open++;
48449 @@ -3331,7 +3331,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48450
48451 if (debug_level >= DEBUG_LEVEL_INFO)
48452 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
48453 - __FILE__,__LINE__, tty->driver->name, port->count );
48454 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48455
48456 tty_unlock(tty);
48457 schedule();
48458 @@ -3343,12 +3343,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48459
48460 /* FIXME: Racy on hangup during close wait */
48461 if (extra_count)
48462 - port->count++;
48463 + atomic_inc(&port->count);
48464 port->blocked_open--;
48465
48466 if (debug_level >= DEBUG_LEVEL_INFO)
48467 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
48468 - __FILE__,__LINE__, tty->driver->name, port->count );
48469 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48470
48471 if (!retval)
48472 port->flags |= ASYNC_NORMAL_ACTIVE;
48473 @@ -3400,7 +3400,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48474
48475 if (debug_level >= DEBUG_LEVEL_INFO)
48476 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
48477 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48478 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48479
48480 /* If port is closing, signal caller to try again */
48481 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48482 @@ -3419,10 +3419,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48483 spin_unlock_irqrestore(&info->netlock, flags);
48484 goto cleanup;
48485 }
48486 - info->port.count++;
48487 + atomic_inc(&info->port.count);
48488 spin_unlock_irqrestore(&info->netlock, flags);
48489
48490 - if (info->port.count == 1) {
48491 + if (atomic_read(&info->port.count) == 1) {
48492 /* 1st open on this device, init hardware */
48493 retval = startup(info);
48494 if (retval < 0)
48495 @@ -3446,8 +3446,8 @@ cleanup:
48496 if (retval) {
48497 if (tty->count == 1)
48498 info->port.tty = NULL; /* tty layer will release tty struct */
48499 - if(info->port.count)
48500 - info->port.count--;
48501 + if (atomic_read(&info->port.count))
48502 + atomic_dec(&info->port.count);
48503 }
48504
48505 return retval;
48506 @@ -7665,7 +7665,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48507 unsigned short new_crctype;
48508
48509 /* return error if TTY interface open */
48510 - if (info->port.count)
48511 + if (atomic_read(&info->port.count))
48512 return -EBUSY;
48513
48514 switch (encoding)
48515 @@ -7760,7 +7760,7 @@ static int hdlcdev_open(struct net_device *dev)
48516
48517 /* arbitrate between network and tty opens */
48518 spin_lock_irqsave(&info->netlock, flags);
48519 - if (info->port.count != 0 || info->netcount != 0) {
48520 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48521 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48522 spin_unlock_irqrestore(&info->netlock, flags);
48523 return -EBUSY;
48524 @@ -7846,7 +7846,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48525 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48526
48527 /* return error if TTY interface open */
48528 - if (info->port.count)
48529 + if (atomic_read(&info->port.count))
48530 return -EBUSY;
48531
48532 if (cmd != SIOCWANDEV)
48533 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
48534 index 1abf946..1ee34fc 100644
48535 --- a/drivers/tty/synclink_gt.c
48536 +++ b/drivers/tty/synclink_gt.c
48537 @@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48538 tty->driver_data = info;
48539 info->port.tty = tty;
48540
48541 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
48542 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
48543
48544 /* If port is closing, signal caller to try again */
48545 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48546 @@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48547 mutex_unlock(&info->port.mutex);
48548 goto cleanup;
48549 }
48550 - info->port.count++;
48551 + atomic_inc(&info->port.count);
48552 spin_unlock_irqrestore(&info->netlock, flags);
48553
48554 - if (info->port.count == 1) {
48555 + if (atomic_read(&info->port.count) == 1) {
48556 /* 1st open on this device, init hardware */
48557 retval = startup(info);
48558 if (retval < 0) {
48559 @@ -715,8 +715,8 @@ cleanup:
48560 if (retval) {
48561 if (tty->count == 1)
48562 info->port.tty = NULL; /* tty layer will release tty struct */
48563 - if(info->port.count)
48564 - info->port.count--;
48565 + if(atomic_read(&info->port.count))
48566 + atomic_dec(&info->port.count);
48567 }
48568
48569 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
48570 @@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48571
48572 if (sanity_check(info, tty->name, "close"))
48573 return;
48574 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
48575 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
48576
48577 if (tty_port_close_start(&info->port, tty, filp) == 0)
48578 goto cleanup;
48579 @@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48580 tty_port_close_end(&info->port, tty);
48581 info->port.tty = NULL;
48582 cleanup:
48583 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
48584 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
48585 }
48586
48587 static void hangup(struct tty_struct *tty)
48588 @@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
48589 shutdown(info);
48590
48591 spin_lock_irqsave(&info->port.lock, flags);
48592 - info->port.count = 0;
48593 + atomic_set(&info->port.count, 0);
48594 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48595 info->port.tty = NULL;
48596 spin_unlock_irqrestore(&info->port.lock, flags);
48597 @@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48598 unsigned short new_crctype;
48599
48600 /* return error if TTY interface open */
48601 - if (info->port.count)
48602 + if (atomic_read(&info->port.count))
48603 return -EBUSY;
48604
48605 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
48606 @@ -1544,7 +1544,7 @@ static int hdlcdev_open(struct net_device *dev)
48607
48608 /* arbitrate between network and tty opens */
48609 spin_lock_irqsave(&info->netlock, flags);
48610 - if (info->port.count != 0 || info->netcount != 0) {
48611 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48612 DBGINFO(("%s hdlc_open busy\n", dev->name));
48613 spin_unlock_irqrestore(&info->netlock, flags);
48614 return -EBUSY;
48615 @@ -1629,7 +1629,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48616 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
48617
48618 /* return error if TTY interface open */
48619 - if (info->port.count)
48620 + if (atomic_read(&info->port.count))
48621 return -EBUSY;
48622
48623 if (cmd != SIOCWANDEV)
48624 @@ -2413,7 +2413,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
48625 if (port == NULL)
48626 continue;
48627 spin_lock(&port->lock);
48628 - if ((port->port.count || port->netcount) &&
48629 + if ((atomic_read(&port->port.count) || port->netcount) &&
48630 port->pending_bh && !port->bh_running &&
48631 !port->bh_requested) {
48632 DBGISR(("%s bh queued\n", port->device_name));
48633 @@ -3302,7 +3302,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48634 spin_lock_irqsave(&info->lock, flags);
48635 if (!tty_hung_up_p(filp)) {
48636 extra_count = true;
48637 - port->count--;
48638 + atomic_dec(&port->count);
48639 }
48640 spin_unlock_irqrestore(&info->lock, flags);
48641 port->blocked_open++;
48642 @@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48643 remove_wait_queue(&port->open_wait, &wait);
48644
48645 if (extra_count)
48646 - port->count++;
48647 + atomic_inc(&port->count);
48648 port->blocked_open--;
48649
48650 if (!retval)
48651 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
48652 index ff17138..e38b41e 100644
48653 --- a/drivers/tty/synclinkmp.c
48654 +++ b/drivers/tty/synclinkmp.c
48655 @@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48656
48657 if (debug_level >= DEBUG_LEVEL_INFO)
48658 printk("%s(%d):%s open(), old ref count = %d\n",
48659 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48660 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48661
48662 /* If port is closing, signal caller to try again */
48663 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48664 @@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48665 spin_unlock_irqrestore(&info->netlock, flags);
48666 goto cleanup;
48667 }
48668 - info->port.count++;
48669 + atomic_inc(&info->port.count);
48670 spin_unlock_irqrestore(&info->netlock, flags);
48671
48672 - if (info->port.count == 1) {
48673 + if (atomic_read(&info->port.count) == 1) {
48674 /* 1st open on this device, init hardware */
48675 retval = startup(info);
48676 if (retval < 0)
48677 @@ -796,8 +796,8 @@ cleanup:
48678 if (retval) {
48679 if (tty->count == 1)
48680 info->port.tty = NULL; /* tty layer will release tty struct */
48681 - if(info->port.count)
48682 - info->port.count--;
48683 + if(atomic_read(&info->port.count))
48684 + atomic_dec(&info->port.count);
48685 }
48686
48687 return retval;
48688 @@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48689
48690 if (debug_level >= DEBUG_LEVEL_INFO)
48691 printk("%s(%d):%s close() entry, count=%d\n",
48692 - __FILE__,__LINE__, info->device_name, info->port.count);
48693 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
48694
48695 if (tty_port_close_start(&info->port, tty, filp) == 0)
48696 goto cleanup;
48697 @@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48698 cleanup:
48699 if (debug_level >= DEBUG_LEVEL_INFO)
48700 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
48701 - tty->driver->name, info->port.count);
48702 + tty->driver->name, atomic_read(&info->port.count));
48703 }
48704
48705 /* Called by tty_hangup() when a hangup is signaled.
48706 @@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
48707 shutdown(info);
48708
48709 spin_lock_irqsave(&info->port.lock, flags);
48710 - info->port.count = 0;
48711 + atomic_set(&info->port.count, 0);
48712 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48713 info->port.tty = NULL;
48714 spin_unlock_irqrestore(&info->port.lock, flags);
48715 @@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48716 unsigned short new_crctype;
48717
48718 /* return error if TTY interface open */
48719 - if (info->port.count)
48720 + if (atomic_read(&info->port.count))
48721 return -EBUSY;
48722
48723 switch (encoding)
48724 @@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
48725
48726 /* arbitrate between network and tty opens */
48727 spin_lock_irqsave(&info->netlock, flags);
48728 - if (info->port.count != 0 || info->netcount != 0) {
48729 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48730 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48731 spin_unlock_irqrestore(&info->netlock, flags);
48732 return -EBUSY;
48733 @@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48734 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48735
48736 /* return error if TTY interface open */
48737 - if (info->port.count)
48738 + if (atomic_read(&info->port.count))
48739 return -EBUSY;
48740
48741 if (cmd != SIOCWANDEV)
48742 @@ -2620,7 +2620,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
48743 * do not request bottom half processing if the
48744 * device is not open in a normal mode.
48745 */
48746 - if ( port && (port->port.count || port->netcount) &&
48747 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
48748 port->pending_bh && !port->bh_running &&
48749 !port->bh_requested ) {
48750 if ( debug_level >= DEBUG_LEVEL_ISR )
48751 @@ -3318,12 +3318,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48752
48753 if (debug_level >= DEBUG_LEVEL_INFO)
48754 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
48755 - __FILE__,__LINE__, tty->driver->name, port->count );
48756 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48757
48758 spin_lock_irqsave(&info->lock, flags);
48759 if (!tty_hung_up_p(filp)) {
48760 extra_count = true;
48761 - port->count--;
48762 + atomic_dec(&port->count);
48763 }
48764 spin_unlock_irqrestore(&info->lock, flags);
48765 port->blocked_open++;
48766 @@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48767
48768 if (debug_level >= DEBUG_LEVEL_INFO)
48769 printk("%s(%d):%s block_til_ready() count=%d\n",
48770 - __FILE__,__LINE__, tty->driver->name, port->count );
48771 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48772
48773 tty_unlock(tty);
48774 schedule();
48775 @@ -3363,12 +3363,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48776 remove_wait_queue(&port->open_wait, &wait);
48777
48778 if (extra_count)
48779 - port->count++;
48780 + atomic_inc(&port->count);
48781 port->blocked_open--;
48782
48783 if (debug_level >= DEBUG_LEVEL_INFO)
48784 printk("%s(%d):%s block_til_ready() after, count=%d\n",
48785 - __FILE__,__LINE__, tty->driver->name, port->count );
48786 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48787
48788 if (!retval)
48789 port->flags |= ASYNC_NORMAL_ACTIVE;
48790 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
48791 index b51c154..17d55d1 100644
48792 --- a/drivers/tty/sysrq.c
48793 +++ b/drivers/tty/sysrq.c
48794 @@ -1022,7 +1022,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
48795 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
48796 size_t count, loff_t *ppos)
48797 {
48798 - if (count) {
48799 + if (count && capable(CAP_SYS_ADMIN)) {
48800 char c;
48801
48802 if (get_user(c, buf))
48803 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
48804 index 4476682..d77e748 100644
48805 --- a/drivers/tty/tty_io.c
48806 +++ b/drivers/tty/tty_io.c
48807 @@ -3466,7 +3466,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
48808
48809 void tty_default_fops(struct file_operations *fops)
48810 {
48811 - *fops = tty_fops;
48812 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
48813 }
48814
48815 /*
48816 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
48817 index 1afe192..73d2c20 100644
48818 --- a/drivers/tty/tty_ldisc.c
48819 +++ b/drivers/tty/tty_ldisc.c
48820 @@ -66,7 +66,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
48821 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
48822 tty_ldiscs[disc] = new_ldisc;
48823 new_ldisc->num = disc;
48824 - new_ldisc->refcount = 0;
48825 + atomic_set(&new_ldisc->refcount, 0);
48826 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
48827
48828 return ret;
48829 @@ -94,7 +94,7 @@ int tty_unregister_ldisc(int disc)
48830 return -EINVAL;
48831
48832 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
48833 - if (tty_ldiscs[disc]->refcount)
48834 + if (atomic_read(&tty_ldiscs[disc]->refcount))
48835 ret = -EBUSY;
48836 else
48837 tty_ldiscs[disc] = NULL;
48838 @@ -115,7 +115,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
48839 if (ldops) {
48840 ret = ERR_PTR(-EAGAIN);
48841 if (try_module_get(ldops->owner)) {
48842 - ldops->refcount++;
48843 + atomic_inc(&ldops->refcount);
48844 ret = ldops;
48845 }
48846 }
48847 @@ -128,7 +128,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
48848 unsigned long flags;
48849
48850 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
48851 - ldops->refcount--;
48852 + atomic_dec(&ldops->refcount);
48853 module_put(ldops->owner);
48854 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
48855 }
48856 @@ -196,7 +196,7 @@ static inline void tty_ldisc_put(struct tty_ldisc *ld)
48857 /* unreleased reader reference(s) will cause this WARN */
48858 WARN_ON(!atomic_dec_and_test(&ld->users));
48859
48860 - ld->ops->refcount--;
48861 + atomic_dec(&ld->ops->refcount);
48862 module_put(ld->ops->owner);
48863 kfree(ld);
48864 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
48865 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
48866 index f597e88..b7f68ed 100644
48867 --- a/drivers/tty/tty_port.c
48868 +++ b/drivers/tty/tty_port.c
48869 @@ -232,7 +232,7 @@ void tty_port_hangup(struct tty_port *port)
48870 unsigned long flags;
48871
48872 spin_lock_irqsave(&port->lock, flags);
48873 - port->count = 0;
48874 + atomic_set(&port->count, 0);
48875 port->flags &= ~ASYNC_NORMAL_ACTIVE;
48876 tty = port->tty;
48877 if (tty)
48878 @@ -390,7 +390,7 @@ int tty_port_block_til_ready(struct tty_port *port,
48879 /* The port lock protects the port counts */
48880 spin_lock_irqsave(&port->lock, flags);
48881 if (!tty_hung_up_p(filp))
48882 - port->count--;
48883 + atomic_dec(&port->count);
48884 port->blocked_open++;
48885 spin_unlock_irqrestore(&port->lock, flags);
48886
48887 @@ -432,7 +432,7 @@ int tty_port_block_til_ready(struct tty_port *port,
48888 we must not mess that up further */
48889 spin_lock_irqsave(&port->lock, flags);
48890 if (!tty_hung_up_p(filp))
48891 - port->count++;
48892 + atomic_inc(&port->count);
48893 port->blocked_open--;
48894 if (retval == 0)
48895 port->flags |= ASYNC_NORMAL_ACTIVE;
48896 @@ -466,19 +466,19 @@ int tty_port_close_start(struct tty_port *port,
48897 return 0;
48898 }
48899
48900 - if (tty->count == 1 && port->count != 1) {
48901 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
48902 printk(KERN_WARNING
48903 "tty_port_close_start: tty->count = 1 port count = %d.\n",
48904 - port->count);
48905 - port->count = 1;
48906 + atomic_read(&port->count));
48907 + atomic_set(&port->count, 1);
48908 }
48909 - if (--port->count < 0) {
48910 + if (atomic_dec_return(&port->count) < 0) {
48911 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
48912 - port->count);
48913 - port->count = 0;
48914 + atomic_read(&port->count));
48915 + atomic_set(&port->count, 0);
48916 }
48917
48918 - if (port->count) {
48919 + if (atomic_read(&port->count)) {
48920 spin_unlock_irqrestore(&port->lock, flags);
48921 if (port->ops->drop)
48922 port->ops->drop(port);
48923 @@ -564,7 +564,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
48924 {
48925 spin_lock_irq(&port->lock);
48926 if (!tty_hung_up_p(filp))
48927 - ++port->count;
48928 + atomic_inc(&port->count);
48929 spin_unlock_irq(&port->lock);
48930 tty_port_tty_set(port, tty);
48931
48932 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
48933 index a9af1b9a..1e08e7f 100644
48934 --- a/drivers/tty/vt/keyboard.c
48935 +++ b/drivers/tty/vt/keyboard.c
48936 @@ -647,6 +647,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
48937 kbd->kbdmode == VC_OFF) &&
48938 value != KVAL(K_SAK))
48939 return; /* SAK is allowed even in raw mode */
48940 +
48941 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
48942 + {
48943 + void *func = fn_handler[value];
48944 + if (func == fn_show_state || func == fn_show_ptregs ||
48945 + func == fn_show_mem)
48946 + return;
48947 + }
48948 +#endif
48949 +
48950 fn_handler[value](vc);
48951 }
48952
48953 @@ -1795,9 +1805,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
48954 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
48955 return -EFAULT;
48956
48957 - if (!capable(CAP_SYS_TTY_CONFIG))
48958 - perm = 0;
48959 -
48960 switch (cmd) {
48961 case KDGKBENT:
48962 /* Ensure another thread doesn't free it under us */
48963 @@ -1812,6 +1819,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
48964 spin_unlock_irqrestore(&kbd_event_lock, flags);
48965 return put_user(val, &user_kbe->kb_value);
48966 case KDSKBENT:
48967 + if (!capable(CAP_SYS_TTY_CONFIG))
48968 + perm = 0;
48969 +
48970 if (!perm)
48971 return -EPERM;
48972 if (!i && v == K_NOSUCHMAP) {
48973 @@ -1902,9 +1912,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
48974 int i, j, k;
48975 int ret;
48976
48977 - if (!capable(CAP_SYS_TTY_CONFIG))
48978 - perm = 0;
48979 -
48980 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
48981 if (!kbs) {
48982 ret = -ENOMEM;
48983 @@ -1938,6 +1945,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
48984 kfree(kbs);
48985 return ((p && *p) ? -EOVERFLOW : 0);
48986 case KDSKBSENT:
48987 + if (!capable(CAP_SYS_TTY_CONFIG))
48988 + perm = 0;
48989 +
48990 if (!perm) {
48991 ret = -EPERM;
48992 goto reterr;
48993 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
48994 index b645c47..a55c182 100644
48995 --- a/drivers/uio/uio.c
48996 +++ b/drivers/uio/uio.c
48997 @@ -25,6 +25,7 @@
48998 #include <linux/kobject.h>
48999 #include <linux/cdev.h>
49000 #include <linux/uio_driver.h>
49001 +#include <asm/local.h>
49002
49003 #define UIO_MAX_DEVICES (1U << MINORBITS)
49004
49005 @@ -32,10 +33,10 @@ struct uio_device {
49006 struct module *owner;
49007 struct device *dev;
49008 int minor;
49009 - atomic_t event;
49010 + atomic_unchecked_t event;
49011 struct fasync_struct *async_queue;
49012 wait_queue_head_t wait;
49013 - int vma_count;
49014 + local_t vma_count;
49015 struct uio_info *info;
49016 struct kobject *map_dir;
49017 struct kobject *portio_dir;
49018 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
49019 struct device_attribute *attr, char *buf)
49020 {
49021 struct uio_device *idev = dev_get_drvdata(dev);
49022 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
49023 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
49024 }
49025
49026 static struct device_attribute uio_class_attributes[] = {
49027 @@ -398,7 +399,7 @@ void uio_event_notify(struct uio_info *info)
49028 {
49029 struct uio_device *idev = info->uio_dev;
49030
49031 - atomic_inc(&idev->event);
49032 + atomic_inc_unchecked(&idev->event);
49033 wake_up_interruptible(&idev->wait);
49034 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
49035 }
49036 @@ -451,7 +452,7 @@ static int uio_open(struct inode *inode, struct file *filep)
49037 }
49038
49039 listener->dev = idev;
49040 - listener->event_count = atomic_read(&idev->event);
49041 + listener->event_count = atomic_read_unchecked(&idev->event);
49042 filep->private_data = listener;
49043
49044 if (idev->info->open) {
49045 @@ -502,7 +503,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
49046 return -EIO;
49047
49048 poll_wait(filep, &idev->wait, wait);
49049 - if (listener->event_count != atomic_read(&idev->event))
49050 + if (listener->event_count != atomic_read_unchecked(&idev->event))
49051 return POLLIN | POLLRDNORM;
49052 return 0;
49053 }
49054 @@ -527,7 +528,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
49055 do {
49056 set_current_state(TASK_INTERRUPTIBLE);
49057
49058 - event_count = atomic_read(&idev->event);
49059 + event_count = atomic_read_unchecked(&idev->event);
49060 if (event_count != listener->event_count) {
49061 if (copy_to_user(buf, &event_count, count))
49062 retval = -EFAULT;
49063 @@ -596,13 +597,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
49064 static void uio_vma_open(struct vm_area_struct *vma)
49065 {
49066 struct uio_device *idev = vma->vm_private_data;
49067 - idev->vma_count++;
49068 + local_inc(&idev->vma_count);
49069 }
49070
49071 static void uio_vma_close(struct vm_area_struct *vma)
49072 {
49073 struct uio_device *idev = vma->vm_private_data;
49074 - idev->vma_count--;
49075 + local_dec(&idev->vma_count);
49076 }
49077
49078 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
49079 @@ -809,7 +810,7 @@ int __uio_register_device(struct module *owner,
49080 idev->owner = owner;
49081 idev->info = info;
49082 init_waitqueue_head(&idev->wait);
49083 - atomic_set(&idev->event, 0);
49084 + atomic_set_unchecked(&idev->event, 0);
49085
49086 ret = uio_get_minor(idev);
49087 if (ret)
49088 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
49089 index 8a7eb77..c00402f 100644
49090 --- a/drivers/usb/atm/cxacru.c
49091 +++ b/drivers/usb/atm/cxacru.c
49092 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
49093 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
49094 if (ret < 2)
49095 return -EINVAL;
49096 - if (index < 0 || index > 0x7f)
49097 + if (index > 0x7f)
49098 return -EINVAL;
49099 pos += tmp;
49100
49101 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
49102 index d3527dd..26effa2 100644
49103 --- a/drivers/usb/atm/usbatm.c
49104 +++ b/drivers/usb/atm/usbatm.c
49105 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49106 if (printk_ratelimit())
49107 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
49108 __func__, vpi, vci);
49109 - atomic_inc(&vcc->stats->rx_err);
49110 + atomic_inc_unchecked(&vcc->stats->rx_err);
49111 return;
49112 }
49113
49114 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49115 if (length > ATM_MAX_AAL5_PDU) {
49116 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
49117 __func__, length, vcc);
49118 - atomic_inc(&vcc->stats->rx_err);
49119 + atomic_inc_unchecked(&vcc->stats->rx_err);
49120 goto out;
49121 }
49122
49123 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49124 if (sarb->len < pdu_length) {
49125 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
49126 __func__, pdu_length, sarb->len, vcc);
49127 - atomic_inc(&vcc->stats->rx_err);
49128 + atomic_inc_unchecked(&vcc->stats->rx_err);
49129 goto out;
49130 }
49131
49132 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
49133 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
49134 __func__, vcc);
49135 - atomic_inc(&vcc->stats->rx_err);
49136 + atomic_inc_unchecked(&vcc->stats->rx_err);
49137 goto out;
49138 }
49139
49140 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49141 if (printk_ratelimit())
49142 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
49143 __func__, length);
49144 - atomic_inc(&vcc->stats->rx_drop);
49145 + atomic_inc_unchecked(&vcc->stats->rx_drop);
49146 goto out;
49147 }
49148
49149 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49150
49151 vcc->push(vcc, skb);
49152
49153 - atomic_inc(&vcc->stats->rx);
49154 + atomic_inc_unchecked(&vcc->stats->rx);
49155 out:
49156 skb_trim(sarb, 0);
49157 }
49158 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
49159 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
49160
49161 usbatm_pop(vcc, skb);
49162 - atomic_inc(&vcc->stats->tx);
49163 + atomic_inc_unchecked(&vcc->stats->tx);
49164
49165 skb = skb_dequeue(&instance->sndqueue);
49166 }
49167 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
49168 if (!left--)
49169 return sprintf(page,
49170 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
49171 - atomic_read(&atm_dev->stats.aal5.tx),
49172 - atomic_read(&atm_dev->stats.aal5.tx_err),
49173 - atomic_read(&atm_dev->stats.aal5.rx),
49174 - atomic_read(&atm_dev->stats.aal5.rx_err),
49175 - atomic_read(&atm_dev->stats.aal5.rx_drop));
49176 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
49177 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
49178 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
49179 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
49180 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
49181
49182 if (!left--) {
49183 if (instance->disconnected)
49184 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
49185 index 2a3bbdf..91d72cf 100644
49186 --- a/drivers/usb/core/devices.c
49187 +++ b/drivers/usb/core/devices.c
49188 @@ -126,7 +126,7 @@ static const char format_endpt[] =
49189 * time it gets called.
49190 */
49191 static struct device_connect_event {
49192 - atomic_t count;
49193 + atomic_unchecked_t count;
49194 wait_queue_head_t wait;
49195 } device_event = {
49196 .count = ATOMIC_INIT(1),
49197 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
49198
49199 void usbfs_conn_disc_event(void)
49200 {
49201 - atomic_add(2, &device_event.count);
49202 + atomic_add_unchecked(2, &device_event.count);
49203 wake_up(&device_event.wait);
49204 }
49205
49206 @@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
49207
49208 poll_wait(file, &device_event.wait, wait);
49209
49210 - event_count = atomic_read(&device_event.count);
49211 + event_count = atomic_read_unchecked(&device_event.count);
49212 if (file->f_version != event_count) {
49213 file->f_version = event_count;
49214 return POLLIN | POLLRDNORM;
49215 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
49216 index d53547d..6a22d02 100644
49217 --- a/drivers/usb/core/hcd.c
49218 +++ b/drivers/usb/core/hcd.c
49219 @@ -1526,7 +1526,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
49220 */
49221 usb_get_urb(urb);
49222 atomic_inc(&urb->use_count);
49223 - atomic_inc(&urb->dev->urbnum);
49224 + atomic_inc_unchecked(&urb->dev->urbnum);
49225 usbmon_urb_submit(&hcd->self, urb);
49226
49227 /* NOTE requirements on root-hub callers (usbfs and the hub
49228 @@ -1553,7 +1553,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
49229 urb->hcpriv = NULL;
49230 INIT_LIST_HEAD(&urb->urb_list);
49231 atomic_dec(&urb->use_count);
49232 - atomic_dec(&urb->dev->urbnum);
49233 + atomic_dec_unchecked(&urb->dev->urbnum);
49234 if (atomic_read(&urb->reject))
49235 wake_up(&usb_kill_urb_queue);
49236 usb_put_urb(urb);
49237 diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
49238 index da2905a..834a569 100644
49239 --- a/drivers/usb/core/hub.c
49240 +++ b/drivers/usb/core/hub.c
49241 @@ -27,6 +27,7 @@
49242 #include <linux/freezer.h>
49243 #include <linux/random.h>
49244 #include <linux/pm_qos.h>
49245 +#include <linux/grsecurity.h>
49246
49247 #include <asm/uaccess.h>
49248 #include <asm/byteorder.h>
49249 @@ -4424,6 +4425,10 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
49250 goto done;
49251 return;
49252 }
49253 +
49254 + if (gr_handle_new_usb())
49255 + goto done;
49256 +
49257 if (hub_is_superspeed(hub->hdev))
49258 unit_load = 150;
49259 else
49260 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
49261 index 444d30e..f15c850 100644
49262 --- a/drivers/usb/core/message.c
49263 +++ b/drivers/usb/core/message.c
49264 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
49265 * method can wait for it to complete. Since you don't have a handle on the
49266 * URB used, you can't cancel the request.
49267 */
49268 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
49269 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
49270 __u8 requesttype, __u16 value, __u16 index, void *data,
49271 __u16 size, int timeout)
49272 {
49273 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
49274 index aa38db4..0a08682 100644
49275 --- a/drivers/usb/core/sysfs.c
49276 +++ b/drivers/usb/core/sysfs.c
49277 @@ -239,7 +239,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
49278 struct usb_device *udev;
49279
49280 udev = to_usb_device(dev);
49281 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
49282 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
49283 }
49284 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
49285
49286 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
49287 index b10da72..43aa0b2 100644
49288 --- a/drivers/usb/core/usb.c
49289 +++ b/drivers/usb/core/usb.c
49290 @@ -389,7 +389,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
49291 set_dev_node(&dev->dev, dev_to_node(bus->controller));
49292 dev->state = USB_STATE_ATTACHED;
49293 dev->lpm_disable_count = 1;
49294 - atomic_set(&dev->urbnum, 0);
49295 + atomic_set_unchecked(&dev->urbnum, 0);
49296
49297 INIT_LIST_HEAD(&dev->ep0.urb_list);
49298 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
49299 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
49300 index f77083f..f3e2e34 100644
49301 --- a/drivers/usb/dwc3/gadget.c
49302 +++ b/drivers/usb/dwc3/gadget.c
49303 @@ -550,8 +550,6 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep,
49304 if (!usb_endpoint_xfer_isoc(desc))
49305 return 0;
49306
49307 - memset(&trb_link, 0, sizeof(trb_link));
49308 -
49309 /* Link TRB for ISOC. The HWO bit is never reset */
49310 trb_st_hw = &dep->trb_pool[0];
49311
49312 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
49313 index 5e29dde..eca992f 100644
49314 --- a/drivers/usb/early/ehci-dbgp.c
49315 +++ b/drivers/usb/early/ehci-dbgp.c
49316 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
49317
49318 #ifdef CONFIG_KGDB
49319 static struct kgdb_io kgdbdbgp_io_ops;
49320 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
49321 +static struct kgdb_io kgdbdbgp_io_ops_console;
49322 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
49323 #else
49324 #define dbgp_kgdb_mode (0)
49325 #endif
49326 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
49327 .write_char = kgdbdbgp_write_char,
49328 };
49329
49330 +static struct kgdb_io kgdbdbgp_io_ops_console = {
49331 + .name = "kgdbdbgp",
49332 + .read_char = kgdbdbgp_read_char,
49333 + .write_char = kgdbdbgp_write_char,
49334 + .is_console = 1
49335 +};
49336 +
49337 static int kgdbdbgp_wait_time;
49338
49339 static int __init kgdbdbgp_parse_config(char *str)
49340 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
49341 ptr++;
49342 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
49343 }
49344 - kgdb_register_io_module(&kgdbdbgp_io_ops);
49345 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
49346 + if (early_dbgp_console.index != -1)
49347 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
49348 + else
49349 + kgdb_register_io_module(&kgdbdbgp_io_ops);
49350
49351 return 0;
49352 }
49353 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
49354 index b369292..9f3ba40 100644
49355 --- a/drivers/usb/gadget/u_serial.c
49356 +++ b/drivers/usb/gadget/u_serial.c
49357 @@ -733,9 +733,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
49358 spin_lock_irq(&port->port_lock);
49359
49360 /* already open? Great. */
49361 - if (port->port.count) {
49362 + if (atomic_read(&port->port.count)) {
49363 status = 0;
49364 - port->port.count++;
49365 + atomic_inc(&port->port.count);
49366
49367 /* currently opening/closing? wait ... */
49368 } else if (port->openclose) {
49369 @@ -794,7 +794,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
49370 tty->driver_data = port;
49371 port->port.tty = tty;
49372
49373 - port->port.count = 1;
49374 + atomic_set(&port->port.count, 1);
49375 port->openclose = false;
49376
49377 /* if connected, start the I/O stream */
49378 @@ -836,11 +836,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
49379
49380 spin_lock_irq(&port->port_lock);
49381
49382 - if (port->port.count != 1) {
49383 - if (port->port.count == 0)
49384 + if (atomic_read(&port->port.count) != 1) {
49385 + if (atomic_read(&port->port.count) == 0)
49386 WARN_ON(1);
49387 else
49388 - --port->port.count;
49389 + atomic_dec(&port->port.count);
49390 goto exit;
49391 }
49392
49393 @@ -850,7 +850,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
49394 * and sleep if necessary
49395 */
49396 port->openclose = true;
49397 - port->port.count = 0;
49398 + atomic_set(&port->port.count, 0);
49399
49400 gser = port->port_usb;
49401 if (gser && gser->disconnect)
49402 @@ -1066,7 +1066,7 @@ static int gs_closed(struct gs_port *port)
49403 int cond;
49404
49405 spin_lock_irq(&port->port_lock);
49406 - cond = (port->port.count == 0) && !port->openclose;
49407 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
49408 spin_unlock_irq(&port->port_lock);
49409 return cond;
49410 }
49411 @@ -1209,7 +1209,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
49412 /* if it's already open, start I/O ... and notify the serial
49413 * protocol about open/close status (connect/disconnect).
49414 */
49415 - if (port->port.count) {
49416 + if (atomic_read(&port->port.count)) {
49417 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
49418 gs_start_io(port);
49419 if (gser->connect)
49420 @@ -1256,7 +1256,7 @@ void gserial_disconnect(struct gserial *gser)
49421
49422 port->port_usb = NULL;
49423 gser->ioport = NULL;
49424 - if (port->port.count > 0 || port->openclose) {
49425 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
49426 wake_up_interruptible(&port->drain_wait);
49427 if (port->port.tty)
49428 tty_hangup(port->port.tty);
49429 @@ -1272,7 +1272,7 @@ void gserial_disconnect(struct gserial *gser)
49430
49431 /* finally, free any unused/unusable I/O buffers */
49432 spin_lock_irqsave(&port->port_lock, flags);
49433 - if (port->port.count == 0 && !port->openclose)
49434 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
49435 gs_buf_free(&port->port_write_buf);
49436 gs_free_requests(gser->out, &port->read_pool, NULL);
49437 gs_free_requests(gser->out, &port->read_queue, NULL);
49438 diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
49439 index ba6a5d6..f88f7f3 100644
49440 --- a/drivers/usb/misc/appledisplay.c
49441 +++ b/drivers/usb/misc/appledisplay.c
49442 @@ -83,7 +83,7 @@ struct appledisplay {
49443 spinlock_t lock;
49444 };
49445
49446 -static atomic_t count_displays = ATOMIC_INIT(0);
49447 +static atomic_unchecked_t count_displays = ATOMIC_INIT(0);
49448 static struct workqueue_struct *wq;
49449
49450 static void appledisplay_complete(struct urb *urb)
49451 @@ -281,7 +281,7 @@ static int appledisplay_probe(struct usb_interface *iface,
49452
49453 /* Register backlight device */
49454 snprintf(bl_name, sizeof(bl_name), "appledisplay%d",
49455 - atomic_inc_return(&count_displays) - 1);
49456 + atomic_inc_return_unchecked(&count_displays) - 1);
49457 memset(&props, 0, sizeof(struct backlight_properties));
49458 props.type = BACKLIGHT_RAW;
49459 props.max_brightness = 0xff;
49460 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
49461 index 5f3bcd3..bfca43f 100644
49462 --- a/drivers/usb/serial/console.c
49463 +++ b/drivers/usb/serial/console.c
49464 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
49465
49466 info->port = port;
49467
49468 - ++port->port.count;
49469 + atomic_inc(&port->port.count);
49470 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
49471 if (serial->type->set_termios) {
49472 /*
49473 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
49474 }
49475 /* Now that any required fake tty operations are completed restore
49476 * the tty port count */
49477 - --port->port.count;
49478 + atomic_dec(&port->port.count);
49479 /* The console is special in terms of closing the device so
49480 * indicate this port is now acting as a system console. */
49481 port->port.console = 1;
49482 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
49483 free_tty:
49484 kfree(tty);
49485 reset_open_count:
49486 - port->port.count = 0;
49487 + atomic_set(&port->port.count, 0);
49488 usb_autopm_put_interface(serial->interface);
49489 error_get_interface:
49490 usb_serial_put(serial);
49491 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
49492 index 75f70f0..d467e1a 100644
49493 --- a/drivers/usb/storage/usb.h
49494 +++ b/drivers/usb/storage/usb.h
49495 @@ -63,7 +63,7 @@ struct us_unusual_dev {
49496 __u8 useProtocol;
49497 __u8 useTransport;
49498 int (*initFunction)(struct us_data *);
49499 -};
49500 +} __do_const;
49501
49502
49503 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
49504 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
49505 index d6bea3e..60b250e 100644
49506 --- a/drivers/usb/wusbcore/wa-hc.h
49507 +++ b/drivers/usb/wusbcore/wa-hc.h
49508 @@ -192,7 +192,7 @@ struct wahc {
49509 struct list_head xfer_delayed_list;
49510 spinlock_t xfer_list_lock;
49511 struct work_struct xfer_work;
49512 - atomic_t xfer_id_count;
49513 + atomic_unchecked_t xfer_id_count;
49514 };
49515
49516
49517 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
49518 INIT_LIST_HEAD(&wa->xfer_delayed_list);
49519 spin_lock_init(&wa->xfer_list_lock);
49520 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
49521 - atomic_set(&wa->xfer_id_count, 1);
49522 + atomic_set_unchecked(&wa->xfer_id_count, 1);
49523 }
49524
49525 /**
49526 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
49527 index 028fc83..65bb105 100644
49528 --- a/drivers/usb/wusbcore/wa-xfer.c
49529 +++ b/drivers/usb/wusbcore/wa-xfer.c
49530 @@ -296,7 +296,7 @@ out:
49531 */
49532 static void wa_xfer_id_init(struct wa_xfer *xfer)
49533 {
49534 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
49535 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
49536 }
49537
49538 /*
49539 diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
49540 index 6d78736..65be90e 100644
49541 --- a/drivers/vfio/vfio.c
49542 +++ b/drivers/vfio/vfio.c
49543 @@ -486,7 +486,7 @@ static int vfio_group_nb_add_dev(struct vfio_group *group, struct device *dev)
49544 return 0;
49545
49546 /* TODO Prevent device auto probing */
49547 - WARN("Device %s added to live group %d!\n", dev_name(dev),
49548 + WARN(1, "Device %s added to live group %d!\n", dev_name(dev),
49549 iommu_group_id(group->iommu_group));
49550
49551 return 0;
49552 @@ -506,7 +506,7 @@ static int vfio_group_nb_del_dev(struct vfio_group *group, struct device *dev)
49553 if (likely(!device))
49554 return 0;
49555
49556 - WARN("Device %s removed from live group %d!\n", dev_name(dev),
49557 + WARN(1, "Device %s removed from live group %d!\n", dev_name(dev),
49558 iommu_group_id(group->iommu_group));
49559
49560 vfio_device_put(device);
49561 diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
49562 index 5174eba..86e764a 100644
49563 --- a/drivers/vhost/vringh.c
49564 +++ b/drivers/vhost/vringh.c
49565 @@ -800,7 +800,7 @@ static inline int getu16_kern(u16 *val, const u16 *p)
49566
49567 static inline int putu16_kern(u16 *p, u16 val)
49568 {
49569 - ACCESS_ONCE(*p) = val;
49570 + ACCESS_ONCE_RW(*p) = val;
49571 return 0;
49572 }
49573
49574 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
49575 index 8c55011..eed4ae1a 100644
49576 --- a/drivers/video/aty/aty128fb.c
49577 +++ b/drivers/video/aty/aty128fb.c
49578 @@ -149,7 +149,7 @@ enum {
49579 };
49580
49581 /* Must match above enum */
49582 -static char * const r128_family[] = {
49583 +static const char * const r128_family[] = {
49584 "AGP",
49585 "PCI",
49586 "PRO AGP",
49587 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
49588 index 4f27fdc..d3537e6 100644
49589 --- a/drivers/video/aty/atyfb_base.c
49590 +++ b/drivers/video/aty/atyfb_base.c
49591 @@ -1325,10 +1325,14 @@ static int atyfb_set_par(struct fb_info *info)
49592 par->accel_flags = var->accel_flags; /* hack */
49593
49594 if (var->accel_flags) {
49595 - info->fbops->fb_sync = atyfb_sync;
49596 + pax_open_kernel();
49597 + *(void **)&info->fbops->fb_sync = atyfb_sync;
49598 + pax_close_kernel();
49599 info->flags &= ~FBINFO_HWACCEL_DISABLED;
49600 } else {
49601 - info->fbops->fb_sync = NULL;
49602 + pax_open_kernel();
49603 + *(void **)&info->fbops->fb_sync = NULL;
49604 + pax_close_kernel();
49605 info->flags |= FBINFO_HWACCEL_DISABLED;
49606 }
49607
49608 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
49609 index 95ec042..e6affdd 100644
49610 --- a/drivers/video/aty/mach64_cursor.c
49611 +++ b/drivers/video/aty/mach64_cursor.c
49612 @@ -7,6 +7,7 @@
49613 #include <linux/string.h>
49614
49615 #include <asm/io.h>
49616 +#include <asm/pgtable.h>
49617
49618 #ifdef __sparc__
49619 #include <asm/fbio.h>
49620 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
49621 info->sprite.buf_align = 16; /* and 64 lines tall. */
49622 info->sprite.flags = FB_PIXMAP_IO;
49623
49624 - info->fbops->fb_cursor = atyfb_cursor;
49625 + pax_open_kernel();
49626 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
49627 + pax_close_kernel();
49628
49629 return 0;
49630 }
49631 diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
49632 index c74e7aa..e3c2790 100644
49633 --- a/drivers/video/backlight/backlight.c
49634 +++ b/drivers/video/backlight/backlight.c
49635 @@ -304,7 +304,7 @@ struct backlight_device *backlight_device_register(const char *name,
49636 new_bd->dev.class = backlight_class;
49637 new_bd->dev.parent = parent;
49638 new_bd->dev.release = bl_device_release;
49639 - dev_set_name(&new_bd->dev, name);
49640 + dev_set_name(&new_bd->dev, "%s", name);
49641 dev_set_drvdata(&new_bd->dev, devdata);
49642
49643 /* Set default properties */
49644 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
49645 index bca6ccc..252107e 100644
49646 --- a/drivers/video/backlight/kb3886_bl.c
49647 +++ b/drivers/video/backlight/kb3886_bl.c
49648 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
49649 static unsigned long kb3886bl_flags;
49650 #define KB3886BL_SUSPENDED 0x01
49651
49652 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
49653 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
49654 {
49655 .ident = "Sahara Touch-iT",
49656 .matches = {
49657 diff --git a/drivers/video/backlight/lcd.c b/drivers/video/backlight/lcd.c
49658 index 34fb6bd..3649fd9 100644
49659 --- a/drivers/video/backlight/lcd.c
49660 +++ b/drivers/video/backlight/lcd.c
49661 @@ -219,7 +219,7 @@ struct lcd_device *lcd_device_register(const char *name, struct device *parent,
49662 new_ld->dev.class = lcd_class;
49663 new_ld->dev.parent = parent;
49664 new_ld->dev.release = lcd_device_release;
49665 - dev_set_name(&new_ld->dev, name);
49666 + dev_set_name(&new_ld->dev, "%s", name);
49667 dev_set_drvdata(&new_ld->dev, devdata);
49668
49669 rc = device_register(&new_ld->dev);
49670 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
49671 index 900aa4e..6d49418 100644
49672 --- a/drivers/video/fb_defio.c
49673 +++ b/drivers/video/fb_defio.c
49674 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
49675
49676 BUG_ON(!fbdefio);
49677 mutex_init(&fbdefio->lock);
49678 - info->fbops->fb_mmap = fb_deferred_io_mmap;
49679 + pax_open_kernel();
49680 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
49681 + pax_close_kernel();
49682 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
49683 INIT_LIST_HEAD(&fbdefio->pagelist);
49684 if (fbdefio->delay == 0) /* set a default of 1 s */
49685 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
49686 page->mapping = NULL;
49687 }
49688
49689 - info->fbops->fb_mmap = NULL;
49690 + *(void **)&info->fbops->fb_mmap = NULL;
49691 mutex_destroy(&fbdefio->lock);
49692 }
49693 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
49694 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
49695 index 5c3960d..15cf8fc 100644
49696 --- a/drivers/video/fbcmap.c
49697 +++ b/drivers/video/fbcmap.c
49698 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
49699 rc = -ENODEV;
49700 goto out;
49701 }
49702 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
49703 - !info->fbops->fb_setcmap)) {
49704 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
49705 rc = -EINVAL;
49706 goto out1;
49707 }
49708 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
49709 index 098bfc6..796841d 100644
49710 --- a/drivers/video/fbmem.c
49711 +++ b/drivers/video/fbmem.c
49712 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49713 image->dx += image->width + 8;
49714 }
49715 } else if (rotate == FB_ROTATE_UD) {
49716 - for (x = 0; x < num && image->dx >= 0; x++) {
49717 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
49718 info->fbops->fb_imageblit(info, image);
49719 image->dx -= image->width + 8;
49720 }
49721 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49722 image->dy += image->height + 8;
49723 }
49724 } else if (rotate == FB_ROTATE_CCW) {
49725 - for (x = 0; x < num && image->dy >= 0; x++) {
49726 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
49727 info->fbops->fb_imageblit(info, image);
49728 image->dy -= image->height + 8;
49729 }
49730 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
49731 return -EFAULT;
49732 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
49733 return -EINVAL;
49734 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
49735 + if (con2fb.framebuffer >= FB_MAX)
49736 return -EINVAL;
49737 if (!registered_fb[con2fb.framebuffer])
49738 request_module("fb%d", con2fb.framebuffer);
49739 diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
49740 index d4d2c5f..ebbd113 100644
49741 --- a/drivers/video/hyperv_fb.c
49742 +++ b/drivers/video/hyperv_fb.c
49743 @@ -233,7 +233,7 @@ static uint screen_fb_size;
49744 static inline int synthvid_send(struct hv_device *hdev,
49745 struct synthvid_msg *msg)
49746 {
49747 - static atomic64_t request_id = ATOMIC64_INIT(0);
49748 + static atomic64_unchecked_t request_id = ATOMIC64_INIT(0);
49749 int ret;
49750
49751 msg->pipe_hdr.type = PIPE_MSG_DATA;
49752 @@ -241,7 +241,7 @@ static inline int synthvid_send(struct hv_device *hdev,
49753
49754 ret = vmbus_sendpacket(hdev->channel, msg,
49755 msg->vid_hdr.size + sizeof(struct pipe_msg_hdr),
49756 - atomic64_inc_return(&request_id),
49757 + atomic64_inc_return_unchecked(&request_id),
49758 VM_PKT_DATA_INBAND, 0);
49759
49760 if (ret)
49761 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
49762 index 7672d2e..b56437f 100644
49763 --- a/drivers/video/i810/i810_accel.c
49764 +++ b/drivers/video/i810/i810_accel.c
49765 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
49766 }
49767 }
49768 printk("ringbuffer lockup!!!\n");
49769 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
49770 i810_report_error(mmio);
49771 par->dev_flags |= LOCKUP;
49772 info->pixmap.scan_align = 1;
49773 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
49774 index 3c14e43..eafa544 100644
49775 --- a/drivers/video/logo/logo_linux_clut224.ppm
49776 +++ b/drivers/video/logo/logo_linux_clut224.ppm
49777 @@ -1,1604 +1,1123 @@
49778 P3
49779 -# Standard 224-color Linux logo
49780 80 80
49781 255
49782 - 0 0 0 0 0 0 0 0 0 0 0 0
49783 - 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
49785 - 0 0 0 0 0 0 0 0 0 0 0 0
49786 - 0 0 0 0 0 0 0 0 0 0 0 0
49787 - 0 0 0 0 0 0 0 0 0 0 0 0
49788 - 0 0 0 0 0 0 0 0 0 0 0 0
49789 - 0 0 0 0 0 0 0 0 0 0 0 0
49790 - 0 0 0 0 0 0 0 0 0 0 0 0
49791 - 6 6 6 6 6 6 10 10 10 10 10 10
49792 - 10 10 10 6 6 6 6 6 6 6 6 6
49793 - 0 0 0 0 0 0 0 0 0 0 0 0
49794 - 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
49796 - 0 0 0 0 0 0 0 0 0 0 0 0
49797 - 0 0 0 0 0 0 0 0 0 0 0 0
49798 - 0 0 0 0 0 0 0 0 0 0 0 0
49799 - 0 0 0 0 0 0 0 0 0 0 0 0
49800 - 0 0 0 0 0 0 0 0 0 0 0 0
49801 - 0 0 0 0 0 0 0 0 0 0 0 0
49802 - 0 0 0 0 0 0 0 0 0 0 0 0
49803 - 0 0 0 0 0 0 0 0 0 0 0 0
49804 - 0 0 0 0 0 0 0 0 0 0 0 0
49805 - 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
49807 - 0 0 0 0 0 0 0 0 0 0 0 0
49808 - 0 0 0 0 0 0 0 0 0 0 0 0
49809 - 0 0 0 0 0 0 0 0 0 0 0 0
49810 - 0 0 0 6 6 6 10 10 10 14 14 14
49811 - 22 22 22 26 26 26 30 30 30 34 34 34
49812 - 30 30 30 30 30 30 26 26 26 18 18 18
49813 - 14 14 14 10 10 10 6 6 6 0 0 0
49814 - 0 0 0 0 0 0 0 0 0 0 0 0
49815 - 0 0 0 0 0 0 0 0 0 0 0 0
49816 - 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
49818 - 0 0 0 0 0 0 0 0 0 0 0 0
49819 - 0 0 0 0 0 0 0 0 0 0 0 0
49820 - 0 0 0 0 0 0 0 0 0 0 0 0
49821 - 0 0 0 0 0 0 0 0 0 0 0 0
49822 - 0 0 0 0 0 0 0 0 0 0 0 0
49823 - 0 0 0 0 0 1 0 0 1 0 0 0
49824 - 0 0 0 0 0 0 0 0 0 0 0 0
49825 - 0 0 0 0 0 0 0 0 0 0 0 0
49826 - 0 0 0 0 0 0 0 0 0 0 0 0
49827 - 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
49829 - 0 0 0 0 0 0 0 0 0 0 0 0
49830 - 6 6 6 14 14 14 26 26 26 42 42 42
49831 - 54 54 54 66 66 66 78 78 78 78 78 78
49832 - 78 78 78 74 74 74 66 66 66 54 54 54
49833 - 42 42 42 26 26 26 18 18 18 10 10 10
49834 - 6 6 6 0 0 0 0 0 0 0 0 0
49835 - 0 0 0 0 0 0 0 0 0 0 0 0
49836 - 0 0 0 0 0 0 0 0 0 0 0 0
49837 - 0 0 0 0 0 0 0 0 0 0 0 0
49838 - 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
49840 - 0 0 0 0 0 0 0 0 0 0 0 0
49841 - 0 0 0 0 0 0 0 0 0 0 0 0
49842 - 0 0 0 0 0 0 0 0 0 0 0 0
49843 - 0 0 1 0 0 0 0 0 0 0 0 0
49844 - 0 0 0 0 0 0 0 0 0 0 0 0
49845 - 0 0 0 0 0 0 0 0 0 0 0 0
49846 - 0 0 0 0 0 0 0 0 0 0 0 0
49847 - 0 0 0 0 0 0 0 0 0 0 0 0
49848 - 0 0 0 0 0 0 0 0 0 0 0 0
49849 - 0 0 0 0 0 0 0 0 0 10 10 10
49850 - 22 22 22 42 42 42 66 66 66 86 86 86
49851 - 66 66 66 38 38 38 38 38 38 22 22 22
49852 - 26 26 26 34 34 34 54 54 54 66 66 66
49853 - 86 86 86 70 70 70 46 46 46 26 26 26
49854 - 14 14 14 6 6 6 0 0 0 0 0 0
49855 - 0 0 0 0 0 0 0 0 0 0 0 0
49856 - 0 0 0 0 0 0 0 0 0 0 0 0
49857 - 0 0 0 0 0 0 0 0 0 0 0 0
49858 - 0 0 0 0 0 0 0 0 0 0 0 0
49859 - 0 0 0 0 0 0 0 0 0 0 0 0
49860 - 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
49862 - 0 0 0 0 0 0 0 0 0 0 0 0
49863 - 0 0 1 0 0 1 0 0 1 0 0 0
49864 - 0 0 0 0 0 0 0 0 0 0 0 0
49865 - 0 0 0 0 0 0 0 0 0 0 0 0
49866 - 0 0 0 0 0 0 0 0 0 0 0 0
49867 - 0 0 0 0 0 0 0 0 0 0 0 0
49868 - 0 0 0 0 0 0 0 0 0 0 0 0
49869 - 0 0 0 0 0 0 10 10 10 26 26 26
49870 - 50 50 50 82 82 82 58 58 58 6 6 6
49871 - 2 2 6 2 2 6 2 2 6 2 2 6
49872 - 2 2 6 2 2 6 2 2 6 2 2 6
49873 - 6 6 6 54 54 54 86 86 86 66 66 66
49874 - 38 38 38 18 18 18 6 6 6 0 0 0
49875 - 0 0 0 0 0 0 0 0 0 0 0 0
49876 - 0 0 0 0 0 0 0 0 0 0 0 0
49877 - 0 0 0 0 0 0 0 0 0 0 0 0
49878 - 0 0 0 0 0 0 0 0 0 0 0 0
49879 - 0 0 0 0 0 0 0 0 0 0 0 0
49880 - 0 0 0 0 0 0 0 0 0 0 0 0
49881 - 0 0 0 0 0 0 0 0 0 0 0 0
49882 - 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
49884 - 0 0 0 0 0 0 0 0 0 0 0 0
49885 - 0 0 0 0 0 0 0 0 0 0 0 0
49886 - 0 0 0 0 0 0 0 0 0 0 0 0
49887 - 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
49889 - 0 0 0 6 6 6 22 22 22 50 50 50
49890 - 78 78 78 34 34 34 2 2 6 2 2 6
49891 - 2 2 6 2 2 6 2 2 6 2 2 6
49892 - 2 2 6 2 2 6 2 2 6 2 2 6
49893 - 2 2 6 2 2 6 6 6 6 70 70 70
49894 - 78 78 78 46 46 46 22 22 22 6 6 6
49895 - 0 0 0 0 0 0 0 0 0 0 0 0
49896 - 0 0 0 0 0 0 0 0 0 0 0 0
49897 - 0 0 0 0 0 0 0 0 0 0 0 0
49898 - 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
49900 - 0 0 0 0 0 0 0 0 0 0 0 0
49901 - 0 0 0 0 0 0 0 0 0 0 0 0
49902 - 0 0 0 0 0 0 0 0 0 0 0 0
49903 - 0 0 1 0 0 1 0 0 1 0 0 0
49904 - 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
49906 - 0 0 0 0 0 0 0 0 0 0 0 0
49907 - 0 0 0 0 0 0 0 0 0 0 0 0
49908 - 0 0 0 0 0 0 0 0 0 0 0 0
49909 - 6 6 6 18 18 18 42 42 42 82 82 82
49910 - 26 26 26 2 2 6 2 2 6 2 2 6
49911 - 2 2 6 2 2 6 2 2 6 2 2 6
49912 - 2 2 6 2 2 6 2 2 6 14 14 14
49913 - 46 46 46 34 34 34 6 6 6 2 2 6
49914 - 42 42 42 78 78 78 42 42 42 18 18 18
49915 - 6 6 6 0 0 0 0 0 0 0 0 0
49916 - 0 0 0 0 0 0 0 0 0 0 0 0
49917 - 0 0 0 0 0 0 0 0 0 0 0 0
49918 - 0 0 0 0 0 0 0 0 0 0 0 0
49919 - 0 0 0 0 0 0 0 0 0 0 0 0
49920 - 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
49922 - 0 0 0 0 0 0 0 0 0 0 0 0
49923 - 0 0 1 0 0 0 0 0 1 0 0 0
49924 - 0 0 0 0 0 0 0 0 0 0 0 0
49925 - 0 0 0 0 0 0 0 0 0 0 0 0
49926 - 0 0 0 0 0 0 0 0 0 0 0 0
49927 - 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
49929 - 10 10 10 30 30 30 66 66 66 58 58 58
49930 - 2 2 6 2 2 6 2 2 6 2 2 6
49931 - 2 2 6 2 2 6 2 2 6 2 2 6
49932 - 2 2 6 2 2 6 2 2 6 26 26 26
49933 - 86 86 86 101 101 101 46 46 46 10 10 10
49934 - 2 2 6 58 58 58 70 70 70 34 34 34
49935 - 10 10 10 0 0 0 0 0 0 0 0 0
49936 - 0 0 0 0 0 0 0 0 0 0 0 0
49937 - 0 0 0 0 0 0 0 0 0 0 0 0
49938 - 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
49940 - 0 0 0 0 0 0 0 0 0 0 0 0
49941 - 0 0 0 0 0 0 0 0 0 0 0 0
49942 - 0 0 0 0 0 0 0 0 0 0 0 0
49943 - 0 0 1 0 0 1 0 0 1 0 0 0
49944 - 0 0 0 0 0 0 0 0 0 0 0 0
49945 - 0 0 0 0 0 0 0 0 0 0 0 0
49946 - 0 0 0 0 0 0 0 0 0 0 0 0
49947 - 0 0 0 0 0 0 0 0 0 0 0 0
49948 - 0 0 0 0 0 0 0 0 0 0 0 0
49949 - 14 14 14 42 42 42 86 86 86 10 10 10
49950 - 2 2 6 2 2 6 2 2 6 2 2 6
49951 - 2 2 6 2 2 6 2 2 6 2 2 6
49952 - 2 2 6 2 2 6 2 2 6 30 30 30
49953 - 94 94 94 94 94 94 58 58 58 26 26 26
49954 - 2 2 6 6 6 6 78 78 78 54 54 54
49955 - 22 22 22 6 6 6 0 0 0 0 0 0
49956 - 0 0 0 0 0 0 0 0 0 0 0 0
49957 - 0 0 0 0 0 0 0 0 0 0 0 0
49958 - 0 0 0 0 0 0 0 0 0 0 0 0
49959 - 0 0 0 0 0 0 0 0 0 0 0 0
49960 - 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
49962 - 0 0 0 0 0 0 0 0 0 0 0 0
49963 - 0 0 0 0 0 0 0 0 0 0 0 0
49964 - 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
49966 - 0 0 0 0 0 0 0 0 0 0 0 0
49967 - 0 0 0 0 0 0 0 0 0 0 0 0
49968 - 0 0 0 0 0 0 0 0 0 6 6 6
49969 - 22 22 22 62 62 62 62 62 62 2 2 6
49970 - 2 2 6 2 2 6 2 2 6 2 2 6
49971 - 2 2 6 2 2 6 2 2 6 2 2 6
49972 - 2 2 6 2 2 6 2 2 6 26 26 26
49973 - 54 54 54 38 38 38 18 18 18 10 10 10
49974 - 2 2 6 2 2 6 34 34 34 82 82 82
49975 - 38 38 38 14 14 14 0 0 0 0 0 0
49976 - 0 0 0 0 0 0 0 0 0 0 0 0
49977 - 0 0 0 0 0 0 0 0 0 0 0 0
49978 - 0 0 0 0 0 0 0 0 0 0 0 0
49979 - 0 0 0 0 0 0 0 0 0 0 0 0
49980 - 0 0 0 0 0 0 0 0 0 0 0 0
49981 - 0 0 0 0 0 0 0 0 0 0 0 0
49982 - 0 0 0 0 0 0 0 0 0 0 0 0
49983 - 0 0 0 0 0 1 0 0 1 0 0 0
49984 - 0 0 0 0 0 0 0 0 0 0 0 0
49985 - 0 0 0 0 0 0 0 0 0 0 0 0
49986 - 0 0 0 0 0 0 0 0 0 0 0 0
49987 - 0 0 0 0 0 0 0 0 0 0 0 0
49988 - 0 0 0 0 0 0 0 0 0 6 6 6
49989 - 30 30 30 78 78 78 30 30 30 2 2 6
49990 - 2 2 6 2 2 6 2 2 6 2 2 6
49991 - 2 2 6 2 2 6 2 2 6 2 2 6
49992 - 2 2 6 2 2 6 2 2 6 10 10 10
49993 - 10 10 10 2 2 6 2 2 6 2 2 6
49994 - 2 2 6 2 2 6 2 2 6 78 78 78
49995 - 50 50 50 18 18 18 6 6 6 0 0 0
49996 - 0 0 0 0 0 0 0 0 0 0 0 0
49997 - 0 0 0 0 0 0 0 0 0 0 0 0
49998 - 0 0 0 0 0 0 0 0 0 0 0 0
49999 - 0 0 0 0 0 0 0 0 0 0 0 0
50000 - 0 0 0 0 0 0 0 0 0 0 0 0
50001 - 0 0 0 0 0 0 0 0 0 0 0 0
50002 - 0 0 0 0 0 0 0 0 0 0 0 0
50003 - 0 0 1 0 0 0 0 0 0 0 0 0
50004 - 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
50006 - 0 0 0 0 0 0 0 0 0 0 0 0
50007 - 0 0 0 0 0 0 0 0 0 0 0 0
50008 - 0 0 0 0 0 0 0 0 0 10 10 10
50009 - 38 38 38 86 86 86 14 14 14 2 2 6
50010 - 2 2 6 2 2 6 2 2 6 2 2 6
50011 - 2 2 6 2 2 6 2 2 6 2 2 6
50012 - 2 2 6 2 2 6 2 2 6 2 2 6
50013 - 2 2 6 2 2 6 2 2 6 2 2 6
50014 - 2 2 6 2 2 6 2 2 6 54 54 54
50015 - 66 66 66 26 26 26 6 6 6 0 0 0
50016 - 0 0 0 0 0 0 0 0 0 0 0 0
50017 - 0 0 0 0 0 0 0 0 0 0 0 0
50018 - 0 0 0 0 0 0 0 0 0 0 0 0
50019 - 0 0 0 0 0 0 0 0 0 0 0 0
50020 - 0 0 0 0 0 0 0 0 0 0 0 0
50021 - 0 0 0 0 0 0 0 0 0 0 0 0
50022 - 0 0 0 0 0 0 0 0 0 0 0 0
50023 - 0 0 0 0 0 1 0 0 1 0 0 0
50024 - 0 0 0 0 0 0 0 0 0 0 0 0
50025 - 0 0 0 0 0 0 0 0 0 0 0 0
50026 - 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
50028 - 0 0 0 0 0 0 0 0 0 14 14 14
50029 - 42 42 42 82 82 82 2 2 6 2 2 6
50030 - 2 2 6 6 6 6 10 10 10 2 2 6
50031 - 2 2 6 2 2 6 2 2 6 2 2 6
50032 - 2 2 6 2 2 6 2 2 6 6 6 6
50033 - 14 14 14 10 10 10 2 2 6 2 2 6
50034 - 2 2 6 2 2 6 2 2 6 18 18 18
50035 - 82 82 82 34 34 34 10 10 10 0 0 0
50036 - 0 0 0 0 0 0 0 0 0 0 0 0
50037 - 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
50039 - 0 0 0 0 0 0 0 0 0 0 0 0
50040 - 0 0 0 0 0 0 0 0 0 0 0 0
50041 - 0 0 0 0 0 0 0 0 0 0 0 0
50042 - 0 0 0 0 0 0 0 0 0 0 0 0
50043 - 0 0 1 0 0 0 0 0 0 0 0 0
50044 - 0 0 0 0 0 0 0 0 0 0 0 0
50045 - 0 0 0 0 0 0 0 0 0 0 0 0
50046 - 0 0 0 0 0 0 0 0 0 0 0 0
50047 - 0 0 0 0 0 0 0 0 0 0 0 0
50048 - 0 0 0 0 0 0 0 0 0 14 14 14
50049 - 46 46 46 86 86 86 2 2 6 2 2 6
50050 - 6 6 6 6 6 6 22 22 22 34 34 34
50051 - 6 6 6 2 2 6 2 2 6 2 2 6
50052 - 2 2 6 2 2 6 18 18 18 34 34 34
50053 - 10 10 10 50 50 50 22 22 22 2 2 6
50054 - 2 2 6 2 2 6 2 2 6 10 10 10
50055 - 86 86 86 42 42 42 14 14 14 0 0 0
50056 - 0 0 0 0 0 0 0 0 0 0 0 0
50057 - 0 0 0 0 0 0 0 0 0 0 0 0
50058 - 0 0 0 0 0 0 0 0 0 0 0 0
50059 - 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
50061 - 0 0 0 0 0 0 0 0 0 0 0 0
50062 - 0 0 0 0 0 0 0 0 0 0 0 0
50063 - 0 0 1 0 0 1 0 0 1 0 0 0
50064 - 0 0 0 0 0 0 0 0 0 0 0 0
50065 - 0 0 0 0 0 0 0 0 0 0 0 0
50066 - 0 0 0 0 0 0 0 0 0 0 0 0
50067 - 0 0 0 0 0 0 0 0 0 0 0 0
50068 - 0 0 0 0 0 0 0 0 0 14 14 14
50069 - 46 46 46 86 86 86 2 2 6 2 2 6
50070 - 38 38 38 116 116 116 94 94 94 22 22 22
50071 - 22 22 22 2 2 6 2 2 6 2 2 6
50072 - 14 14 14 86 86 86 138 138 138 162 162 162
50073 -154 154 154 38 38 38 26 26 26 6 6 6
50074 - 2 2 6 2 2 6 2 2 6 2 2 6
50075 - 86 86 86 46 46 46 14 14 14 0 0 0
50076 - 0 0 0 0 0 0 0 0 0 0 0 0
50077 - 0 0 0 0 0 0 0 0 0 0 0 0
50078 - 0 0 0 0 0 0 0 0 0 0 0 0
50079 - 0 0 0 0 0 0 0 0 0 0 0 0
50080 - 0 0 0 0 0 0 0 0 0 0 0 0
50081 - 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
50083 - 0 0 0 0 0 0 0 0 0 0 0 0
50084 - 0 0 0 0 0 0 0 0 0 0 0 0
50085 - 0 0 0 0 0 0 0 0 0 0 0 0
50086 - 0 0 0 0 0 0 0 0 0 0 0 0
50087 - 0 0 0 0 0 0 0 0 0 0 0 0
50088 - 0 0 0 0 0 0 0 0 0 14 14 14
50089 - 46 46 46 86 86 86 2 2 6 14 14 14
50090 -134 134 134 198 198 198 195 195 195 116 116 116
50091 - 10 10 10 2 2 6 2 2 6 6 6 6
50092 -101 98 89 187 187 187 210 210 210 218 218 218
50093 -214 214 214 134 134 134 14 14 14 6 6 6
50094 - 2 2 6 2 2 6 2 2 6 2 2 6
50095 - 86 86 86 50 50 50 18 18 18 6 6 6
50096 - 0 0 0 0 0 0 0 0 0 0 0 0
50097 - 0 0 0 0 0 0 0 0 0 0 0 0
50098 - 0 0 0 0 0 0 0 0 0 0 0 0
50099 - 0 0 0 0 0 0 0 0 0 0 0 0
50100 - 0 0 0 0 0 0 0 0 0 0 0 0
50101 - 0 0 0 0 0 0 0 0 0 0 0 0
50102 - 0 0 0 0 0 0 0 0 1 0 0 0
50103 - 0 0 1 0 0 1 0 0 1 0 0 0
50104 - 0 0 0 0 0 0 0 0 0 0 0 0
50105 - 0 0 0 0 0 0 0 0 0 0 0 0
50106 - 0 0 0 0 0 0 0 0 0 0 0 0
50107 - 0 0 0 0 0 0 0 0 0 0 0 0
50108 - 0 0 0 0 0 0 0 0 0 14 14 14
50109 - 46 46 46 86 86 86 2 2 6 54 54 54
50110 -218 218 218 195 195 195 226 226 226 246 246 246
50111 - 58 58 58 2 2 6 2 2 6 30 30 30
50112 -210 210 210 253 253 253 174 174 174 123 123 123
50113 -221 221 221 234 234 234 74 74 74 2 2 6
50114 - 2 2 6 2 2 6 2 2 6 2 2 6
50115 - 70 70 70 58 58 58 22 22 22 6 6 6
50116 - 0 0 0 0 0 0 0 0 0 0 0 0
50117 - 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
50119 - 0 0 0 0 0 0 0 0 0 0 0 0
50120 - 0 0 0 0 0 0 0 0 0 0 0 0
50121 - 0 0 0 0 0 0 0 0 0 0 0 0
50122 - 0 0 0 0 0 0 0 0 0 0 0 0
50123 - 0 0 0 0 0 0 0 0 0 0 0 0
50124 - 0 0 0 0 0 0 0 0 0 0 0 0
50125 - 0 0 0 0 0 0 0 0 0 0 0 0
50126 - 0 0 0 0 0 0 0 0 0 0 0 0
50127 - 0 0 0 0 0 0 0 0 0 0 0 0
50128 - 0 0 0 0 0 0 0 0 0 14 14 14
50129 - 46 46 46 82 82 82 2 2 6 106 106 106
50130 -170 170 170 26 26 26 86 86 86 226 226 226
50131 -123 123 123 10 10 10 14 14 14 46 46 46
50132 -231 231 231 190 190 190 6 6 6 70 70 70
50133 - 90 90 90 238 238 238 158 158 158 2 2 6
50134 - 2 2 6 2 2 6 2 2 6 2 2 6
50135 - 70 70 70 58 58 58 22 22 22 6 6 6
50136 - 0 0 0 0 0 0 0 0 0 0 0 0
50137 - 0 0 0 0 0 0 0 0 0 0 0 0
50138 - 0 0 0 0 0 0 0 0 0 0 0 0
50139 - 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
50141 - 0 0 0 0 0 0 0 0 0 0 0 0
50142 - 0 0 0 0 0 0 0 0 1 0 0 0
50143 - 0 0 1 0 0 1 0 0 1 0 0 0
50144 - 0 0 0 0 0 0 0 0 0 0 0 0
50145 - 0 0 0 0 0 0 0 0 0 0 0 0
50146 - 0 0 0 0 0 0 0 0 0 0 0 0
50147 - 0 0 0 0 0 0 0 0 0 0 0 0
50148 - 0 0 0 0 0 0 0 0 0 14 14 14
50149 - 42 42 42 86 86 86 6 6 6 116 116 116
50150 -106 106 106 6 6 6 70 70 70 149 149 149
50151 -128 128 128 18 18 18 38 38 38 54 54 54
50152 -221 221 221 106 106 106 2 2 6 14 14 14
50153 - 46 46 46 190 190 190 198 198 198 2 2 6
50154 - 2 2 6 2 2 6 2 2 6 2 2 6
50155 - 74 74 74 62 62 62 22 22 22 6 6 6
50156 - 0 0 0 0 0 0 0 0 0 0 0 0
50157 - 0 0 0 0 0 0 0 0 0 0 0 0
50158 - 0 0 0 0 0 0 0 0 0 0 0 0
50159 - 0 0 0 0 0 0 0 0 0 0 0 0
50160 - 0 0 0 0 0 0 0 0 0 0 0 0
50161 - 0 0 0 0 0 0 0 0 0 0 0 0
50162 - 0 0 0 0 0 0 0 0 1 0 0 0
50163 - 0 0 1 0 0 0 0 0 1 0 0 0
50164 - 0 0 0 0 0 0 0 0 0 0 0 0
50165 - 0 0 0 0 0 0 0 0 0 0 0 0
50166 - 0 0 0 0 0 0 0 0 0 0 0 0
50167 - 0 0 0 0 0 0 0 0 0 0 0 0
50168 - 0 0 0 0 0 0 0 0 0 14 14 14
50169 - 42 42 42 94 94 94 14 14 14 101 101 101
50170 -128 128 128 2 2 6 18 18 18 116 116 116
50171 -118 98 46 121 92 8 121 92 8 98 78 10
50172 -162 162 162 106 106 106 2 2 6 2 2 6
50173 - 2 2 6 195 195 195 195 195 195 6 6 6
50174 - 2 2 6 2 2 6 2 2 6 2 2 6
50175 - 74 74 74 62 62 62 22 22 22 6 6 6
50176 - 0 0 0 0 0 0 0 0 0 0 0 0
50177 - 0 0 0 0 0 0 0 0 0 0 0 0
50178 - 0 0 0 0 0 0 0 0 0 0 0 0
50179 - 0 0 0 0 0 0 0 0 0 0 0 0
50180 - 0 0 0 0 0 0 0 0 0 0 0 0
50181 - 0 0 0 0 0 0 0 0 0 0 0 0
50182 - 0 0 0 0 0 0 0 0 1 0 0 1
50183 - 0 0 1 0 0 0 0 0 1 0 0 0
50184 - 0 0 0 0 0 0 0 0 0 0 0 0
50185 - 0 0 0 0 0 0 0 0 0 0 0 0
50186 - 0 0 0 0 0 0 0 0 0 0 0 0
50187 - 0 0 0 0 0 0 0 0 0 0 0 0
50188 - 0 0 0 0 0 0 0 0 0 10 10 10
50189 - 38 38 38 90 90 90 14 14 14 58 58 58
50190 -210 210 210 26 26 26 54 38 6 154 114 10
50191 -226 170 11 236 186 11 225 175 15 184 144 12
50192 -215 174 15 175 146 61 37 26 9 2 2 6
50193 - 70 70 70 246 246 246 138 138 138 2 2 6
50194 - 2 2 6 2 2 6 2 2 6 2 2 6
50195 - 70 70 70 66 66 66 26 26 26 6 6 6
50196 - 0 0 0 0 0 0 0 0 0 0 0 0
50197 - 0 0 0 0 0 0 0 0 0 0 0 0
50198 - 0 0 0 0 0 0 0 0 0 0 0 0
50199 - 0 0 0 0 0 0 0 0 0 0 0 0
50200 - 0 0 0 0 0 0 0 0 0 0 0 0
50201 - 0 0 0 0 0 0 0 0 0 0 0 0
50202 - 0 0 0 0 0 0 0 0 0 0 0 0
50203 - 0 0 0 0 0 0 0 0 0 0 0 0
50204 - 0 0 0 0 0 0 0 0 0 0 0 0
50205 - 0 0 0 0 0 0 0 0 0 0 0 0
50206 - 0 0 0 0 0 0 0 0 0 0 0 0
50207 - 0 0 0 0 0 0 0 0 0 0 0 0
50208 - 0 0 0 0 0 0 0 0 0 10 10 10
50209 - 38 38 38 86 86 86 14 14 14 10 10 10
50210 -195 195 195 188 164 115 192 133 9 225 175 15
50211 -239 182 13 234 190 10 232 195 16 232 200 30
50212 -245 207 45 241 208 19 232 195 16 184 144 12
50213 -218 194 134 211 206 186 42 42 42 2 2 6
50214 - 2 2 6 2 2 6 2 2 6 2 2 6
50215 - 50 50 50 74 74 74 30 30 30 6 6 6
50216 - 0 0 0 0 0 0 0 0 0 0 0 0
50217 - 0 0 0 0 0 0 0 0 0 0 0 0
50218 - 0 0 0 0 0 0 0 0 0 0 0 0
50219 - 0 0 0 0 0 0 0 0 0 0 0 0
50220 - 0 0 0 0 0 0 0 0 0 0 0 0
50221 - 0 0 0 0 0 0 0 0 0 0 0 0
50222 - 0 0 0 0 0 0 0 0 0 0 0 0
50223 - 0 0 0 0 0 0 0 0 0 0 0 0
50224 - 0 0 0 0 0 0 0 0 0 0 0 0
50225 - 0 0 0 0 0 0 0 0 0 0 0 0
50226 - 0 0 0 0 0 0 0 0 0 0 0 0
50227 - 0 0 0 0 0 0 0 0 0 0 0 0
50228 - 0 0 0 0 0 0 0 0 0 10 10 10
50229 - 34 34 34 86 86 86 14 14 14 2 2 6
50230 -121 87 25 192 133 9 219 162 10 239 182 13
50231 -236 186 11 232 195 16 241 208 19 244 214 54
50232 -246 218 60 246 218 38 246 215 20 241 208 19
50233 -241 208 19 226 184 13 121 87 25 2 2 6
50234 - 2 2 6 2 2 6 2 2 6 2 2 6
50235 - 50 50 50 82 82 82 34 34 34 10 10 10
50236 - 0 0 0 0 0 0 0 0 0 0 0 0
50237 - 0 0 0 0 0 0 0 0 0 0 0 0
50238 - 0 0 0 0 0 0 0 0 0 0 0 0
50239 - 0 0 0 0 0 0 0 0 0 0 0 0
50240 - 0 0 0 0 0 0 0 0 0 0 0 0
50241 - 0 0 0 0 0 0 0 0 0 0 0 0
50242 - 0 0 0 0 0 0 0 0 0 0 0 0
50243 - 0 0 0 0 0 0 0 0 0 0 0 0
50244 - 0 0 0 0 0 0 0 0 0 0 0 0
50245 - 0 0 0 0 0 0 0 0 0 0 0 0
50246 - 0 0 0 0 0 0 0 0 0 0 0 0
50247 - 0 0 0 0 0 0 0 0 0 0 0 0
50248 - 0 0 0 0 0 0 0 0 0 10 10 10
50249 - 34 34 34 82 82 82 30 30 30 61 42 6
50250 -180 123 7 206 145 10 230 174 11 239 182 13
50251 -234 190 10 238 202 15 241 208 19 246 218 74
50252 -246 218 38 246 215 20 246 215 20 246 215 20
50253 -226 184 13 215 174 15 184 144 12 6 6 6
50254 - 2 2 6 2 2 6 2 2 6 2 2 6
50255 - 26 26 26 94 94 94 42 42 42 14 14 14
50256 - 0 0 0 0 0 0 0 0 0 0 0 0
50257 - 0 0 0 0 0 0 0 0 0 0 0 0
50258 - 0 0 0 0 0 0 0 0 0 0 0 0
50259 - 0 0 0 0 0 0 0 0 0 0 0 0
50260 - 0 0 0 0 0 0 0 0 0 0 0 0
50261 - 0 0 0 0 0 0 0 0 0 0 0 0
50262 - 0 0 0 0 0 0 0 0 0 0 0 0
50263 - 0 0 0 0 0 0 0 0 0 0 0 0
50264 - 0 0 0 0 0 0 0 0 0 0 0 0
50265 - 0 0 0 0 0 0 0 0 0 0 0 0
50266 - 0 0 0 0 0 0 0 0 0 0 0 0
50267 - 0 0 0 0 0 0 0 0 0 0 0 0
50268 - 0 0 0 0 0 0 0 0 0 10 10 10
50269 - 30 30 30 78 78 78 50 50 50 104 69 6
50270 -192 133 9 216 158 10 236 178 12 236 186 11
50271 -232 195 16 241 208 19 244 214 54 245 215 43
50272 -246 215 20 246 215 20 241 208 19 198 155 10
50273 -200 144 11 216 158 10 156 118 10 2 2 6
50274 - 2 2 6 2 2 6 2 2 6 2 2 6
50275 - 6 6 6 90 90 90 54 54 54 18 18 18
50276 - 6 6 6 0 0 0 0 0 0 0 0 0
50277 - 0 0 0 0 0 0 0 0 0 0 0 0
50278 - 0 0 0 0 0 0 0 0 0 0 0 0
50279 - 0 0 0 0 0 0 0 0 0 0 0 0
50280 - 0 0 0 0 0 0 0 0 0 0 0 0
50281 - 0 0 0 0 0 0 0 0 0 0 0 0
50282 - 0 0 0 0 0 0 0 0 0 0 0 0
50283 - 0 0 0 0 0 0 0 0 0 0 0 0
50284 - 0 0 0 0 0 0 0 0 0 0 0 0
50285 - 0 0 0 0 0 0 0 0 0 0 0 0
50286 - 0 0 0 0 0 0 0 0 0 0 0 0
50287 - 0 0 0 0 0 0 0 0 0 0 0 0
50288 - 0 0 0 0 0 0 0 0 0 10 10 10
50289 - 30 30 30 78 78 78 46 46 46 22 22 22
50290 -137 92 6 210 162 10 239 182 13 238 190 10
50291 -238 202 15 241 208 19 246 215 20 246 215 20
50292 -241 208 19 203 166 17 185 133 11 210 150 10
50293 -216 158 10 210 150 10 102 78 10 2 2 6
50294 - 6 6 6 54 54 54 14 14 14 2 2 6
50295 - 2 2 6 62 62 62 74 74 74 30 30 30
50296 - 10 10 10 0 0 0 0 0 0 0 0 0
50297 - 0 0 0 0 0 0 0 0 0 0 0 0
50298 - 0 0 0 0 0 0 0 0 0 0 0 0
50299 - 0 0 0 0 0 0 0 0 0 0 0 0
50300 - 0 0 0 0 0 0 0 0 0 0 0 0
50301 - 0 0 0 0 0 0 0 0 0 0 0 0
50302 - 0 0 0 0 0 0 0 0 0 0 0 0
50303 - 0 0 0 0 0 0 0 0 0 0 0 0
50304 - 0 0 0 0 0 0 0 0 0 0 0 0
50305 - 0 0 0 0 0 0 0 0 0 0 0 0
50306 - 0 0 0 0 0 0 0 0 0 0 0 0
50307 - 0 0 0 0 0 0 0 0 0 0 0 0
50308 - 0 0 0 0 0 0 0 0 0 10 10 10
50309 - 34 34 34 78 78 78 50 50 50 6 6 6
50310 - 94 70 30 139 102 15 190 146 13 226 184 13
50311 -232 200 30 232 195 16 215 174 15 190 146 13
50312 -168 122 10 192 133 9 210 150 10 213 154 11
50313 -202 150 34 182 157 106 101 98 89 2 2 6
50314 - 2 2 6 78 78 78 116 116 116 58 58 58
50315 - 2 2 6 22 22 22 90 90 90 46 46 46
50316 - 18 18 18 6 6 6 0 0 0 0 0 0
50317 - 0 0 0 0 0 0 0 0 0 0 0 0
50318 - 0 0 0 0 0 0 0 0 0 0 0 0
50319 - 0 0 0 0 0 0 0 0 0 0 0 0
50320 - 0 0 0 0 0 0 0 0 0 0 0 0
50321 - 0 0 0 0 0 0 0 0 0 0 0 0
50322 - 0 0 0 0 0 0 0 0 0 0 0 0
50323 - 0 0 0 0 0 0 0 0 0 0 0 0
50324 - 0 0 0 0 0 0 0 0 0 0 0 0
50325 - 0 0 0 0 0 0 0 0 0 0 0 0
50326 - 0 0 0 0 0 0 0 0 0 0 0 0
50327 - 0 0 0 0 0 0 0 0 0 0 0 0
50328 - 0 0 0 0 0 0 0 0 0 10 10 10
50329 - 38 38 38 86 86 86 50 50 50 6 6 6
50330 -128 128 128 174 154 114 156 107 11 168 122 10
50331 -198 155 10 184 144 12 197 138 11 200 144 11
50332 -206 145 10 206 145 10 197 138 11 188 164 115
50333 -195 195 195 198 198 198 174 174 174 14 14 14
50334 - 2 2 6 22 22 22 116 116 116 116 116 116
50335 - 22 22 22 2 2 6 74 74 74 70 70 70
50336 - 30 30 30 10 10 10 0 0 0 0 0 0
50337 - 0 0 0 0 0 0 0 0 0 0 0 0
50338 - 0 0 0 0 0 0 0 0 0 0 0 0
50339 - 0 0 0 0 0 0 0 0 0 0 0 0
50340 - 0 0 0 0 0 0 0 0 0 0 0 0
50341 - 0 0 0 0 0 0 0 0 0 0 0 0
50342 - 0 0 0 0 0 0 0 0 0 0 0 0
50343 - 0 0 0 0 0 0 0 0 0 0 0 0
50344 - 0 0 0 0 0 0 0 0 0 0 0 0
50345 - 0 0 0 0 0 0 0 0 0 0 0 0
50346 - 0 0 0 0 0 0 0 0 0 0 0 0
50347 - 0 0 0 0 0 0 0 0 0 0 0 0
50348 - 0 0 0 0 0 0 6 6 6 18 18 18
50349 - 50 50 50 101 101 101 26 26 26 10 10 10
50350 -138 138 138 190 190 190 174 154 114 156 107 11
50351 -197 138 11 200 144 11 197 138 11 192 133 9
50352 -180 123 7 190 142 34 190 178 144 187 187 187
50353 -202 202 202 221 221 221 214 214 214 66 66 66
50354 - 2 2 6 2 2 6 50 50 50 62 62 62
50355 - 6 6 6 2 2 6 10 10 10 90 90 90
50356 - 50 50 50 18 18 18 6 6 6 0 0 0
50357 - 0 0 0 0 0 0 0 0 0 0 0 0
50358 - 0 0 0 0 0 0 0 0 0 0 0 0
50359 - 0 0 0 0 0 0 0 0 0 0 0 0
50360 - 0 0 0 0 0 0 0 0 0 0 0 0
50361 - 0 0 0 0 0 0 0 0 0 0 0 0
50362 - 0 0 0 0 0 0 0 0 0 0 0 0
50363 - 0 0 0 0 0 0 0 0 0 0 0 0
50364 - 0 0 0 0 0 0 0 0 0 0 0 0
50365 - 0 0 0 0 0 0 0 0 0 0 0 0
50366 - 0 0 0 0 0 0 0 0 0 0 0 0
50367 - 0 0 0 0 0 0 0 0 0 0 0 0
50368 - 0 0 0 0 0 0 10 10 10 34 34 34
50369 - 74 74 74 74 74 74 2 2 6 6 6 6
50370 -144 144 144 198 198 198 190 190 190 178 166 146
50371 -154 121 60 156 107 11 156 107 11 168 124 44
50372 -174 154 114 187 187 187 190 190 190 210 210 210
50373 -246 246 246 253 253 253 253 253 253 182 182 182
50374 - 6 6 6 2 2 6 2 2 6 2 2 6
50375 - 2 2 6 2 2 6 2 2 6 62 62 62
50376 - 74 74 74 34 34 34 14 14 14 0 0 0
50377 - 0 0 0 0 0 0 0 0 0 0 0 0
50378 - 0 0 0 0 0 0 0 0 0 0 0 0
50379 - 0 0 0 0 0 0 0 0 0 0 0 0
50380 - 0 0 0 0 0 0 0 0 0 0 0 0
50381 - 0 0 0 0 0 0 0 0 0 0 0 0
50382 - 0 0 0 0 0 0 0 0 0 0 0 0
50383 - 0 0 0 0 0 0 0 0 0 0 0 0
50384 - 0 0 0 0 0 0 0 0 0 0 0 0
50385 - 0 0 0 0 0 0 0 0 0 0 0 0
50386 - 0 0 0 0 0 0 0 0 0 0 0 0
50387 - 0 0 0 0 0 0 0 0 0 0 0 0
50388 - 0 0 0 10 10 10 22 22 22 54 54 54
50389 - 94 94 94 18 18 18 2 2 6 46 46 46
50390 -234 234 234 221 221 221 190 190 190 190 190 190
50391 -190 190 190 187 187 187 187 187 187 190 190 190
50392 -190 190 190 195 195 195 214 214 214 242 242 242
50393 -253 253 253 253 253 253 253 253 253 253 253 253
50394 - 82 82 82 2 2 6 2 2 6 2 2 6
50395 - 2 2 6 2 2 6 2 2 6 14 14 14
50396 - 86 86 86 54 54 54 22 22 22 6 6 6
50397 - 0 0 0 0 0 0 0 0 0 0 0 0
50398 - 0 0 0 0 0 0 0 0 0 0 0 0
50399 - 0 0 0 0 0 0 0 0 0 0 0 0
50400 - 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
50402 - 0 0 0 0 0 0 0 0 0 0 0 0
50403 - 0 0 0 0 0 0 0 0 0 0 0 0
50404 - 0 0 0 0 0 0 0 0 0 0 0 0
50405 - 0 0 0 0 0 0 0 0 0 0 0 0
50406 - 0 0 0 0 0 0 0 0 0 0 0 0
50407 - 0 0 0 0 0 0 0 0 0 0 0 0
50408 - 6 6 6 18 18 18 46 46 46 90 90 90
50409 - 46 46 46 18 18 18 6 6 6 182 182 182
50410 -253 253 253 246 246 246 206 206 206 190 190 190
50411 -190 190 190 190 190 190 190 190 190 190 190 190
50412 -206 206 206 231 231 231 250 250 250 253 253 253
50413 -253 253 253 253 253 253 253 253 253 253 253 253
50414 -202 202 202 14 14 14 2 2 6 2 2 6
50415 - 2 2 6 2 2 6 2 2 6 2 2 6
50416 - 42 42 42 86 86 86 42 42 42 18 18 18
50417 - 6 6 6 0 0 0 0 0 0 0 0 0
50418 - 0 0 0 0 0 0 0 0 0 0 0 0
50419 - 0 0 0 0 0 0 0 0 0 0 0 0
50420 - 0 0 0 0 0 0 0 0 0 0 0 0
50421 - 0 0 0 0 0 0 0 0 0 0 0 0
50422 - 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
50424 - 0 0 0 0 0 0 0 0 0 0 0 0
50425 - 0 0 0 0 0 0 0 0 0 0 0 0
50426 - 0 0 0 0 0 0 0 0 0 0 0 0
50427 - 0 0 0 0 0 0 0 0 0 6 6 6
50428 - 14 14 14 38 38 38 74 74 74 66 66 66
50429 - 2 2 6 6 6 6 90 90 90 250 250 250
50430 -253 253 253 253 253 253 238 238 238 198 198 198
50431 -190 190 190 190 190 190 195 195 195 221 221 221
50432 -246 246 246 253 253 253 253 253 253 253 253 253
50433 -253 253 253 253 253 253 253 253 253 253 253 253
50434 -253 253 253 82 82 82 2 2 6 2 2 6
50435 - 2 2 6 2 2 6 2 2 6 2 2 6
50436 - 2 2 6 78 78 78 70 70 70 34 34 34
50437 - 14 14 14 6 6 6 0 0 0 0 0 0
50438 - 0 0 0 0 0 0 0 0 0 0 0 0
50439 - 0 0 0 0 0 0 0 0 0 0 0 0
50440 - 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
50442 - 0 0 0 0 0 0 0 0 0 0 0 0
50443 - 0 0 0 0 0 0 0 0 0 0 0 0
50444 - 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
50446 - 0 0 0 0 0 0 0 0 0 0 0 0
50447 - 0 0 0 0 0 0 0 0 0 14 14 14
50448 - 34 34 34 66 66 66 78 78 78 6 6 6
50449 - 2 2 6 18 18 18 218 218 218 253 253 253
50450 -253 253 253 253 253 253 253 253 253 246 246 246
50451 -226 226 226 231 231 231 246 246 246 253 253 253
50452 -253 253 253 253 253 253 253 253 253 253 253 253
50453 -253 253 253 253 253 253 253 253 253 253 253 253
50454 -253 253 253 178 178 178 2 2 6 2 2 6
50455 - 2 2 6 2 2 6 2 2 6 2 2 6
50456 - 2 2 6 18 18 18 90 90 90 62 62 62
50457 - 30 30 30 10 10 10 0 0 0 0 0 0
50458 - 0 0 0 0 0 0 0 0 0 0 0 0
50459 - 0 0 0 0 0 0 0 0 0 0 0 0
50460 - 0 0 0 0 0 0 0 0 0 0 0 0
50461 - 0 0 0 0 0 0 0 0 0 0 0 0
50462 - 0 0 0 0 0 0 0 0 0 0 0 0
50463 - 0 0 0 0 0 0 0 0 0 0 0 0
50464 - 0 0 0 0 0 0 0 0 0 0 0 0
50465 - 0 0 0 0 0 0 0 0 0 0 0 0
50466 - 0 0 0 0 0 0 0 0 0 0 0 0
50467 - 0 0 0 0 0 0 10 10 10 26 26 26
50468 - 58 58 58 90 90 90 18 18 18 2 2 6
50469 - 2 2 6 110 110 110 253 253 253 253 253 253
50470 -253 253 253 253 253 253 253 253 253 253 253 253
50471 -250 250 250 253 253 253 253 253 253 253 253 253
50472 -253 253 253 253 253 253 253 253 253 253 253 253
50473 -253 253 253 253 253 253 253 253 253 253 253 253
50474 -253 253 253 231 231 231 18 18 18 2 2 6
50475 - 2 2 6 2 2 6 2 2 6 2 2 6
50476 - 2 2 6 2 2 6 18 18 18 94 94 94
50477 - 54 54 54 26 26 26 10 10 10 0 0 0
50478 - 0 0 0 0 0 0 0 0 0 0 0 0
50479 - 0 0 0 0 0 0 0 0 0 0 0 0
50480 - 0 0 0 0 0 0 0 0 0 0 0 0
50481 - 0 0 0 0 0 0 0 0 0 0 0 0
50482 - 0 0 0 0 0 0 0 0 0 0 0 0
50483 - 0 0 0 0 0 0 0 0 0 0 0 0
50484 - 0 0 0 0 0 0 0 0 0 0 0 0
50485 - 0 0 0 0 0 0 0 0 0 0 0 0
50486 - 0 0 0 0 0 0 0 0 0 0 0 0
50487 - 0 0 0 6 6 6 22 22 22 50 50 50
50488 - 90 90 90 26 26 26 2 2 6 2 2 6
50489 - 14 14 14 195 195 195 250 250 250 253 253 253
50490 -253 253 253 253 253 253 253 253 253 253 253 253
50491 -253 253 253 253 253 253 253 253 253 253 253 253
50492 -253 253 253 253 253 253 253 253 253 253 253 253
50493 -253 253 253 253 253 253 253 253 253 253 253 253
50494 -250 250 250 242 242 242 54 54 54 2 2 6
50495 - 2 2 6 2 2 6 2 2 6 2 2 6
50496 - 2 2 6 2 2 6 2 2 6 38 38 38
50497 - 86 86 86 50 50 50 22 22 22 6 6 6
50498 - 0 0 0 0 0 0 0 0 0 0 0 0
50499 - 0 0 0 0 0 0 0 0 0 0 0 0
50500 - 0 0 0 0 0 0 0 0 0 0 0 0
50501 - 0 0 0 0 0 0 0 0 0 0 0 0
50502 - 0 0 0 0 0 0 0 0 0 0 0 0
50503 - 0 0 0 0 0 0 0 0 0 0 0 0
50504 - 0 0 0 0 0 0 0 0 0 0 0 0
50505 - 0 0 0 0 0 0 0 0 0 0 0 0
50506 - 0 0 0 0 0 0 0 0 0 0 0 0
50507 - 6 6 6 14 14 14 38 38 38 82 82 82
50508 - 34 34 34 2 2 6 2 2 6 2 2 6
50509 - 42 42 42 195 195 195 246 246 246 253 253 253
50510 -253 253 253 253 253 253 253 253 253 250 250 250
50511 -242 242 242 242 242 242 250 250 250 253 253 253
50512 -253 253 253 253 253 253 253 253 253 253 253 253
50513 -253 253 253 250 250 250 246 246 246 238 238 238
50514 -226 226 226 231 231 231 101 101 101 6 6 6
50515 - 2 2 6 2 2 6 2 2 6 2 2 6
50516 - 2 2 6 2 2 6 2 2 6 2 2 6
50517 - 38 38 38 82 82 82 42 42 42 14 14 14
50518 - 6 6 6 0 0 0 0 0 0 0 0 0
50519 - 0 0 0 0 0 0 0 0 0 0 0 0
50520 - 0 0 0 0 0 0 0 0 0 0 0 0
50521 - 0 0 0 0 0 0 0 0 0 0 0 0
50522 - 0 0 0 0 0 0 0 0 0 0 0 0
50523 - 0 0 0 0 0 0 0 0 0 0 0 0
50524 - 0 0 0 0 0 0 0 0 0 0 0 0
50525 - 0 0 0 0 0 0 0 0 0 0 0 0
50526 - 0 0 0 0 0 0 0 0 0 0 0 0
50527 - 10 10 10 26 26 26 62 62 62 66 66 66
50528 - 2 2 6 2 2 6 2 2 6 6 6 6
50529 - 70 70 70 170 170 170 206 206 206 234 234 234
50530 -246 246 246 250 250 250 250 250 250 238 238 238
50531 -226 226 226 231 231 231 238 238 238 250 250 250
50532 -250 250 250 250 250 250 246 246 246 231 231 231
50533 -214 214 214 206 206 206 202 202 202 202 202 202
50534 -198 198 198 202 202 202 182 182 182 18 18 18
50535 - 2 2 6 2 2 6 2 2 6 2 2 6
50536 - 2 2 6 2 2 6 2 2 6 2 2 6
50537 - 2 2 6 62 62 62 66 66 66 30 30 30
50538 - 10 10 10 0 0 0 0 0 0 0 0 0
50539 - 0 0 0 0 0 0 0 0 0 0 0 0
50540 - 0 0 0 0 0 0 0 0 0 0 0 0
50541 - 0 0 0 0 0 0 0 0 0 0 0 0
50542 - 0 0 0 0 0 0 0 0 0 0 0 0
50543 - 0 0 0 0 0 0 0 0 0 0 0 0
50544 - 0 0 0 0 0 0 0 0 0 0 0 0
50545 - 0 0 0 0 0 0 0 0 0 0 0 0
50546 - 0 0 0 0 0 0 0 0 0 0 0 0
50547 - 14 14 14 42 42 42 82 82 82 18 18 18
50548 - 2 2 6 2 2 6 2 2 6 10 10 10
50549 - 94 94 94 182 182 182 218 218 218 242 242 242
50550 -250 250 250 253 253 253 253 253 253 250 250 250
50551 -234 234 234 253 253 253 253 253 253 253 253 253
50552 -253 253 253 253 253 253 253 253 253 246 246 246
50553 -238 238 238 226 226 226 210 210 210 202 202 202
50554 -195 195 195 195 195 195 210 210 210 158 158 158
50555 - 6 6 6 14 14 14 50 50 50 14 14 14
50556 - 2 2 6 2 2 6 2 2 6 2 2 6
50557 - 2 2 6 6 6 6 86 86 86 46 46 46
50558 - 18 18 18 6 6 6 0 0 0 0 0 0
50559 - 0 0 0 0 0 0 0 0 0 0 0 0
50560 - 0 0 0 0 0 0 0 0 0 0 0 0
50561 - 0 0 0 0 0 0 0 0 0 0 0 0
50562 - 0 0 0 0 0 0 0 0 0 0 0 0
50563 - 0 0 0 0 0 0 0 0 0 0 0 0
50564 - 0 0 0 0 0 0 0 0 0 0 0 0
50565 - 0 0 0 0 0 0 0 0 0 0 0 0
50566 - 0 0 0 0 0 0 0 0 0 6 6 6
50567 - 22 22 22 54 54 54 70 70 70 2 2 6
50568 - 2 2 6 10 10 10 2 2 6 22 22 22
50569 -166 166 166 231 231 231 250 250 250 253 253 253
50570 -253 253 253 253 253 253 253 253 253 250 250 250
50571 -242 242 242 253 253 253 253 253 253 253 253 253
50572 -253 253 253 253 253 253 253 253 253 253 253 253
50573 -253 253 253 253 253 253 253 253 253 246 246 246
50574 -231 231 231 206 206 206 198 198 198 226 226 226
50575 - 94 94 94 2 2 6 6 6 6 38 38 38
50576 - 30 30 30 2 2 6 2 2 6 2 2 6
50577 - 2 2 6 2 2 6 62 62 62 66 66 66
50578 - 26 26 26 10 10 10 0 0 0 0 0 0
50579 - 0 0 0 0 0 0 0 0 0 0 0 0
50580 - 0 0 0 0 0 0 0 0 0 0 0 0
50581 - 0 0 0 0 0 0 0 0 0 0 0 0
50582 - 0 0 0 0 0 0 0 0 0 0 0 0
50583 - 0 0 0 0 0 0 0 0 0 0 0 0
50584 - 0 0 0 0 0 0 0 0 0 0 0 0
50585 - 0 0 0 0 0 0 0 0 0 0 0 0
50586 - 0 0 0 0 0 0 0 0 0 10 10 10
50587 - 30 30 30 74 74 74 50 50 50 2 2 6
50588 - 26 26 26 26 26 26 2 2 6 106 106 106
50589 -238 238 238 253 253 253 253 253 253 253 253 253
50590 -253 253 253 253 253 253 253 253 253 253 253 253
50591 -253 253 253 253 253 253 253 253 253 253 253 253
50592 -253 253 253 253 253 253 253 253 253 253 253 253
50593 -253 253 253 253 253 253 253 253 253 253 253 253
50594 -253 253 253 246 246 246 218 218 218 202 202 202
50595 -210 210 210 14 14 14 2 2 6 2 2 6
50596 - 30 30 30 22 22 22 2 2 6 2 2 6
50597 - 2 2 6 2 2 6 18 18 18 86 86 86
50598 - 42 42 42 14 14 14 0 0 0 0 0 0
50599 - 0 0 0 0 0 0 0 0 0 0 0 0
50600 - 0 0 0 0 0 0 0 0 0 0 0 0
50601 - 0 0 0 0 0 0 0 0 0 0 0 0
50602 - 0 0 0 0 0 0 0 0 0 0 0 0
50603 - 0 0 0 0 0 0 0 0 0 0 0 0
50604 - 0 0 0 0 0 0 0 0 0 0 0 0
50605 - 0 0 0 0 0 0 0 0 0 0 0 0
50606 - 0 0 0 0 0 0 0 0 0 14 14 14
50607 - 42 42 42 90 90 90 22 22 22 2 2 6
50608 - 42 42 42 2 2 6 18 18 18 218 218 218
50609 -253 253 253 253 253 253 253 253 253 253 253 253
50610 -253 253 253 253 253 253 253 253 253 253 253 253
50611 -253 253 253 253 253 253 253 253 253 253 253 253
50612 -253 253 253 253 253 253 253 253 253 253 253 253
50613 -253 253 253 253 253 253 253 253 253 253 253 253
50614 -253 253 253 253 253 253 250 250 250 221 221 221
50615 -218 218 218 101 101 101 2 2 6 14 14 14
50616 - 18 18 18 38 38 38 10 10 10 2 2 6
50617 - 2 2 6 2 2 6 2 2 6 78 78 78
50618 - 58 58 58 22 22 22 6 6 6 0 0 0
50619 - 0 0 0 0 0 0 0 0 0 0 0 0
50620 - 0 0 0 0 0 0 0 0 0 0 0 0
50621 - 0 0 0 0 0 0 0 0 0 0 0 0
50622 - 0 0 0 0 0 0 0 0 0 0 0 0
50623 - 0 0 0 0 0 0 0 0 0 0 0 0
50624 - 0 0 0 0 0 0 0 0 0 0 0 0
50625 - 0 0 0 0 0 0 0 0 0 0 0 0
50626 - 0 0 0 0 0 0 6 6 6 18 18 18
50627 - 54 54 54 82 82 82 2 2 6 26 26 26
50628 - 22 22 22 2 2 6 123 123 123 253 253 253
50629 -253 253 253 253 253 253 253 253 253 253 253 253
50630 -253 253 253 253 253 253 253 253 253 253 253 253
50631 -253 253 253 253 253 253 253 253 253 253 253 253
50632 -253 253 253 253 253 253 253 253 253 253 253 253
50633 -253 253 253 253 253 253 253 253 253 253 253 253
50634 -253 253 253 253 253 253 253 253 253 250 250 250
50635 -238 238 238 198 198 198 6 6 6 38 38 38
50636 - 58 58 58 26 26 26 38 38 38 2 2 6
50637 - 2 2 6 2 2 6 2 2 6 46 46 46
50638 - 78 78 78 30 30 30 10 10 10 0 0 0
50639 - 0 0 0 0 0 0 0 0 0 0 0 0
50640 - 0 0 0 0 0 0 0 0 0 0 0 0
50641 - 0 0 0 0 0 0 0 0 0 0 0 0
50642 - 0 0 0 0 0 0 0 0 0 0 0 0
50643 - 0 0 0 0 0 0 0 0 0 0 0 0
50644 - 0 0 0 0 0 0 0 0 0 0 0 0
50645 - 0 0 0 0 0 0 0 0 0 0 0 0
50646 - 0 0 0 0 0 0 10 10 10 30 30 30
50647 - 74 74 74 58 58 58 2 2 6 42 42 42
50648 - 2 2 6 22 22 22 231 231 231 253 253 253
50649 -253 253 253 253 253 253 253 253 253 253 253 253
50650 -253 253 253 253 253 253 253 253 253 250 250 250
50651 -253 253 253 253 253 253 253 253 253 253 253 253
50652 -253 253 253 253 253 253 253 253 253 253 253 253
50653 -253 253 253 253 253 253 253 253 253 253 253 253
50654 -253 253 253 253 253 253 253 253 253 253 253 253
50655 -253 253 253 246 246 246 46 46 46 38 38 38
50656 - 42 42 42 14 14 14 38 38 38 14 14 14
50657 - 2 2 6 2 2 6 2 2 6 6 6 6
50658 - 86 86 86 46 46 46 14 14 14 0 0 0
50659 - 0 0 0 0 0 0 0 0 0 0 0 0
50660 - 0 0 0 0 0 0 0 0 0 0 0 0
50661 - 0 0 0 0 0 0 0 0 0 0 0 0
50662 - 0 0 0 0 0 0 0 0 0 0 0 0
50663 - 0 0 0 0 0 0 0 0 0 0 0 0
50664 - 0 0 0 0 0 0 0 0 0 0 0 0
50665 - 0 0 0 0 0 0 0 0 0 0 0 0
50666 - 0 0 0 6 6 6 14 14 14 42 42 42
50667 - 90 90 90 18 18 18 18 18 18 26 26 26
50668 - 2 2 6 116 116 116 253 253 253 253 253 253
50669 -253 253 253 253 253 253 253 253 253 253 253 253
50670 -253 253 253 253 253 253 250 250 250 238 238 238
50671 -253 253 253 253 253 253 253 253 253 253 253 253
50672 -253 253 253 253 253 253 253 253 253 253 253 253
50673 -253 253 253 253 253 253 253 253 253 253 253 253
50674 -253 253 253 253 253 253 253 253 253 253 253 253
50675 -253 253 253 253 253 253 94 94 94 6 6 6
50676 - 2 2 6 2 2 6 10 10 10 34 34 34
50677 - 2 2 6 2 2 6 2 2 6 2 2 6
50678 - 74 74 74 58 58 58 22 22 22 6 6 6
50679 - 0 0 0 0 0 0 0 0 0 0 0 0
50680 - 0 0 0 0 0 0 0 0 0 0 0 0
50681 - 0 0 0 0 0 0 0 0 0 0 0 0
50682 - 0 0 0 0 0 0 0 0 0 0 0 0
50683 - 0 0 0 0 0 0 0 0 0 0 0 0
50684 - 0 0 0 0 0 0 0 0 0 0 0 0
50685 - 0 0 0 0 0 0 0 0 0 0 0 0
50686 - 0 0 0 10 10 10 26 26 26 66 66 66
50687 - 82 82 82 2 2 6 38 38 38 6 6 6
50688 - 14 14 14 210 210 210 253 253 253 253 253 253
50689 -253 253 253 253 253 253 253 253 253 253 253 253
50690 -253 253 253 253 253 253 246 246 246 242 242 242
50691 -253 253 253 253 253 253 253 253 253 253 253 253
50692 -253 253 253 253 253 253 253 253 253 253 253 253
50693 -253 253 253 253 253 253 253 253 253 253 253 253
50694 -253 253 253 253 253 253 253 253 253 253 253 253
50695 -253 253 253 253 253 253 144 144 144 2 2 6
50696 - 2 2 6 2 2 6 2 2 6 46 46 46
50697 - 2 2 6 2 2 6 2 2 6 2 2 6
50698 - 42 42 42 74 74 74 30 30 30 10 10 10
50699 - 0 0 0 0 0 0 0 0 0 0 0 0
50700 - 0 0 0 0 0 0 0 0 0 0 0 0
50701 - 0 0 0 0 0 0 0 0 0 0 0 0
50702 - 0 0 0 0 0 0 0 0 0 0 0 0
50703 - 0 0 0 0 0 0 0 0 0 0 0 0
50704 - 0 0 0 0 0 0 0 0 0 0 0 0
50705 - 0 0 0 0 0 0 0 0 0 0 0 0
50706 - 6 6 6 14 14 14 42 42 42 90 90 90
50707 - 26 26 26 6 6 6 42 42 42 2 2 6
50708 - 74 74 74 250 250 250 253 253 253 253 253 253
50709 -253 253 253 253 253 253 253 253 253 253 253 253
50710 -253 253 253 253 253 253 242 242 242 242 242 242
50711 -253 253 253 253 253 253 253 253 253 253 253 253
50712 -253 253 253 253 253 253 253 253 253 253 253 253
50713 -253 253 253 253 253 253 253 253 253 253 253 253
50714 -253 253 253 253 253 253 253 253 253 253 253 253
50715 -253 253 253 253 253 253 182 182 182 2 2 6
50716 - 2 2 6 2 2 6 2 2 6 46 46 46
50717 - 2 2 6 2 2 6 2 2 6 2 2 6
50718 - 10 10 10 86 86 86 38 38 38 10 10 10
50719 - 0 0 0 0 0 0 0 0 0 0 0 0
50720 - 0 0 0 0 0 0 0 0 0 0 0 0
50721 - 0 0 0 0 0 0 0 0 0 0 0 0
50722 - 0 0 0 0 0 0 0 0 0 0 0 0
50723 - 0 0 0 0 0 0 0 0 0 0 0 0
50724 - 0 0 0 0 0 0 0 0 0 0 0 0
50725 - 0 0 0 0 0 0 0 0 0 0 0 0
50726 - 10 10 10 26 26 26 66 66 66 82 82 82
50727 - 2 2 6 22 22 22 18 18 18 2 2 6
50728 -149 149 149 253 253 253 253 253 253 253 253 253
50729 -253 253 253 253 253 253 253 253 253 253 253 253
50730 -253 253 253 253 253 253 234 234 234 242 242 242
50731 -253 253 253 253 253 253 253 253 253 253 253 253
50732 -253 253 253 253 253 253 253 253 253 253 253 253
50733 -253 253 253 253 253 253 253 253 253 253 253 253
50734 -253 253 253 253 253 253 253 253 253 253 253 253
50735 -253 253 253 253 253 253 206 206 206 2 2 6
50736 - 2 2 6 2 2 6 2 2 6 38 38 38
50737 - 2 2 6 2 2 6 2 2 6 2 2 6
50738 - 6 6 6 86 86 86 46 46 46 14 14 14
50739 - 0 0 0 0 0 0 0 0 0 0 0 0
50740 - 0 0 0 0 0 0 0 0 0 0 0 0
50741 - 0 0 0 0 0 0 0 0 0 0 0 0
50742 - 0 0 0 0 0 0 0 0 0 0 0 0
50743 - 0 0 0 0 0 0 0 0 0 0 0 0
50744 - 0 0 0 0 0 0 0 0 0 0 0 0
50745 - 0 0 0 0 0 0 0 0 0 6 6 6
50746 - 18 18 18 46 46 46 86 86 86 18 18 18
50747 - 2 2 6 34 34 34 10 10 10 6 6 6
50748 -210 210 210 253 253 253 253 253 253 253 253 253
50749 -253 253 253 253 253 253 253 253 253 253 253 253
50750 -253 253 253 253 253 253 234 234 234 242 242 242
50751 -253 253 253 253 253 253 253 253 253 253 253 253
50752 -253 253 253 253 253 253 253 253 253 253 253 253
50753 -253 253 253 253 253 253 253 253 253 253 253 253
50754 -253 253 253 253 253 253 253 253 253 253 253 253
50755 -253 253 253 253 253 253 221 221 221 6 6 6
50756 - 2 2 6 2 2 6 6 6 6 30 30 30
50757 - 2 2 6 2 2 6 2 2 6 2 2 6
50758 - 2 2 6 82 82 82 54 54 54 18 18 18
50759 - 6 6 6 0 0 0 0 0 0 0 0 0
50760 - 0 0 0 0 0 0 0 0 0 0 0 0
50761 - 0 0 0 0 0 0 0 0 0 0 0 0
50762 - 0 0 0 0 0 0 0 0 0 0 0 0
50763 - 0 0 0 0 0 0 0 0 0 0 0 0
50764 - 0 0 0 0 0 0 0 0 0 0 0 0
50765 - 0 0 0 0 0 0 0 0 0 10 10 10
50766 - 26 26 26 66 66 66 62 62 62 2 2 6
50767 - 2 2 6 38 38 38 10 10 10 26 26 26
50768 -238 238 238 253 253 253 253 253 253 253 253 253
50769 -253 253 253 253 253 253 253 253 253 253 253 253
50770 -253 253 253 253 253 253 231 231 231 238 238 238
50771 -253 253 253 253 253 253 253 253 253 253 253 253
50772 -253 253 253 253 253 253 253 253 253 253 253 253
50773 -253 253 253 253 253 253 253 253 253 253 253 253
50774 -253 253 253 253 253 253 253 253 253 253 253 253
50775 -253 253 253 253 253 253 231 231 231 6 6 6
50776 - 2 2 6 2 2 6 10 10 10 30 30 30
50777 - 2 2 6 2 2 6 2 2 6 2 2 6
50778 - 2 2 6 66 66 66 58 58 58 22 22 22
50779 - 6 6 6 0 0 0 0 0 0 0 0 0
50780 - 0 0 0 0 0 0 0 0 0 0 0 0
50781 - 0 0 0 0 0 0 0 0 0 0 0 0
50782 - 0 0 0 0 0 0 0 0 0 0 0 0
50783 - 0 0 0 0 0 0 0 0 0 0 0 0
50784 - 0 0 0 0 0 0 0 0 0 0 0 0
50785 - 0 0 0 0 0 0 0 0 0 10 10 10
50786 - 38 38 38 78 78 78 6 6 6 2 2 6
50787 - 2 2 6 46 46 46 14 14 14 42 42 42
50788 -246 246 246 253 253 253 253 253 253 253 253 253
50789 -253 253 253 253 253 253 253 253 253 253 253 253
50790 -253 253 253 253 253 253 231 231 231 242 242 242
50791 -253 253 253 253 253 253 253 253 253 253 253 253
50792 -253 253 253 253 253 253 253 253 253 253 253 253
50793 -253 253 253 253 253 253 253 253 253 253 253 253
50794 -253 253 253 253 253 253 253 253 253 253 253 253
50795 -253 253 253 253 253 253 234 234 234 10 10 10
50796 - 2 2 6 2 2 6 22 22 22 14 14 14
50797 - 2 2 6 2 2 6 2 2 6 2 2 6
50798 - 2 2 6 66 66 66 62 62 62 22 22 22
50799 - 6 6 6 0 0 0 0 0 0 0 0 0
50800 - 0 0 0 0 0 0 0 0 0 0 0 0
50801 - 0 0 0 0 0 0 0 0 0 0 0 0
50802 - 0 0 0 0 0 0 0 0 0 0 0 0
50803 - 0 0 0 0 0 0 0 0 0 0 0 0
50804 - 0 0 0 0 0 0 0 0 0 0 0 0
50805 - 0 0 0 0 0 0 6 6 6 18 18 18
50806 - 50 50 50 74 74 74 2 2 6 2 2 6
50807 - 14 14 14 70 70 70 34 34 34 62 62 62
50808 -250 250 250 253 253 253 253 253 253 253 253 253
50809 -253 253 253 253 253 253 253 253 253 253 253 253
50810 -253 253 253 253 253 253 231 231 231 246 246 246
50811 -253 253 253 253 253 253 253 253 253 253 253 253
50812 -253 253 253 253 253 253 253 253 253 253 253 253
50813 -253 253 253 253 253 253 253 253 253 253 253 253
50814 -253 253 253 253 253 253 253 253 253 253 253 253
50815 -253 253 253 253 253 253 234 234 234 14 14 14
50816 - 2 2 6 2 2 6 30 30 30 2 2 6
50817 - 2 2 6 2 2 6 2 2 6 2 2 6
50818 - 2 2 6 66 66 66 62 62 62 22 22 22
50819 - 6 6 6 0 0 0 0 0 0 0 0 0
50820 - 0 0 0 0 0 0 0 0 0 0 0 0
50821 - 0 0 0 0 0 0 0 0 0 0 0 0
50822 - 0 0 0 0 0 0 0 0 0 0 0 0
50823 - 0 0 0 0 0 0 0 0 0 0 0 0
50824 - 0 0 0 0 0 0 0 0 0 0 0 0
50825 - 0 0 0 0 0 0 6 6 6 18 18 18
50826 - 54 54 54 62 62 62 2 2 6 2 2 6
50827 - 2 2 6 30 30 30 46 46 46 70 70 70
50828 -250 250 250 253 253 253 253 253 253 253 253 253
50829 -253 253 253 253 253 253 253 253 253 253 253 253
50830 -253 253 253 253 253 253 231 231 231 246 246 246
50831 -253 253 253 253 253 253 253 253 253 253 253 253
50832 -253 253 253 253 253 253 253 253 253 253 253 253
50833 -253 253 253 253 253 253 253 253 253 253 253 253
50834 -253 253 253 253 253 253 253 253 253 253 253 253
50835 -253 253 253 253 253 253 226 226 226 10 10 10
50836 - 2 2 6 6 6 6 30 30 30 2 2 6
50837 - 2 2 6 2 2 6 2 2 6 2 2 6
50838 - 2 2 6 66 66 66 58 58 58 22 22 22
50839 - 6 6 6 0 0 0 0 0 0 0 0 0
50840 - 0 0 0 0 0 0 0 0 0 0 0 0
50841 - 0 0 0 0 0 0 0 0 0 0 0 0
50842 - 0 0 0 0 0 0 0 0 0 0 0 0
50843 - 0 0 0 0 0 0 0 0 0 0 0 0
50844 - 0 0 0 0 0 0 0 0 0 0 0 0
50845 - 0 0 0 0 0 0 6 6 6 22 22 22
50846 - 58 58 58 62 62 62 2 2 6 2 2 6
50847 - 2 2 6 2 2 6 30 30 30 78 78 78
50848 -250 250 250 253 253 253 253 253 253 253 253 253
50849 -253 253 253 253 253 253 253 253 253 253 253 253
50850 -253 253 253 253 253 253 231 231 231 246 246 246
50851 -253 253 253 253 253 253 253 253 253 253 253 253
50852 -253 253 253 253 253 253 253 253 253 253 253 253
50853 -253 253 253 253 253 253 253 253 253 253 253 253
50854 -253 253 253 253 253 253 253 253 253 253 253 253
50855 -253 253 253 253 253 253 206 206 206 2 2 6
50856 - 22 22 22 34 34 34 18 14 6 22 22 22
50857 - 26 26 26 18 18 18 6 6 6 2 2 6
50858 - 2 2 6 82 82 82 54 54 54 18 18 18
50859 - 6 6 6 0 0 0 0 0 0 0 0 0
50860 - 0 0 0 0 0 0 0 0 0 0 0 0
50861 - 0 0 0 0 0 0 0 0 0 0 0 0
50862 - 0 0 0 0 0 0 0 0 0 0 0 0
50863 - 0 0 0 0 0 0 0 0 0 0 0 0
50864 - 0 0 0 0 0 0 0 0 0 0 0 0
50865 - 0 0 0 0 0 0 6 6 6 26 26 26
50866 - 62 62 62 106 106 106 74 54 14 185 133 11
50867 -210 162 10 121 92 8 6 6 6 62 62 62
50868 -238 238 238 253 253 253 253 253 253 253 253 253
50869 -253 253 253 253 253 253 253 253 253 253 253 253
50870 -253 253 253 253 253 253 231 231 231 246 246 246
50871 -253 253 253 253 253 253 253 253 253 253 253 253
50872 -253 253 253 253 253 253 253 253 253 253 253 253
50873 -253 253 253 253 253 253 253 253 253 253 253 253
50874 -253 253 253 253 253 253 253 253 253 253 253 253
50875 -253 253 253 253 253 253 158 158 158 18 18 18
50876 - 14 14 14 2 2 6 2 2 6 2 2 6
50877 - 6 6 6 18 18 18 66 66 66 38 38 38
50878 - 6 6 6 94 94 94 50 50 50 18 18 18
50879 - 6 6 6 0 0 0 0 0 0 0 0 0
50880 - 0 0 0 0 0 0 0 0 0 0 0 0
50881 - 0 0 0 0 0 0 0 0 0 0 0 0
50882 - 0 0 0 0 0 0 0 0 0 0 0 0
50883 - 0 0 0 0 0 0 0 0 0 0 0 0
50884 - 0 0 0 0 0 0 0 0 0 6 6 6
50885 - 10 10 10 10 10 10 18 18 18 38 38 38
50886 - 78 78 78 142 134 106 216 158 10 242 186 14
50887 -246 190 14 246 190 14 156 118 10 10 10 10
50888 - 90 90 90 238 238 238 253 253 253 253 253 253
50889 -253 253 253 253 253 253 253 253 253 253 253 253
50890 -253 253 253 253 253 253 231 231 231 250 250 250
50891 -253 253 253 253 253 253 253 253 253 253 253 253
50892 -253 253 253 253 253 253 253 253 253 253 253 253
50893 -253 253 253 253 253 253 253 253 253 253 253 253
50894 -253 253 253 253 253 253 253 253 253 246 230 190
50895 -238 204 91 238 204 91 181 142 44 37 26 9
50896 - 2 2 6 2 2 6 2 2 6 2 2 6
50897 - 2 2 6 2 2 6 38 38 38 46 46 46
50898 - 26 26 26 106 106 106 54 54 54 18 18 18
50899 - 6 6 6 0 0 0 0 0 0 0 0 0
50900 - 0 0 0 0 0 0 0 0 0 0 0 0
50901 - 0 0 0 0 0 0 0 0 0 0 0 0
50902 - 0 0 0 0 0 0 0 0 0 0 0 0
50903 - 0 0 0 0 0 0 0 0 0 0 0 0
50904 - 0 0 0 6 6 6 14 14 14 22 22 22
50905 - 30 30 30 38 38 38 50 50 50 70 70 70
50906 -106 106 106 190 142 34 226 170 11 242 186 14
50907 -246 190 14 246 190 14 246 190 14 154 114 10
50908 - 6 6 6 74 74 74 226 226 226 253 253 253
50909 -253 253 253 253 253 253 253 253 253 253 253 253
50910 -253 253 253 253 253 253 231 231 231 250 250 250
50911 -253 253 253 253 253 253 253 253 253 253 253 253
50912 -253 253 253 253 253 253 253 253 253 253 253 253
50913 -253 253 253 253 253 253 253 253 253 253 253 253
50914 -253 253 253 253 253 253 253 253 253 228 184 62
50915 -241 196 14 241 208 19 232 195 16 38 30 10
50916 - 2 2 6 2 2 6 2 2 6 2 2 6
50917 - 2 2 6 6 6 6 30 30 30 26 26 26
50918 -203 166 17 154 142 90 66 66 66 26 26 26
50919 - 6 6 6 0 0 0 0 0 0 0 0 0
50920 - 0 0 0 0 0 0 0 0 0 0 0 0
50921 - 0 0 0 0 0 0 0 0 0 0 0 0
50922 - 0 0 0 0 0 0 0 0 0 0 0 0
50923 - 0 0 0 0 0 0 0 0 0 0 0 0
50924 - 6 6 6 18 18 18 38 38 38 58 58 58
50925 - 78 78 78 86 86 86 101 101 101 123 123 123
50926 -175 146 61 210 150 10 234 174 13 246 186 14
50927 -246 190 14 246 190 14 246 190 14 238 190 10
50928 -102 78 10 2 2 6 46 46 46 198 198 198
50929 -253 253 253 253 253 253 253 253 253 253 253 253
50930 -253 253 253 253 253 253 234 234 234 242 242 242
50931 -253 253 253 253 253 253 253 253 253 253 253 253
50932 -253 253 253 253 253 253 253 253 253 253 253 253
50933 -253 253 253 253 253 253 253 253 253 253 253 253
50934 -253 253 253 253 253 253 253 253 253 224 178 62
50935 -242 186 14 241 196 14 210 166 10 22 18 6
50936 - 2 2 6 2 2 6 2 2 6 2 2 6
50937 - 2 2 6 2 2 6 6 6 6 121 92 8
50938 -238 202 15 232 195 16 82 82 82 34 34 34
50939 - 10 10 10 0 0 0 0 0 0 0 0 0
50940 - 0 0 0 0 0 0 0 0 0 0 0 0
50941 - 0 0 0 0 0 0 0 0 0 0 0 0
50942 - 0 0 0 0 0 0 0 0 0 0 0 0
50943 - 0 0 0 0 0 0 0 0 0 0 0 0
50944 - 14 14 14 38 38 38 70 70 70 154 122 46
50945 -190 142 34 200 144 11 197 138 11 197 138 11
50946 -213 154 11 226 170 11 242 186 14 246 190 14
50947 -246 190 14 246 190 14 246 190 14 246 190 14
50948 -225 175 15 46 32 6 2 2 6 22 22 22
50949 -158 158 158 250 250 250 253 253 253 253 253 253
50950 -253 253 253 253 253 253 253 253 253 253 253 253
50951 -253 253 253 253 253 253 253 253 253 253 253 253
50952 -253 253 253 253 253 253 253 253 253 253 253 253
50953 -253 253 253 253 253 253 253 253 253 253 253 253
50954 -253 253 253 250 250 250 242 242 242 224 178 62
50955 -239 182 13 236 186 11 213 154 11 46 32 6
50956 - 2 2 6 2 2 6 2 2 6 2 2 6
50957 - 2 2 6 2 2 6 61 42 6 225 175 15
50958 -238 190 10 236 186 11 112 100 78 42 42 42
50959 - 14 14 14 0 0 0 0 0 0 0 0 0
50960 - 0 0 0 0 0 0 0 0 0 0 0 0
50961 - 0 0 0 0 0 0 0 0 0 0 0 0
50962 - 0 0 0 0 0 0 0 0 0 0 0 0
50963 - 0 0 0 0 0 0 0 0 0 6 6 6
50964 - 22 22 22 54 54 54 154 122 46 213 154 11
50965 -226 170 11 230 174 11 226 170 11 226 170 11
50966 -236 178 12 242 186 14 246 190 14 246 190 14
50967 -246 190 14 246 190 14 246 190 14 246 190 14
50968 -241 196 14 184 144 12 10 10 10 2 2 6
50969 - 6 6 6 116 116 116 242 242 242 253 253 253
50970 -253 253 253 253 253 253 253 253 253 253 253 253
50971 -253 253 253 253 253 253 253 253 253 253 253 253
50972 -253 253 253 253 253 253 253 253 253 253 253 253
50973 -253 253 253 253 253 253 253 253 253 253 253 253
50974 -253 253 253 231 231 231 198 198 198 214 170 54
50975 -236 178 12 236 178 12 210 150 10 137 92 6
50976 - 18 14 6 2 2 6 2 2 6 2 2 6
50977 - 6 6 6 70 47 6 200 144 11 236 178 12
50978 -239 182 13 239 182 13 124 112 88 58 58 58
50979 - 22 22 22 6 6 6 0 0 0 0 0 0
50980 - 0 0 0 0 0 0 0 0 0 0 0 0
50981 - 0 0 0 0 0 0 0 0 0 0 0 0
50982 - 0 0 0 0 0 0 0 0 0 0 0 0
50983 - 0 0 0 0 0 0 0 0 0 10 10 10
50984 - 30 30 30 70 70 70 180 133 36 226 170 11
50985 -239 182 13 242 186 14 242 186 14 246 186 14
50986 -246 190 14 246 190 14 246 190 14 246 190 14
50987 -246 190 14 246 190 14 246 190 14 246 190 14
50988 -246 190 14 232 195 16 98 70 6 2 2 6
50989 - 2 2 6 2 2 6 66 66 66 221 221 221
50990 -253 253 253 253 253 253 253 253 253 253 253 253
50991 -253 253 253 253 253 253 253 253 253 253 253 253
50992 -253 253 253 253 253 253 253 253 253 253 253 253
50993 -253 253 253 253 253 253 253 253 253 253 253 253
50994 -253 253 253 206 206 206 198 198 198 214 166 58
50995 -230 174 11 230 174 11 216 158 10 192 133 9
50996 -163 110 8 116 81 8 102 78 10 116 81 8
50997 -167 114 7 197 138 11 226 170 11 239 182 13
50998 -242 186 14 242 186 14 162 146 94 78 78 78
50999 - 34 34 34 14 14 14 6 6 6 0 0 0
51000 - 0 0 0 0 0 0 0 0 0 0 0 0
51001 - 0 0 0 0 0 0 0 0 0 0 0 0
51002 - 0 0 0 0 0 0 0 0 0 0 0 0
51003 - 0 0 0 0 0 0 0 0 0 6 6 6
51004 - 30 30 30 78 78 78 190 142 34 226 170 11
51005 -239 182 13 246 190 14 246 190 14 246 190 14
51006 -246 190 14 246 190 14 246 190 14 246 190 14
51007 -246 190 14 246 190 14 246 190 14 246 190 14
51008 -246 190 14 241 196 14 203 166 17 22 18 6
51009 - 2 2 6 2 2 6 2 2 6 38 38 38
51010 -218 218 218 253 253 253 253 253 253 253 253 253
51011 -253 253 253 253 253 253 253 253 253 253 253 253
51012 -253 253 253 253 253 253 253 253 253 253 253 253
51013 -253 253 253 253 253 253 253 253 253 253 253 253
51014 -250 250 250 206 206 206 198 198 198 202 162 69
51015 -226 170 11 236 178 12 224 166 10 210 150 10
51016 -200 144 11 197 138 11 192 133 9 197 138 11
51017 -210 150 10 226 170 11 242 186 14 246 190 14
51018 -246 190 14 246 186 14 225 175 15 124 112 88
51019 - 62 62 62 30 30 30 14 14 14 6 6 6
51020 - 0 0 0 0 0 0 0 0 0 0 0 0
51021 - 0 0 0 0 0 0 0 0 0 0 0 0
51022 - 0 0 0 0 0 0 0 0 0 0 0 0
51023 - 0 0 0 0 0 0 0 0 0 10 10 10
51024 - 30 30 30 78 78 78 174 135 50 224 166 10
51025 -239 182 13 246 190 14 246 190 14 246 190 14
51026 -246 190 14 246 190 14 246 190 14 246 190 14
51027 -246 190 14 246 190 14 246 190 14 246 190 14
51028 -246 190 14 246 190 14 241 196 14 139 102 15
51029 - 2 2 6 2 2 6 2 2 6 2 2 6
51030 - 78 78 78 250 250 250 253 253 253 253 253 253
51031 -253 253 253 253 253 253 253 253 253 253 253 253
51032 -253 253 253 253 253 253 253 253 253 253 253 253
51033 -253 253 253 253 253 253 253 253 253 253 253 253
51034 -250 250 250 214 214 214 198 198 198 190 150 46
51035 -219 162 10 236 178 12 234 174 13 224 166 10
51036 -216 158 10 213 154 11 213 154 11 216 158 10
51037 -226 170 11 239 182 13 246 190 14 246 190 14
51038 -246 190 14 246 190 14 242 186 14 206 162 42
51039 -101 101 101 58 58 58 30 30 30 14 14 14
51040 - 6 6 6 0 0 0 0 0 0 0 0 0
51041 - 0 0 0 0 0 0 0 0 0 0 0 0
51042 - 0 0 0 0 0 0 0 0 0 0 0 0
51043 - 0 0 0 0 0 0 0 0 0 10 10 10
51044 - 30 30 30 74 74 74 174 135 50 216 158 10
51045 -236 178 12 246 190 14 246 190 14 246 190 14
51046 -246 190 14 246 190 14 246 190 14 246 190 14
51047 -246 190 14 246 190 14 246 190 14 246 190 14
51048 -246 190 14 246 190 14 241 196 14 226 184 13
51049 - 61 42 6 2 2 6 2 2 6 2 2 6
51050 - 22 22 22 238 238 238 253 253 253 253 253 253
51051 -253 253 253 253 253 253 253 253 253 253 253 253
51052 -253 253 253 253 253 253 253 253 253 253 253 253
51053 -253 253 253 253 253 253 253 253 253 253 253 253
51054 -253 253 253 226 226 226 187 187 187 180 133 36
51055 -216 158 10 236 178 12 239 182 13 236 178 12
51056 -230 174 11 226 170 11 226 170 11 230 174 11
51057 -236 178 12 242 186 14 246 190 14 246 190 14
51058 -246 190 14 246 190 14 246 186 14 239 182 13
51059 -206 162 42 106 106 106 66 66 66 34 34 34
51060 - 14 14 14 6 6 6 0 0 0 0 0 0
51061 - 0 0 0 0 0 0 0 0 0 0 0 0
51062 - 0 0 0 0 0 0 0 0 0 0 0 0
51063 - 0 0 0 0 0 0 0 0 0 6 6 6
51064 - 26 26 26 70 70 70 163 133 67 213 154 11
51065 -236 178 12 246 190 14 246 190 14 246 190 14
51066 -246 190 14 246 190 14 246 190 14 246 190 14
51067 -246 190 14 246 190 14 246 190 14 246 190 14
51068 -246 190 14 246 190 14 246 190 14 241 196 14
51069 -190 146 13 18 14 6 2 2 6 2 2 6
51070 - 46 46 46 246 246 246 253 253 253 253 253 253
51071 -253 253 253 253 253 253 253 253 253 253 253 253
51072 -253 253 253 253 253 253 253 253 253 253 253 253
51073 -253 253 253 253 253 253 253 253 253 253 253 253
51074 -253 253 253 221 221 221 86 86 86 156 107 11
51075 -216 158 10 236 178 12 242 186 14 246 186 14
51076 -242 186 14 239 182 13 239 182 13 242 186 14
51077 -242 186 14 246 186 14 246 190 14 246 190 14
51078 -246 190 14 246 190 14 246 190 14 246 190 14
51079 -242 186 14 225 175 15 142 122 72 66 66 66
51080 - 30 30 30 10 10 10 0 0 0 0 0 0
51081 - 0 0 0 0 0 0 0 0 0 0 0 0
51082 - 0 0 0 0 0 0 0 0 0 0 0 0
51083 - 0 0 0 0 0 0 0 0 0 6 6 6
51084 - 26 26 26 70 70 70 163 133 67 210 150 10
51085 -236 178 12 246 190 14 246 190 14 246 190 14
51086 -246 190 14 246 190 14 246 190 14 246 190 14
51087 -246 190 14 246 190 14 246 190 14 246 190 14
51088 -246 190 14 246 190 14 246 190 14 246 190 14
51089 -232 195 16 121 92 8 34 34 34 106 106 106
51090 -221 221 221 253 253 253 253 253 253 253 253 253
51091 -253 253 253 253 253 253 253 253 253 253 253 253
51092 -253 253 253 253 253 253 253 253 253 253 253 253
51093 -253 253 253 253 253 253 253 253 253 253 253 253
51094 -242 242 242 82 82 82 18 14 6 163 110 8
51095 -216 158 10 236 178 12 242 186 14 246 190 14
51096 -246 190 14 246 190 14 246 190 14 246 190 14
51097 -246 190 14 246 190 14 246 190 14 246 190 14
51098 -246 190 14 246 190 14 246 190 14 246 190 14
51099 -246 190 14 246 190 14 242 186 14 163 133 67
51100 - 46 46 46 18 18 18 6 6 6 0 0 0
51101 - 0 0 0 0 0 0 0 0 0 0 0 0
51102 - 0 0 0 0 0 0 0 0 0 0 0 0
51103 - 0 0 0 0 0 0 0 0 0 10 10 10
51104 - 30 30 30 78 78 78 163 133 67 210 150 10
51105 -236 178 12 246 186 14 246 190 14 246 190 14
51106 -246 190 14 246 190 14 246 190 14 246 190 14
51107 -246 190 14 246 190 14 246 190 14 246 190 14
51108 -246 190 14 246 190 14 246 190 14 246 190 14
51109 -241 196 14 215 174 15 190 178 144 253 253 253
51110 -253 253 253 253 253 253 253 253 253 253 253 253
51111 -253 253 253 253 253 253 253 253 253 253 253 253
51112 -253 253 253 253 253 253 253 253 253 253 253 253
51113 -253 253 253 253 253 253 253 253 253 218 218 218
51114 - 58 58 58 2 2 6 22 18 6 167 114 7
51115 -216 158 10 236 178 12 246 186 14 246 190 14
51116 -246 190 14 246 190 14 246 190 14 246 190 14
51117 -246 190 14 246 190 14 246 190 14 246 190 14
51118 -246 190 14 246 190 14 246 190 14 246 190 14
51119 -246 190 14 246 186 14 242 186 14 190 150 46
51120 - 54 54 54 22 22 22 6 6 6 0 0 0
51121 - 0 0 0 0 0 0 0 0 0 0 0 0
51122 - 0 0 0 0 0 0 0 0 0 0 0 0
51123 - 0 0 0 0 0 0 0 0 0 14 14 14
51124 - 38 38 38 86 86 86 180 133 36 213 154 11
51125 -236 178 12 246 186 14 246 190 14 246 190 14
51126 -246 190 14 246 190 14 246 190 14 246 190 14
51127 -246 190 14 246 190 14 246 190 14 246 190 14
51128 -246 190 14 246 190 14 246 190 14 246 190 14
51129 -246 190 14 232 195 16 190 146 13 214 214 214
51130 -253 253 253 253 253 253 253 253 253 253 253 253
51131 -253 253 253 253 253 253 253 253 253 253 253 253
51132 -253 253 253 253 253 253 253 253 253 253 253 253
51133 -253 253 253 250 250 250 170 170 170 26 26 26
51134 - 2 2 6 2 2 6 37 26 9 163 110 8
51135 -219 162 10 239 182 13 246 186 14 246 190 14
51136 -246 190 14 246 190 14 246 190 14 246 190 14
51137 -246 190 14 246 190 14 246 190 14 246 190 14
51138 -246 190 14 246 190 14 246 190 14 246 190 14
51139 -246 186 14 236 178 12 224 166 10 142 122 72
51140 - 46 46 46 18 18 18 6 6 6 0 0 0
51141 - 0 0 0 0 0 0 0 0 0 0 0 0
51142 - 0 0 0 0 0 0 0 0 0 0 0 0
51143 - 0 0 0 0 0 0 6 6 6 18 18 18
51144 - 50 50 50 109 106 95 192 133 9 224 166 10
51145 -242 186 14 246 190 14 246 190 14 246 190 14
51146 -246 190 14 246 190 14 246 190 14 246 190 14
51147 -246 190 14 246 190 14 246 190 14 246 190 14
51148 -246 190 14 246 190 14 246 190 14 246 190 14
51149 -242 186 14 226 184 13 210 162 10 142 110 46
51150 -226 226 226 253 253 253 253 253 253 253 253 253
51151 -253 253 253 253 253 253 253 253 253 253 253 253
51152 -253 253 253 253 253 253 253 253 253 253 253 253
51153 -198 198 198 66 66 66 2 2 6 2 2 6
51154 - 2 2 6 2 2 6 50 34 6 156 107 11
51155 -219 162 10 239 182 13 246 186 14 246 190 14
51156 -246 190 14 246 190 14 246 190 14 246 190 14
51157 -246 190 14 246 190 14 246 190 14 246 190 14
51158 -246 190 14 246 190 14 246 190 14 242 186 14
51159 -234 174 13 213 154 11 154 122 46 66 66 66
51160 - 30 30 30 10 10 10 0 0 0 0 0 0
51161 - 0 0 0 0 0 0 0 0 0 0 0 0
51162 - 0 0 0 0 0 0 0 0 0 0 0 0
51163 - 0 0 0 0 0 0 6 6 6 22 22 22
51164 - 58 58 58 154 121 60 206 145 10 234 174 13
51165 -242 186 14 246 186 14 246 190 14 246 190 14
51166 -246 190 14 246 190 14 246 190 14 246 190 14
51167 -246 190 14 246 190 14 246 190 14 246 190 14
51168 -246 190 14 246 190 14 246 190 14 246 190 14
51169 -246 186 14 236 178 12 210 162 10 163 110 8
51170 - 61 42 6 138 138 138 218 218 218 250 250 250
51171 -253 253 253 253 253 253 253 253 253 250 250 250
51172 -242 242 242 210 210 210 144 144 144 66 66 66
51173 - 6 6 6 2 2 6 2 2 6 2 2 6
51174 - 2 2 6 2 2 6 61 42 6 163 110 8
51175 -216 158 10 236 178 12 246 190 14 246 190 14
51176 -246 190 14 246 190 14 246 190 14 246 190 14
51177 -246 190 14 246 190 14 246 190 14 246 190 14
51178 -246 190 14 239 182 13 230 174 11 216 158 10
51179 -190 142 34 124 112 88 70 70 70 38 38 38
51180 - 18 18 18 6 6 6 0 0 0 0 0 0
51181 - 0 0 0 0 0 0 0 0 0 0 0 0
51182 - 0 0 0 0 0 0 0 0 0 0 0 0
51183 - 0 0 0 0 0 0 6 6 6 22 22 22
51184 - 62 62 62 168 124 44 206 145 10 224 166 10
51185 -236 178 12 239 182 13 242 186 14 242 186 14
51186 -246 186 14 246 190 14 246 190 14 246 190 14
51187 -246 190 14 246 190 14 246 190 14 246 190 14
51188 -246 190 14 246 190 14 246 190 14 246 190 14
51189 -246 190 14 236 178 12 216 158 10 175 118 6
51190 - 80 54 7 2 2 6 6 6 6 30 30 30
51191 - 54 54 54 62 62 62 50 50 50 38 38 38
51192 - 14 14 14 2 2 6 2 2 6 2 2 6
51193 - 2 2 6 2 2 6 2 2 6 2 2 6
51194 - 2 2 6 6 6 6 80 54 7 167 114 7
51195 -213 154 11 236 178 12 246 190 14 246 190 14
51196 -246 190 14 246 190 14 246 190 14 246 190 14
51197 -246 190 14 242 186 14 239 182 13 239 182 13
51198 -230 174 11 210 150 10 174 135 50 124 112 88
51199 - 82 82 82 54 54 54 34 34 34 18 18 18
51200 - 6 6 6 0 0 0 0 0 0 0 0 0
51201 - 0 0 0 0 0 0 0 0 0 0 0 0
51202 - 0 0 0 0 0 0 0 0 0 0 0 0
51203 - 0 0 0 0 0 0 6 6 6 18 18 18
51204 - 50 50 50 158 118 36 192 133 9 200 144 11
51205 -216 158 10 219 162 10 224 166 10 226 170 11
51206 -230 174 11 236 178 12 239 182 13 239 182 13
51207 -242 186 14 246 186 14 246 190 14 246 190 14
51208 -246 190 14 246 190 14 246 190 14 246 190 14
51209 -246 186 14 230 174 11 210 150 10 163 110 8
51210 -104 69 6 10 10 10 2 2 6 2 2 6
51211 - 2 2 6 2 2 6 2 2 6 2 2 6
51212 - 2 2 6 2 2 6 2 2 6 2 2 6
51213 - 2 2 6 2 2 6 2 2 6 2 2 6
51214 - 2 2 6 6 6 6 91 60 6 167 114 7
51215 -206 145 10 230 174 11 242 186 14 246 190 14
51216 -246 190 14 246 190 14 246 186 14 242 186 14
51217 -239 182 13 230 174 11 224 166 10 213 154 11
51218 -180 133 36 124 112 88 86 86 86 58 58 58
51219 - 38 38 38 22 22 22 10 10 10 6 6 6
51220 - 0 0 0 0 0 0 0 0 0 0 0 0
51221 - 0 0 0 0 0 0 0 0 0 0 0 0
51222 - 0 0 0 0 0 0 0 0 0 0 0 0
51223 - 0 0 0 0 0 0 0 0 0 14 14 14
51224 - 34 34 34 70 70 70 138 110 50 158 118 36
51225 -167 114 7 180 123 7 192 133 9 197 138 11
51226 -200 144 11 206 145 10 213 154 11 219 162 10
51227 -224 166 10 230 174 11 239 182 13 242 186 14
51228 -246 186 14 246 186 14 246 186 14 246 186 14
51229 -239 182 13 216 158 10 185 133 11 152 99 6
51230 -104 69 6 18 14 6 2 2 6 2 2 6
51231 - 2 2 6 2 2 6 2 2 6 2 2 6
51232 - 2 2 6 2 2 6 2 2 6 2 2 6
51233 - 2 2 6 2 2 6 2 2 6 2 2 6
51234 - 2 2 6 6 6 6 80 54 7 152 99 6
51235 -192 133 9 219 162 10 236 178 12 239 182 13
51236 -246 186 14 242 186 14 239 182 13 236 178 12
51237 -224 166 10 206 145 10 192 133 9 154 121 60
51238 - 94 94 94 62 62 62 42 42 42 22 22 22
51239 - 14 14 14 6 6 6 0 0 0 0 0 0
51240 - 0 0 0 0 0 0 0 0 0 0 0 0
51241 - 0 0 0 0 0 0 0 0 0 0 0 0
51242 - 0 0 0 0 0 0 0 0 0 0 0 0
51243 - 0 0 0 0 0 0 0 0 0 6 6 6
51244 - 18 18 18 34 34 34 58 58 58 78 78 78
51245 -101 98 89 124 112 88 142 110 46 156 107 11
51246 -163 110 8 167 114 7 175 118 6 180 123 7
51247 -185 133 11 197 138 11 210 150 10 219 162 10
51248 -226 170 11 236 178 12 236 178 12 234 174 13
51249 -219 162 10 197 138 11 163 110 8 130 83 6
51250 - 91 60 6 10 10 10 2 2 6 2 2 6
51251 - 18 18 18 38 38 38 38 38 38 38 38 38
51252 - 38 38 38 38 38 38 38 38 38 38 38 38
51253 - 38 38 38 38 38 38 26 26 26 2 2 6
51254 - 2 2 6 6 6 6 70 47 6 137 92 6
51255 -175 118 6 200 144 11 219 162 10 230 174 11
51256 -234 174 13 230 174 11 219 162 10 210 150 10
51257 -192 133 9 163 110 8 124 112 88 82 82 82
51258 - 50 50 50 30 30 30 14 14 14 6 6 6
51259 - 0 0 0 0 0 0 0 0 0 0 0 0
51260 - 0 0 0 0 0 0 0 0 0 0 0 0
51261 - 0 0 0 0 0 0 0 0 0 0 0 0
51262 - 0 0 0 0 0 0 0 0 0 0 0 0
51263 - 0 0 0 0 0 0 0 0 0 0 0 0
51264 - 6 6 6 14 14 14 22 22 22 34 34 34
51265 - 42 42 42 58 58 58 74 74 74 86 86 86
51266 -101 98 89 122 102 70 130 98 46 121 87 25
51267 -137 92 6 152 99 6 163 110 8 180 123 7
51268 -185 133 11 197 138 11 206 145 10 200 144 11
51269 -180 123 7 156 107 11 130 83 6 104 69 6
51270 - 50 34 6 54 54 54 110 110 110 101 98 89
51271 - 86 86 86 82 82 82 78 78 78 78 78 78
51272 - 78 78 78 78 78 78 78 78 78 78 78 78
51273 - 78 78 78 82 82 82 86 86 86 94 94 94
51274 -106 106 106 101 101 101 86 66 34 124 80 6
51275 -156 107 11 180 123 7 192 133 9 200 144 11
51276 -206 145 10 200 144 11 192 133 9 175 118 6
51277 -139 102 15 109 106 95 70 70 70 42 42 42
51278 - 22 22 22 10 10 10 0 0 0 0 0 0
51279 - 0 0 0 0 0 0 0 0 0 0 0 0
51280 - 0 0 0 0 0 0 0 0 0 0 0 0
51281 - 0 0 0 0 0 0 0 0 0 0 0 0
51282 - 0 0 0 0 0 0 0 0 0 0 0 0
51283 - 0 0 0 0 0 0 0 0 0 0 0 0
51284 - 0 0 0 0 0 0 6 6 6 10 10 10
51285 - 14 14 14 22 22 22 30 30 30 38 38 38
51286 - 50 50 50 62 62 62 74 74 74 90 90 90
51287 -101 98 89 112 100 78 121 87 25 124 80 6
51288 -137 92 6 152 99 6 152 99 6 152 99 6
51289 -138 86 6 124 80 6 98 70 6 86 66 30
51290 -101 98 89 82 82 82 58 58 58 46 46 46
51291 - 38 38 38 34 34 34 34 34 34 34 34 34
51292 - 34 34 34 34 34 34 34 34 34 34 34 34
51293 - 34 34 34 34 34 34 38 38 38 42 42 42
51294 - 54 54 54 82 82 82 94 86 76 91 60 6
51295 -134 86 6 156 107 11 167 114 7 175 118 6
51296 -175 118 6 167 114 7 152 99 6 121 87 25
51297 -101 98 89 62 62 62 34 34 34 18 18 18
51298 - 6 6 6 0 0 0 0 0 0 0 0 0
51299 - 0 0 0 0 0 0 0 0 0 0 0 0
51300 - 0 0 0 0 0 0 0 0 0 0 0 0
51301 - 0 0 0 0 0 0 0 0 0 0 0 0
51302 - 0 0 0 0 0 0 0 0 0 0 0 0
51303 - 0 0 0 0 0 0 0 0 0 0 0 0
51304 - 0 0 0 0 0 0 0 0 0 0 0 0
51305 - 0 0 0 6 6 6 6 6 6 10 10 10
51306 - 18 18 18 22 22 22 30 30 30 42 42 42
51307 - 50 50 50 66 66 66 86 86 86 101 98 89
51308 -106 86 58 98 70 6 104 69 6 104 69 6
51309 -104 69 6 91 60 6 82 62 34 90 90 90
51310 - 62 62 62 38 38 38 22 22 22 14 14 14
51311 - 10 10 10 10 10 10 10 10 10 10 10 10
51312 - 10 10 10 10 10 10 6 6 6 10 10 10
51313 - 10 10 10 10 10 10 10 10 10 14 14 14
51314 - 22 22 22 42 42 42 70 70 70 89 81 66
51315 - 80 54 7 104 69 6 124 80 6 137 92 6
51316 -134 86 6 116 81 8 100 82 52 86 86 86
51317 - 58 58 58 30 30 30 14 14 14 6 6 6
51318 - 0 0 0 0 0 0 0 0 0 0 0 0
51319 - 0 0 0 0 0 0 0 0 0 0 0 0
51320 - 0 0 0 0 0 0 0 0 0 0 0 0
51321 - 0 0 0 0 0 0 0 0 0 0 0 0
51322 - 0 0 0 0 0 0 0 0 0 0 0 0
51323 - 0 0 0 0 0 0 0 0 0 0 0 0
51324 - 0 0 0 0 0 0 0 0 0 0 0 0
51325 - 0 0 0 0 0 0 0 0 0 0 0 0
51326 - 0 0 0 6 6 6 10 10 10 14 14 14
51327 - 18 18 18 26 26 26 38 38 38 54 54 54
51328 - 70 70 70 86 86 86 94 86 76 89 81 66
51329 - 89 81 66 86 86 86 74 74 74 50 50 50
51330 - 30 30 30 14 14 14 6 6 6 0 0 0
51331 - 0 0 0 0 0 0 0 0 0 0 0 0
51332 - 0 0 0 0 0 0 0 0 0 0 0 0
51333 - 0 0 0 0 0 0 0 0 0 0 0 0
51334 - 6 6 6 18 18 18 34 34 34 58 58 58
51335 - 82 82 82 89 81 66 89 81 66 89 81 66
51336 - 94 86 66 94 86 76 74 74 74 50 50 50
51337 - 26 26 26 14 14 14 6 6 6 0 0 0
51338 - 0 0 0 0 0 0 0 0 0 0 0 0
51339 - 0 0 0 0 0 0 0 0 0 0 0 0
51340 - 0 0 0 0 0 0 0 0 0 0 0 0
51341 - 0 0 0 0 0 0 0 0 0 0 0 0
51342 - 0 0 0 0 0 0 0 0 0 0 0 0
51343 - 0 0 0 0 0 0 0 0 0 0 0 0
51344 - 0 0 0 0 0 0 0 0 0 0 0 0
51345 - 0 0 0 0 0 0 0 0 0 0 0 0
51346 - 0 0 0 0 0 0 0 0 0 0 0 0
51347 - 6 6 6 6 6 6 14 14 14 18 18 18
51348 - 30 30 30 38 38 38 46 46 46 54 54 54
51349 - 50 50 50 42 42 42 30 30 30 18 18 18
51350 - 10 10 10 0 0 0 0 0 0 0 0 0
51351 - 0 0 0 0 0 0 0 0 0 0 0 0
51352 - 0 0 0 0 0 0 0 0 0 0 0 0
51353 - 0 0 0 0 0 0 0 0 0 0 0 0
51354 - 0 0 0 6 6 6 14 14 14 26 26 26
51355 - 38 38 38 50 50 50 58 58 58 58 58 58
51356 - 54 54 54 42 42 42 30 30 30 18 18 18
51357 - 10 10 10 0 0 0 0 0 0 0 0 0
51358 - 0 0 0 0 0 0 0 0 0 0 0 0
51359 - 0 0 0 0 0 0 0 0 0 0 0 0
51360 - 0 0 0 0 0 0 0 0 0 0 0 0
51361 - 0 0 0 0 0 0 0 0 0 0 0 0
51362 - 0 0 0 0 0 0 0 0 0 0 0 0
51363 - 0 0 0 0 0 0 0 0 0 0 0 0
51364 - 0 0 0 0 0 0 0 0 0 0 0 0
51365 - 0 0 0 0 0 0 0 0 0 0 0 0
51366 - 0 0 0 0 0 0 0 0 0 0 0 0
51367 - 0 0 0 0 0 0 0 0 0 6 6 6
51368 - 6 6 6 10 10 10 14 14 14 18 18 18
51369 - 18 18 18 14 14 14 10 10 10 6 6 6
51370 - 0 0 0 0 0 0 0 0 0 0 0 0
51371 - 0 0 0 0 0 0 0 0 0 0 0 0
51372 - 0 0 0 0 0 0 0 0 0 0 0 0
51373 - 0 0 0 0 0 0 0 0 0 0 0 0
51374 - 0 0 0 0 0 0 0 0 0 6 6 6
51375 - 14 14 14 18 18 18 22 22 22 22 22 22
51376 - 18 18 18 14 14 14 10 10 10 6 6 6
51377 - 0 0 0 0 0 0 0 0 0 0 0 0
51378 - 0 0 0 0 0 0 0 0 0 0 0 0
51379 - 0 0 0 0 0 0 0 0 0 0 0 0
51380 - 0 0 0 0 0 0 0 0 0 0 0 0
51381 - 0 0 0 0 0 0 0 0 0 0 0 0
51382 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51383 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51384 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51385 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51386 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51387 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51388 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51389 +4 4 4 4 4 4 4 4 4 4 4 4 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 4 4 4
51397 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51398 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51399 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51400 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51401 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51402 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51403 +4 4 4 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51412 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51413 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51414 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51415 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51416 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51417 +4 4 4 4 4 4 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4
51426 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51427 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51428 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51429 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51430 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51431 +4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51441 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51442 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51443 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51444 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51445 +4 4 4 4 4 4 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 4 4 4
51455 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51456 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51457 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51458 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51470 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
51471 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
51472 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
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 1 1 1 0 0 0
51476 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
51477 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
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 4 4 4 4 4 4 4 4 4 4 4 4
51484 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
51485 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
51486 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 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 3 3 3 0 0 0 1 1 1 6 6 6
51490 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
51491 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
51492 +1 1 1 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 4 4 4 4 4 4 4 4 4
51498 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
51499 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
51500 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 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 0 0 0 4 4 4 41 54 63 125 124 125
51504 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
51505 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
51506 +2 2 2 2 1 0 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 5 5 5 5 5 5 2 2 2 0 0 0
51512 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
51513 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
51514 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 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 5 5 5 5 5 5
51517 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
51518 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
51519 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
51520 +37 51 59 2 0 0 1 1 1 4 5 5 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 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
51526 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
51527 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
51528 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
51529 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51530 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
51531 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
51532 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
51533 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
51534 +64 123 161 14 17 19 0 0 0 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 5 5 5
51539 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
51540 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
51541 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
51542 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
51543 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
51544 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
51545 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
51546 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
51547 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
51548 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 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 5 5 5 3 3 3
51553 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
51554 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
51555 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
51556 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
51557 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
51558 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
51559 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
51560 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
51561 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
51562 +31 91 132 3 6 7 0 0 0 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 2 2 2 0 0 0 4 0 0
51567 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
51568 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
51569 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
51570 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
51571 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
51572 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
51573 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
51574 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
51575 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
51576 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
51577 +4 4 4 4 4 4
51578 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51579 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51580 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
51581 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
51582 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
51583 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
51584 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
51585 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
51586 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
51587 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
51588 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
51589 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
51590 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
51591 +4 4 4 4 4 4
51592 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51593 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51594 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
51595 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
51596 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
51597 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
51598 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
51599 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
51600 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
51601 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
51602 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
51603 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
51604 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
51605 +4 4 4 4 4 4
51606 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51607 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
51608 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
51609 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
51610 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
51611 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
51612 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
51613 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
51614 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
51615 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
51616 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
51617 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
51618 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
51619 +4 4 4 4 4 4
51620 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51621 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
51622 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
51623 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
51624 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
51625 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
51626 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
51627 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
51628 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
51629 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
51630 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
51631 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
51632 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
51633 +0 0 0 4 4 4
51634 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
51635 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
51636 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
51637 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
51638 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
51639 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
51640 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
51641 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
51642 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
51643 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
51644 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
51645 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
51646 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
51647 +2 0 0 0 0 0
51648 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
51649 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
51650 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
51651 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
51652 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
51653 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
51654 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
51655 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
51656 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
51657 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
51658 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
51659 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
51660 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
51661 +37 38 37 0 0 0
51662 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
51663 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
51664 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
51665 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
51666 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
51667 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
51668 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
51669 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
51670 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
51671 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
51672 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
51673 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
51674 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
51675 +85 115 134 4 0 0
51676 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
51677 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
51678 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
51679 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
51680 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
51681 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
51682 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
51683 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
51684 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
51685 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
51686 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
51687 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
51688 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
51689 +60 73 81 4 0 0
51690 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
51691 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
51692 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
51693 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
51694 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
51695 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
51696 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
51697 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
51698 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
51699 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
51700 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
51701 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
51702 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
51703 +16 19 21 4 0 0
51704 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
51705 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
51706 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
51707 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
51708 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
51709 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
51710 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
51711 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
51712 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
51713 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
51714 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
51715 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
51716 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
51717 +4 0 0 4 3 3
51718 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
51719 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
51720 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
51721 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
51722 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
51723 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
51724 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
51725 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
51726 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
51727 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
51728 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
51729 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
51730 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
51731 +3 2 2 4 4 4
51732 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
51733 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
51734 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
51735 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
51736 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
51737 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
51738 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
51739 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
51740 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
51741 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
51742 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
51743 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
51744 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
51745 +4 4 4 4 4 4
51746 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
51747 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
51748 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
51749 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
51750 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
51751 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
51752 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
51753 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
51754 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
51755 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
51756 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
51757 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
51758 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
51759 +4 4 4 4 4 4
51760 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
51761 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
51762 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
51763 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
51764 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
51765 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
51766 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
51767 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
51768 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
51769 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
51770 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
51771 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
51772 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
51773 +5 5 5 5 5 5
51774 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
51775 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
51776 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
51777 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
51778 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
51779 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51780 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
51781 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
51782 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
51783 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
51784 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
51785 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
51786 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
51787 +5 5 5 4 4 4
51788 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
51789 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
51790 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
51791 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
51792 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
51793 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
51794 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
51795 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
51796 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
51797 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
51798 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
51799 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
51800 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51801 +4 4 4 4 4 4
51802 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
51803 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
51804 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
51805 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
51806 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
51807 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51808 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51809 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
51810 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
51811 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
51812 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
51813 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
51814 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51815 +4 4 4 4 4 4
51816 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
51817 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
51818 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
51819 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
51820 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
51821 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
51822 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
51823 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
51824 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
51825 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
51826 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
51827 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51828 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51829 +4 4 4 4 4 4
51830 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
51831 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
51832 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
51833 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
51834 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
51835 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51836 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51837 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
51838 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
51839 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
51840 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
51841 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51842 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51843 +4 4 4 4 4 4
51844 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
51845 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
51846 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
51847 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
51848 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
51849 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
51850 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
51851 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
51852 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
51853 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
51854 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51855 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51856 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51857 +4 4 4 4 4 4
51858 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
51859 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
51860 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
51861 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
51862 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
51863 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
51864 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
51865 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
51866 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
51867 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
51868 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
51869 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51870 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51871 +4 4 4 4 4 4
51872 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
51873 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
51874 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
51875 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
51876 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
51877 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
51878 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
51879 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
51880 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
51881 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
51882 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
51883 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51884 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51885 +4 4 4 4 4 4
51886 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
51887 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
51888 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
51889 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
51890 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
51891 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
51892 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
51893 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
51894 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
51895 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
51896 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51897 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51898 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51899 +4 4 4 4 4 4
51900 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
51901 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
51902 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
51903 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
51904 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51905 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
51906 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
51907 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
51908 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
51909 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
51910 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51911 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51912 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51913 +4 4 4 4 4 4
51914 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
51915 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
51916 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
51917 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
51918 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51919 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
51920 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
51921 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
51922 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
51923 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
51924 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51925 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51926 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51927 +4 4 4 4 4 4
51928 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
51929 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
51930 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
51931 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
51932 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51933 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
51934 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
51935 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
51936 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
51937 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51938 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51939 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51940 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51941 +4 4 4 4 4 4
51942 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
51943 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
51944 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
51945 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
51946 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
51947 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
51948 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
51949 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
51950 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51951 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51952 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51953 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51954 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51955 +4 4 4 4 4 4
51956 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
51957 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
51958 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
51959 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
51960 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51961 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
51962 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
51963 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
51964 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51965 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51966 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51967 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51968 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51969 +4 4 4 4 4 4
51970 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
51971 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
51972 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
51973 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
51974 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
51975 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
51976 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
51977 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
51978 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51979 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51980 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51981 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51982 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51983 +4 4 4 4 4 4
51984 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
51985 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
51986 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51987 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
51988 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
51989 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
51990 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
51991 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
51992 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
51993 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51994 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51995 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51996 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51997 +4 4 4 4 4 4
51998 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
51999 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
52000 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
52001 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
52002 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
52003 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
52004 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
52005 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
52006 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
52007 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52008 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52009 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52010 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52011 +4 4 4 4 4 4
52012 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
52013 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
52014 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
52015 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
52016 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
52017 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
52018 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
52019 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
52020 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
52021 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52022 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52023 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52024 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52025 +4 4 4 4 4 4
52026 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
52027 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
52028 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
52029 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
52030 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
52031 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
52032 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
52033 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
52034 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
52035 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52036 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52037 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52038 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52039 +4 4 4 4 4 4
52040 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
52041 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
52042 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
52043 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
52044 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
52045 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
52046 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
52047 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
52048 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
52049 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52050 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52051 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52052 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52053 +4 4 4 4 4 4
52054 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
52055 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
52056 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
52057 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
52058 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
52059 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
52060 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
52061 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
52062 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
52063 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52064 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52065 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52066 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52067 +4 4 4 4 4 4
52068 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
52069 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
52070 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
52071 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
52072 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
52073 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
52074 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
52075 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
52076 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
52077 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52078 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52079 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52080 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52081 +4 4 4 4 4 4
52082 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
52083 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
52084 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
52085 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
52086 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
52087 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
52088 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
52089 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
52090 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
52091 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52092 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52093 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52094 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52095 +4 4 4 4 4 4
52096 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
52097 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
52098 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
52099 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
52100 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
52101 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
52102 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
52103 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
52104 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
52105 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52106 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52107 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52108 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52109 +4 4 4 4 4 4
52110 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
52111 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
52112 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
52113 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
52114 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
52115 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
52116 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
52117 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
52118 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
52119 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52120 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52121 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52122 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52123 +4 4 4 4 4 4
52124 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
52125 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
52126 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
52127 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
52128 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
52129 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
52130 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
52131 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
52132 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
52133 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52134 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52135 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52136 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52137 +4 4 4 4 4 4
52138 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
52139 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
52140 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
52141 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
52142 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
52143 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
52144 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
52145 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
52146 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
52147 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
52148 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52149 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52150 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52151 +4 4 4 4 4 4
52152 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
52153 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
52154 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
52155 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
52156 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
52157 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
52158 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
52159 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
52160 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
52161 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
52162 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52163 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52164 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52165 +4 4 4 4 4 4
52166 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
52167 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
52168 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
52169 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
52170 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
52171 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
52172 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52173 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
52174 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
52175 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
52176 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
52177 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52178 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52179 +4 4 4 4 4 4
52180 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
52181 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
52182 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
52183 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
52184 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
52185 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
52186 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
52187 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
52188 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
52189 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
52190 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52191 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52192 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52193 +4 4 4 4 4 4
52194 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
52195 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
52196 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
52197 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
52198 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
52199 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
52200 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
52201 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
52202 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
52203 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
52204 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52205 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52206 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52207 +4 4 4 4 4 4
52208 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
52209 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
52210 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
52211 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
52212 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
52213 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
52214 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
52215 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
52216 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
52217 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
52218 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52219 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52220 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52221 +4 4 4 4 4 4
52222 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
52223 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
52224 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
52225 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
52226 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
52227 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
52228 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
52229 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
52230 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
52231 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
52232 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52233 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52234 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52235 +4 4 4 4 4 4
52236 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
52237 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
52238 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
52239 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
52240 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
52241 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
52242 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
52243 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
52244 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
52245 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
52246 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52247 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52248 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52249 +4 4 4 4 4 4
52250 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
52251 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
52252 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
52253 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
52254 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
52255 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
52256 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
52257 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
52258 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
52259 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52260 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52261 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52262 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52263 +4 4 4 4 4 4
52264 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
52265 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
52266 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
52267 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
52268 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
52269 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
52270 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
52271 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
52272 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
52273 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52274 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52275 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52276 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52277 +4 4 4 4 4 4
52278 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
52279 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
52280 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
52281 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
52282 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
52283 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
52284 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
52285 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
52286 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52287 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52288 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52289 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52290 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52291 +4 4 4 4 4 4
52292 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
52293 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
52294 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
52295 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
52296 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
52297 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
52298 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
52299 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
52300 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52301 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52302 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52303 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52304 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52305 +4 4 4 4 4 4
52306 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
52307 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
52308 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
52309 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
52310 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
52311 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
52312 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
52313 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
52314 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52315 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52316 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52317 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52318 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52319 +4 4 4 4 4 4
52320 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
52321 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
52322 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
52323 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
52324 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
52325 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
52326 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
52327 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
52328 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52329 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52330 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52331 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52332 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52333 +4 4 4 4 4 4
52334 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52335 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
52336 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
52337 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
52338 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
52339 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
52340 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
52341 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
52342 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52343 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52344 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52345 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52346 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52347 +4 4 4 4 4 4
52348 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52349 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
52350 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
52351 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
52352 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
52353 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
52354 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
52355 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
52356 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52357 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52358 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52359 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52360 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52361 +4 4 4 4 4 4
52362 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52363 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52364 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
52365 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
52366 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
52367 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
52368 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
52369 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
52370 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52371 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52372 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52373 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52374 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52375 +4 4 4 4 4 4
52376 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52377 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52378 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
52379 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
52380 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
52381 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
52382 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
52383 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52384 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52385 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52386 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52387 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52388 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52389 +4 4 4 4 4 4
52390 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52391 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52392 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52393 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
52394 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
52395 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
52396 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
52397 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52398 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52399 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52400 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52401 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52402 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52403 +4 4 4 4 4 4
52404 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52405 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52406 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52407 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
52408 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
52409 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
52410 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
52411 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52412 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52413 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52414 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52415 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52416 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52417 +4 4 4 4 4 4
52418 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52419 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52420 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52421 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
52422 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
52423 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
52424 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
52425 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52426 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52427 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52428 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52429 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52430 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52431 +4 4 4 4 4 4
52432 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52433 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52434 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52435 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
52436 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
52437 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
52438 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52439 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52440 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52441 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52442 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52443 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52444 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52445 +4 4 4 4 4 4
52446 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52447 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52448 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52449 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52450 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
52451 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
52452 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
52453 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52454 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52455 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52456 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52457 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52458 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52459 +4 4 4 4 4 4
52460 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52461 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52462 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52463 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52464 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
52465 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
52466 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52467 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52468 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52469 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52470 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52471 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52472 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52473 +4 4 4 4 4 4
52474 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52475 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52476 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52477 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52478 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
52479 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
52480 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52481 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52482 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52483 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52484 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52485 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52486 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52487 +4 4 4 4 4 4
52488 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52489 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52490 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52491 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52492 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
52493 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
52494 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52495 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52496 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52497 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52498 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52499 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52500 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52501 +4 4 4 4 4 4
52502 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
52503 index fe92eed..106e085 100644
52504 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
52505 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
52506 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
52507 struct mb862xxfb_par *par = info->par;
52508
52509 if (info->var.bits_per_pixel == 32) {
52510 - info->fbops->fb_fillrect = cfb_fillrect;
52511 - info->fbops->fb_copyarea = cfb_copyarea;
52512 - info->fbops->fb_imageblit = cfb_imageblit;
52513 + pax_open_kernel();
52514 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
52515 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
52516 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
52517 + pax_close_kernel();
52518 } else {
52519 outreg(disp, GC_L0EM, 3);
52520 - info->fbops->fb_fillrect = mb86290fb_fillrect;
52521 - info->fbops->fb_copyarea = mb86290fb_copyarea;
52522 - info->fbops->fb_imageblit = mb86290fb_imageblit;
52523 + pax_open_kernel();
52524 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
52525 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
52526 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
52527 + pax_close_kernel();
52528 }
52529 outreg(draw, GDC_REG_DRAW_BASE, 0);
52530 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
52531 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
52532 index ff22871..b129bed 100644
52533 --- a/drivers/video/nvidia/nvidia.c
52534 +++ b/drivers/video/nvidia/nvidia.c
52535 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
52536 info->fix.line_length = (info->var.xres_virtual *
52537 info->var.bits_per_pixel) >> 3;
52538 if (info->var.accel_flags) {
52539 - info->fbops->fb_imageblit = nvidiafb_imageblit;
52540 - info->fbops->fb_fillrect = nvidiafb_fillrect;
52541 - info->fbops->fb_copyarea = nvidiafb_copyarea;
52542 - info->fbops->fb_sync = nvidiafb_sync;
52543 + pax_open_kernel();
52544 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
52545 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
52546 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
52547 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
52548 + pax_close_kernel();
52549 info->pixmap.scan_align = 4;
52550 info->flags &= ~FBINFO_HWACCEL_DISABLED;
52551 info->flags |= FBINFO_READS_FAST;
52552 NVResetGraphics(info);
52553 } else {
52554 - info->fbops->fb_imageblit = cfb_imageblit;
52555 - info->fbops->fb_fillrect = cfb_fillrect;
52556 - info->fbops->fb_copyarea = cfb_copyarea;
52557 - info->fbops->fb_sync = NULL;
52558 + pax_open_kernel();
52559 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
52560 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
52561 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
52562 + *(void **)&info->fbops->fb_sync = NULL;
52563 + pax_close_kernel();
52564 info->pixmap.scan_align = 1;
52565 info->flags |= FBINFO_HWACCEL_DISABLED;
52566 info->flags &= ~FBINFO_READS_FAST;
52567 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
52568 info->pixmap.size = 8 * 1024;
52569 info->pixmap.flags = FB_PIXMAP_SYSTEM;
52570
52571 - if (!hwcur)
52572 - info->fbops->fb_cursor = NULL;
52573 + if (!hwcur) {
52574 + pax_open_kernel();
52575 + *(void **)&info->fbops->fb_cursor = NULL;
52576 + pax_close_kernel();
52577 + }
52578
52579 info->var.accel_flags = (!noaccel);
52580
52581 diff --git a/drivers/video/output.c b/drivers/video/output.c
52582 index 0d6f2cd..6285b97 100644
52583 --- a/drivers/video/output.c
52584 +++ b/drivers/video/output.c
52585 @@ -97,7 +97,7 @@ struct output_device *video_output_register(const char *name,
52586 new_dev->props = op;
52587 new_dev->dev.class = &video_output_class;
52588 new_dev->dev.parent = dev;
52589 - dev_set_name(&new_dev->dev, name);
52590 + dev_set_name(&new_dev->dev, "%s", name);
52591 dev_set_drvdata(&new_dev->dev, devdata);
52592 ret_code = device_register(&new_dev->dev);
52593 if (ret_code) {
52594 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
52595 index 05c2dc3..ea1f391 100644
52596 --- a/drivers/video/s1d13xxxfb.c
52597 +++ b/drivers/video/s1d13xxxfb.c
52598 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
52599
52600 switch(prod_id) {
52601 case S1D13506_PROD_ID: /* activate acceleration */
52602 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
52603 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
52604 + pax_open_kernel();
52605 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
52606 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
52607 + pax_close_kernel();
52608 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
52609 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
52610 break;
52611 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
52612 index b2b33fc..f9f4658 100644
52613 --- a/drivers/video/smscufx.c
52614 +++ b/drivers/video/smscufx.c
52615 @@ -1175,7 +1175,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
52616 fb_deferred_io_cleanup(info);
52617 kfree(info->fbdefio);
52618 info->fbdefio = NULL;
52619 - info->fbops->fb_mmap = ufx_ops_mmap;
52620 + pax_open_kernel();
52621 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
52622 + pax_close_kernel();
52623 }
52624
52625 pr_debug("released /dev/fb%d user=%d count=%d",
52626 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
52627 index ec03e72..f578436 100644
52628 --- a/drivers/video/udlfb.c
52629 +++ b/drivers/video/udlfb.c
52630 @@ -623,11 +623,11 @@ int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
52631 dlfb_urb_completion(urb);
52632
52633 error:
52634 - atomic_add(bytes_sent, &dev->bytes_sent);
52635 - atomic_add(bytes_identical, &dev->bytes_identical);
52636 - atomic_add(width*height*2, &dev->bytes_rendered);
52637 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
52638 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
52639 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
52640 end_cycles = get_cycles();
52641 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
52642 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
52643 >> 10)), /* Kcycles */
52644 &dev->cpu_kcycles_used);
52645
52646 @@ -748,11 +748,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
52647 dlfb_urb_completion(urb);
52648
52649 error:
52650 - atomic_add(bytes_sent, &dev->bytes_sent);
52651 - atomic_add(bytes_identical, &dev->bytes_identical);
52652 - atomic_add(bytes_rendered, &dev->bytes_rendered);
52653 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
52654 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
52655 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
52656 end_cycles = get_cycles();
52657 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
52658 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
52659 >> 10)), /* Kcycles */
52660 &dev->cpu_kcycles_used);
52661 }
52662 @@ -993,7 +993,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
52663 fb_deferred_io_cleanup(info);
52664 kfree(info->fbdefio);
52665 info->fbdefio = NULL;
52666 - info->fbops->fb_mmap = dlfb_ops_mmap;
52667 + pax_open_kernel();
52668 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
52669 + pax_close_kernel();
52670 }
52671
52672 pr_warn("released /dev/fb%d user=%d count=%d\n",
52673 @@ -1376,7 +1378,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
52674 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52675 struct dlfb_data *dev = fb_info->par;
52676 return snprintf(buf, PAGE_SIZE, "%u\n",
52677 - atomic_read(&dev->bytes_rendered));
52678 + atomic_read_unchecked(&dev->bytes_rendered));
52679 }
52680
52681 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
52682 @@ -1384,7 +1386,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
52683 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52684 struct dlfb_data *dev = fb_info->par;
52685 return snprintf(buf, PAGE_SIZE, "%u\n",
52686 - atomic_read(&dev->bytes_identical));
52687 + atomic_read_unchecked(&dev->bytes_identical));
52688 }
52689
52690 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
52691 @@ -1392,7 +1394,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
52692 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52693 struct dlfb_data *dev = fb_info->par;
52694 return snprintf(buf, PAGE_SIZE, "%u\n",
52695 - atomic_read(&dev->bytes_sent));
52696 + atomic_read_unchecked(&dev->bytes_sent));
52697 }
52698
52699 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
52700 @@ -1400,7 +1402,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
52701 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52702 struct dlfb_data *dev = fb_info->par;
52703 return snprintf(buf, PAGE_SIZE, "%u\n",
52704 - atomic_read(&dev->cpu_kcycles_used));
52705 + atomic_read_unchecked(&dev->cpu_kcycles_used));
52706 }
52707
52708 static ssize_t edid_show(
52709 @@ -1460,10 +1462,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
52710 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52711 struct dlfb_data *dev = fb_info->par;
52712
52713 - atomic_set(&dev->bytes_rendered, 0);
52714 - atomic_set(&dev->bytes_identical, 0);
52715 - atomic_set(&dev->bytes_sent, 0);
52716 - atomic_set(&dev->cpu_kcycles_used, 0);
52717 + atomic_set_unchecked(&dev->bytes_rendered, 0);
52718 + atomic_set_unchecked(&dev->bytes_identical, 0);
52719 + atomic_set_unchecked(&dev->bytes_sent, 0);
52720 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
52721
52722 return count;
52723 }
52724 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
52725 index e328a61..1b08ecb 100644
52726 --- a/drivers/video/uvesafb.c
52727 +++ b/drivers/video/uvesafb.c
52728 @@ -19,6 +19,7 @@
52729 #include <linux/io.h>
52730 #include <linux/mutex.h>
52731 #include <linux/slab.h>
52732 +#include <linux/moduleloader.h>
52733 #include <video/edid.h>
52734 #include <video/uvesafb.h>
52735 #ifdef CONFIG_X86
52736 @@ -569,10 +570,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
52737 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
52738 par->pmi_setpal = par->ypan = 0;
52739 } else {
52740 +
52741 +#ifdef CONFIG_PAX_KERNEXEC
52742 +#ifdef CONFIG_MODULES
52743 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
52744 +#endif
52745 + if (!par->pmi_code) {
52746 + par->pmi_setpal = par->ypan = 0;
52747 + return 0;
52748 + }
52749 +#endif
52750 +
52751 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
52752 + task->t.regs.edi);
52753 +
52754 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52755 + pax_open_kernel();
52756 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
52757 + pax_close_kernel();
52758 +
52759 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
52760 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
52761 +#else
52762 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
52763 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
52764 +#endif
52765 +
52766 printk(KERN_INFO "uvesafb: protected mode interface info at "
52767 "%04x:%04x\n",
52768 (u16)task->t.regs.es, (u16)task->t.regs.edi);
52769 @@ -817,13 +840,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
52770 par->ypan = ypan;
52771
52772 if (par->pmi_setpal || par->ypan) {
52773 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
52774 if (__supported_pte_mask & _PAGE_NX) {
52775 par->pmi_setpal = par->ypan = 0;
52776 printk(KERN_WARNING "uvesafb: NX protection is actively."
52777 "We have better not to use the PMI.\n");
52778 - } else {
52779 + } else
52780 +#endif
52781 uvesafb_vbe_getpmi(task, par);
52782 - }
52783 }
52784 #else
52785 /* The protected mode interface is not available on non-x86. */
52786 @@ -1457,8 +1481,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
52787 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
52788
52789 /* Disable blanking if the user requested so. */
52790 - if (!blank)
52791 - info->fbops->fb_blank = NULL;
52792 + if (!blank) {
52793 + pax_open_kernel();
52794 + *(void **)&info->fbops->fb_blank = NULL;
52795 + pax_close_kernel();
52796 + }
52797
52798 /*
52799 * Find out how much IO memory is required for the mode with
52800 @@ -1534,8 +1561,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
52801 info->flags = FBINFO_FLAG_DEFAULT |
52802 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
52803
52804 - if (!par->ypan)
52805 - info->fbops->fb_pan_display = NULL;
52806 + if (!par->ypan) {
52807 + pax_open_kernel();
52808 + *(void **)&info->fbops->fb_pan_display = NULL;
52809 + pax_close_kernel();
52810 + }
52811 }
52812
52813 static void uvesafb_init_mtrr(struct fb_info *info)
52814 @@ -1836,6 +1866,11 @@ out:
52815 if (par->vbe_modes)
52816 kfree(par->vbe_modes);
52817
52818 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52819 + if (par->pmi_code)
52820 + module_free_exec(NULL, par->pmi_code);
52821 +#endif
52822 +
52823 framebuffer_release(info);
52824 return err;
52825 }
52826 @@ -1862,6 +1897,12 @@ static int uvesafb_remove(struct platform_device *dev)
52827 kfree(par->vbe_state_orig);
52828 if (par->vbe_state_saved)
52829 kfree(par->vbe_state_saved);
52830 +
52831 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52832 + if (par->pmi_code)
52833 + module_free_exec(NULL, par->pmi_code);
52834 +#endif
52835 +
52836 }
52837
52838 framebuffer_release(info);
52839 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
52840 index 501b340..d80aa17 100644
52841 --- a/drivers/video/vesafb.c
52842 +++ b/drivers/video/vesafb.c
52843 @@ -9,6 +9,7 @@
52844 */
52845
52846 #include <linux/module.h>
52847 +#include <linux/moduleloader.h>
52848 #include <linux/kernel.h>
52849 #include <linux/errno.h>
52850 #include <linux/string.h>
52851 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
52852 static int vram_total __initdata; /* Set total amount of memory */
52853 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
52854 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
52855 -static void (*pmi_start)(void) __read_mostly;
52856 -static void (*pmi_pal) (void) __read_mostly;
52857 +static void (*pmi_start)(void) __read_only;
52858 +static void (*pmi_pal) (void) __read_only;
52859 static int depth __read_mostly;
52860 static int vga_compat __read_mostly;
52861 /* --------------------------------------------------------------------- */
52862 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
52863 unsigned int size_vmode;
52864 unsigned int size_remap;
52865 unsigned int size_total;
52866 + void *pmi_code = NULL;
52867
52868 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
52869 return -ENODEV;
52870 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
52871 size_remap = size_total;
52872 vesafb_fix.smem_len = size_remap;
52873
52874 -#ifndef __i386__
52875 - screen_info.vesapm_seg = 0;
52876 -#endif
52877 -
52878 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
52879 printk(KERN_WARNING
52880 "vesafb: cannot reserve video memory at 0x%lx\n",
52881 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
52882 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
52883 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
52884
52885 +#ifdef __i386__
52886 +
52887 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52888 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
52889 + if (!pmi_code)
52890 +#elif !defined(CONFIG_PAX_KERNEXEC)
52891 + if (0)
52892 +#endif
52893 +
52894 +#endif
52895 + screen_info.vesapm_seg = 0;
52896 +
52897 if (screen_info.vesapm_seg) {
52898 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
52899 - screen_info.vesapm_seg,screen_info.vesapm_off);
52900 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
52901 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
52902 }
52903
52904 if (screen_info.vesapm_seg < 0xc000)
52905 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
52906
52907 if (ypan || pmi_setpal) {
52908 unsigned short *pmi_base;
52909 +
52910 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
52911 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
52912 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
52913 +
52914 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52915 + pax_open_kernel();
52916 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
52917 +#else
52918 + pmi_code = pmi_base;
52919 +#endif
52920 +
52921 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
52922 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
52923 +
52924 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52925 + pmi_start = ktva_ktla(pmi_start);
52926 + pmi_pal = ktva_ktla(pmi_pal);
52927 + pax_close_kernel();
52928 +#endif
52929 +
52930 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
52931 if (pmi_base[3]) {
52932 printk(KERN_INFO "vesafb: pmi: ports = ");
52933 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
52934 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
52935 (ypan ? FBINFO_HWACCEL_YPAN : 0);
52936
52937 - if (!ypan)
52938 - info->fbops->fb_pan_display = NULL;
52939 + if (!ypan) {
52940 + pax_open_kernel();
52941 + *(void **)&info->fbops->fb_pan_display = NULL;
52942 + pax_close_kernel();
52943 + }
52944
52945 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
52946 err = -ENOMEM;
52947 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
52948 info->node, info->fix.id);
52949 return 0;
52950 err:
52951 +
52952 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52953 + module_free_exec(NULL, pmi_code);
52954 +#endif
52955 +
52956 if (info->screen_base)
52957 iounmap(info->screen_base);
52958 framebuffer_release(info);
52959 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
52960 index 88714ae..16c2e11 100644
52961 --- a/drivers/video/via/via_clock.h
52962 +++ b/drivers/video/via/via_clock.h
52963 @@ -56,7 +56,7 @@ struct via_clock {
52964
52965 void (*set_engine_pll_state)(u8 state);
52966 void (*set_engine_pll)(struct via_pll_config config);
52967 -};
52968 +} __no_const;
52969
52970
52971 static inline u32 get_pll_internal_frequency(u32 ref_freq,
52972 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
52973 index fef20db..d28b1ab 100644
52974 --- a/drivers/xen/xenfs/xenstored.c
52975 +++ b/drivers/xen/xenfs/xenstored.c
52976 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
52977 static int xsd_kva_open(struct inode *inode, struct file *file)
52978 {
52979 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
52980 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52981 + NULL);
52982 +#else
52983 xen_store_interface);
52984 +#endif
52985 +
52986 if (!file->private_data)
52987 return -ENOMEM;
52988 return 0;
52989 diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
52990 index 055562c..fdfb10d 100644
52991 --- a/fs/9p/vfs_addr.c
52992 +++ b/fs/9p/vfs_addr.c
52993 @@ -186,7 +186,7 @@ static int v9fs_vfs_writepage_locked(struct page *page)
52994
52995 retval = v9fs_file_write_internal(inode,
52996 v9inode->writeback_fid,
52997 - (__force const char __user *)buffer,
52998 + (const char __force_user *)buffer,
52999 len, &offset, 0);
53000 if (retval > 0)
53001 retval = 0;
53002 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
53003 index d86edc8..40ff2fb 100644
53004 --- a/fs/9p/vfs_inode.c
53005 +++ b/fs/9p/vfs_inode.c
53006 @@ -1314,7 +1314,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
53007 void
53008 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
53009 {
53010 - char *s = nd_get_link(nd);
53011 + const char *s = nd_get_link(nd);
53012
53013 p9_debug(P9_DEBUG_VFS, " %s %s\n",
53014 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
53015 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
53016 index 370b24c..ff0be7b 100644
53017 --- a/fs/Kconfig.binfmt
53018 +++ b/fs/Kconfig.binfmt
53019 @@ -103,7 +103,7 @@ config HAVE_AOUT
53020
53021 config BINFMT_AOUT
53022 tristate "Kernel support for a.out and ECOFF binaries"
53023 - depends on HAVE_AOUT
53024 + depends on HAVE_AOUT && BROKEN
53025 ---help---
53026 A.out (Assembler.OUTput) is a set of formats for libraries and
53027 executables used in the earliest versions of UNIX. Linux used
53028 diff --git a/fs/afs/inode.c b/fs/afs/inode.c
53029 index 789bc25..fafaeea 100644
53030 --- a/fs/afs/inode.c
53031 +++ b/fs/afs/inode.c
53032 @@ -141,7 +141,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
53033 struct afs_vnode *vnode;
53034 struct super_block *sb;
53035 struct inode *inode;
53036 - static atomic_t afs_autocell_ino;
53037 + static atomic_unchecked_t afs_autocell_ino;
53038
53039 _enter("{%x:%u},%*.*s,",
53040 AFS_FS_I(dir)->fid.vid, AFS_FS_I(dir)->fid.vnode,
53041 @@ -154,7 +154,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
53042 data.fid.unique = 0;
53043 data.fid.vnode = 0;
53044
53045 - inode = iget5_locked(sb, atomic_inc_return(&afs_autocell_ino),
53046 + inode = iget5_locked(sb, atomic_inc_return_unchecked(&afs_autocell_ino),
53047 afs_iget5_autocell_test, afs_iget5_set,
53048 &data);
53049 if (!inode) {
53050 diff --git a/fs/aio.c b/fs/aio.c
53051 index 2bbcacf..8614116 100644
53052 --- a/fs/aio.c
53053 +++ b/fs/aio.c
53054 @@ -160,7 +160,7 @@ static int aio_setup_ring(struct kioctx *ctx)
53055 size += sizeof(struct io_event) * nr_events;
53056 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
53057
53058 - if (nr_pages < 0)
53059 + if (nr_pages <= 0)
53060 return -EINVAL;
53061
53062 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
53063 @@ -950,6 +950,7 @@ static ssize_t aio_rw_vect_retry(struct kiocb *iocb, int rw, aio_rw_op *rw_op)
53064 static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
53065 {
53066 ssize_t ret;
53067 + struct iovec iovstack;
53068
53069 kiocb->ki_nr_segs = kiocb->ki_nbytes;
53070
53071 @@ -957,17 +958,22 @@ static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
53072 if (compat)
53073 ret = compat_rw_copy_check_uvector(rw,
53074 (struct compat_iovec __user *)kiocb->ki_buf,
53075 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
53076 + kiocb->ki_nr_segs, 1, &iovstack,
53077 &kiocb->ki_iovec);
53078 else
53079 #endif
53080 ret = rw_copy_check_uvector(rw,
53081 (struct iovec __user *)kiocb->ki_buf,
53082 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
53083 + kiocb->ki_nr_segs, 1, &iovstack,
53084 &kiocb->ki_iovec);
53085 if (ret < 0)
53086 return ret;
53087
53088 + if (kiocb->ki_iovec == &iovstack) {
53089 + kiocb->ki_inline_vec = iovstack;
53090 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
53091 + }
53092 +
53093 /* ki_nbytes now reflect bytes instead of segs */
53094 kiocb->ki_nbytes = ret;
53095 return 0;
53096 diff --git a/fs/attr.c b/fs/attr.c
53097 index 1449adb..a2038c2 100644
53098 --- a/fs/attr.c
53099 +++ b/fs/attr.c
53100 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
53101 unsigned long limit;
53102
53103 limit = rlimit(RLIMIT_FSIZE);
53104 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
53105 if (limit != RLIM_INFINITY && offset > limit)
53106 goto out_sig;
53107 if (offset > inode->i_sb->s_maxbytes)
53108 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
53109 index 3db70da..7aeec5b 100644
53110 --- a/fs/autofs4/waitq.c
53111 +++ b/fs/autofs4/waitq.c
53112 @@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
53113 {
53114 unsigned long sigpipe, flags;
53115 mm_segment_t fs;
53116 - const char *data = (const char *)addr;
53117 + const char __user *data = (const char __force_user *)addr;
53118 ssize_t wr = 0;
53119
53120 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
53121 @@ -346,6 +346,10 @@ static int validate_request(struct autofs_wait_queue **wait,
53122 return 1;
53123 }
53124
53125 +#ifdef CONFIG_GRKERNSEC_HIDESYM
53126 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
53127 +#endif
53128 +
53129 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
53130 enum autofs_notify notify)
53131 {
53132 @@ -379,7 +383,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
53133
53134 /* If this is a direct mount request create a dummy name */
53135 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
53136 +#ifdef CONFIG_GRKERNSEC_HIDESYM
53137 + /* this name does get written to userland via autofs4_write() */
53138 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
53139 +#else
53140 qstr.len = sprintf(name, "%p", dentry);
53141 +#endif
53142 else {
53143 qstr.len = autofs4_getpath(sbi, dentry, &name);
53144 if (!qstr.len) {
53145 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
53146 index 2722387..c8dd2a7 100644
53147 --- a/fs/befs/endian.h
53148 +++ b/fs/befs/endian.h
53149 @@ -11,7 +11,7 @@
53150
53151 #include <asm/byteorder.h>
53152
53153 -static inline u64
53154 +static inline u64 __intentional_overflow(-1)
53155 fs64_to_cpu(const struct super_block *sb, fs64 n)
53156 {
53157 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
53158 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
53159 return (__force fs64)cpu_to_be64(n);
53160 }
53161
53162 -static inline u32
53163 +static inline u32 __intentional_overflow(-1)
53164 fs32_to_cpu(const struct super_block *sb, fs32 n)
53165 {
53166 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
53167 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
53168 index f95dddc..b1e2c1c 100644
53169 --- a/fs/befs/linuxvfs.c
53170 +++ b/fs/befs/linuxvfs.c
53171 @@ -510,7 +510,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
53172 {
53173 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
53174 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
53175 - char *link = nd_get_link(nd);
53176 + const char *link = nd_get_link(nd);
53177 if (!IS_ERR(link))
53178 kfree(link);
53179 }
53180 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
53181 index bce8769..7fc7544 100644
53182 --- a/fs/binfmt_aout.c
53183 +++ b/fs/binfmt_aout.c
53184 @@ -16,6 +16,7 @@
53185 #include <linux/string.h>
53186 #include <linux/fs.h>
53187 #include <linux/file.h>
53188 +#include <linux/security.h>
53189 #include <linux/stat.h>
53190 #include <linux/fcntl.h>
53191 #include <linux/ptrace.h>
53192 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
53193 #endif
53194 # define START_STACK(u) ((void __user *)u.start_stack)
53195
53196 + memset(&dump, 0, sizeof(dump));
53197 +
53198 fs = get_fs();
53199 set_fs(KERNEL_DS);
53200 has_dumped = 1;
53201 @@ -69,10 +72,12 @@ static int aout_core_dump(struct coredump_params *cprm)
53202
53203 /* If the size of the dump file exceeds the rlimit, then see what would happen
53204 if we wrote the stack, but not the data area. */
53205 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
53206 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
53207 dump.u_dsize = 0;
53208
53209 /* Make sure we have enough room to write the stack and data areas. */
53210 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
53211 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
53212 dump.u_ssize = 0;
53213
53214 @@ -233,6 +238,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
53215 rlim = rlimit(RLIMIT_DATA);
53216 if (rlim >= RLIM_INFINITY)
53217 rlim = ~0;
53218 +
53219 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
53220 if (ex.a_data + ex.a_bss > rlim)
53221 return -ENOMEM;
53222
53223 @@ -267,6 +274,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
53224
53225 install_exec_creds(bprm);
53226
53227 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
53228 + current->mm->pax_flags = 0UL;
53229 +#endif
53230 +
53231 +#ifdef CONFIG_PAX_PAGEEXEC
53232 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
53233 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
53234 +
53235 +#ifdef CONFIG_PAX_EMUTRAMP
53236 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
53237 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
53238 +#endif
53239 +
53240 +#ifdef CONFIG_PAX_MPROTECT
53241 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
53242 + current->mm->pax_flags |= MF_PAX_MPROTECT;
53243 +#endif
53244 +
53245 + }
53246 +#endif
53247 +
53248 if (N_MAGIC(ex) == OMAGIC) {
53249 unsigned long text_addr, map_size;
53250 loff_t pos;
53251 @@ -324,7 +352,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
53252 }
53253
53254 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
53255 - PROT_READ | PROT_WRITE | PROT_EXEC,
53256 + PROT_READ | PROT_WRITE,
53257 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
53258 fd_offset + ex.a_text);
53259 if (error != N_DATADDR(ex)) {
53260 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
53261 index f8a0b0e..6f036ed 100644
53262 --- a/fs/binfmt_elf.c
53263 +++ b/fs/binfmt_elf.c
53264 @@ -34,6 +34,7 @@
53265 #include <linux/utsname.h>
53266 #include <linux/coredump.h>
53267 #include <linux/sched.h>
53268 +#include <linux/xattr.h>
53269 #include <asm/uaccess.h>
53270 #include <asm/param.h>
53271 #include <asm/page.h>
53272 @@ -60,6 +61,14 @@ static int elf_core_dump(struct coredump_params *cprm);
53273 #define elf_core_dump NULL
53274 #endif
53275
53276 +#ifdef CONFIG_PAX_MPROTECT
53277 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
53278 +#endif
53279 +
53280 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
53281 +static void elf_handle_mmap(struct file *file);
53282 +#endif
53283 +
53284 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
53285 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
53286 #else
53287 @@ -79,6 +88,15 @@ static struct linux_binfmt elf_format = {
53288 .load_binary = load_elf_binary,
53289 .load_shlib = load_elf_library,
53290 .core_dump = elf_core_dump,
53291 +
53292 +#ifdef CONFIG_PAX_MPROTECT
53293 + .handle_mprotect= elf_handle_mprotect,
53294 +#endif
53295 +
53296 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
53297 + .handle_mmap = elf_handle_mmap,
53298 +#endif
53299 +
53300 .min_coredump = ELF_EXEC_PAGESIZE,
53301 };
53302
53303 @@ -86,6 +104,8 @@ static struct linux_binfmt elf_format = {
53304
53305 static int set_brk(unsigned long start, unsigned long end)
53306 {
53307 + unsigned long e = end;
53308 +
53309 start = ELF_PAGEALIGN(start);
53310 end = ELF_PAGEALIGN(end);
53311 if (end > start) {
53312 @@ -94,7 +114,7 @@ static int set_brk(unsigned long start, unsigned long end)
53313 if (BAD_ADDR(addr))
53314 return addr;
53315 }
53316 - current->mm->start_brk = current->mm->brk = end;
53317 + current->mm->start_brk = current->mm->brk = e;
53318 return 0;
53319 }
53320
53321 @@ -155,12 +175,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
53322 elf_addr_t __user *u_rand_bytes;
53323 const char *k_platform = ELF_PLATFORM;
53324 const char *k_base_platform = ELF_BASE_PLATFORM;
53325 - unsigned char k_rand_bytes[16];
53326 + u32 k_rand_bytes[4];
53327 int items;
53328 elf_addr_t *elf_info;
53329 int ei_index = 0;
53330 const struct cred *cred = current_cred();
53331 struct vm_area_struct *vma;
53332 + unsigned long saved_auxv[AT_VECTOR_SIZE];
53333
53334 /*
53335 * In some cases (e.g. Hyper-Threading), we want to avoid L1
53336 @@ -202,8 +223,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
53337 * Generate 16 random bytes for userspace PRNG seeding.
53338 */
53339 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
53340 - u_rand_bytes = (elf_addr_t __user *)
53341 - STACK_ALLOC(p, sizeof(k_rand_bytes));
53342 + prandom_seed(k_rand_bytes[0] ^ prandom_u32());
53343 + prandom_seed(k_rand_bytes[1] ^ prandom_u32());
53344 + prandom_seed(k_rand_bytes[2] ^ prandom_u32());
53345 + prandom_seed(k_rand_bytes[3] ^ prandom_u32());
53346 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
53347 + u_rand_bytes = (elf_addr_t __user *) p;
53348 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
53349 return -EFAULT;
53350
53351 @@ -318,9 +343,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
53352 return -EFAULT;
53353 current->mm->env_end = p;
53354
53355 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
53356 +
53357 /* Put the elf_info on the stack in the right place. */
53358 sp = (elf_addr_t __user *)envp + 1;
53359 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
53360 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
53361 return -EFAULT;
53362 return 0;
53363 }
53364 @@ -388,15 +415,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
53365 an ELF header */
53366
53367 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
53368 - struct file *interpreter, unsigned long *interp_map_addr,
53369 - unsigned long no_base)
53370 + struct file *interpreter, unsigned long no_base)
53371 {
53372 struct elf_phdr *elf_phdata;
53373 struct elf_phdr *eppnt;
53374 - unsigned long load_addr = 0;
53375 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
53376 int load_addr_set = 0;
53377 unsigned long last_bss = 0, elf_bss = 0;
53378 - unsigned long error = ~0UL;
53379 + unsigned long error = -EINVAL;
53380 unsigned long total_size;
53381 int retval, i, size;
53382
53383 @@ -442,6 +468,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
53384 goto out_close;
53385 }
53386
53387 +#ifdef CONFIG_PAX_SEGMEXEC
53388 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
53389 + pax_task_size = SEGMEXEC_TASK_SIZE;
53390 +#endif
53391 +
53392 eppnt = elf_phdata;
53393 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
53394 if (eppnt->p_type == PT_LOAD) {
53395 @@ -465,8 +496,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
53396 map_addr = elf_map(interpreter, load_addr + vaddr,
53397 eppnt, elf_prot, elf_type, total_size);
53398 total_size = 0;
53399 - if (!*interp_map_addr)
53400 - *interp_map_addr = map_addr;
53401 error = map_addr;
53402 if (BAD_ADDR(map_addr))
53403 goto out_close;
53404 @@ -485,8 +514,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
53405 k = load_addr + eppnt->p_vaddr;
53406 if (BAD_ADDR(k) ||
53407 eppnt->p_filesz > eppnt->p_memsz ||
53408 - eppnt->p_memsz > TASK_SIZE ||
53409 - TASK_SIZE - eppnt->p_memsz < k) {
53410 + eppnt->p_memsz > pax_task_size ||
53411 + pax_task_size - eppnt->p_memsz < k) {
53412 error = -ENOMEM;
53413 goto out_close;
53414 }
53415 @@ -538,6 +567,315 @@ out:
53416 return error;
53417 }
53418
53419 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
53420 +#ifdef CONFIG_PAX_SOFTMODE
53421 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
53422 +{
53423 + unsigned long pax_flags = 0UL;
53424 +
53425 +#ifdef CONFIG_PAX_PAGEEXEC
53426 + if (elf_phdata->p_flags & PF_PAGEEXEC)
53427 + pax_flags |= MF_PAX_PAGEEXEC;
53428 +#endif
53429 +
53430 +#ifdef CONFIG_PAX_SEGMEXEC
53431 + if (elf_phdata->p_flags & PF_SEGMEXEC)
53432 + pax_flags |= MF_PAX_SEGMEXEC;
53433 +#endif
53434 +
53435 +#ifdef CONFIG_PAX_EMUTRAMP
53436 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
53437 + pax_flags |= MF_PAX_EMUTRAMP;
53438 +#endif
53439 +
53440 +#ifdef CONFIG_PAX_MPROTECT
53441 + if (elf_phdata->p_flags & PF_MPROTECT)
53442 + pax_flags |= MF_PAX_MPROTECT;
53443 +#endif
53444 +
53445 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
53446 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
53447 + pax_flags |= MF_PAX_RANDMMAP;
53448 +#endif
53449 +
53450 + return pax_flags;
53451 +}
53452 +#endif
53453 +
53454 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
53455 +{
53456 + unsigned long pax_flags = 0UL;
53457 +
53458 +#ifdef CONFIG_PAX_PAGEEXEC
53459 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
53460 + pax_flags |= MF_PAX_PAGEEXEC;
53461 +#endif
53462 +
53463 +#ifdef CONFIG_PAX_SEGMEXEC
53464 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
53465 + pax_flags |= MF_PAX_SEGMEXEC;
53466 +#endif
53467 +
53468 +#ifdef CONFIG_PAX_EMUTRAMP
53469 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
53470 + pax_flags |= MF_PAX_EMUTRAMP;
53471 +#endif
53472 +
53473 +#ifdef CONFIG_PAX_MPROTECT
53474 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
53475 + pax_flags |= MF_PAX_MPROTECT;
53476 +#endif
53477 +
53478 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
53479 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
53480 + pax_flags |= MF_PAX_RANDMMAP;
53481 +#endif
53482 +
53483 + return pax_flags;
53484 +}
53485 +#endif
53486 +
53487 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
53488 +#ifdef CONFIG_PAX_SOFTMODE
53489 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
53490 +{
53491 + unsigned long pax_flags = 0UL;
53492 +
53493 +#ifdef CONFIG_PAX_PAGEEXEC
53494 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
53495 + pax_flags |= MF_PAX_PAGEEXEC;
53496 +#endif
53497 +
53498 +#ifdef CONFIG_PAX_SEGMEXEC
53499 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
53500 + pax_flags |= MF_PAX_SEGMEXEC;
53501 +#endif
53502 +
53503 +#ifdef CONFIG_PAX_EMUTRAMP
53504 + if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
53505 + pax_flags |= MF_PAX_EMUTRAMP;
53506 +#endif
53507 +
53508 +#ifdef CONFIG_PAX_MPROTECT
53509 + if (pax_flags_softmode & MF_PAX_MPROTECT)
53510 + pax_flags |= MF_PAX_MPROTECT;
53511 +#endif
53512 +
53513 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
53514 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
53515 + pax_flags |= MF_PAX_RANDMMAP;
53516 +#endif
53517 +
53518 + return pax_flags;
53519 +}
53520 +#endif
53521 +
53522 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
53523 +{
53524 + unsigned long pax_flags = 0UL;
53525 +
53526 +#ifdef CONFIG_PAX_PAGEEXEC
53527 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
53528 + pax_flags |= MF_PAX_PAGEEXEC;
53529 +#endif
53530 +
53531 +#ifdef CONFIG_PAX_SEGMEXEC
53532 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
53533 + pax_flags |= MF_PAX_SEGMEXEC;
53534 +#endif
53535 +
53536 +#ifdef CONFIG_PAX_EMUTRAMP
53537 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
53538 + pax_flags |= MF_PAX_EMUTRAMP;
53539 +#endif
53540 +
53541 +#ifdef CONFIG_PAX_MPROTECT
53542 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
53543 + pax_flags |= MF_PAX_MPROTECT;
53544 +#endif
53545 +
53546 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
53547 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
53548 + pax_flags |= MF_PAX_RANDMMAP;
53549 +#endif
53550 +
53551 + return pax_flags;
53552 +}
53553 +#endif
53554 +
53555 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
53556 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
53557 +{
53558 + unsigned long pax_flags = 0UL;
53559 +
53560 +#ifdef CONFIG_PAX_EI_PAX
53561 +
53562 +#ifdef CONFIG_PAX_PAGEEXEC
53563 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
53564 + pax_flags |= MF_PAX_PAGEEXEC;
53565 +#endif
53566 +
53567 +#ifdef CONFIG_PAX_SEGMEXEC
53568 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
53569 + pax_flags |= MF_PAX_SEGMEXEC;
53570 +#endif
53571 +
53572 +#ifdef CONFIG_PAX_EMUTRAMP
53573 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
53574 + pax_flags |= MF_PAX_EMUTRAMP;
53575 +#endif
53576 +
53577 +#ifdef CONFIG_PAX_MPROTECT
53578 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
53579 + pax_flags |= MF_PAX_MPROTECT;
53580 +#endif
53581 +
53582 +#ifdef CONFIG_PAX_ASLR
53583 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
53584 + pax_flags |= MF_PAX_RANDMMAP;
53585 +#endif
53586 +
53587 +#else
53588 +
53589 +#ifdef CONFIG_PAX_PAGEEXEC
53590 + pax_flags |= MF_PAX_PAGEEXEC;
53591 +#endif
53592 +
53593 +#ifdef CONFIG_PAX_SEGMEXEC
53594 + pax_flags |= MF_PAX_SEGMEXEC;
53595 +#endif
53596 +
53597 +#ifdef CONFIG_PAX_MPROTECT
53598 + pax_flags |= MF_PAX_MPROTECT;
53599 +#endif
53600 +
53601 +#ifdef CONFIG_PAX_RANDMMAP
53602 + if (randomize_va_space)
53603 + pax_flags |= MF_PAX_RANDMMAP;
53604 +#endif
53605 +
53606 +#endif
53607 +
53608 + return pax_flags;
53609 +}
53610 +
53611 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
53612 +{
53613 +
53614 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
53615 + unsigned long i;
53616 +
53617 + for (i = 0UL; i < elf_ex->e_phnum; i++)
53618 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
53619 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
53620 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
53621 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
53622 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
53623 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
53624 + return ~0UL;
53625 +
53626 +#ifdef CONFIG_PAX_SOFTMODE
53627 + if (pax_softmode)
53628 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
53629 + else
53630 +#endif
53631 +
53632 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
53633 + break;
53634 + }
53635 +#endif
53636 +
53637 + return ~0UL;
53638 +}
53639 +
53640 +static unsigned long pax_parse_xattr_pax(struct file * const file)
53641 +{
53642 +
53643 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
53644 + ssize_t xattr_size, i;
53645 + unsigned char xattr_value[sizeof("pemrs") - 1];
53646 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
53647 +
53648 + xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
53649 + if (xattr_size <= 0 || xattr_size > sizeof xattr_value)
53650 + return ~0UL;
53651 +
53652 + for (i = 0; i < xattr_size; i++)
53653 + switch (xattr_value[i]) {
53654 + default:
53655 + return ~0UL;
53656 +
53657 +#define parse_flag(option1, option2, flag) \
53658 + case option1: \
53659 + if (pax_flags_hardmode & MF_PAX_##flag) \
53660 + return ~0UL; \
53661 + pax_flags_hardmode |= MF_PAX_##flag; \
53662 + break; \
53663 + case option2: \
53664 + if (pax_flags_softmode & MF_PAX_##flag) \
53665 + return ~0UL; \
53666 + pax_flags_softmode |= MF_PAX_##flag; \
53667 + break;
53668 +
53669 + parse_flag('p', 'P', PAGEEXEC);
53670 + parse_flag('e', 'E', EMUTRAMP);
53671 + parse_flag('m', 'M', MPROTECT);
53672 + parse_flag('r', 'R', RANDMMAP);
53673 + parse_flag('s', 'S', SEGMEXEC);
53674 +
53675 +#undef parse_flag
53676 + }
53677 +
53678 + if (pax_flags_hardmode & pax_flags_softmode)
53679 + return ~0UL;
53680 +
53681 +#ifdef CONFIG_PAX_SOFTMODE
53682 + if (pax_softmode)
53683 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
53684 + else
53685 +#endif
53686 +
53687 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
53688 +#else
53689 + return ~0UL;
53690 +#endif
53691 +
53692 +}
53693 +
53694 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
53695 +{
53696 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
53697 +
53698 + pax_flags = pax_parse_ei_pax(elf_ex);
53699 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
53700 + xattr_pax_flags = pax_parse_xattr_pax(file);
53701 +
53702 + if (pt_pax_flags == ~0UL)
53703 + pt_pax_flags = xattr_pax_flags;
53704 + else if (xattr_pax_flags == ~0UL)
53705 + xattr_pax_flags = pt_pax_flags;
53706 + if (pt_pax_flags != xattr_pax_flags)
53707 + return -EINVAL;
53708 + if (pt_pax_flags != ~0UL)
53709 + pax_flags = pt_pax_flags;
53710 +
53711 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
53712 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
53713 + if ((__supported_pte_mask & _PAGE_NX))
53714 + pax_flags &= ~MF_PAX_SEGMEXEC;
53715 + else
53716 + pax_flags &= ~MF_PAX_PAGEEXEC;
53717 + }
53718 +#endif
53719 +
53720 + if (0 > pax_check_flags(&pax_flags))
53721 + return -EINVAL;
53722 +
53723 + current->mm->pax_flags = pax_flags;
53724 + return 0;
53725 +}
53726 +#endif
53727 +
53728 /*
53729 * These are the functions used to load ELF style executables and shared
53730 * libraries. There is no binary dependent code anywhere else.
53731 @@ -554,6 +892,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
53732 {
53733 unsigned int random_variable = 0;
53734
53735 +#ifdef CONFIG_PAX_RANDUSTACK
53736 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
53737 + return stack_top - current->mm->delta_stack;
53738 +#endif
53739 +
53740 if ((current->flags & PF_RANDOMIZE) &&
53741 !(current->personality & ADDR_NO_RANDOMIZE)) {
53742 random_variable = get_random_int() & STACK_RND_MASK;
53743 @@ -572,7 +915,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
53744 unsigned long load_addr = 0, load_bias = 0;
53745 int load_addr_set = 0;
53746 char * elf_interpreter = NULL;
53747 - unsigned long error;
53748 + unsigned long error = 0;
53749 struct elf_phdr *elf_ppnt, *elf_phdata;
53750 unsigned long elf_bss, elf_brk;
53751 int retval, i;
53752 @@ -582,12 +925,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
53753 unsigned long start_code, end_code, start_data, end_data;
53754 unsigned long reloc_func_desc __maybe_unused = 0;
53755 int executable_stack = EXSTACK_DEFAULT;
53756 - unsigned long def_flags = 0;
53757 struct pt_regs *regs = current_pt_regs();
53758 struct {
53759 struct elfhdr elf_ex;
53760 struct elfhdr interp_elf_ex;
53761 } *loc;
53762 + unsigned long pax_task_size = TASK_SIZE;
53763
53764 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
53765 if (!loc) {
53766 @@ -723,11 +1066,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
53767 goto out_free_dentry;
53768
53769 /* OK, This is the point of no return */
53770 - current->mm->def_flags = def_flags;
53771 +
53772 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
53773 + current->mm->pax_flags = 0UL;
53774 +#endif
53775 +
53776 +#ifdef CONFIG_PAX_DLRESOLVE
53777 + current->mm->call_dl_resolve = 0UL;
53778 +#endif
53779 +
53780 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
53781 + current->mm->call_syscall = 0UL;
53782 +#endif
53783 +
53784 +#ifdef CONFIG_PAX_ASLR
53785 + current->mm->delta_mmap = 0UL;
53786 + current->mm->delta_stack = 0UL;
53787 +#endif
53788 +
53789 + current->mm->def_flags = 0;
53790 +
53791 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
53792 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
53793 + send_sig(SIGKILL, current, 0);
53794 + goto out_free_dentry;
53795 + }
53796 +#endif
53797 +
53798 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
53799 + pax_set_initial_flags(bprm);
53800 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
53801 + if (pax_set_initial_flags_func)
53802 + (pax_set_initial_flags_func)(bprm);
53803 +#endif
53804 +
53805 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
53806 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
53807 + current->mm->context.user_cs_limit = PAGE_SIZE;
53808 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
53809 + }
53810 +#endif
53811 +
53812 +#ifdef CONFIG_PAX_SEGMEXEC
53813 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
53814 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
53815 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
53816 + pax_task_size = SEGMEXEC_TASK_SIZE;
53817 + current->mm->def_flags |= VM_NOHUGEPAGE;
53818 + }
53819 +#endif
53820 +
53821 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
53822 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
53823 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
53824 + put_cpu();
53825 + }
53826 +#endif
53827
53828 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
53829 may depend on the personality. */
53830 SET_PERSONALITY(loc->elf_ex);
53831 +
53832 +#ifdef CONFIG_PAX_ASLR
53833 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
53834 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
53835 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
53836 + }
53837 +#endif
53838 +
53839 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
53840 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
53841 + executable_stack = EXSTACK_DISABLE_X;
53842 + current->personality &= ~READ_IMPLIES_EXEC;
53843 + } else
53844 +#endif
53845 +
53846 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
53847 current->personality |= READ_IMPLIES_EXEC;
53848
53849 @@ -819,6 +1232,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
53850 #else
53851 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
53852 #endif
53853 +
53854 +#ifdef CONFIG_PAX_RANDMMAP
53855 + /* PaX: randomize base address at the default exe base if requested */
53856 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
53857 +#ifdef CONFIG_SPARC64
53858 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
53859 +#else
53860 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
53861 +#endif
53862 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
53863 + elf_flags |= MAP_FIXED;
53864 + }
53865 +#endif
53866 +
53867 }
53868
53869 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
53870 @@ -851,9 +1278,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
53871 * allowed task size. Note that p_filesz must always be
53872 * <= p_memsz so it is only necessary to check p_memsz.
53873 */
53874 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
53875 - elf_ppnt->p_memsz > TASK_SIZE ||
53876 - TASK_SIZE - elf_ppnt->p_memsz < k) {
53877 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
53878 + elf_ppnt->p_memsz > pax_task_size ||
53879 + pax_task_size - elf_ppnt->p_memsz < k) {
53880 /* set_brk can never work. Avoid overflows. */
53881 send_sig(SIGKILL, current, 0);
53882 retval = -EINVAL;
53883 @@ -892,17 +1319,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
53884 goto out_free_dentry;
53885 }
53886 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
53887 - send_sig(SIGSEGV, current, 0);
53888 - retval = -EFAULT; /* Nobody gets to see this, but.. */
53889 - goto out_free_dentry;
53890 + /*
53891 + * This bss-zeroing can fail if the ELF
53892 + * file specifies odd protections. So
53893 + * we don't check the return value
53894 + */
53895 }
53896
53897 +#ifdef CONFIG_PAX_RANDMMAP
53898 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
53899 + unsigned long start, size, flags;
53900 + vm_flags_t vm_flags;
53901 +
53902 + start = ELF_PAGEALIGN(elf_brk);
53903 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
53904 + flags = MAP_FIXED | MAP_PRIVATE;
53905 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
53906 +
53907 + down_write(&current->mm->mmap_sem);
53908 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
53909 + retval = -ENOMEM;
53910 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
53911 +// if (current->personality & ADDR_NO_RANDOMIZE)
53912 +// vm_flags |= VM_READ | VM_MAYREAD;
53913 + start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
53914 + retval = IS_ERR_VALUE(start) ? start : 0;
53915 + }
53916 + up_write(&current->mm->mmap_sem);
53917 + if (retval == 0)
53918 + retval = set_brk(start + size, start + size + PAGE_SIZE);
53919 + if (retval < 0) {
53920 + send_sig(SIGKILL, current, 0);
53921 + goto out_free_dentry;
53922 + }
53923 + }
53924 +#endif
53925 +
53926 if (elf_interpreter) {
53927 - unsigned long interp_map_addr = 0;
53928 -
53929 elf_entry = load_elf_interp(&loc->interp_elf_ex,
53930 interpreter,
53931 - &interp_map_addr,
53932 load_bias);
53933 if (!IS_ERR((void *)elf_entry)) {
53934 /*
53935 @@ -1124,7 +1579,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
53936 * Decide what to dump of a segment, part, all or none.
53937 */
53938 static unsigned long vma_dump_size(struct vm_area_struct *vma,
53939 - unsigned long mm_flags)
53940 + unsigned long mm_flags, long signr)
53941 {
53942 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
53943
53944 @@ -1162,7 +1617,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
53945 if (vma->vm_file == NULL)
53946 return 0;
53947
53948 - if (FILTER(MAPPED_PRIVATE))
53949 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
53950 goto whole;
53951
53952 /*
53953 @@ -1387,9 +1842,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
53954 {
53955 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
53956 int i = 0;
53957 - do
53958 + do {
53959 i += 2;
53960 - while (auxv[i - 2] != AT_NULL);
53961 + } while (auxv[i - 2] != AT_NULL);
53962 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
53963 }
53964
53965 @@ -1398,7 +1853,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
53966 {
53967 mm_segment_t old_fs = get_fs();
53968 set_fs(KERNEL_DS);
53969 - copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
53970 + copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
53971 set_fs(old_fs);
53972 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
53973 }
53974 @@ -2019,14 +2474,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
53975 }
53976
53977 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
53978 - unsigned long mm_flags)
53979 + struct coredump_params *cprm)
53980 {
53981 struct vm_area_struct *vma;
53982 size_t size = 0;
53983
53984 for (vma = first_vma(current, gate_vma); vma != NULL;
53985 vma = next_vma(vma, gate_vma))
53986 - size += vma_dump_size(vma, mm_flags);
53987 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53988 return size;
53989 }
53990
53991 @@ -2119,7 +2574,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53992
53993 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
53994
53995 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
53996 + offset += elf_core_vma_data_size(gate_vma, cprm);
53997 offset += elf_core_extra_data_size();
53998 e_shoff = offset;
53999
54000 @@ -2133,10 +2588,12 @@ static int elf_core_dump(struct coredump_params *cprm)
54001 offset = dataoff;
54002
54003 size += sizeof(*elf);
54004 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
54005 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
54006 goto end_coredump;
54007
54008 size += sizeof(*phdr4note);
54009 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
54010 if (size > cprm->limit
54011 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
54012 goto end_coredump;
54013 @@ -2150,7 +2607,7 @@ static int elf_core_dump(struct coredump_params *cprm)
54014 phdr.p_offset = offset;
54015 phdr.p_vaddr = vma->vm_start;
54016 phdr.p_paddr = 0;
54017 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
54018 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
54019 phdr.p_memsz = vma->vm_end - vma->vm_start;
54020 offset += phdr.p_filesz;
54021 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
54022 @@ -2161,6 +2618,7 @@ static int elf_core_dump(struct coredump_params *cprm)
54023 phdr.p_align = ELF_EXEC_PAGESIZE;
54024
54025 size += sizeof(phdr);
54026 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
54027 if (size > cprm->limit
54028 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
54029 goto end_coredump;
54030 @@ -2185,7 +2643,7 @@ static int elf_core_dump(struct coredump_params *cprm)
54031 unsigned long addr;
54032 unsigned long end;
54033
54034 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
54035 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
54036
54037 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
54038 struct page *page;
54039 @@ -2194,6 +2652,7 @@ static int elf_core_dump(struct coredump_params *cprm)
54040 page = get_dump_page(addr);
54041 if (page) {
54042 void *kaddr = kmap(page);
54043 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
54044 stop = ((size += PAGE_SIZE) > cprm->limit) ||
54045 !dump_write(cprm->file, kaddr,
54046 PAGE_SIZE);
54047 @@ -2211,6 +2670,7 @@ static int elf_core_dump(struct coredump_params *cprm)
54048
54049 if (e_phnum == PN_XNUM) {
54050 size += sizeof(*shdr4extnum);
54051 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
54052 if (size > cprm->limit
54053 || !dump_write(cprm->file, shdr4extnum,
54054 sizeof(*shdr4extnum)))
54055 @@ -2231,6 +2691,167 @@ out:
54056
54057 #endif /* CONFIG_ELF_CORE */
54058
54059 +#ifdef CONFIG_PAX_MPROTECT
54060 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
54061 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
54062 + * we'll remove VM_MAYWRITE for good on RELRO segments.
54063 + *
54064 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
54065 + * basis because we want to allow the common case and not the special ones.
54066 + */
54067 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
54068 +{
54069 + struct elfhdr elf_h;
54070 + struct elf_phdr elf_p;
54071 + unsigned long i;
54072 + unsigned long oldflags;
54073 + bool is_textrel_rw, is_textrel_rx, is_relro;
54074 +
54075 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT) || !vma->vm_file)
54076 + return;
54077 +
54078 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
54079 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
54080 +
54081 +#ifdef CONFIG_PAX_ELFRELOCS
54082 + /* possible TEXTREL */
54083 + is_textrel_rw = !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
54084 + is_textrel_rx = vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_WRITE | VM_READ) && newflags == (VM_EXEC | VM_READ);
54085 +#else
54086 + is_textrel_rw = false;
54087 + is_textrel_rx = false;
54088 +#endif
54089 +
54090 + /* possible RELRO */
54091 + is_relro = vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
54092 +
54093 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
54094 + return;
54095 +
54096 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
54097 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
54098 +
54099 +#ifdef CONFIG_PAX_ETEXECRELOCS
54100 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
54101 +#else
54102 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
54103 +#endif
54104 +
54105 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
54106 + !elf_check_arch(&elf_h) ||
54107 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
54108 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
54109 + return;
54110 +
54111 + for (i = 0UL; i < elf_h.e_phnum; i++) {
54112 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
54113 + return;
54114 + switch (elf_p.p_type) {
54115 + case PT_DYNAMIC:
54116 + if (!is_textrel_rw && !is_textrel_rx)
54117 + continue;
54118 + i = 0UL;
54119 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
54120 + elf_dyn dyn;
54121 +
54122 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
54123 + break;
54124 + if (dyn.d_tag == DT_NULL)
54125 + break;
54126 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
54127 + gr_log_textrel(vma);
54128 + if (is_textrel_rw)
54129 + vma->vm_flags |= VM_MAYWRITE;
54130 + else
54131 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
54132 + vma->vm_flags &= ~VM_MAYWRITE;
54133 + break;
54134 + }
54135 + i++;
54136 + }
54137 + is_textrel_rw = false;
54138 + is_textrel_rx = false;
54139 + continue;
54140 +
54141 + case PT_GNU_RELRO:
54142 + if (!is_relro)
54143 + continue;
54144 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
54145 + vma->vm_flags &= ~VM_MAYWRITE;
54146 + is_relro = false;
54147 + continue;
54148 +
54149 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
54150 + case PT_PAX_FLAGS: {
54151 + const char *msg_mprotect = "", *msg_emutramp = "";
54152 + char *buffer_lib, *buffer_exe;
54153 +
54154 + if (elf_p.p_flags & PF_NOMPROTECT)
54155 + msg_mprotect = "MPROTECT disabled";
54156 +
54157 +#ifdef CONFIG_PAX_EMUTRAMP
54158 + if (!(vma->vm_mm->pax_flags & MF_PAX_EMUTRAMP) && !(elf_p.p_flags & PF_NOEMUTRAMP))
54159 + msg_emutramp = "EMUTRAMP enabled";
54160 +#endif
54161 +
54162 + if (!msg_mprotect[0] && !msg_emutramp[0])
54163 + continue;
54164 +
54165 + if (!printk_ratelimit())
54166 + continue;
54167 +
54168 + buffer_lib = (char *)__get_free_page(GFP_KERNEL);
54169 + buffer_exe = (char *)__get_free_page(GFP_KERNEL);
54170 + if (buffer_lib && buffer_exe) {
54171 + char *path_lib, *path_exe;
54172 +
54173 + path_lib = pax_get_path(&vma->vm_file->f_path, buffer_lib, PAGE_SIZE);
54174 + path_exe = pax_get_path(&vma->vm_mm->exe_file->f_path, buffer_exe, PAGE_SIZE);
54175 +
54176 + pr_info("PAX: %s wants %s%s%s on %s\n", path_lib, msg_mprotect,
54177 + (msg_mprotect[0] && msg_emutramp[0] ? " and " : ""), msg_emutramp, path_exe);
54178 +
54179 + }
54180 + free_page((unsigned long)buffer_exe);
54181 + free_page((unsigned long)buffer_lib);
54182 + continue;
54183 + }
54184 +#endif
54185 +
54186 + }
54187 + }
54188 +}
54189 +#endif
54190 +
54191 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
54192 +
54193 +extern int grsec_enable_log_rwxmaps;
54194 +
54195 +static void elf_handle_mmap(struct file *file)
54196 +{
54197 + struct elfhdr elf_h;
54198 + struct elf_phdr elf_p;
54199 + unsigned long i;
54200 +
54201 + if (!grsec_enable_log_rwxmaps)
54202 + return;
54203 +
54204 + if (sizeof(elf_h) != kernel_read(file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
54205 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
54206 + (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC) || !elf_check_arch(&elf_h) ||
54207 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
54208 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
54209 + return;
54210 +
54211 + for (i = 0UL; i < elf_h.e_phnum; i++) {
54212 + if (sizeof(elf_p) != kernel_read(file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
54213 + return;
54214 + if (elf_p.p_type == PT_GNU_STACK && (elf_p.p_flags & PF_X))
54215 + gr_log_ptgnustack(file);
54216 + }
54217 +}
54218 +#endif
54219 +
54220 static int __init init_elf_binfmt(void)
54221 {
54222 register_binfmt(&elf_format);
54223 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
54224 index d50bbe5..af3b649 100644
54225 --- a/fs/binfmt_flat.c
54226 +++ b/fs/binfmt_flat.c
54227 @@ -566,7 +566,9 @@ static int load_flat_file(struct linux_binprm * bprm,
54228 realdatastart = (unsigned long) -ENOMEM;
54229 printk("Unable to allocate RAM for process data, errno %d\n",
54230 (int)-realdatastart);
54231 + down_write(&current->mm->mmap_sem);
54232 vm_munmap(textpos, text_len);
54233 + up_write(&current->mm->mmap_sem);
54234 ret = realdatastart;
54235 goto err;
54236 }
54237 @@ -590,8 +592,10 @@ static int load_flat_file(struct linux_binprm * bprm,
54238 }
54239 if (IS_ERR_VALUE(result)) {
54240 printk("Unable to read data+bss, errno %d\n", (int)-result);
54241 + down_write(&current->mm->mmap_sem);
54242 vm_munmap(textpos, text_len);
54243 vm_munmap(realdatastart, len);
54244 + up_write(&current->mm->mmap_sem);
54245 ret = result;
54246 goto err;
54247 }
54248 @@ -653,8 +657,10 @@ static int load_flat_file(struct linux_binprm * bprm,
54249 }
54250 if (IS_ERR_VALUE(result)) {
54251 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
54252 + down_write(&current->mm->mmap_sem);
54253 vm_munmap(textpos, text_len + data_len + extra +
54254 MAX_SHARED_LIBS * sizeof(unsigned long));
54255 + up_write(&current->mm->mmap_sem);
54256 ret = result;
54257 goto err;
54258 }
54259 diff --git a/fs/bio.c b/fs/bio.c
54260 index c5eae72..599e3cf 100644
54261 --- a/fs/bio.c
54262 +++ b/fs/bio.c
54263 @@ -1106,7 +1106,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
54264 /*
54265 * Overflow, abort
54266 */
54267 - if (end < start)
54268 + if (end < start || end - start > INT_MAX - nr_pages)
54269 return ERR_PTR(-EINVAL);
54270
54271 nr_pages += end - start;
54272 @@ -1240,7 +1240,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
54273 /*
54274 * Overflow, abort
54275 */
54276 - if (end < start)
54277 + if (end < start || end - start > INT_MAX - nr_pages)
54278 return ERR_PTR(-EINVAL);
54279
54280 nr_pages += end - start;
54281 @@ -1502,7 +1502,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
54282 const int read = bio_data_dir(bio) == READ;
54283 struct bio_map_data *bmd = bio->bi_private;
54284 int i;
54285 - char *p = bmd->sgvecs[0].iov_base;
54286 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
54287
54288 bio_for_each_segment_all(bvec, bio, i) {
54289 char *addr = page_address(bvec->bv_page);
54290 diff --git a/fs/block_dev.c b/fs/block_dev.c
54291 index 85f5c85..d6f0b1a 100644
54292 --- a/fs/block_dev.c
54293 +++ b/fs/block_dev.c
54294 @@ -658,7 +658,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
54295 else if (bdev->bd_contains == bdev)
54296 return true; /* is a whole device which isn't held */
54297
54298 - else if (whole->bd_holder == bd_may_claim)
54299 + else if (whole->bd_holder == (void *)bd_may_claim)
54300 return true; /* is a partition of a device that is being partitioned */
54301 else if (whole->bd_holder != NULL)
54302 return false; /* is a partition of a held device */
54303 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
54304 index 7fb054b..ad36c67 100644
54305 --- a/fs/btrfs/ctree.c
54306 +++ b/fs/btrfs/ctree.c
54307 @@ -1076,9 +1076,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
54308 free_extent_buffer(buf);
54309 add_root_to_dirty_list(root);
54310 } else {
54311 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
54312 - parent_start = parent->start;
54313 - else
54314 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
54315 + if (parent)
54316 + parent_start = parent->start;
54317 + else
54318 + parent_start = 0;
54319 + } else
54320 parent_start = 0;
54321
54322 WARN_ON(trans->transid != btrfs_header_generation(parent));
54323 diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
54324 index f26f38c..3d0f149 100644
54325 --- a/fs/btrfs/delayed-inode.c
54326 +++ b/fs/btrfs/delayed-inode.c
54327 @@ -458,7 +458,7 @@ static int __btrfs_add_delayed_deletion_item(struct btrfs_delayed_node *node,
54328
54329 static void finish_one_item(struct btrfs_delayed_root *delayed_root)
54330 {
54331 - int seq = atomic_inc_return(&delayed_root->items_seq);
54332 + int seq = atomic_inc_return_unchecked(&delayed_root->items_seq);
54333 if ((atomic_dec_return(&delayed_root->items) <
54334 BTRFS_DELAYED_BACKGROUND || seq % BTRFS_DELAYED_BATCH == 0) &&
54335 waitqueue_active(&delayed_root->wait))
54336 @@ -1391,7 +1391,7 @@ void btrfs_assert_delayed_root_empty(struct btrfs_root *root)
54337 static int refs_newer(struct btrfs_delayed_root *delayed_root,
54338 int seq, int count)
54339 {
54340 - int val = atomic_read(&delayed_root->items_seq);
54341 + int val = atomic_read_unchecked(&delayed_root->items_seq);
54342
54343 if (val < seq || val >= seq + count)
54344 return 1;
54345 @@ -1408,7 +1408,7 @@ void btrfs_balance_delayed_items(struct btrfs_root *root)
54346 if (atomic_read(&delayed_root->items) < BTRFS_DELAYED_BACKGROUND)
54347 return;
54348
54349 - seq = atomic_read(&delayed_root->items_seq);
54350 + seq = atomic_read_unchecked(&delayed_root->items_seq);
54351
54352 if (atomic_read(&delayed_root->items) >= BTRFS_DELAYED_WRITEBACK) {
54353 int ret;
54354 diff --git a/fs/btrfs/delayed-inode.h b/fs/btrfs/delayed-inode.h
54355 index 1d5c5f7..0ba0afc 100644
54356 --- a/fs/btrfs/delayed-inode.h
54357 +++ b/fs/btrfs/delayed-inode.h
54358 @@ -43,7 +43,7 @@ struct btrfs_delayed_root {
54359 */
54360 struct list_head prepare_list;
54361 atomic_t items; /* for delayed items */
54362 - atomic_t items_seq; /* for delayed items */
54363 + atomic_unchecked_t items_seq; /* for delayed items */
54364 int nodes; /* for delayed nodes */
54365 wait_queue_head_t wait;
54366 };
54367 @@ -87,7 +87,7 @@ static inline void btrfs_init_delayed_root(
54368 struct btrfs_delayed_root *delayed_root)
54369 {
54370 atomic_set(&delayed_root->items, 0);
54371 - atomic_set(&delayed_root->items_seq, 0);
54372 + atomic_set_unchecked(&delayed_root->items_seq, 0);
54373 delayed_root->nodes = 0;
54374 spin_lock_init(&delayed_root->lock);
54375 init_waitqueue_head(&delayed_root->wait);
54376 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
54377 index 0f81d67..0ad55fe 100644
54378 --- a/fs/btrfs/ioctl.c
54379 +++ b/fs/btrfs/ioctl.c
54380 @@ -3084,9 +3084,12 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
54381 for (i = 0; i < num_types; i++) {
54382 struct btrfs_space_info *tmp;
54383
54384 + /* Don't copy in more than we allocated */
54385 if (!slot_count)
54386 break;
54387
54388 + slot_count--;
54389 +
54390 info = NULL;
54391 rcu_read_lock();
54392 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
54393 @@ -3108,10 +3111,7 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
54394 memcpy(dest, &space, sizeof(space));
54395 dest++;
54396 space_args.total_spaces++;
54397 - slot_count--;
54398 }
54399 - if (!slot_count)
54400 - break;
54401 }
54402 up_read(&info->groups_sem);
54403 }
54404 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
54405 index f0857e0..e7023c5 100644
54406 --- a/fs/btrfs/super.c
54407 +++ b/fs/btrfs/super.c
54408 @@ -265,7 +265,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
54409 function, line, errstr);
54410 return;
54411 }
54412 - ACCESS_ONCE(trans->transaction->aborted) = errno;
54413 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
54414 __btrfs_std_error(root->fs_info, function, line, errno, NULL);
54415 }
54416 /*
54417 diff --git a/fs/buffer.c b/fs/buffer.c
54418 index d2a4d1b..df798ca 100644
54419 --- a/fs/buffer.c
54420 +++ b/fs/buffer.c
54421 @@ -3367,7 +3367,7 @@ void __init buffer_init(void)
54422 bh_cachep = kmem_cache_create("buffer_head",
54423 sizeof(struct buffer_head), 0,
54424 (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|
54425 - SLAB_MEM_SPREAD),
54426 + SLAB_MEM_SPREAD|SLAB_NO_SANITIZE),
54427 NULL);
54428
54429 /*
54430 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
54431 index 622f469..e8d2d55 100644
54432 --- a/fs/cachefiles/bind.c
54433 +++ b/fs/cachefiles/bind.c
54434 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
54435 args);
54436
54437 /* start by checking things over */
54438 - ASSERT(cache->fstop_percent >= 0 &&
54439 - cache->fstop_percent < cache->fcull_percent &&
54440 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
54441 cache->fcull_percent < cache->frun_percent &&
54442 cache->frun_percent < 100);
54443
54444 - ASSERT(cache->bstop_percent >= 0 &&
54445 - cache->bstop_percent < cache->bcull_percent &&
54446 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
54447 cache->bcull_percent < cache->brun_percent &&
54448 cache->brun_percent < 100);
54449
54450 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
54451 index 0a1467b..6a53245 100644
54452 --- a/fs/cachefiles/daemon.c
54453 +++ b/fs/cachefiles/daemon.c
54454 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
54455 if (n > buflen)
54456 return -EMSGSIZE;
54457
54458 - if (copy_to_user(_buffer, buffer, n) != 0)
54459 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
54460 return -EFAULT;
54461
54462 return n;
54463 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
54464 if (test_bit(CACHEFILES_DEAD, &cache->flags))
54465 return -EIO;
54466
54467 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
54468 + if (datalen > PAGE_SIZE - 1)
54469 return -EOPNOTSUPP;
54470
54471 /* drag the command string into the kernel so we can parse it */
54472 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
54473 if (args[0] != '%' || args[1] != '\0')
54474 return -EINVAL;
54475
54476 - if (fstop < 0 || fstop >= cache->fcull_percent)
54477 + if (fstop >= cache->fcull_percent)
54478 return cachefiles_daemon_range_error(cache, args);
54479
54480 cache->fstop_percent = fstop;
54481 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
54482 if (args[0] != '%' || args[1] != '\0')
54483 return -EINVAL;
54484
54485 - if (bstop < 0 || bstop >= cache->bcull_percent)
54486 + if (bstop >= cache->bcull_percent)
54487 return cachefiles_daemon_range_error(cache, args);
54488
54489 cache->bstop_percent = bstop;
54490 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
54491 index 4938251..7e01445 100644
54492 --- a/fs/cachefiles/internal.h
54493 +++ b/fs/cachefiles/internal.h
54494 @@ -59,7 +59,7 @@ struct cachefiles_cache {
54495 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
54496 struct rb_root active_nodes; /* active nodes (can't be culled) */
54497 rwlock_t active_lock; /* lock for active_nodes */
54498 - atomic_t gravecounter; /* graveyard uniquifier */
54499 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
54500 unsigned frun_percent; /* when to stop culling (% files) */
54501 unsigned fcull_percent; /* when to start culling (% files) */
54502 unsigned fstop_percent; /* when to stop allocating (% files) */
54503 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
54504 * proc.c
54505 */
54506 #ifdef CONFIG_CACHEFILES_HISTOGRAM
54507 -extern atomic_t cachefiles_lookup_histogram[HZ];
54508 -extern atomic_t cachefiles_mkdir_histogram[HZ];
54509 -extern atomic_t cachefiles_create_histogram[HZ];
54510 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
54511 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
54512 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
54513
54514 extern int __init cachefiles_proc_init(void);
54515 extern void cachefiles_proc_cleanup(void);
54516 static inline
54517 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
54518 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
54519 {
54520 unsigned long jif = jiffies - start_jif;
54521 if (jif >= HZ)
54522 jif = HZ - 1;
54523 - atomic_inc(&histogram[jif]);
54524 + atomic_inc_unchecked(&histogram[jif]);
54525 }
54526
54527 #else
54528 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
54529 index 8c01c5fc..15f982e 100644
54530 --- a/fs/cachefiles/namei.c
54531 +++ b/fs/cachefiles/namei.c
54532 @@ -317,7 +317,7 @@ try_again:
54533 /* first step is to make up a grave dentry in the graveyard */
54534 sprintf(nbuffer, "%08x%08x",
54535 (uint32_t) get_seconds(),
54536 - (uint32_t) atomic_inc_return(&cache->gravecounter));
54537 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
54538
54539 /* do the multiway lock magic */
54540 trap = lock_rename(cache->graveyard, dir);
54541 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
54542 index eccd339..4c1d995 100644
54543 --- a/fs/cachefiles/proc.c
54544 +++ b/fs/cachefiles/proc.c
54545 @@ -14,9 +14,9 @@
54546 #include <linux/seq_file.h>
54547 #include "internal.h"
54548
54549 -atomic_t cachefiles_lookup_histogram[HZ];
54550 -atomic_t cachefiles_mkdir_histogram[HZ];
54551 -atomic_t cachefiles_create_histogram[HZ];
54552 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
54553 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
54554 +atomic_unchecked_t cachefiles_create_histogram[HZ];
54555
54556 /*
54557 * display the latency histogram
54558 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
54559 return 0;
54560 default:
54561 index = (unsigned long) v - 3;
54562 - x = atomic_read(&cachefiles_lookup_histogram[index]);
54563 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
54564 - z = atomic_read(&cachefiles_create_histogram[index]);
54565 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
54566 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
54567 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
54568 if (x == 0 && y == 0 && z == 0)
54569 return 0;
54570
54571 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
54572 index 317f9ee..3d24511 100644
54573 --- a/fs/cachefiles/rdwr.c
54574 +++ b/fs/cachefiles/rdwr.c
54575 @@ -966,7 +966,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
54576 old_fs = get_fs();
54577 set_fs(KERNEL_DS);
54578 ret = file->f_op->write(
54579 - file, (const void __user *) data, len, &pos);
54580 + file, (const void __force_user *) data, len, &pos);
54581 set_fs(old_fs);
54582 kunmap(page);
54583 file_end_write(file);
54584 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
54585 index f02d82b..2632cf86 100644
54586 --- a/fs/ceph/dir.c
54587 +++ b/fs/ceph/dir.c
54588 @@ -243,7 +243,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
54589 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
54590 struct ceph_mds_client *mdsc = fsc->mdsc;
54591 unsigned frag = fpos_frag(filp->f_pos);
54592 - int off = fpos_off(filp->f_pos);
54593 + unsigned int off = fpos_off(filp->f_pos);
54594 int err;
54595 u32 ftype;
54596 struct ceph_mds_reply_info_parsed *rinfo;
54597 diff --git a/fs/ceph/super.c b/fs/ceph/super.c
54598 index 7d377c9..3fb6559 100644
54599 --- a/fs/ceph/super.c
54600 +++ b/fs/ceph/super.c
54601 @@ -839,7 +839,7 @@ static int ceph_compare_super(struct super_block *sb, void *data)
54602 /*
54603 * construct our own bdi so we can control readahead, etc.
54604 */
54605 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
54606 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
54607
54608 static int ceph_register_bdi(struct super_block *sb,
54609 struct ceph_fs_client *fsc)
54610 @@ -856,7 +856,7 @@ static int ceph_register_bdi(struct super_block *sb,
54611 default_backing_dev_info.ra_pages;
54612
54613 err = bdi_register(&fsc->backing_dev_info, NULL, "ceph-%ld",
54614 - atomic_long_inc_return(&bdi_seq));
54615 + atomic_long_inc_return_unchecked(&bdi_seq));
54616 if (!err)
54617 sb->s_bdi = &fsc->backing_dev_info;
54618 return err;
54619 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
54620 index d597483..747901b 100644
54621 --- a/fs/cifs/cifs_debug.c
54622 +++ b/fs/cifs/cifs_debug.c
54623 @@ -284,8 +284,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
54624
54625 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
54626 #ifdef CONFIG_CIFS_STATS2
54627 - atomic_set(&totBufAllocCount, 0);
54628 - atomic_set(&totSmBufAllocCount, 0);
54629 + atomic_set_unchecked(&totBufAllocCount, 0);
54630 + atomic_set_unchecked(&totSmBufAllocCount, 0);
54631 #endif /* CONFIG_CIFS_STATS2 */
54632 spin_lock(&cifs_tcp_ses_lock);
54633 list_for_each(tmp1, &cifs_tcp_ses_list) {
54634 @@ -298,7 +298,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
54635 tcon = list_entry(tmp3,
54636 struct cifs_tcon,
54637 tcon_list);
54638 - atomic_set(&tcon->num_smbs_sent, 0);
54639 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
54640 if (server->ops->clear_stats)
54641 server->ops->clear_stats(tcon);
54642 }
54643 @@ -330,8 +330,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
54644 smBufAllocCount.counter, cifs_min_small);
54645 #ifdef CONFIG_CIFS_STATS2
54646 seq_printf(m, "Total Large %d Small %d Allocations\n",
54647 - atomic_read(&totBufAllocCount),
54648 - atomic_read(&totSmBufAllocCount));
54649 + atomic_read_unchecked(&totBufAllocCount),
54650 + atomic_read_unchecked(&totSmBufAllocCount));
54651 #endif /* CONFIG_CIFS_STATS2 */
54652
54653 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
54654 @@ -360,7 +360,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
54655 if (tcon->need_reconnect)
54656 seq_puts(m, "\tDISCONNECTED ");
54657 seq_printf(m, "\nSMBs: %d",
54658 - atomic_read(&tcon->num_smbs_sent));
54659 + atomic_read_unchecked(&tcon->num_smbs_sent));
54660 if (server->ops->print_stats)
54661 server->ops->print_stats(m, tcon);
54662 }
54663 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
54664 index 3752b9f..8db5569 100644
54665 --- a/fs/cifs/cifsfs.c
54666 +++ b/fs/cifs/cifsfs.c
54667 @@ -1035,7 +1035,7 @@ cifs_init_request_bufs(void)
54668 */
54669 cifs_req_cachep = kmem_cache_create("cifs_request",
54670 CIFSMaxBufSize + max_hdr_size, 0,
54671 - SLAB_HWCACHE_ALIGN, NULL);
54672 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
54673 if (cifs_req_cachep == NULL)
54674 return -ENOMEM;
54675
54676 @@ -1062,7 +1062,7 @@ cifs_init_request_bufs(void)
54677 efficient to alloc 1 per page off the slab compared to 17K (5page)
54678 alloc of large cifs buffers even when page debugging is on */
54679 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
54680 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
54681 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
54682 NULL);
54683 if (cifs_sm_req_cachep == NULL) {
54684 mempool_destroy(cifs_req_poolp);
54685 @@ -1147,8 +1147,8 @@ init_cifs(void)
54686 atomic_set(&bufAllocCount, 0);
54687 atomic_set(&smBufAllocCount, 0);
54688 #ifdef CONFIG_CIFS_STATS2
54689 - atomic_set(&totBufAllocCount, 0);
54690 - atomic_set(&totSmBufAllocCount, 0);
54691 + atomic_set_unchecked(&totBufAllocCount, 0);
54692 + atomic_set_unchecked(&totSmBufAllocCount, 0);
54693 #endif /* CONFIG_CIFS_STATS2 */
54694
54695 atomic_set(&midCount, 0);
54696 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
54697 index ea3a0b3..0194e39 100644
54698 --- a/fs/cifs/cifsglob.h
54699 +++ b/fs/cifs/cifsglob.h
54700 @@ -752,35 +752,35 @@ struct cifs_tcon {
54701 __u16 Flags; /* optional support bits */
54702 enum statusEnum tidStatus;
54703 #ifdef CONFIG_CIFS_STATS
54704 - atomic_t num_smbs_sent;
54705 + atomic_unchecked_t num_smbs_sent;
54706 union {
54707 struct {
54708 - atomic_t num_writes;
54709 - atomic_t num_reads;
54710 - atomic_t num_flushes;
54711 - atomic_t num_oplock_brks;
54712 - atomic_t num_opens;
54713 - atomic_t num_closes;
54714 - atomic_t num_deletes;
54715 - atomic_t num_mkdirs;
54716 - atomic_t num_posixopens;
54717 - atomic_t num_posixmkdirs;
54718 - atomic_t num_rmdirs;
54719 - atomic_t num_renames;
54720 - atomic_t num_t2renames;
54721 - atomic_t num_ffirst;
54722 - atomic_t num_fnext;
54723 - atomic_t num_fclose;
54724 - atomic_t num_hardlinks;
54725 - atomic_t num_symlinks;
54726 - atomic_t num_locks;
54727 - atomic_t num_acl_get;
54728 - atomic_t num_acl_set;
54729 + atomic_unchecked_t num_writes;
54730 + atomic_unchecked_t num_reads;
54731 + atomic_unchecked_t num_flushes;
54732 + atomic_unchecked_t num_oplock_brks;
54733 + atomic_unchecked_t num_opens;
54734 + atomic_unchecked_t num_closes;
54735 + atomic_unchecked_t num_deletes;
54736 + atomic_unchecked_t num_mkdirs;
54737 + atomic_unchecked_t num_posixopens;
54738 + atomic_unchecked_t num_posixmkdirs;
54739 + atomic_unchecked_t num_rmdirs;
54740 + atomic_unchecked_t num_renames;
54741 + atomic_unchecked_t num_t2renames;
54742 + atomic_unchecked_t num_ffirst;
54743 + atomic_unchecked_t num_fnext;
54744 + atomic_unchecked_t num_fclose;
54745 + atomic_unchecked_t num_hardlinks;
54746 + atomic_unchecked_t num_symlinks;
54747 + atomic_unchecked_t num_locks;
54748 + atomic_unchecked_t num_acl_get;
54749 + atomic_unchecked_t num_acl_set;
54750 } cifs_stats;
54751 #ifdef CONFIG_CIFS_SMB2
54752 struct {
54753 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
54754 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
54755 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
54756 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
54757 } smb2_stats;
54758 #endif /* CONFIG_CIFS_SMB2 */
54759 } stats;
54760 @@ -1081,7 +1081,7 @@ convert_delimiter(char *path, char delim)
54761 }
54762
54763 #ifdef CONFIG_CIFS_STATS
54764 -#define cifs_stats_inc atomic_inc
54765 +#define cifs_stats_inc atomic_inc_unchecked
54766
54767 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
54768 unsigned int bytes)
54769 @@ -1446,8 +1446,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
54770 /* Various Debug counters */
54771 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
54772 #ifdef CONFIG_CIFS_STATS2
54773 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
54774 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
54775 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
54776 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
54777 #endif
54778 GLOBAL_EXTERN atomic_t smBufAllocCount;
54779 GLOBAL_EXTERN atomic_t midCount;
54780 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
54781 index b83c3f5..6437caa 100644
54782 --- a/fs/cifs/link.c
54783 +++ b/fs/cifs/link.c
54784 @@ -616,7 +616,7 @@ symlink_exit:
54785
54786 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
54787 {
54788 - char *p = nd_get_link(nd);
54789 + const char *p = nd_get_link(nd);
54790 if (!IS_ERR(p))
54791 kfree(p);
54792 }
54793 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
54794 index 1bec014..f329411 100644
54795 --- a/fs/cifs/misc.c
54796 +++ b/fs/cifs/misc.c
54797 @@ -169,7 +169,7 @@ cifs_buf_get(void)
54798 memset(ret_buf, 0, buf_size + 3);
54799 atomic_inc(&bufAllocCount);
54800 #ifdef CONFIG_CIFS_STATS2
54801 - atomic_inc(&totBufAllocCount);
54802 + atomic_inc_unchecked(&totBufAllocCount);
54803 #endif /* CONFIG_CIFS_STATS2 */
54804 }
54805
54806 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
54807 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
54808 atomic_inc(&smBufAllocCount);
54809 #ifdef CONFIG_CIFS_STATS2
54810 - atomic_inc(&totSmBufAllocCount);
54811 + atomic_inc_unchecked(&totSmBufAllocCount);
54812 #endif /* CONFIG_CIFS_STATS2 */
54813
54814 }
54815 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
54816 index 3efdb9d..e845a5e 100644
54817 --- a/fs/cifs/smb1ops.c
54818 +++ b/fs/cifs/smb1ops.c
54819 @@ -591,27 +591,27 @@ static void
54820 cifs_clear_stats(struct cifs_tcon *tcon)
54821 {
54822 #ifdef CONFIG_CIFS_STATS
54823 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
54824 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
54825 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
54826 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
54827 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
54828 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
54829 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
54830 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
54831 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
54832 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
54833 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
54834 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
54835 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
54836 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
54837 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
54838 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
54839 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
54840 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
54841 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
54842 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
54843 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
54844 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
54845 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
54846 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
54847 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
54848 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
54849 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
54850 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
54851 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
54852 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
54853 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
54854 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
54855 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
54856 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
54857 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
54858 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
54859 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
54860 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
54861 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
54862 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
54863 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
54864 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
54865 #endif
54866 }
54867
54868 @@ -620,36 +620,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
54869 {
54870 #ifdef CONFIG_CIFS_STATS
54871 seq_printf(m, " Oplocks breaks: %d",
54872 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
54873 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
54874 seq_printf(m, "\nReads: %d Bytes: %llu",
54875 - atomic_read(&tcon->stats.cifs_stats.num_reads),
54876 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
54877 (long long)(tcon->bytes_read));
54878 seq_printf(m, "\nWrites: %d Bytes: %llu",
54879 - atomic_read(&tcon->stats.cifs_stats.num_writes),
54880 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
54881 (long long)(tcon->bytes_written));
54882 seq_printf(m, "\nFlushes: %d",
54883 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
54884 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
54885 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
54886 - atomic_read(&tcon->stats.cifs_stats.num_locks),
54887 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
54888 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
54889 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
54890 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
54891 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
54892 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
54893 - atomic_read(&tcon->stats.cifs_stats.num_opens),
54894 - atomic_read(&tcon->stats.cifs_stats.num_closes),
54895 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
54896 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
54897 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
54898 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
54899 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
54900 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
54901 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
54902 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
54903 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
54904 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
54905 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
54906 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
54907 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
54908 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
54909 seq_printf(m, "\nRenames: %d T2 Renames %d",
54910 - atomic_read(&tcon->stats.cifs_stats.num_renames),
54911 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
54912 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
54913 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
54914 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
54915 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
54916 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
54917 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
54918 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
54919 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
54920 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
54921 #endif
54922 }
54923
54924 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
54925 index f2e76f3..c44fac7 100644
54926 --- a/fs/cifs/smb2ops.c
54927 +++ b/fs/cifs/smb2ops.c
54928 @@ -274,8 +274,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
54929 #ifdef CONFIG_CIFS_STATS
54930 int i;
54931 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
54932 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
54933 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
54934 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
54935 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
54936 }
54937 #endif
54938 }
54939 @@ -284,66 +284,66 @@ static void
54940 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
54941 {
54942 #ifdef CONFIG_CIFS_STATS
54943 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
54944 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
54945 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
54946 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
54947 seq_printf(m, "\nNegotiates: %d sent %d failed",
54948 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
54949 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
54950 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
54951 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
54952 seq_printf(m, "\nSessionSetups: %d sent %d failed",
54953 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
54954 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
54955 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
54956 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
54957 #define SMB2LOGOFF 0x0002 /* trivial request/resp */
54958 seq_printf(m, "\nLogoffs: %d sent %d failed",
54959 - atomic_read(&sent[SMB2_LOGOFF_HE]),
54960 - atomic_read(&failed[SMB2_LOGOFF_HE]));
54961 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
54962 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
54963 seq_printf(m, "\nTreeConnects: %d sent %d failed",
54964 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
54965 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
54966 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
54967 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
54968 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
54969 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
54970 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
54971 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
54972 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
54973 seq_printf(m, "\nCreates: %d sent %d failed",
54974 - atomic_read(&sent[SMB2_CREATE_HE]),
54975 - atomic_read(&failed[SMB2_CREATE_HE]));
54976 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
54977 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
54978 seq_printf(m, "\nCloses: %d sent %d failed",
54979 - atomic_read(&sent[SMB2_CLOSE_HE]),
54980 - atomic_read(&failed[SMB2_CLOSE_HE]));
54981 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
54982 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
54983 seq_printf(m, "\nFlushes: %d sent %d failed",
54984 - atomic_read(&sent[SMB2_FLUSH_HE]),
54985 - atomic_read(&failed[SMB2_FLUSH_HE]));
54986 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
54987 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
54988 seq_printf(m, "\nReads: %d sent %d failed",
54989 - atomic_read(&sent[SMB2_READ_HE]),
54990 - atomic_read(&failed[SMB2_READ_HE]));
54991 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
54992 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
54993 seq_printf(m, "\nWrites: %d sent %d failed",
54994 - atomic_read(&sent[SMB2_WRITE_HE]),
54995 - atomic_read(&failed[SMB2_WRITE_HE]));
54996 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
54997 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
54998 seq_printf(m, "\nLocks: %d sent %d failed",
54999 - atomic_read(&sent[SMB2_LOCK_HE]),
55000 - atomic_read(&failed[SMB2_LOCK_HE]));
55001 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
55002 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
55003 seq_printf(m, "\nIOCTLs: %d sent %d failed",
55004 - atomic_read(&sent[SMB2_IOCTL_HE]),
55005 - atomic_read(&failed[SMB2_IOCTL_HE]));
55006 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
55007 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
55008 seq_printf(m, "\nCancels: %d sent %d failed",
55009 - atomic_read(&sent[SMB2_CANCEL_HE]),
55010 - atomic_read(&failed[SMB2_CANCEL_HE]));
55011 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
55012 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
55013 seq_printf(m, "\nEchos: %d sent %d failed",
55014 - atomic_read(&sent[SMB2_ECHO_HE]),
55015 - atomic_read(&failed[SMB2_ECHO_HE]));
55016 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
55017 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
55018 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
55019 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
55020 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
55021 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
55022 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
55023 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
55024 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
55025 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
55026 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
55027 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
55028 seq_printf(m, "\nQueryInfos: %d sent %d failed",
55029 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
55030 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
55031 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
55032 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
55033 seq_printf(m, "\nSetInfos: %d sent %d failed",
55034 - atomic_read(&sent[SMB2_SET_INFO_HE]),
55035 - atomic_read(&failed[SMB2_SET_INFO_HE]));
55036 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
55037 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
55038 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
55039 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
55040 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
55041 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
55042 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
55043 #endif
55044 }
55045
55046 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
55047 index 2b95ce2..d079d75 100644
55048 --- a/fs/cifs/smb2pdu.c
55049 +++ b/fs/cifs/smb2pdu.c
55050 @@ -1760,8 +1760,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
55051 default:
55052 cifs_dbg(VFS, "info level %u isn't supported\n",
55053 srch_inf->info_level);
55054 - rc = -EINVAL;
55055 - goto qdir_exit;
55056 + return -EINVAL;
55057 }
55058
55059 req->FileIndex = cpu_to_le32(index);
55060 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
55061 index 1da168c..8bc7ff6 100644
55062 --- a/fs/coda/cache.c
55063 +++ b/fs/coda/cache.c
55064 @@ -24,7 +24,7 @@
55065 #include "coda_linux.h"
55066 #include "coda_cache.h"
55067
55068 -static atomic_t permission_epoch = ATOMIC_INIT(0);
55069 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
55070
55071 /* replace or extend an acl cache hit */
55072 void coda_cache_enter(struct inode *inode, int mask)
55073 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
55074 struct coda_inode_info *cii = ITOC(inode);
55075
55076 spin_lock(&cii->c_lock);
55077 - cii->c_cached_epoch = atomic_read(&permission_epoch);
55078 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
55079 if (!uid_eq(cii->c_uid, current_fsuid())) {
55080 cii->c_uid = current_fsuid();
55081 cii->c_cached_perm = mask;
55082 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
55083 {
55084 struct coda_inode_info *cii = ITOC(inode);
55085 spin_lock(&cii->c_lock);
55086 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
55087 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
55088 spin_unlock(&cii->c_lock);
55089 }
55090
55091 /* remove all acl caches */
55092 void coda_cache_clear_all(struct super_block *sb)
55093 {
55094 - atomic_inc(&permission_epoch);
55095 + atomic_inc_unchecked(&permission_epoch);
55096 }
55097
55098
55099 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
55100 spin_lock(&cii->c_lock);
55101 hit = (mask & cii->c_cached_perm) == mask &&
55102 uid_eq(cii->c_uid, current_fsuid()) &&
55103 - cii->c_cached_epoch == atomic_read(&permission_epoch);
55104 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
55105 spin_unlock(&cii->c_lock);
55106
55107 return hit;
55108 diff --git a/fs/compat.c b/fs/compat.c
55109 index fc3b55d..7b568ae 100644
55110 --- a/fs/compat.c
55111 +++ b/fs/compat.c
55112 @@ -54,7 +54,7 @@
55113 #include <asm/ioctls.h>
55114 #include "internal.h"
55115
55116 -int compat_log = 1;
55117 +int compat_log = 0;
55118
55119 int compat_printk(const char *fmt, ...)
55120 {
55121 @@ -488,7 +488,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
55122
55123 set_fs(KERNEL_DS);
55124 /* The __user pointer cast is valid because of the set_fs() */
55125 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
55126 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
55127 set_fs(oldfs);
55128 /* truncating is ok because it's a user address */
55129 if (!ret)
55130 @@ -546,7 +546,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
55131 goto out;
55132
55133 ret = -EINVAL;
55134 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
55135 + if (nr_segs > UIO_MAXIOV)
55136 goto out;
55137 if (nr_segs > fast_segs) {
55138 ret = -ENOMEM;
55139 @@ -833,6 +833,7 @@ struct compat_old_linux_dirent {
55140
55141 struct compat_readdir_callback {
55142 struct compat_old_linux_dirent __user *dirent;
55143 + struct file * file;
55144 int result;
55145 };
55146
55147 @@ -850,6 +851,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
55148 buf->result = -EOVERFLOW;
55149 return -EOVERFLOW;
55150 }
55151 +
55152 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55153 + return 0;
55154 +
55155 buf->result++;
55156 dirent = buf->dirent;
55157 if (!access_ok(VERIFY_WRITE, dirent,
55158 @@ -880,6 +885,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
55159
55160 buf.result = 0;
55161 buf.dirent = dirent;
55162 + buf.file = f.file;
55163
55164 error = vfs_readdir(f.file, compat_fillonedir, &buf);
55165 if (buf.result)
55166 @@ -899,6 +905,7 @@ struct compat_linux_dirent {
55167 struct compat_getdents_callback {
55168 struct compat_linux_dirent __user *current_dir;
55169 struct compat_linux_dirent __user *previous;
55170 + struct file * file;
55171 int count;
55172 int error;
55173 };
55174 @@ -920,6 +927,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
55175 buf->error = -EOVERFLOW;
55176 return -EOVERFLOW;
55177 }
55178 +
55179 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55180 + return 0;
55181 +
55182 dirent = buf->previous;
55183 if (dirent) {
55184 if (__put_user(offset, &dirent->d_off))
55185 @@ -965,6 +976,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
55186 buf.previous = NULL;
55187 buf.count = count;
55188 buf.error = 0;
55189 + buf.file = f.file;
55190
55191 error = vfs_readdir(f.file, compat_filldir, &buf);
55192 if (error >= 0)
55193 @@ -985,6 +997,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
55194 struct compat_getdents_callback64 {
55195 struct linux_dirent64 __user *current_dir;
55196 struct linux_dirent64 __user *previous;
55197 + struct file * file;
55198 int count;
55199 int error;
55200 };
55201 @@ -1001,6 +1014,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
55202 buf->error = -EINVAL; /* only used if we fail.. */
55203 if (reclen > buf->count)
55204 return -EINVAL;
55205 +
55206 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55207 + return 0;
55208 +
55209 dirent = buf->previous;
55210
55211 if (dirent) {
55212 @@ -1050,13 +1067,14 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
55213 buf.previous = NULL;
55214 buf.count = count;
55215 buf.error = 0;
55216 + buf.file = f.file;
55217
55218 error = vfs_readdir(f.file, compat_filldir64, &buf);
55219 if (error >= 0)
55220 error = buf.error;
55221 lastdirent = buf.previous;
55222 if (lastdirent) {
55223 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
55224 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
55225 if (__put_user_unaligned(d_off, &lastdirent->d_off))
55226 error = -EFAULT;
55227 else
55228 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
55229 index a81147e..20bf2b5 100644
55230 --- a/fs/compat_binfmt_elf.c
55231 +++ b/fs/compat_binfmt_elf.c
55232 @@ -30,11 +30,13 @@
55233 #undef elf_phdr
55234 #undef elf_shdr
55235 #undef elf_note
55236 +#undef elf_dyn
55237 #undef elf_addr_t
55238 #define elfhdr elf32_hdr
55239 #define elf_phdr elf32_phdr
55240 #define elf_shdr elf32_shdr
55241 #define elf_note elf32_note
55242 +#define elf_dyn Elf32_Dyn
55243 #define elf_addr_t Elf32_Addr
55244
55245 /*
55246 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
55247 index 996cdc5..15e2f33 100644
55248 --- a/fs/compat_ioctl.c
55249 +++ b/fs/compat_ioctl.c
55250 @@ -622,7 +622,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
55251 return -EFAULT;
55252 if (__get_user(udata, &ss32->iomem_base))
55253 return -EFAULT;
55254 - ss.iomem_base = compat_ptr(udata);
55255 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
55256 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
55257 __get_user(ss.port_high, &ss32->port_high))
55258 return -EFAULT;
55259 @@ -703,8 +703,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
55260 for (i = 0; i < nmsgs; i++) {
55261 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
55262 return -EFAULT;
55263 - if (get_user(datap, &umsgs[i].buf) ||
55264 - put_user(compat_ptr(datap), &tmsgs[i].buf))
55265 + if (get_user(datap, (u8 __user * __user *)&umsgs[i].buf) ||
55266 + put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
55267 return -EFAULT;
55268 }
55269 return sys_ioctl(fd, cmd, (unsigned long)tdata);
55270 @@ -797,7 +797,7 @@ static int compat_ioctl_preallocate(struct file *file,
55271 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
55272 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
55273 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
55274 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
55275 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
55276 return -EFAULT;
55277
55278 return ioctl_preallocate(file, p);
55279 @@ -1619,8 +1619,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
55280 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
55281 {
55282 unsigned int a, b;
55283 - a = *(unsigned int *)p;
55284 - b = *(unsigned int *)q;
55285 + a = *(const unsigned int *)p;
55286 + b = *(const unsigned int *)q;
55287 if (a > b)
55288 return 1;
55289 if (a < b)
55290 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
55291 index 7aabc6a..34c1197 100644
55292 --- a/fs/configfs/dir.c
55293 +++ b/fs/configfs/dir.c
55294 @@ -1565,7 +1565,8 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
55295 }
55296 for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
55297 struct configfs_dirent *next;
55298 - const char * name;
55299 + const unsigned char * name;
55300 + char d_name[sizeof(next->s_dentry->d_iname)];
55301 int len;
55302 struct inode *inode = NULL;
55303
55304 @@ -1575,7 +1576,12 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
55305 continue;
55306
55307 name = configfs_get_name(next);
55308 - len = strlen(name);
55309 + if (next->s_dentry && name == next->s_dentry->d_iname) {
55310 + len = next->s_dentry->d_name.len;
55311 + memcpy(d_name, name, len);
55312 + name = d_name;
55313 + } else
55314 + len = strlen(name);
55315
55316 /*
55317 * We'll have a dentry and an inode for
55318 diff --git a/fs/coredump.c b/fs/coredump.c
55319 index dafafba..10b3b27 100644
55320 --- a/fs/coredump.c
55321 +++ b/fs/coredump.c
55322 @@ -52,7 +52,7 @@ struct core_name {
55323 char *corename;
55324 int used, size;
55325 };
55326 -static atomic_t call_count = ATOMIC_INIT(1);
55327 +static atomic_unchecked_t call_count = ATOMIC_INIT(1);
55328
55329 /* The maximal length of core_pattern is also specified in sysctl.c */
55330
55331 @@ -60,7 +60,7 @@ static int expand_corename(struct core_name *cn)
55332 {
55333 char *old_corename = cn->corename;
55334
55335 - cn->size = CORENAME_MAX_SIZE * atomic_inc_return(&call_count);
55336 + cn->size = CORENAME_MAX_SIZE * atomic_inc_return_unchecked(&call_count);
55337 cn->corename = krealloc(old_corename, cn->size, GFP_KERNEL);
55338
55339 if (!cn->corename) {
55340 @@ -157,7 +157,7 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
55341 int pid_in_pattern = 0;
55342 int err = 0;
55343
55344 - cn->size = CORENAME_MAX_SIZE * atomic_read(&call_count);
55345 + cn->size = CORENAME_MAX_SIZE * atomic_read_unchecked(&call_count);
55346 cn->corename = kmalloc(cn->size, GFP_KERNEL);
55347 cn->used = 0;
55348
55349 @@ -435,8 +435,8 @@ static void wait_for_dump_helpers(struct file *file)
55350 struct pipe_inode_info *pipe = file->private_data;
55351
55352 pipe_lock(pipe);
55353 - pipe->readers++;
55354 - pipe->writers--;
55355 + atomic_inc(&pipe->readers);
55356 + atomic_dec(&pipe->writers);
55357 wake_up_interruptible_sync(&pipe->wait);
55358 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
55359 pipe_unlock(pipe);
55360 @@ -445,11 +445,11 @@ static void wait_for_dump_helpers(struct file *file)
55361 * We actually want wait_event_freezable() but then we need
55362 * to clear TIF_SIGPENDING and improve dump_interrupted().
55363 */
55364 - wait_event_interruptible(pipe->wait, pipe->readers == 1);
55365 + wait_event_interruptible(pipe->wait, atomic_read(&pipe->readers) == 1);
55366
55367 pipe_lock(pipe);
55368 - pipe->readers--;
55369 - pipe->writers++;
55370 + atomic_dec(&pipe->readers);
55371 + atomic_inc(&pipe->writers);
55372 pipe_unlock(pipe);
55373 }
55374
55375 @@ -496,7 +496,8 @@ void do_coredump(siginfo_t *siginfo)
55376 struct files_struct *displaced;
55377 bool need_nonrelative = false;
55378 bool core_dumped = false;
55379 - static atomic_t core_dump_count = ATOMIC_INIT(0);
55380 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
55381 + long signr = siginfo->si_signo;
55382 struct coredump_params cprm = {
55383 .siginfo = siginfo,
55384 .regs = signal_pt_regs(),
55385 @@ -509,7 +510,10 @@ void do_coredump(siginfo_t *siginfo)
55386 .mm_flags = mm->flags,
55387 };
55388
55389 - audit_core_dumps(siginfo->si_signo);
55390 + audit_core_dumps(signr);
55391 +
55392 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
55393 + gr_handle_brute_attach(cprm.mm_flags);
55394
55395 binfmt = mm->binfmt;
55396 if (!binfmt || !binfmt->core_dump)
55397 @@ -533,7 +537,7 @@ void do_coredump(siginfo_t *siginfo)
55398 need_nonrelative = true;
55399 }
55400
55401 - retval = coredump_wait(siginfo->si_signo, &core_state);
55402 + retval = coredump_wait(signr, &core_state);
55403 if (retval < 0)
55404 goto fail_creds;
55405
55406 @@ -576,7 +580,7 @@ void do_coredump(siginfo_t *siginfo)
55407 }
55408 cprm.limit = RLIM_INFINITY;
55409
55410 - dump_count = atomic_inc_return(&core_dump_count);
55411 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
55412 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
55413 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
55414 task_tgid_vnr(current), current->comm);
55415 @@ -608,6 +612,8 @@ void do_coredump(siginfo_t *siginfo)
55416 } else {
55417 struct inode *inode;
55418
55419 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
55420 +
55421 if (cprm.limit < binfmt->min_coredump)
55422 goto fail_unlock;
55423
55424 @@ -666,7 +672,7 @@ close_fail:
55425 filp_close(cprm.file, NULL);
55426 fail_dropcount:
55427 if (ispipe)
55428 - atomic_dec(&core_dump_count);
55429 + atomic_dec_unchecked(&core_dump_count);
55430 fail_unlock:
55431 kfree(cn.corename);
55432 fail_corename:
55433 @@ -687,7 +693,7 @@ int dump_write(struct file *file, const void *addr, int nr)
55434 {
55435 return !dump_interrupted() &&
55436 access_ok(VERIFY_READ, addr, nr) &&
55437 - file->f_op->write(file, addr, nr, &file->f_pos) == nr;
55438 + file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
55439 }
55440 EXPORT_SYMBOL(dump_write);
55441
55442 diff --git a/fs/dcache.c b/fs/dcache.c
55443 index f09b908..04b9690 100644
55444 --- a/fs/dcache.c
55445 +++ b/fs/dcache.c
55446 @@ -3086,7 +3086,8 @@ void __init vfs_caches_init(unsigned long mempages)
55447 mempages -= reserve;
55448
55449 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
55450 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
55451 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY|
55452 + SLAB_NO_SANITIZE, NULL);
55453
55454 dcache_init();
55455 inode_init();
55456 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
55457 index c7c83ff..bda9461 100644
55458 --- a/fs/debugfs/inode.c
55459 +++ b/fs/debugfs/inode.c
55460 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
55461 */
55462 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
55463 {
55464 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
55465 + return __create_file(name, S_IFDIR | S_IRWXU,
55466 +#else
55467 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
55468 +#endif
55469 parent, NULL, NULL);
55470 }
55471 EXPORT_SYMBOL_GPL(debugfs_create_dir);
55472 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
55473 index 5eab400..810a3f5 100644
55474 --- a/fs/ecryptfs/inode.c
55475 +++ b/fs/ecryptfs/inode.c
55476 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
55477 old_fs = get_fs();
55478 set_fs(get_ds());
55479 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
55480 - (char __user *)lower_buf,
55481 + (char __force_user *)lower_buf,
55482 PATH_MAX);
55483 set_fs(old_fs);
55484 if (rc < 0)
55485 @@ -706,7 +706,7 @@ out:
55486 static void
55487 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
55488 {
55489 - char *buf = nd_get_link(nd);
55490 + const char *buf = nd_get_link(nd);
55491 if (!IS_ERR(buf)) {
55492 /* Free the char* */
55493 kfree(buf);
55494 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
55495 index e4141f2..d8263e8 100644
55496 --- a/fs/ecryptfs/miscdev.c
55497 +++ b/fs/ecryptfs/miscdev.c
55498 @@ -304,7 +304,7 @@ check_list:
55499 goto out_unlock_msg_ctx;
55500 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
55501 if (msg_ctx->msg) {
55502 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
55503 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
55504 goto out_unlock_msg_ctx;
55505 i += packet_length_size;
55506 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
55507 diff --git a/fs/exec.c b/fs/exec.c
55508 index 1f44670..3c84660 100644
55509 --- a/fs/exec.c
55510 +++ b/fs/exec.c
55511 @@ -55,8 +55,20 @@
55512 #include <linux/pipe_fs_i.h>
55513 #include <linux/oom.h>
55514 #include <linux/compat.h>
55515 +#include <linux/random.h>
55516 +#include <linux/seq_file.h>
55517 +#include <linux/coredump.h>
55518 +#include <linux/mman.h>
55519 +
55520 +#ifdef CONFIG_PAX_REFCOUNT
55521 +#include <linux/kallsyms.h>
55522 +#include <linux/kdebug.h>
55523 +#endif
55524 +
55525 +#include <trace/events/fs.h>
55526
55527 #include <asm/uaccess.h>
55528 +#include <asm/sections.h>
55529 #include <asm/mmu_context.h>
55530 #include <asm/tlb.h>
55531
55532 @@ -66,17 +78,32 @@
55533
55534 #include <trace/events/sched.h>
55535
55536 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
55537 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
55538 +{
55539 + 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");
55540 +}
55541 +#endif
55542 +
55543 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
55544 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
55545 +EXPORT_SYMBOL(pax_set_initial_flags_func);
55546 +#endif
55547 +
55548 int suid_dumpable = 0;
55549
55550 static LIST_HEAD(formats);
55551 static DEFINE_RWLOCK(binfmt_lock);
55552
55553 +extern int gr_process_kernel_exec_ban(void);
55554 +extern int gr_process_suid_exec_ban(const struct linux_binprm *bprm);
55555 +
55556 void __register_binfmt(struct linux_binfmt * fmt, int insert)
55557 {
55558 BUG_ON(!fmt);
55559 write_lock(&binfmt_lock);
55560 - insert ? list_add(&fmt->lh, &formats) :
55561 - list_add_tail(&fmt->lh, &formats);
55562 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
55563 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
55564 write_unlock(&binfmt_lock);
55565 }
55566
55567 @@ -85,7 +112,7 @@ EXPORT_SYMBOL(__register_binfmt);
55568 void unregister_binfmt(struct linux_binfmt * fmt)
55569 {
55570 write_lock(&binfmt_lock);
55571 - list_del(&fmt->lh);
55572 + pax_list_del((struct list_head *)&fmt->lh);
55573 write_unlock(&binfmt_lock);
55574 }
55575
55576 @@ -180,18 +207,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
55577 int write)
55578 {
55579 struct page *page;
55580 - int ret;
55581
55582 -#ifdef CONFIG_STACK_GROWSUP
55583 - if (write) {
55584 - ret = expand_downwards(bprm->vma, pos);
55585 - if (ret < 0)
55586 - return NULL;
55587 - }
55588 -#endif
55589 - ret = get_user_pages(current, bprm->mm, pos,
55590 - 1, write, 1, &page, NULL);
55591 - if (ret <= 0)
55592 + if (0 > expand_downwards(bprm->vma, pos))
55593 + return NULL;
55594 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
55595 return NULL;
55596
55597 if (write) {
55598 @@ -207,6 +226,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
55599 if (size <= ARG_MAX)
55600 return page;
55601
55602 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55603 + // only allow 512KB for argv+env on suid/sgid binaries
55604 + // to prevent easy ASLR exhaustion
55605 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
55606 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
55607 + (size > (512 * 1024))) {
55608 + put_page(page);
55609 + return NULL;
55610 + }
55611 +#endif
55612 +
55613 /*
55614 * Limit to 1/4-th the stack size for the argv+env strings.
55615 * This ensures that:
55616 @@ -266,6 +296,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
55617 vma->vm_end = STACK_TOP_MAX;
55618 vma->vm_start = vma->vm_end - PAGE_SIZE;
55619 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
55620 +
55621 +#ifdef CONFIG_PAX_SEGMEXEC
55622 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
55623 +#endif
55624 +
55625 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
55626 INIT_LIST_HEAD(&vma->anon_vma_chain);
55627
55628 @@ -276,6 +311,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
55629 mm->stack_vm = mm->total_vm = 1;
55630 up_write(&mm->mmap_sem);
55631 bprm->p = vma->vm_end - sizeof(void *);
55632 +
55633 +#ifdef CONFIG_PAX_RANDUSTACK
55634 + if (randomize_va_space)
55635 + bprm->p ^= prandom_u32() & ~PAGE_MASK;
55636 +#endif
55637 +
55638 return 0;
55639 err:
55640 up_write(&mm->mmap_sem);
55641 @@ -396,7 +437,7 @@ struct user_arg_ptr {
55642 } ptr;
55643 };
55644
55645 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
55646 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
55647 {
55648 const char __user *native;
55649
55650 @@ -405,14 +446,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
55651 compat_uptr_t compat;
55652
55653 if (get_user(compat, argv.ptr.compat + nr))
55654 - return ERR_PTR(-EFAULT);
55655 + return (const char __force_user *)ERR_PTR(-EFAULT);
55656
55657 return compat_ptr(compat);
55658 }
55659 #endif
55660
55661 if (get_user(native, argv.ptr.native + nr))
55662 - return ERR_PTR(-EFAULT);
55663 + return (const char __force_user *)ERR_PTR(-EFAULT);
55664
55665 return native;
55666 }
55667 @@ -431,7 +472,7 @@ static int count(struct user_arg_ptr argv, int max)
55668 if (!p)
55669 break;
55670
55671 - if (IS_ERR(p))
55672 + if (IS_ERR((const char __force_kernel *)p))
55673 return -EFAULT;
55674
55675 if (i >= max)
55676 @@ -466,7 +507,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
55677
55678 ret = -EFAULT;
55679 str = get_user_arg_ptr(argv, argc);
55680 - if (IS_ERR(str))
55681 + if (IS_ERR((const char __force_kernel *)str))
55682 goto out;
55683
55684 len = strnlen_user(str, MAX_ARG_STRLEN);
55685 @@ -548,7 +589,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
55686 int r;
55687 mm_segment_t oldfs = get_fs();
55688 struct user_arg_ptr argv = {
55689 - .ptr.native = (const char __user *const __user *)__argv,
55690 + .ptr.native = (const char __force_user * const __force_user *)__argv,
55691 };
55692
55693 set_fs(KERNEL_DS);
55694 @@ -583,7 +624,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
55695 unsigned long new_end = old_end - shift;
55696 struct mmu_gather tlb;
55697
55698 - BUG_ON(new_start > new_end);
55699 + if (new_start >= new_end || new_start < mmap_min_addr)
55700 + return -ENOMEM;
55701
55702 /*
55703 * ensure there are no vmas between where we want to go
55704 @@ -592,6 +634,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
55705 if (vma != find_vma(mm, new_start))
55706 return -EFAULT;
55707
55708 +#ifdef CONFIG_PAX_SEGMEXEC
55709 + BUG_ON(pax_find_mirror_vma(vma));
55710 +#endif
55711 +
55712 /*
55713 * cover the whole range: [new_start, old_end)
55714 */
55715 @@ -672,10 +718,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
55716 stack_top = arch_align_stack(stack_top);
55717 stack_top = PAGE_ALIGN(stack_top);
55718
55719 - if (unlikely(stack_top < mmap_min_addr) ||
55720 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
55721 - return -ENOMEM;
55722 -
55723 stack_shift = vma->vm_end - stack_top;
55724
55725 bprm->p -= stack_shift;
55726 @@ -687,8 +729,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
55727 bprm->exec -= stack_shift;
55728
55729 down_write(&mm->mmap_sem);
55730 +
55731 + /* Move stack pages down in memory. */
55732 + if (stack_shift) {
55733 + ret = shift_arg_pages(vma, stack_shift);
55734 + if (ret)
55735 + goto out_unlock;
55736 + }
55737 +
55738 vm_flags = VM_STACK_FLAGS;
55739
55740 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
55741 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
55742 + vm_flags &= ~VM_EXEC;
55743 +
55744 +#ifdef CONFIG_PAX_MPROTECT
55745 + if (mm->pax_flags & MF_PAX_MPROTECT)
55746 + vm_flags &= ~VM_MAYEXEC;
55747 +#endif
55748 +
55749 + }
55750 +#endif
55751 +
55752 /*
55753 * Adjust stack execute permissions; explicitly enable for
55754 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
55755 @@ -707,13 +769,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
55756 goto out_unlock;
55757 BUG_ON(prev != vma);
55758
55759 - /* Move stack pages down in memory. */
55760 - if (stack_shift) {
55761 - ret = shift_arg_pages(vma, stack_shift);
55762 - if (ret)
55763 - goto out_unlock;
55764 - }
55765 -
55766 /* mprotect_fixup is overkill to remove the temporary stack flags */
55767 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
55768
55769 @@ -737,6 +792,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
55770 #endif
55771 current->mm->start_stack = bprm->p;
55772 ret = expand_stack(vma, stack_base);
55773 +
55774 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
55775 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
55776 + unsigned long size;
55777 + vm_flags_t vm_flags;
55778 +
55779 + size = STACK_TOP - vma->vm_end;
55780 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
55781 +
55782 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
55783 +
55784 +#ifdef CONFIG_X86
55785 + if (!ret) {
55786 + size = PAGE_SIZE + mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
55787 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
55788 + }
55789 +#endif
55790 +
55791 + }
55792 +#endif
55793 +
55794 if (ret)
55795 ret = -EFAULT;
55796
55797 @@ -772,6 +848,8 @@ struct file *open_exec(const char *name)
55798
55799 fsnotify_open(file);
55800
55801 + trace_open_exec(name);
55802 +
55803 err = deny_write_access(file);
55804 if (err)
55805 goto exit;
55806 @@ -795,7 +873,7 @@ int kernel_read(struct file *file, loff_t offset,
55807 old_fs = get_fs();
55808 set_fs(get_ds());
55809 /* The cast to a user pointer is valid due to the set_fs() */
55810 - result = vfs_read(file, (void __user *)addr, count, &pos);
55811 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
55812 set_fs(old_fs);
55813 return result;
55814 }
55815 @@ -1251,7 +1329,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
55816 }
55817 rcu_read_unlock();
55818
55819 - if (p->fs->users > n_fs) {
55820 + if (atomic_read(&p->fs->users) > n_fs) {
55821 bprm->unsafe |= LSM_UNSAFE_SHARE;
55822 } else {
55823 res = -EAGAIN;
55824 @@ -1451,6 +1529,31 @@ int search_binary_handler(struct linux_binprm *bprm)
55825
55826 EXPORT_SYMBOL(search_binary_handler);
55827
55828 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55829 +static DEFINE_PER_CPU(u64, exec_counter);
55830 +static int __init init_exec_counters(void)
55831 +{
55832 + unsigned int cpu;
55833 +
55834 + for_each_possible_cpu(cpu) {
55835 + per_cpu(exec_counter, cpu) = (u64)cpu;
55836 + }
55837 +
55838 + return 0;
55839 +}
55840 +early_initcall(init_exec_counters);
55841 +static inline void increment_exec_counter(void)
55842 +{
55843 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
55844 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
55845 +}
55846 +#else
55847 +static inline void increment_exec_counter(void) {}
55848 +#endif
55849 +
55850 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
55851 + struct user_arg_ptr argv);
55852 +
55853 /*
55854 * sys_execve() executes a new program.
55855 */
55856 @@ -1458,6 +1561,11 @@ static int do_execve_common(const char *filename,
55857 struct user_arg_ptr argv,
55858 struct user_arg_ptr envp)
55859 {
55860 +#ifdef CONFIG_GRKERNSEC
55861 + struct file *old_exec_file;
55862 + struct acl_subject_label *old_acl;
55863 + struct rlimit old_rlim[RLIM_NLIMITS];
55864 +#endif
55865 struct linux_binprm *bprm;
55866 struct file *file;
55867 struct files_struct *displaced;
55868 @@ -1465,6 +1573,8 @@ static int do_execve_common(const char *filename,
55869 int retval;
55870 const struct cred *cred = current_cred();
55871
55872 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&cred->user->processes), 1);
55873 +
55874 /*
55875 * We move the actual failure in case of RLIMIT_NPROC excess from
55876 * set*uid() to execve() because too many poorly written programs
55877 @@ -1505,12 +1615,22 @@ static int do_execve_common(const char *filename,
55878 if (IS_ERR(file))
55879 goto out_unmark;
55880
55881 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
55882 + retval = -EPERM;
55883 + goto out_file;
55884 + }
55885 +
55886 sched_exec();
55887
55888 bprm->file = file;
55889 bprm->filename = filename;
55890 bprm->interp = filename;
55891
55892 + if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
55893 + retval = -EACCES;
55894 + goto out_file;
55895 + }
55896 +
55897 retval = bprm_mm_init(bprm);
55898 if (retval)
55899 goto out_file;
55900 @@ -1527,24 +1647,70 @@ static int do_execve_common(const char *filename,
55901 if (retval < 0)
55902 goto out;
55903
55904 +#ifdef CONFIG_GRKERNSEC
55905 + old_acl = current->acl;
55906 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
55907 + old_exec_file = current->exec_file;
55908 + get_file(file);
55909 + current->exec_file = file;
55910 +#endif
55911 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55912 + /* limit suid stack to 8MB
55913 + * we saved the old limits above and will restore them if this exec fails
55914 + */
55915 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
55916 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
55917 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
55918 +#endif
55919 +
55920 + if (gr_process_kernel_exec_ban() || gr_process_suid_exec_ban(bprm)) {
55921 + retval = -EPERM;
55922 + goto out_fail;
55923 + }
55924 +
55925 + if (!gr_tpe_allow(file)) {
55926 + retval = -EACCES;
55927 + goto out_fail;
55928 + }
55929 +
55930 + if (gr_check_crash_exec(file)) {
55931 + retval = -EACCES;
55932 + goto out_fail;
55933 + }
55934 +
55935 + retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
55936 + bprm->unsafe);
55937 + if (retval < 0)
55938 + goto out_fail;
55939 +
55940 retval = copy_strings_kernel(1, &bprm->filename, bprm);
55941 if (retval < 0)
55942 - goto out;
55943 + goto out_fail;
55944
55945 bprm->exec = bprm->p;
55946 retval = copy_strings(bprm->envc, envp, bprm);
55947 if (retval < 0)
55948 - goto out;
55949 + goto out_fail;
55950
55951 retval = copy_strings(bprm->argc, argv, bprm);
55952 if (retval < 0)
55953 - goto out;
55954 + goto out_fail;
55955 +
55956 + gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
55957 +
55958 + gr_handle_exec_args(bprm, argv);
55959
55960 retval = search_binary_handler(bprm);
55961 if (retval < 0)
55962 - goto out;
55963 + goto out_fail;
55964 +#ifdef CONFIG_GRKERNSEC
55965 + if (old_exec_file)
55966 + fput(old_exec_file);
55967 +#endif
55968
55969 /* execve succeeded */
55970 +
55971 + increment_exec_counter();
55972 current->fs->in_exec = 0;
55973 current->in_execve = 0;
55974 acct_update_integrals(current);
55975 @@ -1553,6 +1719,14 @@ static int do_execve_common(const char *filename,
55976 put_files_struct(displaced);
55977 return retval;
55978
55979 +out_fail:
55980 +#ifdef CONFIG_GRKERNSEC
55981 + current->acl = old_acl;
55982 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
55983 + fput(current->exec_file);
55984 + current->exec_file = old_exec_file;
55985 +#endif
55986 +
55987 out:
55988 if (bprm->mm) {
55989 acct_arg_size(bprm, 0);
55990 @@ -1701,3 +1875,287 @@ asmlinkage long compat_sys_execve(const char __user * filename,
55991 return error;
55992 }
55993 #endif
55994 +
55995 +int pax_check_flags(unsigned long *flags)
55996 +{
55997 + int retval = 0;
55998 +
55999 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
56000 + if (*flags & MF_PAX_SEGMEXEC)
56001 + {
56002 + *flags &= ~MF_PAX_SEGMEXEC;
56003 + retval = -EINVAL;
56004 + }
56005 +#endif
56006 +
56007 + if ((*flags & MF_PAX_PAGEEXEC)
56008 +
56009 +#ifdef CONFIG_PAX_PAGEEXEC
56010 + && (*flags & MF_PAX_SEGMEXEC)
56011 +#endif
56012 +
56013 + )
56014 + {
56015 + *flags &= ~MF_PAX_PAGEEXEC;
56016 + retval = -EINVAL;
56017 + }
56018 +
56019 + if ((*flags & MF_PAX_MPROTECT)
56020 +
56021 +#ifdef CONFIG_PAX_MPROTECT
56022 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
56023 +#endif
56024 +
56025 + )
56026 + {
56027 + *flags &= ~MF_PAX_MPROTECT;
56028 + retval = -EINVAL;
56029 + }
56030 +
56031 + if ((*flags & MF_PAX_EMUTRAMP)
56032 +
56033 +#ifdef CONFIG_PAX_EMUTRAMP
56034 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
56035 +#endif
56036 +
56037 + )
56038 + {
56039 + *flags &= ~MF_PAX_EMUTRAMP;
56040 + retval = -EINVAL;
56041 + }
56042 +
56043 + return retval;
56044 +}
56045 +
56046 +EXPORT_SYMBOL(pax_check_flags);
56047 +
56048 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
56049 +char *pax_get_path(const struct path *path, char *buf, int buflen)
56050 +{
56051 + char *pathname = d_path(path, buf, buflen);
56052 +
56053 + if (IS_ERR(pathname))
56054 + goto toolong;
56055 +
56056 + pathname = mangle_path(buf, pathname, "\t\n\\");
56057 + if (!pathname)
56058 + goto toolong;
56059 +
56060 + *pathname = 0;
56061 + return buf;
56062 +
56063 +toolong:
56064 + return "<path too long>";
56065 +}
56066 +EXPORT_SYMBOL(pax_get_path);
56067 +
56068 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
56069 +{
56070 + struct task_struct *tsk = current;
56071 + struct mm_struct *mm = current->mm;
56072 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
56073 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
56074 + char *path_exec = NULL;
56075 + char *path_fault = NULL;
56076 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
56077 + siginfo_t info = { };
56078 +
56079 + if (buffer_exec && buffer_fault) {
56080 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
56081 +
56082 + down_read(&mm->mmap_sem);
56083 + vma = mm->mmap;
56084 + while (vma && (!vma_exec || !vma_fault)) {
56085 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
56086 + vma_exec = vma;
56087 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
56088 + vma_fault = vma;
56089 + vma = vma->vm_next;
56090 + }
56091 + if (vma_exec)
56092 + path_exec = pax_get_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
56093 + if (vma_fault) {
56094 + start = vma_fault->vm_start;
56095 + end = vma_fault->vm_end;
56096 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
56097 + if (vma_fault->vm_file)
56098 + path_fault = pax_get_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
56099 + else if ((unsigned long)pc >= mm->start_brk && (unsigned long)pc < mm->brk)
56100 + path_fault = "<heap>";
56101 + else if (vma_fault->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
56102 + path_fault = "<stack>";
56103 + else
56104 + path_fault = "<anonymous mapping>";
56105 + }
56106 + up_read(&mm->mmap_sem);
56107 + }
56108 + if (tsk->signal->curr_ip)
56109 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
56110 + else
56111 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
56112 + 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),
56113 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
56114 + free_page((unsigned long)buffer_exec);
56115 + free_page((unsigned long)buffer_fault);
56116 + pax_report_insns(regs, pc, sp);
56117 + info.si_signo = SIGKILL;
56118 + info.si_errno = 0;
56119 + info.si_code = SI_KERNEL;
56120 + info.si_pid = 0;
56121 + info.si_uid = 0;
56122 + do_coredump(&info);
56123 +}
56124 +#endif
56125 +
56126 +#ifdef CONFIG_PAX_REFCOUNT
56127 +void pax_report_refcount_overflow(struct pt_regs *regs)
56128 +{
56129 + if (current->signal->curr_ip)
56130 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
56131 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
56132 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
56133 + else
56134 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
56135 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
56136 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
56137 + preempt_disable();
56138 + show_regs(regs);
56139 + preempt_enable();
56140 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
56141 +}
56142 +#endif
56143 +
56144 +#ifdef CONFIG_PAX_USERCOPY
56145 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
56146 +static noinline int check_stack_object(const void *obj, unsigned long len)
56147 +{
56148 + const void * const stack = task_stack_page(current);
56149 + const void * const stackend = stack + THREAD_SIZE;
56150 +
56151 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
56152 + const void *frame = NULL;
56153 + const void *oldframe;
56154 +#endif
56155 +
56156 + if (obj + len < obj)
56157 + return -1;
56158 +
56159 + if (obj + len <= stack || stackend <= obj)
56160 + return 0;
56161 +
56162 + if (obj < stack || stackend < obj + len)
56163 + return -1;
56164 +
56165 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
56166 + oldframe = __builtin_frame_address(1);
56167 + if (oldframe)
56168 + frame = __builtin_frame_address(2);
56169 + /*
56170 + low ----------------------------------------------> high
56171 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
56172 + ^----------------^
56173 + allow copies only within here
56174 + */
56175 + while (stack <= frame && frame < stackend) {
56176 + /* if obj + len extends past the last frame, this
56177 + check won't pass and the next frame will be 0,
56178 + causing us to bail out and correctly report
56179 + the copy as invalid
56180 + */
56181 + if (obj + len <= frame)
56182 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
56183 + oldframe = frame;
56184 + frame = *(const void * const *)frame;
56185 + }
56186 + return -1;
56187 +#else
56188 + return 1;
56189 +#endif
56190 +}
56191 +
56192 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
56193 +{
56194 + if (current->signal->curr_ip)
56195 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
56196 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
56197 + else
56198 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
56199 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
56200 + dump_stack();
56201 + gr_handle_kernel_exploit();
56202 + do_group_exit(SIGKILL);
56203 +}
56204 +#endif
56205 +
56206 +#ifdef CONFIG_PAX_USERCOPY
56207 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
56208 +{
56209 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
56210 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
56211 +#ifdef CONFIG_MODULES
56212 + unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
56213 +#else
56214 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
56215 +#endif
56216 +
56217 +#else
56218 + unsigned long textlow = (unsigned long)_stext;
56219 + unsigned long texthigh = (unsigned long)_etext;
56220 +#endif
56221 +
56222 + if (high <= textlow || low > texthigh)
56223 + return false;
56224 + else
56225 + return true;
56226 +}
56227 +#endif
56228 +
56229 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
56230 +{
56231 +
56232 +#ifdef CONFIG_PAX_USERCOPY
56233 + const char *type;
56234 +
56235 + if (!n)
56236 + return;
56237 +
56238 + type = check_heap_object(ptr, n);
56239 + if (!type) {
56240 + int ret = check_stack_object(ptr, n);
56241 + if (ret == 1 || ret == 2)
56242 + return;
56243 + if (ret == 0) {
56244 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
56245 + type = "<kernel text>";
56246 + else
56247 + return;
56248 + } else
56249 + type = "<process stack>";
56250 + }
56251 +
56252 + pax_report_usercopy(ptr, n, to_user, type);
56253 +#endif
56254 +
56255 +}
56256 +EXPORT_SYMBOL(__check_object_size);
56257 +
56258 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
56259 +void pax_track_stack(void)
56260 +{
56261 + unsigned long sp = (unsigned long)&sp;
56262 + if (sp < current_thread_info()->lowest_stack &&
56263 + sp > (unsigned long)task_stack_page(current))
56264 + current_thread_info()->lowest_stack = sp;
56265 +}
56266 +EXPORT_SYMBOL(pax_track_stack);
56267 +#endif
56268 +
56269 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
56270 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
56271 +{
56272 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
56273 + dump_stack();
56274 + do_group_exit(SIGKILL);
56275 +}
56276 +EXPORT_SYMBOL(report_size_overflow);
56277 +#endif
56278 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
56279 index 9f9992b..8b59411 100644
56280 --- a/fs/ext2/balloc.c
56281 +++ b/fs/ext2/balloc.c
56282 @@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
56283
56284 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
56285 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
56286 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
56287 + if (free_blocks < root_blocks + 1 &&
56288 !uid_eq(sbi->s_resuid, current_fsuid()) &&
56289 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
56290 - !in_group_p (sbi->s_resgid))) {
56291 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
56292 return 0;
56293 }
56294 return 1;
56295 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
56296 index 22548f5..41521d8 100644
56297 --- a/fs/ext3/balloc.c
56298 +++ b/fs/ext3/balloc.c
56299 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
56300
56301 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
56302 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
56303 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
56304 + if (free_blocks < root_blocks + 1 &&
56305 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
56306 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
56307 - !in_group_p (sbi->s_resgid))) {
56308 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
56309 return 0;
56310 }
56311 return 1;
56312 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
56313 index 3742e4c..69a797f 100644
56314 --- a/fs/ext4/balloc.c
56315 +++ b/fs/ext4/balloc.c
56316 @@ -528,8 +528,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
56317 /* Hm, nope. Are (enough) root reserved clusters available? */
56318 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
56319 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
56320 - capable(CAP_SYS_RESOURCE) ||
56321 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
56322 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
56323 + capable_nolog(CAP_SYS_RESOURCE)) {
56324
56325 if (free_clusters >= (nclusters + dirty_clusters +
56326 resv_clusters))
56327 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
56328 index 5aae3d1..b5da7f8 100644
56329 --- a/fs/ext4/ext4.h
56330 +++ b/fs/ext4/ext4.h
56331 @@ -1252,19 +1252,19 @@ struct ext4_sb_info {
56332 unsigned long s_mb_last_start;
56333
56334 /* stats for buddy allocator */
56335 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
56336 - atomic_t s_bal_success; /* we found long enough chunks */
56337 - atomic_t s_bal_allocated; /* in blocks */
56338 - atomic_t s_bal_ex_scanned; /* total extents scanned */
56339 - atomic_t s_bal_goals; /* goal hits */
56340 - atomic_t s_bal_breaks; /* too long searches */
56341 - atomic_t s_bal_2orders; /* 2^order hits */
56342 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
56343 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
56344 + atomic_unchecked_t s_bal_allocated; /* in blocks */
56345 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
56346 + atomic_unchecked_t s_bal_goals; /* goal hits */
56347 + atomic_unchecked_t s_bal_breaks; /* too long searches */
56348 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
56349 spinlock_t s_bal_lock;
56350 unsigned long s_mb_buddies_generated;
56351 unsigned long long s_mb_generation_time;
56352 - atomic_t s_mb_lost_chunks;
56353 - atomic_t s_mb_preallocated;
56354 - atomic_t s_mb_discarded;
56355 + atomic_unchecked_t s_mb_lost_chunks;
56356 + atomic_unchecked_t s_mb_preallocated;
56357 + atomic_unchecked_t s_mb_discarded;
56358 atomic_t s_lock_busy;
56359
56360 /* locality groups */
56361 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
56362 index 59c6750..a549154 100644
56363 --- a/fs/ext4/mballoc.c
56364 +++ b/fs/ext4/mballoc.c
56365 @@ -1865,7 +1865,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
56366 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
56367
56368 if (EXT4_SB(sb)->s_mb_stats)
56369 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
56370 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
56371
56372 break;
56373 }
56374 @@ -2170,7 +2170,7 @@ repeat:
56375 ac->ac_status = AC_STATUS_CONTINUE;
56376 ac->ac_flags |= EXT4_MB_HINT_FIRST;
56377 cr = 3;
56378 - atomic_inc(&sbi->s_mb_lost_chunks);
56379 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
56380 goto repeat;
56381 }
56382 }
56383 @@ -2678,25 +2678,25 @@ int ext4_mb_release(struct super_block *sb)
56384 if (sbi->s_mb_stats) {
56385 ext4_msg(sb, KERN_INFO,
56386 "mballoc: %u blocks %u reqs (%u success)",
56387 - atomic_read(&sbi->s_bal_allocated),
56388 - atomic_read(&sbi->s_bal_reqs),
56389 - atomic_read(&sbi->s_bal_success));
56390 + atomic_read_unchecked(&sbi->s_bal_allocated),
56391 + atomic_read_unchecked(&sbi->s_bal_reqs),
56392 + atomic_read_unchecked(&sbi->s_bal_success));
56393 ext4_msg(sb, KERN_INFO,
56394 "mballoc: %u extents scanned, %u goal hits, "
56395 "%u 2^N hits, %u breaks, %u lost",
56396 - atomic_read(&sbi->s_bal_ex_scanned),
56397 - atomic_read(&sbi->s_bal_goals),
56398 - atomic_read(&sbi->s_bal_2orders),
56399 - atomic_read(&sbi->s_bal_breaks),
56400 - atomic_read(&sbi->s_mb_lost_chunks));
56401 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
56402 + atomic_read_unchecked(&sbi->s_bal_goals),
56403 + atomic_read_unchecked(&sbi->s_bal_2orders),
56404 + atomic_read_unchecked(&sbi->s_bal_breaks),
56405 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
56406 ext4_msg(sb, KERN_INFO,
56407 "mballoc: %lu generated and it took %Lu",
56408 sbi->s_mb_buddies_generated,
56409 sbi->s_mb_generation_time);
56410 ext4_msg(sb, KERN_INFO,
56411 "mballoc: %u preallocated, %u discarded",
56412 - atomic_read(&sbi->s_mb_preallocated),
56413 - atomic_read(&sbi->s_mb_discarded));
56414 + atomic_read_unchecked(&sbi->s_mb_preallocated),
56415 + atomic_read_unchecked(&sbi->s_mb_discarded));
56416 }
56417
56418 free_percpu(sbi->s_locality_groups);
56419 @@ -3150,16 +3150,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
56420 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
56421
56422 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
56423 - atomic_inc(&sbi->s_bal_reqs);
56424 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
56425 + atomic_inc_unchecked(&sbi->s_bal_reqs);
56426 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
56427 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
56428 - atomic_inc(&sbi->s_bal_success);
56429 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
56430 + atomic_inc_unchecked(&sbi->s_bal_success);
56431 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
56432 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
56433 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
56434 - atomic_inc(&sbi->s_bal_goals);
56435 + atomic_inc_unchecked(&sbi->s_bal_goals);
56436 if (ac->ac_found > sbi->s_mb_max_to_scan)
56437 - atomic_inc(&sbi->s_bal_breaks);
56438 + atomic_inc_unchecked(&sbi->s_bal_breaks);
56439 }
56440
56441 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
56442 @@ -3559,7 +3559,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
56443 trace_ext4_mb_new_inode_pa(ac, pa);
56444
56445 ext4_mb_use_inode_pa(ac, pa);
56446 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
56447 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
56448
56449 ei = EXT4_I(ac->ac_inode);
56450 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
56451 @@ -3619,7 +3619,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
56452 trace_ext4_mb_new_group_pa(ac, pa);
56453
56454 ext4_mb_use_group_pa(ac, pa);
56455 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
56456 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
56457
56458 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
56459 lg = ac->ac_lg;
56460 @@ -3708,7 +3708,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
56461 * from the bitmap and continue.
56462 */
56463 }
56464 - atomic_add(free, &sbi->s_mb_discarded);
56465 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
56466
56467 return err;
56468 }
56469 @@ -3726,7 +3726,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
56470 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
56471 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
56472 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
56473 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
56474 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
56475 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
56476
56477 return 0;
56478 diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
56479 index 214461e..3614c89 100644
56480 --- a/fs/ext4/mmp.c
56481 +++ b/fs/ext4/mmp.c
56482 @@ -113,7 +113,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
56483 void __dump_mmp_msg(struct super_block *sb, struct mmp_struct *mmp,
56484 const char *function, unsigned int line, const char *msg)
56485 {
56486 - __ext4_warning(sb, function, line, msg);
56487 + __ext4_warning(sb, function, line, "%s", msg);
56488 __ext4_warning(sb, function, line,
56489 "MMP failure info: last update time: %llu, last update "
56490 "node: %s, last update device: %s\n",
56491 diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
56492 index 49d3c01..9579efd 100644
56493 --- a/fs/ext4/resize.c
56494 +++ b/fs/ext4/resize.c
56495 @@ -79,12 +79,20 @@ static int verify_group_input(struct super_block *sb,
56496 ext4_fsblk_t end = start + input->blocks_count;
56497 ext4_group_t group = input->group;
56498 ext4_fsblk_t itend = input->inode_table + sbi->s_itb_per_group;
56499 - unsigned overhead = ext4_group_overhead_blocks(sb, group);
56500 - ext4_fsblk_t metaend = start + overhead;
56501 + unsigned overhead;
56502 + ext4_fsblk_t metaend;
56503 struct buffer_head *bh = NULL;
56504 ext4_grpblk_t free_blocks_count, offset;
56505 int err = -EINVAL;
56506
56507 + if (group != sbi->s_groups_count) {
56508 + ext4_warning(sb, "Cannot add at group %u (only %u groups)",
56509 + input->group, sbi->s_groups_count);
56510 + return -EINVAL;
56511 + }
56512 +
56513 + overhead = ext4_group_overhead_blocks(sb, group);
56514 + metaend = start + overhead;
56515 input->free_blocks_count = free_blocks_count =
56516 input->blocks_count - 2 - overhead - sbi->s_itb_per_group;
56517
56518 @@ -96,10 +104,7 @@ static int verify_group_input(struct super_block *sb,
56519 free_blocks_count, input->reserved_blocks);
56520
56521 ext4_get_group_no_and_offset(sb, start, NULL, &offset);
56522 - if (group != sbi->s_groups_count)
56523 - ext4_warning(sb, "Cannot add at group %u (only %u groups)",
56524 - input->group, sbi->s_groups_count);
56525 - else if (offset != 0)
56526 + if (offset != 0)
56527 ext4_warning(sb, "Last group not full");
56528 else if (input->reserved_blocks > input->blocks_count / 5)
56529 ext4_warning(sb, "Reserved blocks too high (%u)",
56530 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
56531 index 3f7c39e..227f24f 100644
56532 --- a/fs/ext4/super.c
56533 +++ b/fs/ext4/super.c
56534 @@ -1236,7 +1236,7 @@ static ext4_fsblk_t get_sb_block(void **data)
56535 }
56536
56537 #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
56538 -static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
56539 +static const char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
56540 "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n";
56541
56542 #ifdef CONFIG_QUOTA
56543 @@ -2372,7 +2372,7 @@ struct ext4_attr {
56544 ssize_t (*store)(struct ext4_attr *, struct ext4_sb_info *,
56545 const char *, size_t);
56546 int offset;
56547 -};
56548 +} __do_const;
56549
56550 static int parse_strtoull(const char *buf,
56551 unsigned long long max, unsigned long long *value)
56552 diff --git a/fs/fcntl.c b/fs/fcntl.c
56553 index 6599222..e7bf0de 100644
56554 --- a/fs/fcntl.c
56555 +++ b/fs/fcntl.c
56556 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
56557 if (err)
56558 return err;
56559
56560 + if (gr_handle_chroot_fowner(pid, type))
56561 + return -ENOENT;
56562 + if (gr_check_protected_task_fowner(pid, type))
56563 + return -EACCES;
56564 +
56565 f_modown(filp, pid, type, force);
56566 return 0;
56567 }
56568 diff --git a/fs/fhandle.c b/fs/fhandle.c
56569 index 999ff5c..41f4109 100644
56570 --- a/fs/fhandle.c
56571 +++ b/fs/fhandle.c
56572 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
56573 } else
56574 retval = 0;
56575 /* copy the mount id */
56576 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
56577 - sizeof(*mnt_id)) ||
56578 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
56579 copy_to_user(ufh, handle,
56580 sizeof(struct file_handle) + handle_bytes))
56581 retval = -EFAULT;
56582 diff --git a/fs/file.c b/fs/file.c
56583 index 4a78f98..9447397 100644
56584 --- a/fs/file.c
56585 +++ b/fs/file.c
56586 @@ -16,6 +16,7 @@
56587 #include <linux/slab.h>
56588 #include <linux/vmalloc.h>
56589 #include <linux/file.h>
56590 +#include <linux/security.h>
56591 #include <linux/fdtable.h>
56592 #include <linux/bitops.h>
56593 #include <linux/interrupt.h>
56594 @@ -828,6 +829,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
56595 if (!file)
56596 return __close_fd(files, fd);
56597
56598 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
56599 if (fd >= rlimit(RLIMIT_NOFILE))
56600 return -EBADF;
56601
56602 @@ -854,6 +856,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
56603 if (unlikely(oldfd == newfd))
56604 return -EINVAL;
56605
56606 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
56607 if (newfd >= rlimit(RLIMIT_NOFILE))
56608 return -EBADF;
56609
56610 @@ -909,6 +912,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
56611 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
56612 {
56613 int err;
56614 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
56615 if (from >= rlimit(RLIMIT_NOFILE))
56616 return -EINVAL;
56617 err = alloc_fd(from, flags);
56618 diff --git a/fs/filesystems.c b/fs/filesystems.c
56619 index 92567d9..fcd8cbf 100644
56620 --- a/fs/filesystems.c
56621 +++ b/fs/filesystems.c
56622 @@ -273,7 +273,11 @@ struct file_system_type *get_fs_type(const char *name)
56623 int len = dot ? dot - name : strlen(name);
56624
56625 fs = __get_fs_type(name, len);
56626 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
56627 + if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
56628 +#else
56629 if (!fs && (request_module("fs-%.*s", len, name) == 0))
56630 +#endif
56631 fs = __get_fs_type(name, len);
56632
56633 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
56634 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
56635 index d8ac61d..79a36f0 100644
56636 --- a/fs/fs_struct.c
56637 +++ b/fs/fs_struct.c
56638 @@ -4,6 +4,7 @@
56639 #include <linux/path.h>
56640 #include <linux/slab.h>
56641 #include <linux/fs_struct.h>
56642 +#include <linux/grsecurity.h>
56643 #include "internal.h"
56644
56645 /*
56646 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
56647 write_seqcount_begin(&fs->seq);
56648 old_root = fs->root;
56649 fs->root = *path;
56650 + gr_set_chroot_entries(current, path);
56651 write_seqcount_end(&fs->seq);
56652 spin_unlock(&fs->lock);
56653 if (old_root.dentry)
56654 @@ -67,6 +69,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
56655 int hits = 0;
56656 spin_lock(&fs->lock);
56657 write_seqcount_begin(&fs->seq);
56658 + /* this root replacement is only done by pivot_root,
56659 + leave grsec's chroot tagging alone for this task
56660 + so that a pivoted root isn't treated as a chroot
56661 + */
56662 hits += replace_path(&fs->root, old_root, new_root);
56663 hits += replace_path(&fs->pwd, old_root, new_root);
56664 write_seqcount_end(&fs->seq);
56665 @@ -99,7 +105,8 @@ void exit_fs(struct task_struct *tsk)
56666 task_lock(tsk);
56667 spin_lock(&fs->lock);
56668 tsk->fs = NULL;
56669 - kill = !--fs->users;
56670 + gr_clear_chroot_entries(tsk);
56671 + kill = !atomic_dec_return(&fs->users);
56672 spin_unlock(&fs->lock);
56673 task_unlock(tsk);
56674 if (kill)
56675 @@ -112,7 +119,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
56676 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
56677 /* We don't need to lock fs - think why ;-) */
56678 if (fs) {
56679 - fs->users = 1;
56680 + atomic_set(&fs->users, 1);
56681 fs->in_exec = 0;
56682 spin_lock_init(&fs->lock);
56683 seqcount_init(&fs->seq);
56684 @@ -121,6 +128,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
56685 spin_lock(&old->lock);
56686 fs->root = old->root;
56687 path_get(&fs->root);
56688 + /* instead of calling gr_set_chroot_entries here,
56689 + we call it from every caller of this function
56690 + */
56691 fs->pwd = old->pwd;
56692 path_get(&fs->pwd);
56693 spin_unlock(&old->lock);
56694 @@ -139,8 +149,9 @@ int unshare_fs_struct(void)
56695
56696 task_lock(current);
56697 spin_lock(&fs->lock);
56698 - kill = !--fs->users;
56699 + kill = !atomic_dec_return(&fs->users);
56700 current->fs = new_fs;
56701 + gr_set_chroot_entries(current, &new_fs->root);
56702 spin_unlock(&fs->lock);
56703 task_unlock(current);
56704
56705 @@ -153,13 +164,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
56706
56707 int current_umask(void)
56708 {
56709 - return current->fs->umask;
56710 + return current->fs->umask | gr_acl_umask();
56711 }
56712 EXPORT_SYMBOL(current_umask);
56713
56714 /* to be mentioned only in INIT_TASK */
56715 struct fs_struct init_fs = {
56716 - .users = 1,
56717 + .users = ATOMIC_INIT(1),
56718 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
56719 .seq = SEQCNT_ZERO,
56720 .umask = 0022,
56721 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
56722 index e2cba1f..20319c5 100644
56723 --- a/fs/fscache/cookie.c
56724 +++ b/fs/fscache/cookie.c
56725 @@ -19,7 +19,7 @@
56726
56727 struct kmem_cache *fscache_cookie_jar;
56728
56729 -static atomic_t fscache_object_debug_id = ATOMIC_INIT(0);
56730 +static atomic_unchecked_t fscache_object_debug_id = ATOMIC_INIT(0);
56731
56732 static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie);
56733 static int fscache_alloc_object(struct fscache_cache *cache,
56734 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
56735 parent ? (char *) parent->def->name : "<no-parent>",
56736 def->name, netfs_data);
56737
56738 - fscache_stat(&fscache_n_acquires);
56739 + fscache_stat_unchecked(&fscache_n_acquires);
56740
56741 /* if there's no parent cookie, then we don't create one here either */
56742 if (!parent) {
56743 - fscache_stat(&fscache_n_acquires_null);
56744 + fscache_stat_unchecked(&fscache_n_acquires_null);
56745 _leave(" [no parent]");
56746 return NULL;
56747 }
56748 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
56749 /* allocate and initialise a cookie */
56750 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
56751 if (!cookie) {
56752 - fscache_stat(&fscache_n_acquires_oom);
56753 + fscache_stat_unchecked(&fscache_n_acquires_oom);
56754 _leave(" [ENOMEM]");
56755 return NULL;
56756 }
56757 @@ -109,13 +109,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
56758
56759 switch (cookie->def->type) {
56760 case FSCACHE_COOKIE_TYPE_INDEX:
56761 - fscache_stat(&fscache_n_cookie_index);
56762 + fscache_stat_unchecked(&fscache_n_cookie_index);
56763 break;
56764 case FSCACHE_COOKIE_TYPE_DATAFILE:
56765 - fscache_stat(&fscache_n_cookie_data);
56766 + fscache_stat_unchecked(&fscache_n_cookie_data);
56767 break;
56768 default:
56769 - fscache_stat(&fscache_n_cookie_special);
56770 + fscache_stat_unchecked(&fscache_n_cookie_special);
56771 break;
56772 }
56773
56774 @@ -126,13 +126,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
56775 if (fscache_acquire_non_index_cookie(cookie) < 0) {
56776 atomic_dec(&parent->n_children);
56777 __fscache_cookie_put(cookie);
56778 - fscache_stat(&fscache_n_acquires_nobufs);
56779 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
56780 _leave(" = NULL");
56781 return NULL;
56782 }
56783 }
56784
56785 - fscache_stat(&fscache_n_acquires_ok);
56786 + fscache_stat_unchecked(&fscache_n_acquires_ok);
56787 _leave(" = %p", cookie);
56788 return cookie;
56789 }
56790 @@ -168,7 +168,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
56791 cache = fscache_select_cache_for_object(cookie->parent);
56792 if (!cache) {
56793 up_read(&fscache_addremove_sem);
56794 - fscache_stat(&fscache_n_acquires_no_cache);
56795 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
56796 _leave(" = -ENOMEDIUM [no cache]");
56797 return -ENOMEDIUM;
56798 }
56799 @@ -255,14 +255,14 @@ static int fscache_alloc_object(struct fscache_cache *cache,
56800 object = cache->ops->alloc_object(cache, cookie);
56801 fscache_stat_d(&fscache_n_cop_alloc_object);
56802 if (IS_ERR(object)) {
56803 - fscache_stat(&fscache_n_object_no_alloc);
56804 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
56805 ret = PTR_ERR(object);
56806 goto error;
56807 }
56808
56809 - fscache_stat(&fscache_n_object_alloc);
56810 + fscache_stat_unchecked(&fscache_n_object_alloc);
56811
56812 - object->debug_id = atomic_inc_return(&fscache_object_debug_id);
56813 + object->debug_id = atomic_inc_return_unchecked(&fscache_object_debug_id);
56814
56815 _debug("ALLOC OBJ%x: %s {%lx}",
56816 object->debug_id, cookie->def->name, object->events);
56817 @@ -376,7 +376,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
56818
56819 _enter("{%s}", cookie->def->name);
56820
56821 - fscache_stat(&fscache_n_invalidates);
56822 + fscache_stat_unchecked(&fscache_n_invalidates);
56823
56824 /* Only permit invalidation of data files. Invalidating an index will
56825 * require the caller to release all its attachments to the tree rooted
56826 @@ -434,10 +434,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
56827 {
56828 struct fscache_object *object;
56829
56830 - fscache_stat(&fscache_n_updates);
56831 + fscache_stat_unchecked(&fscache_n_updates);
56832
56833 if (!cookie) {
56834 - fscache_stat(&fscache_n_updates_null);
56835 + fscache_stat_unchecked(&fscache_n_updates_null);
56836 _leave(" [no cookie]");
56837 return;
56838 }
56839 @@ -471,12 +471,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
56840 struct fscache_object *object;
56841 unsigned long event;
56842
56843 - fscache_stat(&fscache_n_relinquishes);
56844 + fscache_stat_unchecked(&fscache_n_relinquishes);
56845 if (retire)
56846 - fscache_stat(&fscache_n_relinquishes_retire);
56847 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
56848
56849 if (!cookie) {
56850 - fscache_stat(&fscache_n_relinquishes_null);
56851 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
56852 _leave(" [no cookie]");
56853 return;
56854 }
56855 @@ -492,7 +492,7 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
56856
56857 /* wait for the cookie to finish being instantiated (or to fail) */
56858 if (test_bit(FSCACHE_COOKIE_CREATING, &cookie->flags)) {
56859 - fscache_stat(&fscache_n_relinquishes_waitcrt);
56860 + fscache_stat_unchecked(&fscache_n_relinquishes_waitcrt);
56861 wait_on_bit(&cookie->flags, FSCACHE_COOKIE_CREATING,
56862 fscache_wait_bit, TASK_UNINTERRUPTIBLE);
56863 }
56864 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
56865 index ee38fef..0a326d4 100644
56866 --- a/fs/fscache/internal.h
56867 +++ b/fs/fscache/internal.h
56868 @@ -148,101 +148,101 @@ extern void fscache_proc_cleanup(void);
56869 * stats.c
56870 */
56871 #ifdef CONFIG_FSCACHE_STATS
56872 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
56873 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
56874 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
56875 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
56876
56877 -extern atomic_t fscache_n_op_pend;
56878 -extern atomic_t fscache_n_op_run;
56879 -extern atomic_t fscache_n_op_enqueue;
56880 -extern atomic_t fscache_n_op_deferred_release;
56881 -extern atomic_t fscache_n_op_release;
56882 -extern atomic_t fscache_n_op_gc;
56883 -extern atomic_t fscache_n_op_cancelled;
56884 -extern atomic_t fscache_n_op_rejected;
56885 +extern atomic_unchecked_t fscache_n_op_pend;
56886 +extern atomic_unchecked_t fscache_n_op_run;
56887 +extern atomic_unchecked_t fscache_n_op_enqueue;
56888 +extern atomic_unchecked_t fscache_n_op_deferred_release;
56889 +extern atomic_unchecked_t fscache_n_op_release;
56890 +extern atomic_unchecked_t fscache_n_op_gc;
56891 +extern atomic_unchecked_t fscache_n_op_cancelled;
56892 +extern atomic_unchecked_t fscache_n_op_rejected;
56893
56894 -extern atomic_t fscache_n_attr_changed;
56895 -extern atomic_t fscache_n_attr_changed_ok;
56896 -extern atomic_t fscache_n_attr_changed_nobufs;
56897 -extern atomic_t fscache_n_attr_changed_nomem;
56898 -extern atomic_t fscache_n_attr_changed_calls;
56899 +extern atomic_unchecked_t fscache_n_attr_changed;
56900 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
56901 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
56902 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
56903 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
56904
56905 -extern atomic_t fscache_n_allocs;
56906 -extern atomic_t fscache_n_allocs_ok;
56907 -extern atomic_t fscache_n_allocs_wait;
56908 -extern atomic_t fscache_n_allocs_nobufs;
56909 -extern atomic_t fscache_n_allocs_intr;
56910 -extern atomic_t fscache_n_allocs_object_dead;
56911 -extern atomic_t fscache_n_alloc_ops;
56912 -extern atomic_t fscache_n_alloc_op_waits;
56913 +extern atomic_unchecked_t fscache_n_allocs;
56914 +extern atomic_unchecked_t fscache_n_allocs_ok;
56915 +extern atomic_unchecked_t fscache_n_allocs_wait;
56916 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
56917 +extern atomic_unchecked_t fscache_n_allocs_intr;
56918 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
56919 +extern atomic_unchecked_t fscache_n_alloc_ops;
56920 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
56921
56922 -extern atomic_t fscache_n_retrievals;
56923 -extern atomic_t fscache_n_retrievals_ok;
56924 -extern atomic_t fscache_n_retrievals_wait;
56925 -extern atomic_t fscache_n_retrievals_nodata;
56926 -extern atomic_t fscache_n_retrievals_nobufs;
56927 -extern atomic_t fscache_n_retrievals_intr;
56928 -extern atomic_t fscache_n_retrievals_nomem;
56929 -extern atomic_t fscache_n_retrievals_object_dead;
56930 -extern atomic_t fscache_n_retrieval_ops;
56931 -extern atomic_t fscache_n_retrieval_op_waits;
56932 +extern atomic_unchecked_t fscache_n_retrievals;
56933 +extern atomic_unchecked_t fscache_n_retrievals_ok;
56934 +extern atomic_unchecked_t fscache_n_retrievals_wait;
56935 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
56936 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
56937 +extern atomic_unchecked_t fscache_n_retrievals_intr;
56938 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
56939 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
56940 +extern atomic_unchecked_t fscache_n_retrieval_ops;
56941 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
56942
56943 -extern atomic_t fscache_n_stores;
56944 -extern atomic_t fscache_n_stores_ok;
56945 -extern atomic_t fscache_n_stores_again;
56946 -extern atomic_t fscache_n_stores_nobufs;
56947 -extern atomic_t fscache_n_stores_oom;
56948 -extern atomic_t fscache_n_store_ops;
56949 -extern atomic_t fscache_n_store_calls;
56950 -extern atomic_t fscache_n_store_pages;
56951 -extern atomic_t fscache_n_store_radix_deletes;
56952 -extern atomic_t fscache_n_store_pages_over_limit;
56953 +extern atomic_unchecked_t fscache_n_stores;
56954 +extern atomic_unchecked_t fscache_n_stores_ok;
56955 +extern atomic_unchecked_t fscache_n_stores_again;
56956 +extern atomic_unchecked_t fscache_n_stores_nobufs;
56957 +extern atomic_unchecked_t fscache_n_stores_oom;
56958 +extern atomic_unchecked_t fscache_n_store_ops;
56959 +extern atomic_unchecked_t fscache_n_store_calls;
56960 +extern atomic_unchecked_t fscache_n_store_pages;
56961 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
56962 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
56963
56964 -extern atomic_t fscache_n_store_vmscan_not_storing;
56965 -extern atomic_t fscache_n_store_vmscan_gone;
56966 -extern atomic_t fscache_n_store_vmscan_busy;
56967 -extern atomic_t fscache_n_store_vmscan_cancelled;
56968 -extern atomic_t fscache_n_store_vmscan_wait;
56969 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
56970 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
56971 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
56972 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
56973 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
56974
56975 -extern atomic_t fscache_n_marks;
56976 -extern atomic_t fscache_n_uncaches;
56977 +extern atomic_unchecked_t fscache_n_marks;
56978 +extern atomic_unchecked_t fscache_n_uncaches;
56979
56980 -extern atomic_t fscache_n_acquires;
56981 -extern atomic_t fscache_n_acquires_null;
56982 -extern atomic_t fscache_n_acquires_no_cache;
56983 -extern atomic_t fscache_n_acquires_ok;
56984 -extern atomic_t fscache_n_acquires_nobufs;
56985 -extern atomic_t fscache_n_acquires_oom;
56986 +extern atomic_unchecked_t fscache_n_acquires;
56987 +extern atomic_unchecked_t fscache_n_acquires_null;
56988 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
56989 +extern atomic_unchecked_t fscache_n_acquires_ok;
56990 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
56991 +extern atomic_unchecked_t fscache_n_acquires_oom;
56992
56993 -extern atomic_t fscache_n_invalidates;
56994 -extern atomic_t fscache_n_invalidates_run;
56995 +extern atomic_unchecked_t fscache_n_invalidates;
56996 +extern atomic_unchecked_t fscache_n_invalidates_run;
56997
56998 -extern atomic_t fscache_n_updates;
56999 -extern atomic_t fscache_n_updates_null;
57000 -extern atomic_t fscache_n_updates_run;
57001 +extern atomic_unchecked_t fscache_n_updates;
57002 +extern atomic_unchecked_t fscache_n_updates_null;
57003 +extern atomic_unchecked_t fscache_n_updates_run;
57004
57005 -extern atomic_t fscache_n_relinquishes;
57006 -extern atomic_t fscache_n_relinquishes_null;
57007 -extern atomic_t fscache_n_relinquishes_waitcrt;
57008 -extern atomic_t fscache_n_relinquishes_retire;
57009 +extern atomic_unchecked_t fscache_n_relinquishes;
57010 +extern atomic_unchecked_t fscache_n_relinquishes_null;
57011 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
57012 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
57013
57014 -extern atomic_t fscache_n_cookie_index;
57015 -extern atomic_t fscache_n_cookie_data;
57016 -extern atomic_t fscache_n_cookie_special;
57017 +extern atomic_unchecked_t fscache_n_cookie_index;
57018 +extern atomic_unchecked_t fscache_n_cookie_data;
57019 +extern atomic_unchecked_t fscache_n_cookie_special;
57020
57021 -extern atomic_t fscache_n_object_alloc;
57022 -extern atomic_t fscache_n_object_no_alloc;
57023 -extern atomic_t fscache_n_object_lookups;
57024 -extern atomic_t fscache_n_object_lookups_negative;
57025 -extern atomic_t fscache_n_object_lookups_positive;
57026 -extern atomic_t fscache_n_object_lookups_timed_out;
57027 -extern atomic_t fscache_n_object_created;
57028 -extern atomic_t fscache_n_object_avail;
57029 -extern atomic_t fscache_n_object_dead;
57030 +extern atomic_unchecked_t fscache_n_object_alloc;
57031 +extern atomic_unchecked_t fscache_n_object_no_alloc;
57032 +extern atomic_unchecked_t fscache_n_object_lookups;
57033 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
57034 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
57035 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
57036 +extern atomic_unchecked_t fscache_n_object_created;
57037 +extern atomic_unchecked_t fscache_n_object_avail;
57038 +extern atomic_unchecked_t fscache_n_object_dead;
57039
57040 -extern atomic_t fscache_n_checkaux_none;
57041 -extern atomic_t fscache_n_checkaux_okay;
57042 -extern atomic_t fscache_n_checkaux_update;
57043 -extern atomic_t fscache_n_checkaux_obsolete;
57044 +extern atomic_unchecked_t fscache_n_checkaux_none;
57045 +extern atomic_unchecked_t fscache_n_checkaux_okay;
57046 +extern atomic_unchecked_t fscache_n_checkaux_update;
57047 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
57048
57049 extern atomic_t fscache_n_cop_alloc_object;
57050 extern atomic_t fscache_n_cop_lookup_object;
57051 @@ -267,6 +267,11 @@ static inline void fscache_stat(atomic_t *stat)
57052 atomic_inc(stat);
57053 }
57054
57055 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
57056 +{
57057 + atomic_inc_unchecked(stat);
57058 +}
57059 +
57060 static inline void fscache_stat_d(atomic_t *stat)
57061 {
57062 atomic_dec(stat);
57063 @@ -279,6 +284,7 @@ extern const struct file_operations fscache_stats_fops;
57064
57065 #define __fscache_stat(stat) (NULL)
57066 #define fscache_stat(stat) do {} while (0)
57067 +#define fscache_stat_unchecked(stat) do {} while (0)
57068 #define fscache_stat_d(stat) do {} while (0)
57069 #endif
57070
57071 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
57072 index 50d41c1..10ee117 100644
57073 --- a/fs/fscache/object.c
57074 +++ b/fs/fscache/object.c
57075 @@ -143,7 +143,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
57076 /* Invalidate an object on disk */
57077 case FSCACHE_OBJECT_INVALIDATING:
57078 clear_bit(FSCACHE_OBJECT_EV_INVALIDATE, &object->events);
57079 - fscache_stat(&fscache_n_invalidates_run);
57080 + fscache_stat_unchecked(&fscache_n_invalidates_run);
57081 fscache_stat(&fscache_n_cop_invalidate_object);
57082 fscache_invalidate_object(object);
57083 fscache_stat_d(&fscache_n_cop_invalidate_object);
57084 @@ -153,7 +153,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
57085 /* update the object metadata on disk */
57086 case FSCACHE_OBJECT_UPDATING:
57087 clear_bit(FSCACHE_OBJECT_EV_UPDATE, &object->events);
57088 - fscache_stat(&fscache_n_updates_run);
57089 + fscache_stat_unchecked(&fscache_n_updates_run);
57090 fscache_stat(&fscache_n_cop_update_object);
57091 object->cache->ops->update_object(object);
57092 fscache_stat_d(&fscache_n_cop_update_object);
57093 @@ -242,7 +242,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
57094 spin_lock(&object->lock);
57095 object->state = FSCACHE_OBJECT_DEAD;
57096 spin_unlock(&object->lock);
57097 - fscache_stat(&fscache_n_object_dead);
57098 + fscache_stat_unchecked(&fscache_n_object_dead);
57099 goto terminal_transit;
57100
57101 /* handle the parent cache of this object being withdrawn from
57102 @@ -257,7 +257,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
57103 spin_lock(&object->lock);
57104 object->state = FSCACHE_OBJECT_DEAD;
57105 spin_unlock(&object->lock);
57106 - fscache_stat(&fscache_n_object_dead);
57107 + fscache_stat_unchecked(&fscache_n_object_dead);
57108 goto terminal_transit;
57109
57110 /* complain about the object being woken up once it is
57111 @@ -495,7 +495,7 @@ static void fscache_lookup_object(struct fscache_object *object)
57112 parent->cookie->def->name, cookie->def->name,
57113 object->cache->tag->name);
57114
57115 - fscache_stat(&fscache_n_object_lookups);
57116 + fscache_stat_unchecked(&fscache_n_object_lookups);
57117 fscache_stat(&fscache_n_cop_lookup_object);
57118 ret = object->cache->ops->lookup_object(object);
57119 fscache_stat_d(&fscache_n_cop_lookup_object);
57120 @@ -506,7 +506,7 @@ static void fscache_lookup_object(struct fscache_object *object)
57121 if (ret == -ETIMEDOUT) {
57122 /* probably stuck behind another object, so move this one to
57123 * the back of the queue */
57124 - fscache_stat(&fscache_n_object_lookups_timed_out);
57125 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
57126 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
57127 }
57128
57129 @@ -529,7 +529,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
57130
57131 spin_lock(&object->lock);
57132 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
57133 - fscache_stat(&fscache_n_object_lookups_negative);
57134 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
57135
57136 /* transit here to allow write requests to begin stacking up
57137 * and read requests to begin returning ENODATA */
57138 @@ -575,7 +575,7 @@ void fscache_obtained_object(struct fscache_object *object)
57139 * result, in which case there may be data available */
57140 spin_lock(&object->lock);
57141 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
57142 - fscache_stat(&fscache_n_object_lookups_positive);
57143 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
57144
57145 clear_bit(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
57146
57147 @@ -589,7 +589,7 @@ void fscache_obtained_object(struct fscache_object *object)
57148 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
57149 } else {
57150 ASSERTCMP(object->state, ==, FSCACHE_OBJECT_CREATING);
57151 - fscache_stat(&fscache_n_object_created);
57152 + fscache_stat_unchecked(&fscache_n_object_created);
57153
57154 object->state = FSCACHE_OBJECT_AVAILABLE;
57155 spin_unlock(&object->lock);
57156 @@ -634,7 +634,7 @@ static void fscache_object_available(struct fscache_object *object)
57157 fscache_enqueue_dependents(object);
57158
57159 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
57160 - fscache_stat(&fscache_n_object_avail);
57161 + fscache_stat_unchecked(&fscache_n_object_avail);
57162
57163 _leave("");
57164 }
57165 @@ -894,7 +894,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
57166 enum fscache_checkaux result;
57167
57168 if (!object->cookie->def->check_aux) {
57169 - fscache_stat(&fscache_n_checkaux_none);
57170 + fscache_stat_unchecked(&fscache_n_checkaux_none);
57171 return FSCACHE_CHECKAUX_OKAY;
57172 }
57173
57174 @@ -903,17 +903,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
57175 switch (result) {
57176 /* entry okay as is */
57177 case FSCACHE_CHECKAUX_OKAY:
57178 - fscache_stat(&fscache_n_checkaux_okay);
57179 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
57180 break;
57181
57182 /* entry requires update */
57183 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
57184 - fscache_stat(&fscache_n_checkaux_update);
57185 + fscache_stat_unchecked(&fscache_n_checkaux_update);
57186 break;
57187
57188 /* entry requires deletion */
57189 case FSCACHE_CHECKAUX_OBSOLETE:
57190 - fscache_stat(&fscache_n_checkaux_obsolete);
57191 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
57192 break;
57193
57194 default:
57195 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
57196 index 762a9ec..2023284 100644
57197 --- a/fs/fscache/operation.c
57198 +++ b/fs/fscache/operation.c
57199 @@ -17,7 +17,7 @@
57200 #include <linux/slab.h>
57201 #include "internal.h"
57202
57203 -atomic_t fscache_op_debug_id;
57204 +atomic_unchecked_t fscache_op_debug_id;
57205 EXPORT_SYMBOL(fscache_op_debug_id);
57206
57207 /**
57208 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
57209 ASSERTCMP(atomic_read(&op->usage), >, 0);
57210 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
57211
57212 - fscache_stat(&fscache_n_op_enqueue);
57213 + fscache_stat_unchecked(&fscache_n_op_enqueue);
57214 switch (op->flags & FSCACHE_OP_TYPE) {
57215 case FSCACHE_OP_ASYNC:
57216 _debug("queue async");
57217 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
57218 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
57219 if (op->processor)
57220 fscache_enqueue_operation(op);
57221 - fscache_stat(&fscache_n_op_run);
57222 + fscache_stat_unchecked(&fscache_n_op_run);
57223 }
57224
57225 /*
57226 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
57227 if (object->n_in_progress > 0) {
57228 atomic_inc(&op->usage);
57229 list_add_tail(&op->pend_link, &object->pending_ops);
57230 - fscache_stat(&fscache_n_op_pend);
57231 + fscache_stat_unchecked(&fscache_n_op_pend);
57232 } else if (!list_empty(&object->pending_ops)) {
57233 atomic_inc(&op->usage);
57234 list_add_tail(&op->pend_link, &object->pending_ops);
57235 - fscache_stat(&fscache_n_op_pend);
57236 + fscache_stat_unchecked(&fscache_n_op_pend);
57237 fscache_start_operations(object);
57238 } else {
57239 ASSERTCMP(object->n_in_progress, ==, 0);
57240 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
57241 object->n_exclusive++; /* reads and writes must wait */
57242 atomic_inc(&op->usage);
57243 list_add_tail(&op->pend_link, &object->pending_ops);
57244 - fscache_stat(&fscache_n_op_pend);
57245 + fscache_stat_unchecked(&fscache_n_op_pend);
57246 ret = 0;
57247 } else {
57248 /* If we're in any other state, there must have been an I/O
57249 @@ -215,11 +215,11 @@ int fscache_submit_op(struct fscache_object *object,
57250 if (object->n_exclusive > 0) {
57251 atomic_inc(&op->usage);
57252 list_add_tail(&op->pend_link, &object->pending_ops);
57253 - fscache_stat(&fscache_n_op_pend);
57254 + fscache_stat_unchecked(&fscache_n_op_pend);
57255 } else if (!list_empty(&object->pending_ops)) {
57256 atomic_inc(&op->usage);
57257 list_add_tail(&op->pend_link, &object->pending_ops);
57258 - fscache_stat(&fscache_n_op_pend);
57259 + fscache_stat_unchecked(&fscache_n_op_pend);
57260 fscache_start_operations(object);
57261 } else {
57262 ASSERTCMP(object->n_exclusive, ==, 0);
57263 @@ -231,12 +231,12 @@ int fscache_submit_op(struct fscache_object *object,
57264 object->n_ops++;
57265 atomic_inc(&op->usage);
57266 list_add_tail(&op->pend_link, &object->pending_ops);
57267 - fscache_stat(&fscache_n_op_pend);
57268 + fscache_stat_unchecked(&fscache_n_op_pend);
57269 ret = 0;
57270 } else if (object->state == FSCACHE_OBJECT_DYING ||
57271 object->state == FSCACHE_OBJECT_LC_DYING ||
57272 object->state == FSCACHE_OBJECT_WITHDRAWING) {
57273 - fscache_stat(&fscache_n_op_rejected);
57274 + fscache_stat_unchecked(&fscache_n_op_rejected);
57275 op->state = FSCACHE_OP_ST_CANCELLED;
57276 ret = -ENOBUFS;
57277 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
57278 @@ -315,7 +315,7 @@ int fscache_cancel_op(struct fscache_operation *op,
57279 ret = -EBUSY;
57280 if (op->state == FSCACHE_OP_ST_PENDING) {
57281 ASSERT(!list_empty(&op->pend_link));
57282 - fscache_stat(&fscache_n_op_cancelled);
57283 + fscache_stat_unchecked(&fscache_n_op_cancelled);
57284 list_del_init(&op->pend_link);
57285 if (do_cancel)
57286 do_cancel(op);
57287 @@ -347,7 +347,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
57288 while (!list_empty(&object->pending_ops)) {
57289 op = list_entry(object->pending_ops.next,
57290 struct fscache_operation, pend_link);
57291 - fscache_stat(&fscache_n_op_cancelled);
57292 + fscache_stat_unchecked(&fscache_n_op_cancelled);
57293 list_del_init(&op->pend_link);
57294
57295 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
57296 @@ -419,7 +419,7 @@ void fscache_put_operation(struct fscache_operation *op)
57297 op->state, ==, FSCACHE_OP_ST_CANCELLED);
57298 op->state = FSCACHE_OP_ST_DEAD;
57299
57300 - fscache_stat(&fscache_n_op_release);
57301 + fscache_stat_unchecked(&fscache_n_op_release);
57302
57303 if (op->release) {
57304 op->release(op);
57305 @@ -442,7 +442,7 @@ void fscache_put_operation(struct fscache_operation *op)
57306 * lock, and defer it otherwise */
57307 if (!spin_trylock(&object->lock)) {
57308 _debug("defer put");
57309 - fscache_stat(&fscache_n_op_deferred_release);
57310 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
57311
57312 cache = object->cache;
57313 spin_lock(&cache->op_gc_list_lock);
57314 @@ -495,7 +495,7 @@ void fscache_operation_gc(struct work_struct *work)
57315
57316 _debug("GC DEFERRED REL OBJ%x OP%x",
57317 object->debug_id, op->debug_id);
57318 - fscache_stat(&fscache_n_op_gc);
57319 + fscache_stat_unchecked(&fscache_n_op_gc);
57320
57321 ASSERTCMP(atomic_read(&op->usage), ==, 0);
57322 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
57323 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
57324 index ff000e5..c44ec6d 100644
57325 --- a/fs/fscache/page.c
57326 +++ b/fs/fscache/page.c
57327 @@ -61,7 +61,7 @@ try_again:
57328 val = radix_tree_lookup(&cookie->stores, page->index);
57329 if (!val) {
57330 rcu_read_unlock();
57331 - fscache_stat(&fscache_n_store_vmscan_not_storing);
57332 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
57333 __fscache_uncache_page(cookie, page);
57334 return true;
57335 }
57336 @@ -91,11 +91,11 @@ try_again:
57337 spin_unlock(&cookie->stores_lock);
57338
57339 if (xpage) {
57340 - fscache_stat(&fscache_n_store_vmscan_cancelled);
57341 - fscache_stat(&fscache_n_store_radix_deletes);
57342 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
57343 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
57344 ASSERTCMP(xpage, ==, page);
57345 } else {
57346 - fscache_stat(&fscache_n_store_vmscan_gone);
57347 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
57348 }
57349
57350 wake_up_bit(&cookie->flags, 0);
57351 @@ -110,11 +110,11 @@ page_busy:
57352 * sleeping on memory allocation, so we may need to impose a timeout
57353 * too. */
57354 if (!(gfp & __GFP_WAIT)) {
57355 - fscache_stat(&fscache_n_store_vmscan_busy);
57356 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
57357 return false;
57358 }
57359
57360 - fscache_stat(&fscache_n_store_vmscan_wait);
57361 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
57362 __fscache_wait_on_page_write(cookie, page);
57363 gfp &= ~__GFP_WAIT;
57364 goto try_again;
57365 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
57366 FSCACHE_COOKIE_STORING_TAG);
57367 if (!radix_tree_tag_get(&cookie->stores, page->index,
57368 FSCACHE_COOKIE_PENDING_TAG)) {
57369 - fscache_stat(&fscache_n_store_radix_deletes);
57370 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
57371 xpage = radix_tree_delete(&cookie->stores, page->index);
57372 }
57373 spin_unlock(&cookie->stores_lock);
57374 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
57375
57376 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
57377
57378 - fscache_stat(&fscache_n_attr_changed_calls);
57379 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
57380
57381 if (fscache_object_is_active(object)) {
57382 fscache_stat(&fscache_n_cop_attr_changed);
57383 @@ -187,11 +187,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
57384
57385 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
57386
57387 - fscache_stat(&fscache_n_attr_changed);
57388 + fscache_stat_unchecked(&fscache_n_attr_changed);
57389
57390 op = kzalloc(sizeof(*op), GFP_KERNEL);
57391 if (!op) {
57392 - fscache_stat(&fscache_n_attr_changed_nomem);
57393 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
57394 _leave(" = -ENOMEM");
57395 return -ENOMEM;
57396 }
57397 @@ -209,7 +209,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
57398 if (fscache_submit_exclusive_op(object, op) < 0)
57399 goto nobufs;
57400 spin_unlock(&cookie->lock);
57401 - fscache_stat(&fscache_n_attr_changed_ok);
57402 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
57403 fscache_put_operation(op);
57404 _leave(" = 0");
57405 return 0;
57406 @@ -217,7 +217,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
57407 nobufs:
57408 spin_unlock(&cookie->lock);
57409 kfree(op);
57410 - fscache_stat(&fscache_n_attr_changed_nobufs);
57411 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
57412 _leave(" = %d", -ENOBUFS);
57413 return -ENOBUFS;
57414 }
57415 @@ -255,7 +255,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
57416 /* allocate a retrieval operation and attempt to submit it */
57417 op = kzalloc(sizeof(*op), GFP_NOIO);
57418 if (!op) {
57419 - fscache_stat(&fscache_n_retrievals_nomem);
57420 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
57421 return NULL;
57422 }
57423
57424 @@ -283,13 +283,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
57425 return 0;
57426 }
57427
57428 - fscache_stat(&fscache_n_retrievals_wait);
57429 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
57430
57431 jif = jiffies;
57432 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
57433 fscache_wait_bit_interruptible,
57434 TASK_INTERRUPTIBLE) != 0) {
57435 - fscache_stat(&fscache_n_retrievals_intr);
57436 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
57437 _leave(" = -ERESTARTSYS");
57438 return -ERESTARTSYS;
57439 }
57440 @@ -318,8 +318,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
57441 */
57442 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
57443 struct fscache_retrieval *op,
57444 - atomic_t *stat_op_waits,
57445 - atomic_t *stat_object_dead)
57446 + atomic_unchecked_t *stat_op_waits,
57447 + atomic_unchecked_t *stat_object_dead)
57448 {
57449 int ret;
57450
57451 @@ -327,7 +327,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
57452 goto check_if_dead;
57453
57454 _debug(">>> WT");
57455 - fscache_stat(stat_op_waits);
57456 + fscache_stat_unchecked(stat_op_waits);
57457 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
57458 fscache_wait_bit_interruptible,
57459 TASK_INTERRUPTIBLE) != 0) {
57460 @@ -344,14 +344,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
57461
57462 check_if_dead:
57463 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
57464 - fscache_stat(stat_object_dead);
57465 + fscache_stat_unchecked(stat_object_dead);
57466 _leave(" = -ENOBUFS [cancelled]");
57467 return -ENOBUFS;
57468 }
57469 if (unlikely(fscache_object_is_dead(object))) {
57470 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
57471 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
57472 - fscache_stat(stat_object_dead);
57473 + fscache_stat_unchecked(stat_object_dead);
57474 return -ENOBUFS;
57475 }
57476 return 0;
57477 @@ -378,7 +378,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
57478
57479 _enter("%p,%p,,,", cookie, page);
57480
57481 - fscache_stat(&fscache_n_retrievals);
57482 + fscache_stat_unchecked(&fscache_n_retrievals);
57483
57484 if (hlist_empty(&cookie->backing_objects))
57485 goto nobufs;
57486 @@ -417,7 +417,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
57487 goto nobufs_unlock_dec;
57488 spin_unlock(&cookie->lock);
57489
57490 - fscache_stat(&fscache_n_retrieval_ops);
57491 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
57492
57493 /* pin the netfs read context in case we need to do the actual netfs
57494 * read because we've encountered a cache read failure */
57495 @@ -447,15 +447,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
57496
57497 error:
57498 if (ret == -ENOMEM)
57499 - fscache_stat(&fscache_n_retrievals_nomem);
57500 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
57501 else if (ret == -ERESTARTSYS)
57502 - fscache_stat(&fscache_n_retrievals_intr);
57503 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
57504 else if (ret == -ENODATA)
57505 - fscache_stat(&fscache_n_retrievals_nodata);
57506 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
57507 else if (ret < 0)
57508 - fscache_stat(&fscache_n_retrievals_nobufs);
57509 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
57510 else
57511 - fscache_stat(&fscache_n_retrievals_ok);
57512 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
57513
57514 fscache_put_retrieval(op);
57515 _leave(" = %d", ret);
57516 @@ -467,7 +467,7 @@ nobufs_unlock:
57517 spin_unlock(&cookie->lock);
57518 kfree(op);
57519 nobufs:
57520 - fscache_stat(&fscache_n_retrievals_nobufs);
57521 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
57522 _leave(" = -ENOBUFS");
57523 return -ENOBUFS;
57524 }
57525 @@ -505,7 +505,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
57526
57527 _enter("%p,,%d,,,", cookie, *nr_pages);
57528
57529 - fscache_stat(&fscache_n_retrievals);
57530 + fscache_stat_unchecked(&fscache_n_retrievals);
57531
57532 if (hlist_empty(&cookie->backing_objects))
57533 goto nobufs;
57534 @@ -541,7 +541,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
57535 goto nobufs_unlock_dec;
57536 spin_unlock(&cookie->lock);
57537
57538 - fscache_stat(&fscache_n_retrieval_ops);
57539 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
57540
57541 /* pin the netfs read context in case we need to do the actual netfs
57542 * read because we've encountered a cache read failure */
57543 @@ -571,15 +571,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
57544
57545 error:
57546 if (ret == -ENOMEM)
57547 - fscache_stat(&fscache_n_retrievals_nomem);
57548 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
57549 else if (ret == -ERESTARTSYS)
57550 - fscache_stat(&fscache_n_retrievals_intr);
57551 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
57552 else if (ret == -ENODATA)
57553 - fscache_stat(&fscache_n_retrievals_nodata);
57554 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
57555 else if (ret < 0)
57556 - fscache_stat(&fscache_n_retrievals_nobufs);
57557 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
57558 else
57559 - fscache_stat(&fscache_n_retrievals_ok);
57560 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
57561
57562 fscache_put_retrieval(op);
57563 _leave(" = %d", ret);
57564 @@ -591,7 +591,7 @@ nobufs_unlock:
57565 spin_unlock(&cookie->lock);
57566 kfree(op);
57567 nobufs:
57568 - fscache_stat(&fscache_n_retrievals_nobufs);
57569 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
57570 _leave(" = -ENOBUFS");
57571 return -ENOBUFS;
57572 }
57573 @@ -615,7 +615,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
57574
57575 _enter("%p,%p,,,", cookie, page);
57576
57577 - fscache_stat(&fscache_n_allocs);
57578 + fscache_stat_unchecked(&fscache_n_allocs);
57579
57580 if (hlist_empty(&cookie->backing_objects))
57581 goto nobufs;
57582 @@ -647,7 +647,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
57583 goto nobufs_unlock;
57584 spin_unlock(&cookie->lock);
57585
57586 - fscache_stat(&fscache_n_alloc_ops);
57587 + fscache_stat_unchecked(&fscache_n_alloc_ops);
57588
57589 ret = fscache_wait_for_retrieval_activation(
57590 object, op,
57591 @@ -663,11 +663,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
57592
57593 error:
57594 if (ret == -ERESTARTSYS)
57595 - fscache_stat(&fscache_n_allocs_intr);
57596 + fscache_stat_unchecked(&fscache_n_allocs_intr);
57597 else if (ret < 0)
57598 - fscache_stat(&fscache_n_allocs_nobufs);
57599 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
57600 else
57601 - fscache_stat(&fscache_n_allocs_ok);
57602 + fscache_stat_unchecked(&fscache_n_allocs_ok);
57603
57604 fscache_put_retrieval(op);
57605 _leave(" = %d", ret);
57606 @@ -677,7 +677,7 @@ nobufs_unlock:
57607 spin_unlock(&cookie->lock);
57608 kfree(op);
57609 nobufs:
57610 - fscache_stat(&fscache_n_allocs_nobufs);
57611 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
57612 _leave(" = -ENOBUFS");
57613 return -ENOBUFS;
57614 }
57615 @@ -736,7 +736,7 @@ static void fscache_write_op(struct fscache_operation *_op)
57616
57617 spin_lock(&cookie->stores_lock);
57618
57619 - fscache_stat(&fscache_n_store_calls);
57620 + fscache_stat_unchecked(&fscache_n_store_calls);
57621
57622 /* find a page to store */
57623 page = NULL;
57624 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
57625 page = results[0];
57626 _debug("gang %d [%lx]", n, page->index);
57627 if (page->index > op->store_limit) {
57628 - fscache_stat(&fscache_n_store_pages_over_limit);
57629 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
57630 goto superseded;
57631 }
57632
57633 @@ -759,7 +759,7 @@ static void fscache_write_op(struct fscache_operation *_op)
57634 spin_unlock(&cookie->stores_lock);
57635 spin_unlock(&object->lock);
57636
57637 - fscache_stat(&fscache_n_store_pages);
57638 + fscache_stat_unchecked(&fscache_n_store_pages);
57639 fscache_stat(&fscache_n_cop_write_page);
57640 ret = object->cache->ops->write_page(op, page);
57641 fscache_stat_d(&fscache_n_cop_write_page);
57642 @@ -860,7 +860,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
57643 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
57644 ASSERT(PageFsCache(page));
57645
57646 - fscache_stat(&fscache_n_stores);
57647 + fscache_stat_unchecked(&fscache_n_stores);
57648
57649 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
57650 _leave(" = -ENOBUFS [invalidating]");
57651 @@ -916,7 +916,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
57652 spin_unlock(&cookie->stores_lock);
57653 spin_unlock(&object->lock);
57654
57655 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
57656 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
57657 op->store_limit = object->store_limit;
57658
57659 if (fscache_submit_op(object, &op->op) < 0)
57660 @@ -924,8 +924,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
57661
57662 spin_unlock(&cookie->lock);
57663 radix_tree_preload_end();
57664 - fscache_stat(&fscache_n_store_ops);
57665 - fscache_stat(&fscache_n_stores_ok);
57666 + fscache_stat_unchecked(&fscache_n_store_ops);
57667 + fscache_stat_unchecked(&fscache_n_stores_ok);
57668
57669 /* the work queue now carries its own ref on the object */
57670 fscache_put_operation(&op->op);
57671 @@ -933,14 +933,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
57672 return 0;
57673
57674 already_queued:
57675 - fscache_stat(&fscache_n_stores_again);
57676 + fscache_stat_unchecked(&fscache_n_stores_again);
57677 already_pending:
57678 spin_unlock(&cookie->stores_lock);
57679 spin_unlock(&object->lock);
57680 spin_unlock(&cookie->lock);
57681 radix_tree_preload_end();
57682 kfree(op);
57683 - fscache_stat(&fscache_n_stores_ok);
57684 + fscache_stat_unchecked(&fscache_n_stores_ok);
57685 _leave(" = 0");
57686 return 0;
57687
57688 @@ -959,14 +959,14 @@ nobufs:
57689 spin_unlock(&cookie->lock);
57690 radix_tree_preload_end();
57691 kfree(op);
57692 - fscache_stat(&fscache_n_stores_nobufs);
57693 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
57694 _leave(" = -ENOBUFS");
57695 return -ENOBUFS;
57696
57697 nomem_free:
57698 kfree(op);
57699 nomem:
57700 - fscache_stat(&fscache_n_stores_oom);
57701 + fscache_stat_unchecked(&fscache_n_stores_oom);
57702 _leave(" = -ENOMEM");
57703 return -ENOMEM;
57704 }
57705 @@ -984,7 +984,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
57706 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
57707 ASSERTCMP(page, !=, NULL);
57708
57709 - fscache_stat(&fscache_n_uncaches);
57710 + fscache_stat_unchecked(&fscache_n_uncaches);
57711
57712 /* cache withdrawal may beat us to it */
57713 if (!PageFsCache(page))
57714 @@ -1035,7 +1035,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
57715 struct fscache_cookie *cookie = op->op.object->cookie;
57716
57717 #ifdef CONFIG_FSCACHE_STATS
57718 - atomic_inc(&fscache_n_marks);
57719 + atomic_inc_unchecked(&fscache_n_marks);
57720 #endif
57721
57722 _debug("- mark %p{%lx}", page, page->index);
57723 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
57724 index 40d13c7..ddf52b9 100644
57725 --- a/fs/fscache/stats.c
57726 +++ b/fs/fscache/stats.c
57727 @@ -18,99 +18,99 @@
57728 /*
57729 * operation counters
57730 */
57731 -atomic_t fscache_n_op_pend;
57732 -atomic_t fscache_n_op_run;
57733 -atomic_t fscache_n_op_enqueue;
57734 -atomic_t fscache_n_op_requeue;
57735 -atomic_t fscache_n_op_deferred_release;
57736 -atomic_t fscache_n_op_release;
57737 -atomic_t fscache_n_op_gc;
57738 -atomic_t fscache_n_op_cancelled;
57739 -atomic_t fscache_n_op_rejected;
57740 +atomic_unchecked_t fscache_n_op_pend;
57741 +atomic_unchecked_t fscache_n_op_run;
57742 +atomic_unchecked_t fscache_n_op_enqueue;
57743 +atomic_unchecked_t fscache_n_op_requeue;
57744 +atomic_unchecked_t fscache_n_op_deferred_release;
57745 +atomic_unchecked_t fscache_n_op_release;
57746 +atomic_unchecked_t fscache_n_op_gc;
57747 +atomic_unchecked_t fscache_n_op_cancelled;
57748 +atomic_unchecked_t fscache_n_op_rejected;
57749
57750 -atomic_t fscache_n_attr_changed;
57751 -atomic_t fscache_n_attr_changed_ok;
57752 -atomic_t fscache_n_attr_changed_nobufs;
57753 -atomic_t fscache_n_attr_changed_nomem;
57754 -atomic_t fscache_n_attr_changed_calls;
57755 +atomic_unchecked_t fscache_n_attr_changed;
57756 +atomic_unchecked_t fscache_n_attr_changed_ok;
57757 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
57758 +atomic_unchecked_t fscache_n_attr_changed_nomem;
57759 +atomic_unchecked_t fscache_n_attr_changed_calls;
57760
57761 -atomic_t fscache_n_allocs;
57762 -atomic_t fscache_n_allocs_ok;
57763 -atomic_t fscache_n_allocs_wait;
57764 -atomic_t fscache_n_allocs_nobufs;
57765 -atomic_t fscache_n_allocs_intr;
57766 -atomic_t fscache_n_allocs_object_dead;
57767 -atomic_t fscache_n_alloc_ops;
57768 -atomic_t fscache_n_alloc_op_waits;
57769 +atomic_unchecked_t fscache_n_allocs;
57770 +atomic_unchecked_t fscache_n_allocs_ok;
57771 +atomic_unchecked_t fscache_n_allocs_wait;
57772 +atomic_unchecked_t fscache_n_allocs_nobufs;
57773 +atomic_unchecked_t fscache_n_allocs_intr;
57774 +atomic_unchecked_t fscache_n_allocs_object_dead;
57775 +atomic_unchecked_t fscache_n_alloc_ops;
57776 +atomic_unchecked_t fscache_n_alloc_op_waits;
57777
57778 -atomic_t fscache_n_retrievals;
57779 -atomic_t fscache_n_retrievals_ok;
57780 -atomic_t fscache_n_retrievals_wait;
57781 -atomic_t fscache_n_retrievals_nodata;
57782 -atomic_t fscache_n_retrievals_nobufs;
57783 -atomic_t fscache_n_retrievals_intr;
57784 -atomic_t fscache_n_retrievals_nomem;
57785 -atomic_t fscache_n_retrievals_object_dead;
57786 -atomic_t fscache_n_retrieval_ops;
57787 -atomic_t fscache_n_retrieval_op_waits;
57788 +atomic_unchecked_t fscache_n_retrievals;
57789 +atomic_unchecked_t fscache_n_retrievals_ok;
57790 +atomic_unchecked_t fscache_n_retrievals_wait;
57791 +atomic_unchecked_t fscache_n_retrievals_nodata;
57792 +atomic_unchecked_t fscache_n_retrievals_nobufs;
57793 +atomic_unchecked_t fscache_n_retrievals_intr;
57794 +atomic_unchecked_t fscache_n_retrievals_nomem;
57795 +atomic_unchecked_t fscache_n_retrievals_object_dead;
57796 +atomic_unchecked_t fscache_n_retrieval_ops;
57797 +atomic_unchecked_t fscache_n_retrieval_op_waits;
57798
57799 -atomic_t fscache_n_stores;
57800 -atomic_t fscache_n_stores_ok;
57801 -atomic_t fscache_n_stores_again;
57802 -atomic_t fscache_n_stores_nobufs;
57803 -atomic_t fscache_n_stores_oom;
57804 -atomic_t fscache_n_store_ops;
57805 -atomic_t fscache_n_store_calls;
57806 -atomic_t fscache_n_store_pages;
57807 -atomic_t fscache_n_store_radix_deletes;
57808 -atomic_t fscache_n_store_pages_over_limit;
57809 +atomic_unchecked_t fscache_n_stores;
57810 +atomic_unchecked_t fscache_n_stores_ok;
57811 +atomic_unchecked_t fscache_n_stores_again;
57812 +atomic_unchecked_t fscache_n_stores_nobufs;
57813 +atomic_unchecked_t fscache_n_stores_oom;
57814 +atomic_unchecked_t fscache_n_store_ops;
57815 +atomic_unchecked_t fscache_n_store_calls;
57816 +atomic_unchecked_t fscache_n_store_pages;
57817 +atomic_unchecked_t fscache_n_store_radix_deletes;
57818 +atomic_unchecked_t fscache_n_store_pages_over_limit;
57819
57820 -atomic_t fscache_n_store_vmscan_not_storing;
57821 -atomic_t fscache_n_store_vmscan_gone;
57822 -atomic_t fscache_n_store_vmscan_busy;
57823 -atomic_t fscache_n_store_vmscan_cancelled;
57824 -atomic_t fscache_n_store_vmscan_wait;
57825 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
57826 +atomic_unchecked_t fscache_n_store_vmscan_gone;
57827 +atomic_unchecked_t fscache_n_store_vmscan_busy;
57828 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
57829 +atomic_unchecked_t fscache_n_store_vmscan_wait;
57830
57831 -atomic_t fscache_n_marks;
57832 -atomic_t fscache_n_uncaches;
57833 +atomic_unchecked_t fscache_n_marks;
57834 +atomic_unchecked_t fscache_n_uncaches;
57835
57836 -atomic_t fscache_n_acquires;
57837 -atomic_t fscache_n_acquires_null;
57838 -atomic_t fscache_n_acquires_no_cache;
57839 -atomic_t fscache_n_acquires_ok;
57840 -atomic_t fscache_n_acquires_nobufs;
57841 -atomic_t fscache_n_acquires_oom;
57842 +atomic_unchecked_t fscache_n_acquires;
57843 +atomic_unchecked_t fscache_n_acquires_null;
57844 +atomic_unchecked_t fscache_n_acquires_no_cache;
57845 +atomic_unchecked_t fscache_n_acquires_ok;
57846 +atomic_unchecked_t fscache_n_acquires_nobufs;
57847 +atomic_unchecked_t fscache_n_acquires_oom;
57848
57849 -atomic_t fscache_n_invalidates;
57850 -atomic_t fscache_n_invalidates_run;
57851 +atomic_unchecked_t fscache_n_invalidates;
57852 +atomic_unchecked_t fscache_n_invalidates_run;
57853
57854 -atomic_t fscache_n_updates;
57855 -atomic_t fscache_n_updates_null;
57856 -atomic_t fscache_n_updates_run;
57857 +atomic_unchecked_t fscache_n_updates;
57858 +atomic_unchecked_t fscache_n_updates_null;
57859 +atomic_unchecked_t fscache_n_updates_run;
57860
57861 -atomic_t fscache_n_relinquishes;
57862 -atomic_t fscache_n_relinquishes_null;
57863 -atomic_t fscache_n_relinquishes_waitcrt;
57864 -atomic_t fscache_n_relinquishes_retire;
57865 +atomic_unchecked_t fscache_n_relinquishes;
57866 +atomic_unchecked_t fscache_n_relinquishes_null;
57867 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
57868 +atomic_unchecked_t fscache_n_relinquishes_retire;
57869
57870 -atomic_t fscache_n_cookie_index;
57871 -atomic_t fscache_n_cookie_data;
57872 -atomic_t fscache_n_cookie_special;
57873 +atomic_unchecked_t fscache_n_cookie_index;
57874 +atomic_unchecked_t fscache_n_cookie_data;
57875 +atomic_unchecked_t fscache_n_cookie_special;
57876
57877 -atomic_t fscache_n_object_alloc;
57878 -atomic_t fscache_n_object_no_alloc;
57879 -atomic_t fscache_n_object_lookups;
57880 -atomic_t fscache_n_object_lookups_negative;
57881 -atomic_t fscache_n_object_lookups_positive;
57882 -atomic_t fscache_n_object_lookups_timed_out;
57883 -atomic_t fscache_n_object_created;
57884 -atomic_t fscache_n_object_avail;
57885 -atomic_t fscache_n_object_dead;
57886 +atomic_unchecked_t fscache_n_object_alloc;
57887 +atomic_unchecked_t fscache_n_object_no_alloc;
57888 +atomic_unchecked_t fscache_n_object_lookups;
57889 +atomic_unchecked_t fscache_n_object_lookups_negative;
57890 +atomic_unchecked_t fscache_n_object_lookups_positive;
57891 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
57892 +atomic_unchecked_t fscache_n_object_created;
57893 +atomic_unchecked_t fscache_n_object_avail;
57894 +atomic_unchecked_t fscache_n_object_dead;
57895
57896 -atomic_t fscache_n_checkaux_none;
57897 -atomic_t fscache_n_checkaux_okay;
57898 -atomic_t fscache_n_checkaux_update;
57899 -atomic_t fscache_n_checkaux_obsolete;
57900 +atomic_unchecked_t fscache_n_checkaux_none;
57901 +atomic_unchecked_t fscache_n_checkaux_okay;
57902 +atomic_unchecked_t fscache_n_checkaux_update;
57903 +atomic_unchecked_t fscache_n_checkaux_obsolete;
57904
57905 atomic_t fscache_n_cop_alloc_object;
57906 atomic_t fscache_n_cop_lookup_object;
57907 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
57908 seq_puts(m, "FS-Cache statistics\n");
57909
57910 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
57911 - atomic_read(&fscache_n_cookie_index),
57912 - atomic_read(&fscache_n_cookie_data),
57913 - atomic_read(&fscache_n_cookie_special));
57914 + atomic_read_unchecked(&fscache_n_cookie_index),
57915 + atomic_read_unchecked(&fscache_n_cookie_data),
57916 + atomic_read_unchecked(&fscache_n_cookie_special));
57917
57918 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
57919 - atomic_read(&fscache_n_object_alloc),
57920 - atomic_read(&fscache_n_object_no_alloc),
57921 - atomic_read(&fscache_n_object_avail),
57922 - atomic_read(&fscache_n_object_dead));
57923 + atomic_read_unchecked(&fscache_n_object_alloc),
57924 + atomic_read_unchecked(&fscache_n_object_no_alloc),
57925 + atomic_read_unchecked(&fscache_n_object_avail),
57926 + atomic_read_unchecked(&fscache_n_object_dead));
57927 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
57928 - atomic_read(&fscache_n_checkaux_none),
57929 - atomic_read(&fscache_n_checkaux_okay),
57930 - atomic_read(&fscache_n_checkaux_update),
57931 - atomic_read(&fscache_n_checkaux_obsolete));
57932 + atomic_read_unchecked(&fscache_n_checkaux_none),
57933 + atomic_read_unchecked(&fscache_n_checkaux_okay),
57934 + atomic_read_unchecked(&fscache_n_checkaux_update),
57935 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
57936
57937 seq_printf(m, "Pages : mrk=%u unc=%u\n",
57938 - atomic_read(&fscache_n_marks),
57939 - atomic_read(&fscache_n_uncaches));
57940 + atomic_read_unchecked(&fscache_n_marks),
57941 + atomic_read_unchecked(&fscache_n_uncaches));
57942
57943 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
57944 " oom=%u\n",
57945 - atomic_read(&fscache_n_acquires),
57946 - atomic_read(&fscache_n_acquires_null),
57947 - atomic_read(&fscache_n_acquires_no_cache),
57948 - atomic_read(&fscache_n_acquires_ok),
57949 - atomic_read(&fscache_n_acquires_nobufs),
57950 - atomic_read(&fscache_n_acquires_oom));
57951 + atomic_read_unchecked(&fscache_n_acquires),
57952 + atomic_read_unchecked(&fscache_n_acquires_null),
57953 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
57954 + atomic_read_unchecked(&fscache_n_acquires_ok),
57955 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
57956 + atomic_read_unchecked(&fscache_n_acquires_oom));
57957
57958 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
57959 - atomic_read(&fscache_n_object_lookups),
57960 - atomic_read(&fscache_n_object_lookups_negative),
57961 - atomic_read(&fscache_n_object_lookups_positive),
57962 - atomic_read(&fscache_n_object_created),
57963 - atomic_read(&fscache_n_object_lookups_timed_out));
57964 + atomic_read_unchecked(&fscache_n_object_lookups),
57965 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
57966 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
57967 + atomic_read_unchecked(&fscache_n_object_created),
57968 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
57969
57970 seq_printf(m, "Invals : n=%u run=%u\n",
57971 - atomic_read(&fscache_n_invalidates),
57972 - atomic_read(&fscache_n_invalidates_run));
57973 + atomic_read_unchecked(&fscache_n_invalidates),
57974 + atomic_read_unchecked(&fscache_n_invalidates_run));
57975
57976 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
57977 - atomic_read(&fscache_n_updates),
57978 - atomic_read(&fscache_n_updates_null),
57979 - atomic_read(&fscache_n_updates_run));
57980 + atomic_read_unchecked(&fscache_n_updates),
57981 + atomic_read_unchecked(&fscache_n_updates_null),
57982 + atomic_read_unchecked(&fscache_n_updates_run));
57983
57984 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
57985 - atomic_read(&fscache_n_relinquishes),
57986 - atomic_read(&fscache_n_relinquishes_null),
57987 - atomic_read(&fscache_n_relinquishes_waitcrt),
57988 - atomic_read(&fscache_n_relinquishes_retire));
57989 + atomic_read_unchecked(&fscache_n_relinquishes),
57990 + atomic_read_unchecked(&fscache_n_relinquishes_null),
57991 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
57992 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
57993
57994 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
57995 - atomic_read(&fscache_n_attr_changed),
57996 - atomic_read(&fscache_n_attr_changed_ok),
57997 - atomic_read(&fscache_n_attr_changed_nobufs),
57998 - atomic_read(&fscache_n_attr_changed_nomem),
57999 - atomic_read(&fscache_n_attr_changed_calls));
58000 + atomic_read_unchecked(&fscache_n_attr_changed),
58001 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
58002 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
58003 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
58004 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
58005
58006 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
58007 - atomic_read(&fscache_n_allocs),
58008 - atomic_read(&fscache_n_allocs_ok),
58009 - atomic_read(&fscache_n_allocs_wait),
58010 - atomic_read(&fscache_n_allocs_nobufs),
58011 - atomic_read(&fscache_n_allocs_intr));
58012 + atomic_read_unchecked(&fscache_n_allocs),
58013 + atomic_read_unchecked(&fscache_n_allocs_ok),
58014 + atomic_read_unchecked(&fscache_n_allocs_wait),
58015 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
58016 + atomic_read_unchecked(&fscache_n_allocs_intr));
58017 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
58018 - atomic_read(&fscache_n_alloc_ops),
58019 - atomic_read(&fscache_n_alloc_op_waits),
58020 - atomic_read(&fscache_n_allocs_object_dead));
58021 + atomic_read_unchecked(&fscache_n_alloc_ops),
58022 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
58023 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
58024
58025 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
58026 " int=%u oom=%u\n",
58027 - atomic_read(&fscache_n_retrievals),
58028 - atomic_read(&fscache_n_retrievals_ok),
58029 - atomic_read(&fscache_n_retrievals_wait),
58030 - atomic_read(&fscache_n_retrievals_nodata),
58031 - atomic_read(&fscache_n_retrievals_nobufs),
58032 - atomic_read(&fscache_n_retrievals_intr),
58033 - atomic_read(&fscache_n_retrievals_nomem));
58034 + atomic_read_unchecked(&fscache_n_retrievals),
58035 + atomic_read_unchecked(&fscache_n_retrievals_ok),
58036 + atomic_read_unchecked(&fscache_n_retrievals_wait),
58037 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
58038 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
58039 + atomic_read_unchecked(&fscache_n_retrievals_intr),
58040 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
58041 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
58042 - atomic_read(&fscache_n_retrieval_ops),
58043 - atomic_read(&fscache_n_retrieval_op_waits),
58044 - atomic_read(&fscache_n_retrievals_object_dead));
58045 + atomic_read_unchecked(&fscache_n_retrieval_ops),
58046 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
58047 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
58048
58049 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
58050 - atomic_read(&fscache_n_stores),
58051 - atomic_read(&fscache_n_stores_ok),
58052 - atomic_read(&fscache_n_stores_again),
58053 - atomic_read(&fscache_n_stores_nobufs),
58054 - atomic_read(&fscache_n_stores_oom));
58055 + atomic_read_unchecked(&fscache_n_stores),
58056 + atomic_read_unchecked(&fscache_n_stores_ok),
58057 + atomic_read_unchecked(&fscache_n_stores_again),
58058 + atomic_read_unchecked(&fscache_n_stores_nobufs),
58059 + atomic_read_unchecked(&fscache_n_stores_oom));
58060 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
58061 - atomic_read(&fscache_n_store_ops),
58062 - atomic_read(&fscache_n_store_calls),
58063 - atomic_read(&fscache_n_store_pages),
58064 - atomic_read(&fscache_n_store_radix_deletes),
58065 - atomic_read(&fscache_n_store_pages_over_limit));
58066 + atomic_read_unchecked(&fscache_n_store_ops),
58067 + atomic_read_unchecked(&fscache_n_store_calls),
58068 + atomic_read_unchecked(&fscache_n_store_pages),
58069 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
58070 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
58071
58072 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
58073 - atomic_read(&fscache_n_store_vmscan_not_storing),
58074 - atomic_read(&fscache_n_store_vmscan_gone),
58075 - atomic_read(&fscache_n_store_vmscan_busy),
58076 - atomic_read(&fscache_n_store_vmscan_cancelled),
58077 - atomic_read(&fscache_n_store_vmscan_wait));
58078 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
58079 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
58080 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
58081 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
58082 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
58083
58084 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
58085 - atomic_read(&fscache_n_op_pend),
58086 - atomic_read(&fscache_n_op_run),
58087 - atomic_read(&fscache_n_op_enqueue),
58088 - atomic_read(&fscache_n_op_cancelled),
58089 - atomic_read(&fscache_n_op_rejected));
58090 + atomic_read_unchecked(&fscache_n_op_pend),
58091 + atomic_read_unchecked(&fscache_n_op_run),
58092 + atomic_read_unchecked(&fscache_n_op_enqueue),
58093 + atomic_read_unchecked(&fscache_n_op_cancelled),
58094 + atomic_read_unchecked(&fscache_n_op_rejected));
58095 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
58096 - atomic_read(&fscache_n_op_deferred_release),
58097 - atomic_read(&fscache_n_op_release),
58098 - atomic_read(&fscache_n_op_gc));
58099 + atomic_read_unchecked(&fscache_n_op_deferred_release),
58100 + atomic_read_unchecked(&fscache_n_op_release),
58101 + atomic_read_unchecked(&fscache_n_op_gc));
58102
58103 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
58104 atomic_read(&fscache_n_cop_alloc_object),
58105 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
58106 index aef34b1..59bfd7b 100644
58107 --- a/fs/fuse/cuse.c
58108 +++ b/fs/fuse/cuse.c
58109 @@ -600,10 +600,12 @@ static int __init cuse_init(void)
58110 INIT_LIST_HEAD(&cuse_conntbl[i]);
58111
58112 /* inherit and extend fuse_dev_operations */
58113 - cuse_channel_fops = fuse_dev_operations;
58114 - cuse_channel_fops.owner = THIS_MODULE;
58115 - cuse_channel_fops.open = cuse_channel_open;
58116 - cuse_channel_fops.release = cuse_channel_release;
58117 + pax_open_kernel();
58118 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
58119 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
58120 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
58121 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
58122 + pax_close_kernel();
58123
58124 cuse_class = class_create(THIS_MODULE, "cuse");
58125 if (IS_ERR(cuse_class))
58126 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
58127 index 1d55f94..088da65 100644
58128 --- a/fs/fuse/dev.c
58129 +++ b/fs/fuse/dev.c
58130 @@ -1339,7 +1339,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
58131 ret = 0;
58132 pipe_lock(pipe);
58133
58134 - if (!pipe->readers) {
58135 + if (!atomic_read(&pipe->readers)) {
58136 send_sig(SIGPIPE, current, 0);
58137 if (!ret)
58138 ret = -EPIPE;
58139 @@ -1364,7 +1364,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
58140 page_nr++;
58141 ret += buf->len;
58142
58143 - if (pipe->files)
58144 + if (atomic_read(&pipe->files))
58145 do_wakeup = 1;
58146 }
58147
58148 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
58149 index 5b12746..b481b03 100644
58150 --- a/fs/fuse/dir.c
58151 +++ b/fs/fuse/dir.c
58152 @@ -1437,7 +1437,7 @@ static char *read_link(struct dentry *dentry)
58153 return link;
58154 }
58155
58156 -static void free_link(char *link)
58157 +static void free_link(const char *link)
58158 {
58159 if (!IS_ERR(link))
58160 free_page((unsigned long) link);
58161 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
58162 index 62b484e..0f9a140 100644
58163 --- a/fs/gfs2/inode.c
58164 +++ b/fs/gfs2/inode.c
58165 @@ -1441,7 +1441,7 @@ out:
58166
58167 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
58168 {
58169 - char *s = nd_get_link(nd);
58170 + const char *s = nd_get_link(nd);
58171 if (!IS_ERR(s))
58172 kfree(s);
58173 }
58174 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
58175 index a3f868a..bb308ae 100644
58176 --- a/fs/hugetlbfs/inode.c
58177 +++ b/fs/hugetlbfs/inode.c
58178 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
58179 struct mm_struct *mm = current->mm;
58180 struct vm_area_struct *vma;
58181 struct hstate *h = hstate_file(file);
58182 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
58183 struct vm_unmapped_area_info info;
58184
58185 if (len & ~huge_page_mask(h))
58186 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
58187 return addr;
58188 }
58189
58190 +#ifdef CONFIG_PAX_RANDMMAP
58191 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
58192 +#endif
58193 +
58194 if (addr) {
58195 addr = ALIGN(addr, huge_page_size(h));
58196 vma = find_vma(mm, addr);
58197 - if (TASK_SIZE - len >= addr &&
58198 - (!vma || addr + len <= vma->vm_start))
58199 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
58200 return addr;
58201 }
58202
58203 info.flags = 0;
58204 info.length = len;
58205 info.low_limit = TASK_UNMAPPED_BASE;
58206 +
58207 +#ifdef CONFIG_PAX_RANDMMAP
58208 + if (mm->pax_flags & MF_PAX_RANDMMAP)
58209 + info.low_limit += mm->delta_mmap;
58210 +#endif
58211 +
58212 info.high_limit = TASK_SIZE;
58213 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
58214 info.align_offset = 0;
58215 @@ -898,7 +908,7 @@ static struct file_system_type hugetlbfs_fs_type = {
58216 };
58217 MODULE_ALIAS_FS("hugetlbfs");
58218
58219 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
58220 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
58221
58222 static int can_do_hugetlb_shm(void)
58223 {
58224 diff --git a/fs/inode.c b/fs/inode.c
58225 index 00d5fc3..98ce7d7 100644
58226 --- a/fs/inode.c
58227 +++ b/fs/inode.c
58228 @@ -878,8 +878,8 @@ unsigned int get_next_ino(void)
58229
58230 #ifdef CONFIG_SMP
58231 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
58232 - static atomic_t shared_last_ino;
58233 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
58234 + static atomic_unchecked_t shared_last_ino;
58235 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
58236
58237 res = next - LAST_INO_BATCH;
58238 }
58239 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
58240 index 4a6cf28..d3a29d3 100644
58241 --- a/fs/jffs2/erase.c
58242 +++ b/fs/jffs2/erase.c
58243 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
58244 struct jffs2_unknown_node marker = {
58245 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
58246 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
58247 - .totlen = cpu_to_je32(c->cleanmarker_size)
58248 + .totlen = cpu_to_je32(c->cleanmarker_size),
58249 + .hdr_crc = cpu_to_je32(0)
58250 };
58251
58252 jffs2_prealloc_raw_node_refs(c, jeb, 1);
58253 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
58254 index a6597d6..41b30ec 100644
58255 --- a/fs/jffs2/wbuf.c
58256 +++ b/fs/jffs2/wbuf.c
58257 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
58258 {
58259 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
58260 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
58261 - .totlen = constant_cpu_to_je32(8)
58262 + .totlen = constant_cpu_to_je32(8),
58263 + .hdr_crc = constant_cpu_to_je32(0)
58264 };
58265
58266 /*
58267 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
58268 index 788e0a9..8433098 100644
58269 --- a/fs/jfs/super.c
58270 +++ b/fs/jfs/super.c
58271 @@ -878,7 +878,7 @@ static int __init init_jfs_fs(void)
58272
58273 jfs_inode_cachep =
58274 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
58275 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
58276 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
58277 init_once);
58278 if (jfs_inode_cachep == NULL)
58279 return -ENOMEM;
58280 diff --git a/fs/libfs.c b/fs/libfs.c
58281 index 916da8c..1588998 100644
58282 --- a/fs/libfs.c
58283 +++ b/fs/libfs.c
58284 @@ -165,6 +165,9 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
58285
58286 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
58287 struct dentry *next;
58288 + char d_name[sizeof(next->d_iname)];
58289 + const unsigned char *name;
58290 +
58291 next = list_entry(p, struct dentry, d_u.d_child);
58292 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
58293 if (!simple_positive(next)) {
58294 @@ -174,7 +177,12 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
58295
58296 spin_unlock(&next->d_lock);
58297 spin_unlock(&dentry->d_lock);
58298 - if (filldir(dirent, next->d_name.name,
58299 + name = next->d_name.name;
58300 + if (name == next->d_iname) {
58301 + memcpy(d_name, name, next->d_name.len);
58302 + name = d_name;
58303 + }
58304 + if (filldir(dirent, name,
58305 next->d_name.len, filp->f_pos,
58306 next->d_inode->i_ino,
58307 dt_type(next->d_inode)) < 0)
58308 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
58309 index acd3947..1f896e2 100644
58310 --- a/fs/lockd/clntproc.c
58311 +++ b/fs/lockd/clntproc.c
58312 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
58313 /*
58314 * Cookie counter for NLM requests
58315 */
58316 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
58317 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
58318
58319 void nlmclnt_next_cookie(struct nlm_cookie *c)
58320 {
58321 - u32 cookie = atomic_inc_return(&nlm_cookie);
58322 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
58323
58324 memcpy(c->data, &cookie, 4);
58325 c->len=4;
58326 diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
58327 index a2aa97d..10d6c41 100644
58328 --- a/fs/lockd/svc.c
58329 +++ b/fs/lockd/svc.c
58330 @@ -305,7 +305,7 @@ static int lockd_start_svc(struct svc_serv *serv)
58331 svc_sock_update_bufs(serv);
58332 serv->sv_maxconn = nlm_max_connections;
58333
58334 - nlmsvc_task = kthread_run(lockd, nlmsvc_rqst, serv->sv_name);
58335 + nlmsvc_task = kthread_run(lockd, nlmsvc_rqst, "%s", serv->sv_name);
58336 if (IS_ERR(nlmsvc_task)) {
58337 error = PTR_ERR(nlmsvc_task);
58338 printk(KERN_WARNING
58339 diff --git a/fs/locks.c b/fs/locks.c
58340 index cb424a4..850e4dd 100644
58341 --- a/fs/locks.c
58342 +++ b/fs/locks.c
58343 @@ -2064,16 +2064,16 @@ void locks_remove_flock(struct file *filp)
58344 return;
58345
58346 if (filp->f_op && filp->f_op->flock) {
58347 - struct file_lock fl = {
58348 + struct file_lock flock = {
58349 .fl_pid = current->tgid,
58350 .fl_file = filp,
58351 .fl_flags = FL_FLOCK,
58352 .fl_type = F_UNLCK,
58353 .fl_end = OFFSET_MAX,
58354 };
58355 - filp->f_op->flock(filp, F_SETLKW, &fl);
58356 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
58357 - fl.fl_ops->fl_release_private(&fl);
58358 + filp->f_op->flock(filp, F_SETLKW, &flock);
58359 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
58360 + flock.fl_ops->fl_release_private(&flock);
58361 }
58362
58363 lock_flocks();
58364 diff --git a/fs/namei.c b/fs/namei.c
58365 index 9ed9361..2b72db1 100644
58366 --- a/fs/namei.c
58367 +++ b/fs/namei.c
58368 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
58369 if (ret != -EACCES)
58370 return ret;
58371
58372 +#ifdef CONFIG_GRKERNSEC
58373 + /* we'll block if we have to log due to a denied capability use */
58374 + if (mask & MAY_NOT_BLOCK)
58375 + return -ECHILD;
58376 +#endif
58377 +
58378 if (S_ISDIR(inode->i_mode)) {
58379 /* DACs are overridable for directories */
58380 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
58381 - return 0;
58382 if (!(mask & MAY_WRITE))
58383 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
58384 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
58385 + inode_capable(inode, CAP_DAC_READ_SEARCH))
58386 return 0;
58387 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
58388 + return 0;
58389 return -EACCES;
58390 }
58391 /*
58392 + * Searching includes executable on directories, else just read.
58393 + */
58394 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
58395 + if (mask == MAY_READ)
58396 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
58397 + inode_capable(inode, CAP_DAC_READ_SEARCH))
58398 + return 0;
58399 +
58400 + /*
58401 * Read/write DACs are always overridable.
58402 * Executable DACs are overridable when there is
58403 * at least one exec bit set.
58404 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
58405 if (inode_capable(inode, CAP_DAC_OVERRIDE))
58406 return 0;
58407
58408 - /*
58409 - * Searching includes executable on directories, else just read.
58410 - */
58411 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
58412 - if (mask == MAY_READ)
58413 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
58414 - return 0;
58415 -
58416 return -EACCES;
58417 }
58418
58419 @@ -820,7 +828,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
58420 {
58421 struct dentry *dentry = link->dentry;
58422 int error;
58423 - char *s;
58424 + const char *s;
58425
58426 BUG_ON(nd->flags & LOOKUP_RCU);
58427
58428 @@ -841,6 +849,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
58429 if (error)
58430 goto out_put_nd_path;
58431
58432 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
58433 + dentry->d_inode, dentry, nd->path.mnt)) {
58434 + error = -EACCES;
58435 + goto out_put_nd_path;
58436 + }
58437 +
58438 nd->last_type = LAST_BIND;
58439 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
58440 error = PTR_ERR(*p);
58441 @@ -1588,6 +1602,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
58442 if (res)
58443 break;
58444 res = walk_component(nd, path, LOOKUP_FOLLOW);
58445 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
58446 + res = -EACCES;
58447 put_link(nd, &link, cookie);
58448 } while (res > 0);
58449
58450 @@ -1686,7 +1702,7 @@ EXPORT_SYMBOL(full_name_hash);
58451 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
58452 {
58453 unsigned long a, b, adata, bdata, mask, hash, len;
58454 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
58455 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
58456
58457 hash = a = 0;
58458 len = -sizeof(unsigned long);
58459 @@ -1968,6 +1984,8 @@ static int path_lookupat(int dfd, const char *name,
58460 if (err)
58461 break;
58462 err = lookup_last(nd, &path);
58463 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
58464 + err = -EACCES;
58465 put_link(nd, &link, cookie);
58466 }
58467 }
58468 @@ -1975,6 +1993,13 @@ static int path_lookupat(int dfd, const char *name,
58469 if (!err)
58470 err = complete_walk(nd);
58471
58472 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
58473 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
58474 + path_put(&nd->path);
58475 + err = -ENOENT;
58476 + }
58477 + }
58478 +
58479 if (!err && nd->flags & LOOKUP_DIRECTORY) {
58480 if (!can_lookup(nd->inode)) {
58481 path_put(&nd->path);
58482 @@ -2002,8 +2027,15 @@ static int filename_lookup(int dfd, struct filename *name,
58483 retval = path_lookupat(dfd, name->name,
58484 flags | LOOKUP_REVAL, nd);
58485
58486 - if (likely(!retval))
58487 + if (likely(!retval)) {
58488 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
58489 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
58490 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
58491 + path_put(&nd->path);
58492 + return -ENOENT;
58493 + }
58494 + }
58495 + }
58496 return retval;
58497 }
58498
58499 @@ -2381,6 +2413,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
58500 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
58501 return -EPERM;
58502
58503 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
58504 + return -EPERM;
58505 + if (gr_handle_rawio(inode))
58506 + return -EPERM;
58507 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
58508 + return -EACCES;
58509 +
58510 return 0;
58511 }
58512
58513 @@ -2602,7 +2641,7 @@ looked_up:
58514 * cleared otherwise prior to returning.
58515 */
58516 static int lookup_open(struct nameidata *nd, struct path *path,
58517 - struct file *file,
58518 + struct path *link, struct file *file,
58519 const struct open_flags *op,
58520 bool got_write, int *opened)
58521 {
58522 @@ -2637,6 +2676,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
58523 /* Negative dentry, just create the file */
58524 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
58525 umode_t mode = op->mode;
58526 +
58527 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
58528 + error = -EACCES;
58529 + goto out_dput;
58530 + }
58531 +
58532 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
58533 + error = -EACCES;
58534 + goto out_dput;
58535 + }
58536 +
58537 if (!IS_POSIXACL(dir->d_inode))
58538 mode &= ~current_umask();
58539 /*
58540 @@ -2658,6 +2708,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
58541 nd->flags & LOOKUP_EXCL);
58542 if (error)
58543 goto out_dput;
58544 + else
58545 + gr_handle_create(dentry, nd->path.mnt);
58546 }
58547 out_no_open:
58548 path->dentry = dentry;
58549 @@ -2672,7 +2724,7 @@ out_dput:
58550 /*
58551 * Handle the last step of open()
58552 */
58553 -static int do_last(struct nameidata *nd, struct path *path,
58554 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
58555 struct file *file, const struct open_flags *op,
58556 int *opened, struct filename *name)
58557 {
58558 @@ -2701,16 +2753,32 @@ static int do_last(struct nameidata *nd, struct path *path,
58559 error = complete_walk(nd);
58560 if (error)
58561 return error;
58562 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
58563 + error = -ENOENT;
58564 + goto out;
58565 + }
58566 audit_inode(name, nd->path.dentry, 0);
58567 if (open_flag & O_CREAT) {
58568 error = -EISDIR;
58569 goto out;
58570 }
58571 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
58572 + error = -EACCES;
58573 + goto out;
58574 + }
58575 goto finish_open;
58576 case LAST_BIND:
58577 error = complete_walk(nd);
58578 if (error)
58579 return error;
58580 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
58581 + error = -ENOENT;
58582 + goto out;
58583 + }
58584 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
58585 + error = -EACCES;
58586 + goto out;
58587 + }
58588 audit_inode(name, dir, 0);
58589 goto finish_open;
58590 }
58591 @@ -2759,7 +2827,7 @@ retry_lookup:
58592 */
58593 }
58594 mutex_lock(&dir->d_inode->i_mutex);
58595 - error = lookup_open(nd, path, file, op, got_write, opened);
58596 + error = lookup_open(nd, path, link, file, op, got_write, opened);
58597 mutex_unlock(&dir->d_inode->i_mutex);
58598
58599 if (error <= 0) {
58600 @@ -2783,11 +2851,28 @@ retry_lookup:
58601 goto finish_open_created;
58602 }
58603
58604 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
58605 + error = -ENOENT;
58606 + goto exit_dput;
58607 + }
58608 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
58609 + error = -EACCES;
58610 + goto exit_dput;
58611 + }
58612 +
58613 /*
58614 * create/update audit record if it already exists.
58615 */
58616 - if (path->dentry->d_inode)
58617 + if (path->dentry->d_inode) {
58618 + /* only check if O_CREAT is specified, all other checks need to go
58619 + into may_open */
58620 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
58621 + error = -EACCES;
58622 + goto exit_dput;
58623 + }
58624 +
58625 audit_inode(name, path->dentry, 0);
58626 + }
58627
58628 /*
58629 * If atomic_open() acquired write access it is dropped now due to
58630 @@ -2828,6 +2913,11 @@ finish_lookup:
58631 }
58632 }
58633 BUG_ON(inode != path->dentry->d_inode);
58634 + /* if we're resolving a symlink to another symlink */
58635 + if (link && gr_handle_symlink_owner(link, inode)) {
58636 + error = -EACCES;
58637 + goto out;
58638 + }
58639 return 1;
58640 }
58641
58642 @@ -2837,7 +2927,6 @@ finish_lookup:
58643 save_parent.dentry = nd->path.dentry;
58644 save_parent.mnt = mntget(path->mnt);
58645 nd->path.dentry = path->dentry;
58646 -
58647 }
58648 nd->inode = inode;
58649 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
58650 @@ -2846,6 +2935,16 @@ finish_lookup:
58651 path_put(&save_parent);
58652 return error;
58653 }
58654 +
58655 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
58656 + error = -ENOENT;
58657 + goto out;
58658 + }
58659 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
58660 + error = -EACCES;
58661 + goto out;
58662 + }
58663 +
58664 error = -EISDIR;
58665 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
58666 goto out;
58667 @@ -2944,7 +3043,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
58668 if (unlikely(error))
58669 goto out;
58670
58671 - error = do_last(nd, &path, file, op, &opened, pathname);
58672 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
58673 while (unlikely(error > 0)) { /* trailing symlink */
58674 struct path link = path;
58675 void *cookie;
58676 @@ -2962,7 +3061,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
58677 error = follow_link(&link, nd, &cookie);
58678 if (unlikely(error))
58679 break;
58680 - error = do_last(nd, &path, file, op, &opened, pathname);
58681 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
58682 put_link(nd, &link, cookie);
58683 }
58684 out:
58685 @@ -3062,8 +3161,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
58686 goto unlock;
58687
58688 error = -EEXIST;
58689 - if (dentry->d_inode)
58690 + if (dentry->d_inode) {
58691 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
58692 + error = -ENOENT;
58693 + }
58694 goto fail;
58695 + }
58696 /*
58697 * Special case - lookup gave negative, but... we had foo/bar/
58698 * From the vfs_mknod() POV we just have a negative dentry -
58699 @@ -3115,6 +3218,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
58700 }
58701 EXPORT_SYMBOL(user_path_create);
58702
58703 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
58704 +{
58705 + struct filename *tmp = getname(pathname);
58706 + struct dentry *res;
58707 + if (IS_ERR(tmp))
58708 + return ERR_CAST(tmp);
58709 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
58710 + if (IS_ERR(res))
58711 + putname(tmp);
58712 + else
58713 + *to = tmp;
58714 + return res;
58715 +}
58716 +
58717 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
58718 {
58719 int error = may_create(dir, dentry);
58720 @@ -3177,6 +3294,17 @@ retry:
58721
58722 if (!IS_POSIXACL(path.dentry->d_inode))
58723 mode &= ~current_umask();
58724 +
58725 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
58726 + error = -EPERM;
58727 + goto out;
58728 + }
58729 +
58730 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
58731 + error = -EACCES;
58732 + goto out;
58733 + }
58734 +
58735 error = security_path_mknod(&path, dentry, mode, dev);
58736 if (error)
58737 goto out;
58738 @@ -3193,6 +3321,8 @@ retry:
58739 break;
58740 }
58741 out:
58742 + if (!error)
58743 + gr_handle_create(dentry, path.mnt);
58744 done_path_create(&path, dentry);
58745 if (retry_estale(error, lookup_flags)) {
58746 lookup_flags |= LOOKUP_REVAL;
58747 @@ -3245,9 +3375,16 @@ retry:
58748
58749 if (!IS_POSIXACL(path.dentry->d_inode))
58750 mode &= ~current_umask();
58751 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
58752 + error = -EACCES;
58753 + goto out;
58754 + }
58755 error = security_path_mkdir(&path, dentry, mode);
58756 if (!error)
58757 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
58758 + if (!error)
58759 + gr_handle_create(dentry, path.mnt);
58760 +out:
58761 done_path_create(&path, dentry);
58762 if (retry_estale(error, lookup_flags)) {
58763 lookup_flags |= LOOKUP_REVAL;
58764 @@ -3328,6 +3465,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
58765 struct filename *name;
58766 struct dentry *dentry;
58767 struct nameidata nd;
58768 + ino_t saved_ino = 0;
58769 + dev_t saved_dev = 0;
58770 unsigned int lookup_flags = 0;
58771 retry:
58772 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
58773 @@ -3360,10 +3499,21 @@ retry:
58774 error = -ENOENT;
58775 goto exit3;
58776 }
58777 +
58778 + saved_ino = dentry->d_inode->i_ino;
58779 + saved_dev = gr_get_dev_from_dentry(dentry);
58780 +
58781 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
58782 + error = -EACCES;
58783 + goto exit3;
58784 + }
58785 +
58786 error = security_path_rmdir(&nd.path, dentry);
58787 if (error)
58788 goto exit3;
58789 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
58790 + if (!error && (saved_dev || saved_ino))
58791 + gr_handle_delete(saved_ino, saved_dev);
58792 exit3:
58793 dput(dentry);
58794 exit2:
58795 @@ -3429,6 +3579,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
58796 struct dentry *dentry;
58797 struct nameidata nd;
58798 struct inode *inode = NULL;
58799 + ino_t saved_ino = 0;
58800 + dev_t saved_dev = 0;
58801 unsigned int lookup_flags = 0;
58802 retry:
58803 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
58804 @@ -3455,10 +3607,22 @@ retry:
58805 if (!inode)
58806 goto slashes;
58807 ihold(inode);
58808 +
58809 + if (inode->i_nlink <= 1) {
58810 + saved_ino = inode->i_ino;
58811 + saved_dev = gr_get_dev_from_dentry(dentry);
58812 + }
58813 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
58814 + error = -EACCES;
58815 + goto exit2;
58816 + }
58817 +
58818 error = security_path_unlink(&nd.path, dentry);
58819 if (error)
58820 goto exit2;
58821 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
58822 + if (!error && (saved_ino || saved_dev))
58823 + gr_handle_delete(saved_ino, saved_dev);
58824 exit2:
58825 dput(dentry);
58826 }
58827 @@ -3536,9 +3700,17 @@ retry:
58828 if (IS_ERR(dentry))
58829 goto out_putname;
58830
58831 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
58832 + error = -EACCES;
58833 + goto out;
58834 + }
58835 +
58836 error = security_path_symlink(&path, dentry, from->name);
58837 if (!error)
58838 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
58839 + if (!error)
58840 + gr_handle_create(dentry, path.mnt);
58841 +out:
58842 done_path_create(&path, dentry);
58843 if (retry_estale(error, lookup_flags)) {
58844 lookup_flags |= LOOKUP_REVAL;
58845 @@ -3612,6 +3784,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
58846 {
58847 struct dentry *new_dentry;
58848 struct path old_path, new_path;
58849 + struct filename *to = NULL;
58850 int how = 0;
58851 int error;
58852
58853 @@ -3635,7 +3808,7 @@ retry:
58854 if (error)
58855 return error;
58856
58857 - new_dentry = user_path_create(newdfd, newname, &new_path,
58858 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
58859 (how & LOOKUP_REVAL));
58860 error = PTR_ERR(new_dentry);
58861 if (IS_ERR(new_dentry))
58862 @@ -3647,11 +3820,28 @@ retry:
58863 error = may_linkat(&old_path);
58864 if (unlikely(error))
58865 goto out_dput;
58866 +
58867 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
58868 + old_path.dentry->d_inode,
58869 + old_path.dentry->d_inode->i_mode, to)) {
58870 + error = -EACCES;
58871 + goto out_dput;
58872 + }
58873 +
58874 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
58875 + old_path.dentry, old_path.mnt, to)) {
58876 + error = -EACCES;
58877 + goto out_dput;
58878 + }
58879 +
58880 error = security_path_link(old_path.dentry, &new_path, new_dentry);
58881 if (error)
58882 goto out_dput;
58883 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
58884 + if (!error)
58885 + gr_handle_create(new_dentry, new_path.mnt);
58886 out_dput:
58887 + putname(to);
58888 done_path_create(&new_path, new_dentry);
58889 if (retry_estale(error, how)) {
58890 how |= LOOKUP_REVAL;
58891 @@ -3897,12 +4087,21 @@ retry:
58892 if (new_dentry == trap)
58893 goto exit5;
58894
58895 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
58896 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
58897 + to);
58898 + if (error)
58899 + goto exit5;
58900 +
58901 error = security_path_rename(&oldnd.path, old_dentry,
58902 &newnd.path, new_dentry);
58903 if (error)
58904 goto exit5;
58905 error = vfs_rename(old_dir->d_inode, old_dentry,
58906 new_dir->d_inode, new_dentry);
58907 + if (!error)
58908 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
58909 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
58910 exit5:
58911 dput(new_dentry);
58912 exit4:
58913 @@ -3934,6 +4133,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
58914
58915 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
58916 {
58917 + char tmpbuf[64];
58918 + const char *newlink;
58919 int len;
58920
58921 len = PTR_ERR(link);
58922 @@ -3943,7 +4144,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
58923 len = strlen(link);
58924 if (len > (unsigned) buflen)
58925 len = buflen;
58926 - if (copy_to_user(buffer, link, len))
58927 +
58928 + if (len < sizeof(tmpbuf)) {
58929 + memcpy(tmpbuf, link, len);
58930 + newlink = tmpbuf;
58931 + } else
58932 + newlink = link;
58933 +
58934 + if (copy_to_user(buffer, newlink, len))
58935 len = -EFAULT;
58936 out:
58937 return len;
58938 diff --git a/fs/namespace.c b/fs/namespace.c
58939 index a45ba4f..44cfe66 100644
58940 --- a/fs/namespace.c
58941 +++ b/fs/namespace.c
58942 @@ -1265,6 +1265,9 @@ static int do_umount(struct mount *mnt, int flags)
58943 if (!(sb->s_flags & MS_RDONLY))
58944 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
58945 up_write(&sb->s_umount);
58946 +
58947 + gr_log_remount(mnt->mnt_devname, retval);
58948 +
58949 return retval;
58950 }
58951
58952 @@ -1283,6 +1286,9 @@ static int do_umount(struct mount *mnt, int flags)
58953 }
58954 br_write_unlock(&vfsmount_lock);
58955 namespace_unlock();
58956 +
58957 + gr_log_unmount(mnt->mnt_devname, retval);
58958 +
58959 return retval;
58960 }
58961
58962 @@ -1302,7 +1308,7 @@ static inline bool may_mount(void)
58963 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
58964 */
58965
58966 -SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
58967 +SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
58968 {
58969 struct path path;
58970 struct mount *mnt;
58971 @@ -1342,7 +1348,7 @@ out:
58972 /*
58973 * The 2.0 compatible umount. No flags.
58974 */
58975 -SYSCALL_DEFINE1(oldumount, char __user *, name)
58976 +SYSCALL_DEFINE1(oldumount, const char __user *, name)
58977 {
58978 return sys_umount(name, 0);
58979 }
58980 @@ -2313,6 +2319,16 @@ long do_mount(const char *dev_name, const char *dir_name,
58981 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
58982 MS_STRICTATIME);
58983
58984 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
58985 + retval = -EPERM;
58986 + goto dput_out;
58987 + }
58988 +
58989 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
58990 + retval = -EPERM;
58991 + goto dput_out;
58992 + }
58993 +
58994 if (flags & MS_REMOUNT)
58995 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
58996 data_page);
58997 @@ -2327,6 +2343,9 @@ long do_mount(const char *dev_name, const char *dir_name,
58998 dev_name, data_page);
58999 dput_out:
59000 path_put(&path);
59001 +
59002 + gr_log_mount(dev_name, dir_name, retval);
59003 +
59004 return retval;
59005 }
59006
59007 @@ -2344,7 +2363,7 @@ static void free_mnt_ns(struct mnt_namespace *ns)
59008 * number incrementing at 10Ghz will take 12,427 years to wrap which
59009 * is effectively never, so we can ignore the possibility.
59010 */
59011 -static atomic64_t mnt_ns_seq = ATOMIC64_INIT(1);
59012 +static atomic64_unchecked_t mnt_ns_seq = ATOMIC64_INIT(1);
59013
59014 static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
59015 {
59016 @@ -2359,7 +2378,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
59017 kfree(new_ns);
59018 return ERR_PTR(ret);
59019 }
59020 - new_ns->seq = atomic64_add_return(1, &mnt_ns_seq);
59021 + new_ns->seq = atomic64_inc_return_unchecked(&mnt_ns_seq);
59022 atomic_set(&new_ns->count, 1);
59023 new_ns->root = NULL;
59024 INIT_LIST_HEAD(&new_ns->list);
59025 @@ -2500,8 +2519,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
59026 }
59027 EXPORT_SYMBOL(mount_subtree);
59028
59029 -SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
59030 - char __user *, type, unsigned long, flags, void __user *, data)
59031 +SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
59032 + const char __user *, type, unsigned long, flags, void __user *, data)
59033 {
59034 int ret;
59035 char *kernel_type;
59036 @@ -2614,6 +2633,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
59037 if (error)
59038 goto out2;
59039
59040 + if (gr_handle_chroot_pivot()) {
59041 + error = -EPERM;
59042 + goto out2;
59043 + }
59044 +
59045 get_fs_root(current->fs, &root);
59046 old_mp = lock_mount(&old);
59047 error = PTR_ERR(old_mp);
59048 @@ -2864,7 +2888,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
59049 !nsown_capable(CAP_SYS_ADMIN))
59050 return -EPERM;
59051
59052 - if (fs->users != 1)
59053 + if (atomic_read(&fs->users) != 1)
59054 return -EINVAL;
59055
59056 get_mnt_ns(mnt_ns);
59057 diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
59058 index cff089a..4c3d57a 100644
59059 --- a/fs/nfs/callback.c
59060 +++ b/fs/nfs/callback.c
59061 @@ -211,7 +211,6 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,
59062 struct svc_rqst *rqstp;
59063 int (*callback_svc)(void *vrqstp);
59064 struct nfs_callback_data *cb_info = &nfs_callback_info[minorversion];
59065 - char svc_name[12];
59066 int ret;
59067
59068 nfs_callback_bc_serv(minorversion, xprt, serv);
59069 @@ -235,10 +234,9 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,
59070
59071 svc_sock_update_bufs(serv);
59072
59073 - sprintf(svc_name, "nfsv4.%u-svc", minorversion);
59074 cb_info->serv = serv;
59075 cb_info->rqst = rqstp;
59076 - cb_info->task = kthread_run(callback_svc, cb_info->rqst, svc_name);
59077 + cb_info->task = kthread_run(callback_svc, cb_info->rqst, "nfsv4.%u-svc", minorversion);
59078 if (IS_ERR(cb_info->task)) {
59079 ret = PTR_ERR(cb_info->task);
59080 svc_exit_thread(cb_info->rqst);
59081 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
59082 index a35582c..ebbdcd5 100644
59083 --- a/fs/nfs/callback_xdr.c
59084 +++ b/fs/nfs/callback_xdr.c
59085 @@ -51,7 +51,7 @@ struct callback_op {
59086 callback_decode_arg_t decode_args;
59087 callback_encode_res_t encode_res;
59088 long res_maxsize;
59089 -};
59090 +} __do_const;
59091
59092 static struct callback_op callback_ops[];
59093
59094 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
59095 index c1c7a9d..7afa0b8 100644
59096 --- a/fs/nfs/inode.c
59097 +++ b/fs/nfs/inode.c
59098 @@ -1043,16 +1043,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
59099 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
59100 }
59101
59102 -static atomic_long_t nfs_attr_generation_counter;
59103 +static atomic_long_unchecked_t nfs_attr_generation_counter;
59104
59105 static unsigned long nfs_read_attr_generation_counter(void)
59106 {
59107 - return atomic_long_read(&nfs_attr_generation_counter);
59108 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
59109 }
59110
59111 unsigned long nfs_inc_attr_generation_counter(void)
59112 {
59113 - return atomic_long_inc_return(&nfs_attr_generation_counter);
59114 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
59115 }
59116
59117 void nfs_fattr_init(struct nfs_fattr *fattr)
59118 diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
59119 index 2c37442..9b9538b 100644
59120 --- a/fs/nfs/nfs4state.c
59121 +++ b/fs/nfs/nfs4state.c
59122 @@ -1193,7 +1193,7 @@ void nfs4_schedule_state_manager(struct nfs_client *clp)
59123 snprintf(buf, sizeof(buf), "%s-manager",
59124 rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR));
59125 rcu_read_unlock();
59126 - task = kthread_run(nfs4_run_state_manager, clp, buf);
59127 + task = kthread_run(nfs4_run_state_manager, clp, "%s", buf);
59128 if (IS_ERR(task)) {
59129 printk(KERN_ERR "%s: kthread_run: %ld\n",
59130 __func__, PTR_ERR(task));
59131 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
59132 index 27d74a2..c4c2a73 100644
59133 --- a/fs/nfsd/nfs4proc.c
59134 +++ b/fs/nfsd/nfs4proc.c
59135 @@ -1126,7 +1126,7 @@ struct nfsd4_operation {
59136 nfsd4op_rsize op_rsize_bop;
59137 stateid_getter op_get_currentstateid;
59138 stateid_setter op_set_currentstateid;
59139 -};
59140 +} __do_const;
59141
59142 static struct nfsd4_operation nfsd4_ops[];
59143
59144 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
59145 index 582321a..0224663 100644
59146 --- a/fs/nfsd/nfs4xdr.c
59147 +++ b/fs/nfsd/nfs4xdr.c
59148 @@ -1458,7 +1458,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
59149
59150 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
59151
59152 -static nfsd4_dec nfsd4_dec_ops[] = {
59153 +static const nfsd4_dec nfsd4_dec_ops[] = {
59154 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
59155 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
59156 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
59157 @@ -1498,7 +1498,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
59158 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
59159 };
59160
59161 -static nfsd4_dec nfsd41_dec_ops[] = {
59162 +static const nfsd4_dec nfsd41_dec_ops[] = {
59163 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
59164 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
59165 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
59166 @@ -1560,7 +1560,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
59167 };
59168
59169 struct nfsd4_minorversion_ops {
59170 - nfsd4_dec *decoders;
59171 + const nfsd4_dec *decoders;
59172 int nops;
59173 };
59174
59175 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
59176 index e76244e..9fe8f2f1 100644
59177 --- a/fs/nfsd/nfscache.c
59178 +++ b/fs/nfsd/nfscache.c
59179 @@ -526,14 +526,17 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
59180 {
59181 struct svc_cacherep *rp = rqstp->rq_cacherep;
59182 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
59183 - int len;
59184 + long len;
59185 size_t bufsize = 0;
59186
59187 if (!rp)
59188 return;
59189
59190 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
59191 - len >>= 2;
59192 + if (statp) {
59193 + len = (char*)statp - (char*)resv->iov_base;
59194 + len = resv->iov_len - len;
59195 + len >>= 2;
59196 + }
59197
59198 /* Don't cache excessive amounts of data and XDR failures */
59199 if (!statp || len > (256 >> 2)) {
59200 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
59201 index baf149a..76b86ad 100644
59202 --- a/fs/nfsd/vfs.c
59203 +++ b/fs/nfsd/vfs.c
59204 @@ -940,7 +940,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
59205 } else {
59206 oldfs = get_fs();
59207 set_fs(KERNEL_DS);
59208 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
59209 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
59210 set_fs(oldfs);
59211 }
59212
59213 @@ -1027,7 +1027,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
59214
59215 /* Write the data. */
59216 oldfs = get_fs(); set_fs(KERNEL_DS);
59217 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
59218 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
59219 set_fs(oldfs);
59220 if (host_err < 0)
59221 goto out_nfserr;
59222 @@ -1573,7 +1573,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
59223 */
59224
59225 oldfs = get_fs(); set_fs(KERNEL_DS);
59226 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
59227 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
59228 set_fs(oldfs);
59229
59230 if (host_err < 0)
59231 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
59232 index fea6bd5..8ee9d81 100644
59233 --- a/fs/nls/nls_base.c
59234 +++ b/fs/nls/nls_base.c
59235 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
59236
59237 int register_nls(struct nls_table * nls)
59238 {
59239 - struct nls_table ** tmp = &tables;
59240 + struct nls_table *tmp = tables;
59241
59242 if (nls->next)
59243 return -EBUSY;
59244
59245 spin_lock(&nls_lock);
59246 - while (*tmp) {
59247 - if (nls == *tmp) {
59248 + while (tmp) {
59249 + if (nls == tmp) {
59250 spin_unlock(&nls_lock);
59251 return -EBUSY;
59252 }
59253 - tmp = &(*tmp)->next;
59254 + tmp = tmp->next;
59255 }
59256 - nls->next = tables;
59257 + pax_open_kernel();
59258 + *(struct nls_table **)&nls->next = tables;
59259 + pax_close_kernel();
59260 tables = nls;
59261 spin_unlock(&nls_lock);
59262 return 0;
59263 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
59264
59265 int unregister_nls(struct nls_table * nls)
59266 {
59267 - struct nls_table ** tmp = &tables;
59268 + struct nls_table * const * tmp = &tables;
59269
59270 spin_lock(&nls_lock);
59271 while (*tmp) {
59272 if (nls == *tmp) {
59273 - *tmp = nls->next;
59274 + pax_open_kernel();
59275 + *(struct nls_table **)tmp = nls->next;
59276 + pax_close_kernel();
59277 spin_unlock(&nls_lock);
59278 return 0;
59279 }
59280 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
59281 index 7424929..35f6be5 100644
59282 --- a/fs/nls/nls_euc-jp.c
59283 +++ b/fs/nls/nls_euc-jp.c
59284 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
59285 p_nls = load_nls("cp932");
59286
59287 if (p_nls) {
59288 - table.charset2upper = p_nls->charset2upper;
59289 - table.charset2lower = p_nls->charset2lower;
59290 + pax_open_kernel();
59291 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
59292 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
59293 + pax_close_kernel();
59294 return register_nls(&table);
59295 }
59296
59297 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
59298 index e7bc1d7..06bd4bb 100644
59299 --- a/fs/nls/nls_koi8-ru.c
59300 +++ b/fs/nls/nls_koi8-ru.c
59301 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
59302 p_nls = load_nls("koi8-u");
59303
59304 if (p_nls) {
59305 - table.charset2upper = p_nls->charset2upper;
59306 - table.charset2lower = p_nls->charset2lower;
59307 + pax_open_kernel();
59308 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
59309 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
59310 + pax_close_kernel();
59311 return register_nls(&table);
59312 }
59313
59314 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
59315 index 77cc85d..a1e6299 100644
59316 --- a/fs/notify/fanotify/fanotify_user.c
59317 +++ b/fs/notify/fanotify/fanotify_user.c
59318 @@ -253,8 +253,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
59319
59320 fd = fanotify_event_metadata.fd;
59321 ret = -EFAULT;
59322 - if (copy_to_user(buf, &fanotify_event_metadata,
59323 - fanotify_event_metadata.event_len))
59324 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
59325 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
59326 goto out_close_fd;
59327
59328 ret = prepare_for_access_response(group, event, fd);
59329 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
59330 index 7b51b05..5ea5ef6 100644
59331 --- a/fs/notify/notification.c
59332 +++ b/fs/notify/notification.c
59333 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
59334 * get set to 0 so it will never get 'freed'
59335 */
59336 static struct fsnotify_event *q_overflow_event;
59337 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
59338 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
59339
59340 /**
59341 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
59342 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
59343 */
59344 u32 fsnotify_get_cookie(void)
59345 {
59346 - return atomic_inc_return(&fsnotify_sync_cookie);
59347 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
59348 }
59349 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
59350
59351 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
59352 index aa411c3..c260a84 100644
59353 --- a/fs/ntfs/dir.c
59354 +++ b/fs/ntfs/dir.c
59355 @@ -1329,7 +1329,7 @@ find_next_index_buffer:
59356 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
59357 ~(s64)(ndir->itype.index.block_size - 1)));
59358 /* Bounds checks. */
59359 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
59360 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
59361 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
59362 "inode 0x%lx or driver bug.", vdir->i_ino);
59363 goto err_out;
59364 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
59365 index c5670b8..2b43d9b 100644
59366 --- a/fs/ntfs/file.c
59367 +++ b/fs/ntfs/file.c
59368 @@ -1282,7 +1282,7 @@ static inline size_t ntfs_copy_from_user(struct page **pages,
59369 char *addr;
59370 size_t total = 0;
59371 unsigned len;
59372 - int left;
59373 + unsigned left;
59374
59375 do {
59376 len = PAGE_CACHE_SIZE - ofs;
59377 @@ -2241,6 +2241,6 @@ const struct inode_operations ntfs_file_inode_ops = {
59378 #endif /* NTFS_RW */
59379 };
59380
59381 -const struct file_operations ntfs_empty_file_ops = {};
59382 +const struct file_operations ntfs_empty_file_ops __read_only;
59383
59384 -const struct inode_operations ntfs_empty_inode_ops = {};
59385 +const struct inode_operations ntfs_empty_inode_ops __read_only;
59386 diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
59387 index 82650d5..db37dcf 100644
59388 --- a/fs/ntfs/super.c
59389 +++ b/fs/ntfs/super.c
59390 @@ -685,7 +685,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
59391 if (!silent)
59392 ntfs_error(sb, "Primary boot sector is invalid.");
59393 } else if (!silent)
59394 - ntfs_error(sb, read_err_str, "primary");
59395 + ntfs_error(sb, read_err_str, "%s", "primary");
59396 if (!(NTFS_SB(sb)->on_errors & ON_ERRORS_RECOVER)) {
59397 if (bh_primary)
59398 brelse(bh_primary);
59399 @@ -701,7 +701,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
59400 goto hotfix_primary_boot_sector;
59401 brelse(bh_backup);
59402 } else if (!silent)
59403 - ntfs_error(sb, read_err_str, "backup");
59404 + ntfs_error(sb, read_err_str, "%s", "backup");
59405 /* Try to read NT3.51- backup boot sector. */
59406 if ((bh_backup = sb_bread(sb, nr_blocks >> 1))) {
59407 if (is_boot_sector_ntfs(sb, (NTFS_BOOT_SECTOR*)
59408 @@ -712,7 +712,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
59409 "sector.");
59410 brelse(bh_backup);
59411 } else if (!silent)
59412 - ntfs_error(sb, read_err_str, "backup");
59413 + ntfs_error(sb, read_err_str, "%s", "backup");
59414 /* We failed. Cleanup and return. */
59415 if (bh_primary)
59416 brelse(bh_primary);
59417 diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
59418 index 20dfec7..e238cb7 100644
59419 --- a/fs/ocfs2/aops.c
59420 +++ b/fs/ocfs2/aops.c
59421 @@ -1756,7 +1756,7 @@ try_again:
59422 goto out;
59423 } else if (ret == 1) {
59424 clusters_need = wc->w_clen;
59425 - ret = ocfs2_refcount_cow(inode, filp, di_bh,
59426 + ret = ocfs2_refcount_cow(inode, di_bh,
59427 wc->w_cpos, wc->w_clen, UINT_MAX);
59428 if (ret) {
59429 mlog_errno(ret);
59430 diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
59431 index ff54014..ff125fd 100644
59432 --- a/fs/ocfs2/file.c
59433 +++ b/fs/ocfs2/file.c
59434 @@ -370,7 +370,7 @@ static int ocfs2_cow_file_pos(struct inode *inode,
59435 if (!(ext_flags & OCFS2_EXT_REFCOUNTED))
59436 goto out;
59437
59438 - return ocfs2_refcount_cow(inode, NULL, fe_bh, cpos, 1, cpos+1);
59439 + return ocfs2_refcount_cow(inode, fe_bh, cpos, 1, cpos+1);
59440
59441 out:
59442 return status;
59443 @@ -899,7 +899,7 @@ static int ocfs2_zero_extend_get_range(struct inode *inode,
59444 zero_clusters = last_cpos - zero_cpos;
59445
59446 if (needs_cow) {
59447 - rc = ocfs2_refcount_cow(inode, NULL, di_bh, zero_cpos,
59448 + rc = ocfs2_refcount_cow(inode, di_bh, zero_cpos,
59449 zero_clusters, UINT_MAX);
59450 if (rc) {
59451 mlog_errno(rc);
59452 @@ -2078,7 +2078,7 @@ static int ocfs2_prepare_inode_for_refcount(struct inode *inode,
59453
59454 *meta_level = 1;
59455
59456 - ret = ocfs2_refcount_cow(inode, file, di_bh, cpos, clusters, UINT_MAX);
59457 + ret = ocfs2_refcount_cow(inode, di_bh, cpos, clusters, UINT_MAX);
59458 if (ret)
59459 mlog_errno(ret);
59460 out:
59461 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
59462 index aebeacd..0dcdd26 100644
59463 --- a/fs/ocfs2/localalloc.c
59464 +++ b/fs/ocfs2/localalloc.c
59465 @@ -1278,7 +1278,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
59466 goto bail;
59467 }
59468
59469 - atomic_inc(&osb->alloc_stats.moves);
59470 + atomic_inc_unchecked(&osb->alloc_stats.moves);
59471
59472 bail:
59473 if (handle)
59474 diff --git a/fs/ocfs2/move_extents.c b/fs/ocfs2/move_extents.c
59475 index f1fc172..452068b 100644
59476 --- a/fs/ocfs2/move_extents.c
59477 +++ b/fs/ocfs2/move_extents.c
59478 @@ -69,7 +69,7 @@ static int __ocfs2_move_extent(handle_t *handle,
59479 u64 ino = ocfs2_metadata_cache_owner(context->et.et_ci);
59480 u64 old_blkno = ocfs2_clusters_to_blocks(inode->i_sb, p_cpos);
59481
59482 - ret = ocfs2_duplicate_clusters_by_page(handle, context->file, cpos,
59483 + ret = ocfs2_duplicate_clusters_by_page(handle, inode, cpos,
59484 p_cpos, new_p_cpos, len);
59485 if (ret) {
59486 mlog_errno(ret);
59487 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
59488 index d355e6e..578d905 100644
59489 --- a/fs/ocfs2/ocfs2.h
59490 +++ b/fs/ocfs2/ocfs2.h
59491 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
59492
59493 struct ocfs2_alloc_stats
59494 {
59495 - atomic_t moves;
59496 - atomic_t local_data;
59497 - atomic_t bitmap_data;
59498 - atomic_t bg_allocs;
59499 - atomic_t bg_extends;
59500 + atomic_unchecked_t moves;
59501 + atomic_unchecked_t local_data;
59502 + atomic_unchecked_t bitmap_data;
59503 + atomic_unchecked_t bg_allocs;
59504 + atomic_unchecked_t bg_extends;
59505 };
59506
59507 enum ocfs2_local_alloc_state
59508 diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
59509 index 998b17e..aefe414 100644
59510 --- a/fs/ocfs2/refcounttree.c
59511 +++ b/fs/ocfs2/refcounttree.c
59512 @@ -49,7 +49,6 @@
59513
59514 struct ocfs2_cow_context {
59515 struct inode *inode;
59516 - struct file *file;
59517 u32 cow_start;
59518 u32 cow_len;
59519 struct ocfs2_extent_tree data_et;
59520 @@ -66,7 +65,7 @@ struct ocfs2_cow_context {
59521 u32 *num_clusters,
59522 unsigned int *extent_flags);
59523 int (*cow_duplicate_clusters)(handle_t *handle,
59524 - struct file *file,
59525 + struct inode *inode,
59526 u32 cpos, u32 old_cluster,
59527 u32 new_cluster, u32 new_len);
59528 };
59529 @@ -2922,14 +2921,12 @@ static int ocfs2_clear_cow_buffer(handle_t *handle, struct buffer_head *bh)
59530 }
59531
59532 int ocfs2_duplicate_clusters_by_page(handle_t *handle,
59533 - struct file *file,
59534 + struct inode *inode,
59535 u32 cpos, u32 old_cluster,
59536 u32 new_cluster, u32 new_len)
59537 {
59538 int ret = 0, partial;
59539 - struct inode *inode = file_inode(file);
59540 - struct ocfs2_caching_info *ci = INODE_CACHE(inode);
59541 - struct super_block *sb = ocfs2_metadata_cache_get_super(ci);
59542 + struct super_block *sb = inode->i_sb;
59543 u64 new_block = ocfs2_clusters_to_blocks(sb, new_cluster);
59544 struct page *page;
59545 pgoff_t page_index;
59546 @@ -2973,13 +2970,6 @@ int ocfs2_duplicate_clusters_by_page(handle_t *handle,
59547 if (PAGE_CACHE_SIZE <= OCFS2_SB(sb)->s_clustersize)
59548 BUG_ON(PageDirty(page));
59549
59550 - if (PageReadahead(page)) {
59551 - page_cache_async_readahead(mapping,
59552 - &file->f_ra, file,
59553 - page, page_index,
59554 - readahead_pages);
59555 - }
59556 -
59557 if (!PageUptodate(page)) {
59558 ret = block_read_full_page(page, ocfs2_get_block);
59559 if (ret) {
59560 @@ -2999,7 +2989,8 @@ int ocfs2_duplicate_clusters_by_page(handle_t *handle,
59561 }
59562 }
59563
59564 - ocfs2_map_and_dirty_page(inode, handle, from, to,
59565 + ocfs2_map_and_dirty_page(inode,
59566 + handle, from, to,
59567 page, 0, &new_block);
59568 mark_page_accessed(page);
59569 unlock:
59570 @@ -3015,12 +3006,11 @@ unlock:
59571 }
59572
59573 int ocfs2_duplicate_clusters_by_jbd(handle_t *handle,
59574 - struct file *file,
59575 + struct inode *inode,
59576 u32 cpos, u32 old_cluster,
59577 u32 new_cluster, u32 new_len)
59578 {
59579 int ret = 0;
59580 - struct inode *inode = file_inode(file);
59581 struct super_block *sb = inode->i_sb;
59582 struct ocfs2_caching_info *ci = INODE_CACHE(inode);
59583 int i, blocks = ocfs2_clusters_to_blocks(sb, new_len);
59584 @@ -3145,7 +3135,7 @@ static int ocfs2_replace_clusters(handle_t *handle,
59585
59586 /*If the old clusters is unwritten, no need to duplicate. */
59587 if (!(ext_flags & OCFS2_EXT_UNWRITTEN)) {
59588 - ret = context->cow_duplicate_clusters(handle, context->file,
59589 + ret = context->cow_duplicate_clusters(handle, context->inode,
59590 cpos, old, new, len);
59591 if (ret) {
59592 mlog_errno(ret);
59593 @@ -3423,35 +3413,12 @@ static int ocfs2_replace_cow(struct ocfs2_cow_context *context)
59594 return ret;
59595 }
59596
59597 -static void ocfs2_readahead_for_cow(struct inode *inode,
59598 - struct file *file,
59599 - u32 start, u32 len)
59600 -{
59601 - struct address_space *mapping;
59602 - pgoff_t index;
59603 - unsigned long num_pages;
59604 - int cs_bits = OCFS2_SB(inode->i_sb)->s_clustersize_bits;
59605 -
59606 - if (!file)
59607 - return;
59608 -
59609 - mapping = file->f_mapping;
59610 - num_pages = (len << cs_bits) >> PAGE_CACHE_SHIFT;
59611 - if (!num_pages)
59612 - num_pages = 1;
59613 -
59614 - index = ((loff_t)start << cs_bits) >> PAGE_CACHE_SHIFT;
59615 - page_cache_sync_readahead(mapping, &file->f_ra, file,
59616 - index, num_pages);
59617 -}
59618 -
59619 /*
59620 * Starting at cpos, try to CoW write_len clusters. Don't CoW
59621 * past max_cpos. This will stop when it runs into a hole or an
59622 * unrefcounted extent.
59623 */
59624 static int ocfs2_refcount_cow_hunk(struct inode *inode,
59625 - struct file *file,
59626 struct buffer_head *di_bh,
59627 u32 cpos, u32 write_len, u32 max_cpos)
59628 {
59629 @@ -3480,8 +3447,6 @@ static int ocfs2_refcount_cow_hunk(struct inode *inode,
59630
59631 BUG_ON(cow_len == 0);
59632
59633 - ocfs2_readahead_for_cow(inode, file, cow_start, cow_len);
59634 -
59635 context = kzalloc(sizeof(struct ocfs2_cow_context), GFP_NOFS);
59636 if (!context) {
59637 ret = -ENOMEM;
59638 @@ -3503,7 +3468,6 @@ static int ocfs2_refcount_cow_hunk(struct inode *inode,
59639 context->ref_root_bh = ref_root_bh;
59640 context->cow_duplicate_clusters = ocfs2_duplicate_clusters_by_page;
59641 context->get_clusters = ocfs2_di_get_clusters;
59642 - context->file = file;
59643
59644 ocfs2_init_dinode_extent_tree(&context->data_et,
59645 INODE_CACHE(inode), di_bh);
59646 @@ -3532,7 +3496,6 @@ out:
59647 * clusters between cpos and cpos+write_len are safe to modify.
59648 */
59649 int ocfs2_refcount_cow(struct inode *inode,
59650 - struct file *file,
59651 struct buffer_head *di_bh,
59652 u32 cpos, u32 write_len, u32 max_cpos)
59653 {
59654 @@ -3552,7 +3515,7 @@ int ocfs2_refcount_cow(struct inode *inode,
59655 num_clusters = write_len;
59656
59657 if (ext_flags & OCFS2_EXT_REFCOUNTED) {
59658 - ret = ocfs2_refcount_cow_hunk(inode, file, di_bh, cpos,
59659 + ret = ocfs2_refcount_cow_hunk(inode, di_bh, cpos,
59660 num_clusters, max_cpos);
59661 if (ret) {
59662 mlog_errno(ret);
59663 diff --git a/fs/ocfs2/refcounttree.h b/fs/ocfs2/refcounttree.h
59664 index 7754608..6422bbcdb 100644
59665 --- a/fs/ocfs2/refcounttree.h
59666 +++ b/fs/ocfs2/refcounttree.h
59667 @@ -53,7 +53,7 @@ int ocfs2_prepare_refcount_change_for_del(struct inode *inode,
59668 int *credits,
59669 int *ref_blocks);
59670 int ocfs2_refcount_cow(struct inode *inode,
59671 - struct file *filep, struct buffer_head *di_bh,
59672 + struct buffer_head *di_bh,
59673 u32 cpos, u32 write_len, u32 max_cpos);
59674
59675 typedef int (ocfs2_post_refcount_func)(struct inode *inode,
59676 @@ -85,11 +85,11 @@ int ocfs2_refcount_cow_xattr(struct inode *inode,
59677 u32 cpos, u32 write_len,
59678 struct ocfs2_post_refcount *post);
59679 int ocfs2_duplicate_clusters_by_page(handle_t *handle,
59680 - struct file *file,
59681 + struct inode *inode,
59682 u32 cpos, u32 old_cluster,
59683 u32 new_cluster, u32 new_len);
59684 int ocfs2_duplicate_clusters_by_jbd(handle_t *handle,
59685 - struct file *file,
59686 + struct inode *inode,
59687 u32 cpos, u32 old_cluster,
59688 u32 new_cluster, u32 new_len);
59689 int ocfs2_cow_sync_writeback(struct super_block *sb,
59690 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
59691 index b7e74b5..19c6536 100644
59692 --- a/fs/ocfs2/suballoc.c
59693 +++ b/fs/ocfs2/suballoc.c
59694 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
59695 mlog_errno(status);
59696 goto bail;
59697 }
59698 - atomic_inc(&osb->alloc_stats.bg_extends);
59699 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
59700
59701 /* You should never ask for this much metadata */
59702 BUG_ON(bits_wanted >
59703 @@ -2007,7 +2007,7 @@ int ocfs2_claim_metadata(handle_t *handle,
59704 mlog_errno(status);
59705 goto bail;
59706 }
59707 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59708 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59709
59710 *suballoc_loc = res.sr_bg_blkno;
59711 *suballoc_bit_start = res.sr_bit_offset;
59712 @@ -2171,7 +2171,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
59713 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
59714 res->sr_bits);
59715
59716 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59717 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59718
59719 BUG_ON(res->sr_bits != 1);
59720
59721 @@ -2213,7 +2213,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
59722 mlog_errno(status);
59723 goto bail;
59724 }
59725 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59726 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59727
59728 BUG_ON(res.sr_bits != 1);
59729
59730 @@ -2317,7 +2317,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
59731 cluster_start,
59732 num_clusters);
59733 if (!status)
59734 - atomic_inc(&osb->alloc_stats.local_data);
59735 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
59736 } else {
59737 if (min_clusters > (osb->bitmap_cpg - 1)) {
59738 /* The only paths asking for contiguousness
59739 @@ -2343,7 +2343,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
59740 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
59741 res.sr_bg_blkno,
59742 res.sr_bit_offset);
59743 - atomic_inc(&osb->alloc_stats.bitmap_data);
59744 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
59745 *num_clusters = res.sr_bits;
59746 }
59747 }
59748 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
59749 index 01b8516..579c4df 100644
59750 --- a/fs/ocfs2/super.c
59751 +++ b/fs/ocfs2/super.c
59752 @@ -301,11 +301,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
59753 "%10s => GlobalAllocs: %d LocalAllocs: %d "
59754 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
59755 "Stats",
59756 - atomic_read(&osb->alloc_stats.bitmap_data),
59757 - atomic_read(&osb->alloc_stats.local_data),
59758 - atomic_read(&osb->alloc_stats.bg_allocs),
59759 - atomic_read(&osb->alloc_stats.moves),
59760 - atomic_read(&osb->alloc_stats.bg_extends));
59761 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
59762 + atomic_read_unchecked(&osb->alloc_stats.local_data),
59763 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
59764 + atomic_read_unchecked(&osb->alloc_stats.moves),
59765 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
59766
59767 out += snprintf(buf + out, len - out,
59768 "%10s => State: %u Descriptor: %llu Size: %u bits "
59769 @@ -2122,11 +2122,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
59770 spin_lock_init(&osb->osb_xattr_lock);
59771 ocfs2_init_steal_slots(osb);
59772
59773 - atomic_set(&osb->alloc_stats.moves, 0);
59774 - atomic_set(&osb->alloc_stats.local_data, 0);
59775 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
59776 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
59777 - atomic_set(&osb->alloc_stats.bg_extends, 0);
59778 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
59779 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
59780 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
59781 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
59782 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
59783
59784 /* Copy the blockcheck stats from the superblock probe */
59785 osb->osb_ecc_stats = *stats;
59786 diff --git a/fs/open.c b/fs/open.c
59787 index 8c74100..4239c48 100644
59788 --- a/fs/open.c
59789 +++ b/fs/open.c
59790 @@ -32,6 +32,8 @@
59791 #include <linux/dnotify.h>
59792 #include <linux/compat.h>
59793
59794 +#define CREATE_TRACE_POINTS
59795 +#include <trace/events/fs.h>
59796 #include "internal.h"
59797
59798 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
59799 @@ -102,6 +104,8 @@ long vfs_truncate(struct path *path, loff_t length)
59800 error = locks_verify_truncate(inode, NULL, length);
59801 if (!error)
59802 error = security_path_truncate(path);
59803 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
59804 + error = -EACCES;
59805 if (!error)
59806 error = do_truncate(path->dentry, length, 0, NULL);
59807
59808 @@ -186,6 +190,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
59809 error = locks_verify_truncate(inode, f.file, length);
59810 if (!error)
59811 error = security_path_truncate(&f.file->f_path);
59812 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
59813 + error = -EACCES;
59814 if (!error)
59815 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
59816 sb_end_write(inode->i_sb);
59817 @@ -360,6 +366,9 @@ retry:
59818 if (__mnt_is_readonly(path.mnt))
59819 res = -EROFS;
59820
59821 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
59822 + res = -EACCES;
59823 +
59824 out_path_release:
59825 path_put(&path);
59826 if (retry_estale(res, lookup_flags)) {
59827 @@ -391,6 +400,8 @@ retry:
59828 if (error)
59829 goto dput_and_out;
59830
59831 + gr_log_chdir(path.dentry, path.mnt);
59832 +
59833 set_fs_pwd(current->fs, &path);
59834
59835 dput_and_out:
59836 @@ -420,6 +431,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
59837 goto out_putf;
59838
59839 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
59840 +
59841 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
59842 + error = -EPERM;
59843 +
59844 + if (!error)
59845 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
59846 +
59847 if (!error)
59848 set_fs_pwd(current->fs, &f.file->f_path);
59849 out_putf:
59850 @@ -449,7 +467,13 @@ retry:
59851 if (error)
59852 goto dput_and_out;
59853
59854 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
59855 + goto dput_and_out;
59856 +
59857 set_fs_root(current->fs, &path);
59858 +
59859 + gr_handle_chroot_chdir(&path);
59860 +
59861 error = 0;
59862 dput_and_out:
59863 path_put(&path);
59864 @@ -471,6 +495,16 @@ static int chmod_common(struct path *path, umode_t mode)
59865 if (error)
59866 return error;
59867 mutex_lock(&inode->i_mutex);
59868 +
59869 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
59870 + error = -EACCES;
59871 + goto out_unlock;
59872 + }
59873 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
59874 + error = -EACCES;
59875 + goto out_unlock;
59876 + }
59877 +
59878 error = security_path_chmod(path, mode);
59879 if (error)
59880 goto out_unlock;
59881 @@ -531,6 +565,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
59882 uid = make_kuid(current_user_ns(), user);
59883 gid = make_kgid(current_user_ns(), group);
59884
59885 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
59886 + return -EACCES;
59887 +
59888 newattrs.ia_valid = ATTR_CTIME;
59889 if (user != (uid_t) -1) {
59890 if (!uid_valid(uid))
59891 @@ -946,6 +983,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
59892 } else {
59893 fsnotify_open(f);
59894 fd_install(fd, f);
59895 + trace_do_sys_open(tmp->name, flags, mode);
59896 }
59897 }
59898 putname(tmp);
59899 diff --git a/fs/pipe.c b/fs/pipe.c
59900 index d2c45e1..009fe1c 100644
59901 --- a/fs/pipe.c
59902 +++ b/fs/pipe.c
59903 @@ -56,7 +56,7 @@ unsigned int pipe_min_size = PAGE_SIZE;
59904
59905 static void pipe_lock_nested(struct pipe_inode_info *pipe, int subclass)
59906 {
59907 - if (pipe->files)
59908 + if (atomic_read(&pipe->files))
59909 mutex_lock_nested(&pipe->mutex, subclass);
59910 }
59911
59912 @@ -71,7 +71,7 @@ EXPORT_SYMBOL(pipe_lock);
59913
59914 void pipe_unlock(struct pipe_inode_info *pipe)
59915 {
59916 - if (pipe->files)
59917 + if (atomic_read(&pipe->files))
59918 mutex_unlock(&pipe->mutex);
59919 }
59920 EXPORT_SYMBOL(pipe_unlock);
59921 @@ -449,9 +449,9 @@ redo:
59922 }
59923 if (bufs) /* More to do? */
59924 continue;
59925 - if (!pipe->writers)
59926 + if (!atomic_read(&pipe->writers))
59927 break;
59928 - if (!pipe->waiting_writers) {
59929 + if (!atomic_read(&pipe->waiting_writers)) {
59930 /* syscall merging: Usually we must not sleep
59931 * if O_NONBLOCK is set, or if we got some data.
59932 * But if a writer sleeps in kernel space, then
59933 @@ -513,7 +513,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
59934 ret = 0;
59935 __pipe_lock(pipe);
59936
59937 - if (!pipe->readers) {
59938 + if (!atomic_read(&pipe->readers)) {
59939 send_sig(SIGPIPE, current, 0);
59940 ret = -EPIPE;
59941 goto out;
59942 @@ -562,7 +562,7 @@ redo1:
59943 for (;;) {
59944 int bufs;
59945
59946 - if (!pipe->readers) {
59947 + if (!atomic_read(&pipe->readers)) {
59948 send_sig(SIGPIPE, current, 0);
59949 if (!ret)
59950 ret = -EPIPE;
59951 @@ -653,9 +653,9 @@ redo2:
59952 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
59953 do_wakeup = 0;
59954 }
59955 - pipe->waiting_writers++;
59956 + atomic_inc(&pipe->waiting_writers);
59957 pipe_wait(pipe);
59958 - pipe->waiting_writers--;
59959 + atomic_dec(&pipe->waiting_writers);
59960 }
59961 out:
59962 __pipe_unlock(pipe);
59963 @@ -709,7 +709,7 @@ pipe_poll(struct file *filp, poll_table *wait)
59964 mask = 0;
59965 if (filp->f_mode & FMODE_READ) {
59966 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
59967 - if (!pipe->writers && filp->f_version != pipe->w_counter)
59968 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
59969 mask |= POLLHUP;
59970 }
59971
59972 @@ -719,7 +719,7 @@ pipe_poll(struct file *filp, poll_table *wait)
59973 * Most Unices do not set POLLERR for FIFOs but on Linux they
59974 * behave exactly like pipes for poll().
59975 */
59976 - if (!pipe->readers)
59977 + if (!atomic_read(&pipe->readers))
59978 mask |= POLLERR;
59979 }
59980
59981 @@ -734,17 +734,17 @@ pipe_release(struct inode *inode, struct file *file)
59982
59983 __pipe_lock(pipe);
59984 if (file->f_mode & FMODE_READ)
59985 - pipe->readers--;
59986 + atomic_dec(&pipe->readers);
59987 if (file->f_mode & FMODE_WRITE)
59988 - pipe->writers--;
59989 + atomic_dec(&pipe->writers);
59990
59991 - if (pipe->readers || pipe->writers) {
59992 + if (atomic_read(&pipe->readers) || atomic_read(&pipe->writers)) {
59993 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
59994 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
59995 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
59996 }
59997 spin_lock(&inode->i_lock);
59998 - if (!--pipe->files) {
59999 + if (atomic_dec_and_test(&pipe->files)) {
60000 inode->i_pipe = NULL;
60001 kill = 1;
60002 }
60003 @@ -811,7 +811,7 @@ void free_pipe_info(struct pipe_inode_info *pipe)
60004 kfree(pipe);
60005 }
60006
60007 -static struct vfsmount *pipe_mnt __read_mostly;
60008 +struct vfsmount *pipe_mnt __read_mostly;
60009
60010 /*
60011 * pipefs_dname() is called from d_path().
60012 @@ -841,8 +841,9 @@ static struct inode * get_pipe_inode(void)
60013 goto fail_iput;
60014
60015 inode->i_pipe = pipe;
60016 - pipe->files = 2;
60017 - pipe->readers = pipe->writers = 1;
60018 + atomic_set(&pipe->files, 2);
60019 + atomic_set(&pipe->readers, 1);
60020 + atomic_set(&pipe->writers, 1);
60021 inode->i_fop = &pipefifo_fops;
60022
60023 /*
60024 @@ -1022,17 +1023,17 @@ static int fifo_open(struct inode *inode, struct file *filp)
60025 spin_lock(&inode->i_lock);
60026 if (inode->i_pipe) {
60027 pipe = inode->i_pipe;
60028 - pipe->files++;
60029 + atomic_inc(&pipe->files);
60030 spin_unlock(&inode->i_lock);
60031 } else {
60032 spin_unlock(&inode->i_lock);
60033 pipe = alloc_pipe_info();
60034 if (!pipe)
60035 return -ENOMEM;
60036 - pipe->files = 1;
60037 + atomic_set(&pipe->files, 1);
60038 spin_lock(&inode->i_lock);
60039 if (unlikely(inode->i_pipe)) {
60040 - inode->i_pipe->files++;
60041 + atomic_inc(&inode->i_pipe->files);
60042 spin_unlock(&inode->i_lock);
60043 free_pipe_info(pipe);
60044 pipe = inode->i_pipe;
60045 @@ -1057,10 +1058,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
60046 * opened, even when there is no process writing the FIFO.
60047 */
60048 pipe->r_counter++;
60049 - if (pipe->readers++ == 0)
60050 + if (atomic_inc_return(&pipe->readers) == 1)
60051 wake_up_partner(pipe);
60052
60053 - if (!is_pipe && !pipe->writers) {
60054 + if (!is_pipe && !atomic_read(&pipe->writers)) {
60055 if ((filp->f_flags & O_NONBLOCK)) {
60056 /* suppress POLLHUP until we have
60057 * seen a writer */
60058 @@ -1079,14 +1080,14 @@ static int fifo_open(struct inode *inode, struct file *filp)
60059 * errno=ENXIO when there is no process reading the FIFO.
60060 */
60061 ret = -ENXIO;
60062 - if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !pipe->readers)
60063 + if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
60064 goto err;
60065
60066 pipe->w_counter++;
60067 - if (!pipe->writers++)
60068 + if (atomic_inc_return(&pipe->writers) == 1)
60069 wake_up_partner(pipe);
60070
60071 - if (!is_pipe && !pipe->readers) {
60072 + if (!is_pipe && !atomic_read(&pipe->readers)) {
60073 if (wait_for_partner(pipe, &pipe->r_counter))
60074 goto err_wr;
60075 }
60076 @@ -1100,11 +1101,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
60077 * the process can at least talk to itself.
60078 */
60079
60080 - pipe->readers++;
60081 - pipe->writers++;
60082 + atomic_inc(&pipe->readers);
60083 + atomic_inc(&pipe->writers);
60084 pipe->r_counter++;
60085 pipe->w_counter++;
60086 - if (pipe->readers == 1 || pipe->writers == 1)
60087 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
60088 wake_up_partner(pipe);
60089 break;
60090
60091 @@ -1118,20 +1119,20 @@ static int fifo_open(struct inode *inode, struct file *filp)
60092 return 0;
60093
60094 err_rd:
60095 - if (!--pipe->readers)
60096 + if (atomic_dec_and_test(&pipe->readers))
60097 wake_up_interruptible(&pipe->wait);
60098 ret = -ERESTARTSYS;
60099 goto err;
60100
60101 err_wr:
60102 - if (!--pipe->writers)
60103 + if (atomic_dec_and_test(&pipe->writers))
60104 wake_up_interruptible(&pipe->wait);
60105 ret = -ERESTARTSYS;
60106 goto err;
60107
60108 err:
60109 spin_lock(&inode->i_lock);
60110 - if (!--pipe->files) {
60111 + if (atomic_dec_and_test(&pipe->files)) {
60112 inode->i_pipe = NULL;
60113 kill = 1;
60114 }
60115 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
60116 index 15af622..0e9f4467 100644
60117 --- a/fs/proc/Kconfig
60118 +++ b/fs/proc/Kconfig
60119 @@ -30,12 +30,12 @@ config PROC_FS
60120
60121 config PROC_KCORE
60122 bool "/proc/kcore support" if !ARM
60123 - depends on PROC_FS && MMU
60124 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
60125
60126 config PROC_VMCORE
60127 bool "/proc/vmcore support"
60128 - depends on PROC_FS && CRASH_DUMP
60129 - default y
60130 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
60131 + default n
60132 help
60133 Exports the dump image of crashed kernel in ELF format.
60134
60135 @@ -59,8 +59,8 @@ config PROC_SYSCTL
60136 limited in memory.
60137
60138 config PROC_PAGE_MONITOR
60139 - default y
60140 - depends on PROC_FS && MMU
60141 + default n
60142 + depends on PROC_FS && MMU && !GRKERNSEC
60143 bool "Enable /proc page monitoring" if EXPERT
60144 help
60145 Various /proc files exist to monitor process memory utilization:
60146 diff --git a/fs/proc/array.c b/fs/proc/array.c
60147 index cbd0f1b..adec3f0 100644
60148 --- a/fs/proc/array.c
60149 +++ b/fs/proc/array.c
60150 @@ -60,6 +60,7 @@
60151 #include <linux/tty.h>
60152 #include <linux/string.h>
60153 #include <linux/mman.h>
60154 +#include <linux/grsecurity.h>
60155 #include <linux/proc_fs.h>
60156 #include <linux/ioport.h>
60157 #include <linux/uaccess.h>
60158 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
60159 seq_putc(m, '\n');
60160 }
60161
60162 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
60163 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
60164 +{
60165 + if (p->mm)
60166 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
60167 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
60168 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
60169 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
60170 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
60171 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
60172 + else
60173 + seq_printf(m, "PaX:\t-----\n");
60174 +}
60175 +#endif
60176 +
60177 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
60178 struct pid *pid, struct task_struct *task)
60179 {
60180 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
60181 task_cpus_allowed(m, task);
60182 cpuset_task_status_allowed(m, task);
60183 task_context_switch_counts(m, task);
60184 +
60185 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
60186 + task_pax(m, task);
60187 +#endif
60188 +
60189 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
60190 + task_grsec_rbac(m, task);
60191 +#endif
60192 +
60193 return 0;
60194 }
60195
60196 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60197 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
60198 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
60199 + _mm->pax_flags & MF_PAX_SEGMEXEC))
60200 +#endif
60201 +
60202 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
60203 struct pid *pid, struct task_struct *task, int whole)
60204 {
60205 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
60206 char tcomm[sizeof(task->comm)];
60207 unsigned long flags;
60208
60209 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60210 + if (current->exec_id != m->exec_id) {
60211 + gr_log_badprocpid("stat");
60212 + return 0;
60213 + }
60214 +#endif
60215 +
60216 state = *get_task_state(task);
60217 vsize = eip = esp = 0;
60218 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
60219 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
60220 gtime = task_gtime(task);
60221 }
60222
60223 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60224 + if (PAX_RAND_FLAGS(mm)) {
60225 + eip = 0;
60226 + esp = 0;
60227 + wchan = 0;
60228 + }
60229 +#endif
60230 +#ifdef CONFIG_GRKERNSEC_HIDESYM
60231 + wchan = 0;
60232 + eip =0;
60233 + esp =0;
60234 +#endif
60235 +
60236 /* scale priority and nice values from timeslices to -20..20 */
60237 /* to make it look like a "normal" Unix priority/nice value */
60238 priority = task_prio(task);
60239 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
60240 seq_put_decimal_ull(m, ' ', vsize);
60241 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
60242 seq_put_decimal_ull(m, ' ', rsslim);
60243 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60244 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
60245 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
60246 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
60247 +#else
60248 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
60249 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
60250 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
60251 +#endif
60252 seq_put_decimal_ull(m, ' ', esp);
60253 seq_put_decimal_ull(m, ' ', eip);
60254 /* The signal information here is obsolete.
60255 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
60256 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
60257 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
60258
60259 - if (mm && permitted) {
60260 + if (mm && permitted
60261 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60262 + && !PAX_RAND_FLAGS(mm)
60263 +#endif
60264 + ) {
60265 seq_put_decimal_ull(m, ' ', mm->start_data);
60266 seq_put_decimal_ull(m, ' ', mm->end_data);
60267 seq_put_decimal_ull(m, ' ', mm->start_brk);
60268 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
60269 struct pid *pid, struct task_struct *task)
60270 {
60271 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
60272 - struct mm_struct *mm = get_task_mm(task);
60273 + struct mm_struct *mm;
60274
60275 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60276 + if (current->exec_id != m->exec_id) {
60277 + gr_log_badprocpid("statm");
60278 + return 0;
60279 + }
60280 +#endif
60281 + mm = get_task_mm(task);
60282 if (mm) {
60283 size = task_statm(mm, &shared, &text, &data, &resident);
60284 mmput(mm);
60285 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
60286 return 0;
60287 }
60288
60289 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
60290 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
60291 +{
60292 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
60293 +}
60294 +#endif
60295 +
60296 #ifdef CONFIG_CHECKPOINT_RESTORE
60297 static struct pid *
60298 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
60299 diff --git a/fs/proc/base.c b/fs/proc/base.c
60300 index c3834da..b402b2b 100644
60301 --- a/fs/proc/base.c
60302 +++ b/fs/proc/base.c
60303 @@ -113,6 +113,14 @@ struct pid_entry {
60304 union proc_op op;
60305 };
60306
60307 +struct getdents_callback {
60308 + struct linux_dirent __user * current_dir;
60309 + struct linux_dirent __user * previous;
60310 + struct file * file;
60311 + int count;
60312 + int error;
60313 +};
60314 +
60315 #define NOD(NAME, MODE, IOP, FOP, OP) { \
60316 .name = (NAME), \
60317 .len = sizeof(NAME) - 1, \
60318 @@ -210,6 +218,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
60319 if (!mm->arg_end)
60320 goto out_mm; /* Shh! No looking before we're done */
60321
60322 + if (gr_acl_handle_procpidmem(task))
60323 + goto out_mm;
60324 +
60325 len = mm->arg_end - mm->arg_start;
60326
60327 if (len > PAGE_SIZE)
60328 @@ -237,12 +248,28 @@ out:
60329 return res;
60330 }
60331
60332 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60333 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
60334 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
60335 + _mm->pax_flags & MF_PAX_SEGMEXEC))
60336 +#endif
60337 +
60338 static int proc_pid_auxv(struct task_struct *task, char *buffer)
60339 {
60340 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
60341 int res = PTR_ERR(mm);
60342 if (mm && !IS_ERR(mm)) {
60343 unsigned int nwords = 0;
60344 +
60345 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60346 + /* allow if we're currently ptracing this task */
60347 + if (PAX_RAND_FLAGS(mm) &&
60348 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
60349 + mmput(mm);
60350 + return 0;
60351 + }
60352 +#endif
60353 +
60354 do {
60355 nwords += 2;
60356 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
60357 @@ -256,7 +283,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
60358 }
60359
60360
60361 -#ifdef CONFIG_KALLSYMS
60362 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60363 /*
60364 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
60365 * Returns the resolved symbol. If that fails, simply return the address.
60366 @@ -295,7 +322,7 @@ static void unlock_trace(struct task_struct *task)
60367 mutex_unlock(&task->signal->cred_guard_mutex);
60368 }
60369
60370 -#ifdef CONFIG_STACKTRACE
60371 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60372
60373 #define MAX_STACK_TRACE_DEPTH 64
60374
60375 @@ -518,7 +545,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
60376 return count;
60377 }
60378
60379 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
60380 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
60381 static int proc_pid_syscall(struct task_struct *task, char *buffer)
60382 {
60383 long nr;
60384 @@ -547,7 +574,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
60385 /************************************************************************/
60386
60387 /* permission checks */
60388 -static int proc_fd_access_allowed(struct inode *inode)
60389 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
60390 {
60391 struct task_struct *task;
60392 int allowed = 0;
60393 @@ -557,7 +584,10 @@ static int proc_fd_access_allowed(struct inode *inode)
60394 */
60395 task = get_proc_task(inode);
60396 if (task) {
60397 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
60398 + if (log)
60399 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
60400 + else
60401 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
60402 put_task_struct(task);
60403 }
60404 return allowed;
60405 @@ -588,10 +618,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
60406 struct task_struct *task,
60407 int hide_pid_min)
60408 {
60409 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
60410 + return false;
60411 +
60412 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60413 + rcu_read_lock();
60414 + {
60415 + const struct cred *tmpcred = current_cred();
60416 + const struct cred *cred = __task_cred(task);
60417 +
60418 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
60419 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
60420 + || in_group_p(grsec_proc_gid)
60421 +#endif
60422 + ) {
60423 + rcu_read_unlock();
60424 + return true;
60425 + }
60426 + }
60427 + rcu_read_unlock();
60428 +
60429 + if (!pid->hide_pid)
60430 + return false;
60431 +#endif
60432 +
60433 if (pid->hide_pid < hide_pid_min)
60434 return true;
60435 if (in_group_p(pid->pid_gid))
60436 return true;
60437 +
60438 return ptrace_may_access(task, PTRACE_MODE_READ);
60439 }
60440
60441 @@ -609,7 +664,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
60442 put_task_struct(task);
60443
60444 if (!has_perms) {
60445 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60446 + {
60447 +#else
60448 if (pid->hide_pid == 2) {
60449 +#endif
60450 /*
60451 * Let's make getdents(), stat(), and open()
60452 * consistent with each other. If a process
60453 @@ -707,6 +766,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
60454 if (!task)
60455 return -ESRCH;
60456
60457 + if (gr_acl_handle_procpidmem(task)) {
60458 + put_task_struct(task);
60459 + return -EPERM;
60460 + }
60461 +
60462 mm = mm_access(task, mode);
60463 put_task_struct(task);
60464
60465 @@ -722,6 +786,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
60466
60467 file->private_data = mm;
60468
60469 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60470 + file->f_version = current->exec_id;
60471 +#endif
60472 +
60473 return 0;
60474 }
60475
60476 @@ -743,6 +811,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
60477 ssize_t copied;
60478 char *page;
60479
60480 +#ifdef CONFIG_GRKERNSEC
60481 + if (write)
60482 + return -EPERM;
60483 +#endif
60484 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60485 + if (file->f_version != current->exec_id) {
60486 + gr_log_badprocpid("mem");
60487 + return 0;
60488 + }
60489 +#endif
60490 +
60491 if (!mm)
60492 return 0;
60493
60494 @@ -755,7 +834,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
60495 goto free;
60496
60497 while (count > 0) {
60498 - int this_len = min_t(int, count, PAGE_SIZE);
60499 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
60500
60501 if (write && copy_from_user(page, buf, this_len)) {
60502 copied = -EFAULT;
60503 @@ -847,6 +926,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
60504 if (!mm)
60505 return 0;
60506
60507 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60508 + if (file->f_version != current->exec_id) {
60509 + gr_log_badprocpid("environ");
60510 + return 0;
60511 + }
60512 +#endif
60513 +
60514 page = (char *)__get_free_page(GFP_TEMPORARY);
60515 if (!page)
60516 return -ENOMEM;
60517 @@ -856,7 +942,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
60518 goto free;
60519 while (count > 0) {
60520 size_t this_len, max_len;
60521 - int retval;
60522 + ssize_t retval;
60523
60524 if (src >= (mm->env_end - mm->env_start))
60525 break;
60526 @@ -1461,7 +1547,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
60527 int error = -EACCES;
60528
60529 /* Are we allowed to snoop on the tasks file descriptors? */
60530 - if (!proc_fd_access_allowed(inode))
60531 + if (!proc_fd_access_allowed(inode, 0))
60532 goto out;
60533
60534 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
60535 @@ -1505,8 +1591,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
60536 struct path path;
60537
60538 /* Are we allowed to snoop on the tasks file descriptors? */
60539 - if (!proc_fd_access_allowed(inode))
60540 - goto out;
60541 + /* logging this is needed for learning on chromium to work properly,
60542 + but we don't want to flood the logs from 'ps' which does a readlink
60543 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
60544 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
60545 + */
60546 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
60547 + if (!proc_fd_access_allowed(inode,0))
60548 + goto out;
60549 + } else {
60550 + if (!proc_fd_access_allowed(inode,1))
60551 + goto out;
60552 + }
60553
60554 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
60555 if (error)
60556 @@ -1556,7 +1652,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
60557 rcu_read_lock();
60558 cred = __task_cred(task);
60559 inode->i_uid = cred->euid;
60560 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
60561 + inode->i_gid = grsec_proc_gid;
60562 +#else
60563 inode->i_gid = cred->egid;
60564 +#endif
60565 rcu_read_unlock();
60566 }
60567 security_task_to_inode(task, inode);
60568 @@ -1592,10 +1692,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
60569 return -ENOENT;
60570 }
60571 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
60572 +#ifdef CONFIG_GRKERNSEC_PROC_USER
60573 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
60574 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60575 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
60576 +#endif
60577 task_dumpable(task)) {
60578 cred = __task_cred(task);
60579 stat->uid = cred->euid;
60580 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
60581 + stat->gid = grsec_proc_gid;
60582 +#else
60583 stat->gid = cred->egid;
60584 +#endif
60585 }
60586 }
60587 rcu_read_unlock();
60588 @@ -1633,11 +1742,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
60589
60590 if (task) {
60591 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
60592 +#ifdef CONFIG_GRKERNSEC_PROC_USER
60593 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
60594 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60595 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
60596 +#endif
60597 task_dumpable(task)) {
60598 rcu_read_lock();
60599 cred = __task_cred(task);
60600 inode->i_uid = cred->euid;
60601 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
60602 + inode->i_gid = grsec_proc_gid;
60603 +#else
60604 inode->i_gid = cred->egid;
60605 +#endif
60606 rcu_read_unlock();
60607 } else {
60608 inode->i_uid = GLOBAL_ROOT_UID;
60609 @@ -2196,6 +2314,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
60610 if (!task)
60611 goto out_no_task;
60612
60613 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
60614 + goto out;
60615 +
60616 /*
60617 * Yes, it does not scale. And it should not. Don't add
60618 * new entries into /proc/<tgid>/ without very good reasons.
60619 @@ -2240,6 +2361,9 @@ static int proc_pident_readdir(struct file *filp,
60620 if (!task)
60621 goto out_no_task;
60622
60623 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
60624 + goto out;
60625 +
60626 ret = 0;
60627 i = filp->f_pos;
60628 switch (i) {
60629 @@ -2653,7 +2777,7 @@ static const struct pid_entry tgid_base_stuff[] = {
60630 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
60631 #endif
60632 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
60633 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
60634 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
60635 INF("syscall", S_IRUGO, proc_pid_syscall),
60636 #endif
60637 INF("cmdline", S_IRUGO, proc_pid_cmdline),
60638 @@ -2678,10 +2802,10 @@ static const struct pid_entry tgid_base_stuff[] = {
60639 #ifdef CONFIG_SECURITY
60640 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
60641 #endif
60642 -#ifdef CONFIG_KALLSYMS
60643 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60644 INF("wchan", S_IRUGO, proc_pid_wchan),
60645 #endif
60646 -#ifdef CONFIG_STACKTRACE
60647 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60648 ONE("stack", S_IRUGO, proc_pid_stack),
60649 #endif
60650 #ifdef CONFIG_SCHEDSTATS
60651 @@ -2715,6 +2839,9 @@ static const struct pid_entry tgid_base_stuff[] = {
60652 #ifdef CONFIG_HARDWALL
60653 INF("hardwall", S_IRUGO, proc_pid_hardwall),
60654 #endif
60655 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
60656 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
60657 +#endif
60658 #ifdef CONFIG_USER_NS
60659 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
60660 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
60661 @@ -2847,7 +2974,14 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
60662 if (!inode)
60663 goto out;
60664
60665 +#ifdef CONFIG_GRKERNSEC_PROC_USER
60666 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
60667 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60668 + inode->i_gid = grsec_proc_gid;
60669 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
60670 +#else
60671 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
60672 +#endif
60673 inode->i_op = &proc_tgid_base_inode_operations;
60674 inode->i_fop = &proc_tgid_base_operations;
60675 inode->i_flags|=S_IMMUTABLE;
60676 @@ -2885,7 +3019,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
60677 if (!task)
60678 goto out;
60679
60680 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
60681 + goto out_put_task;
60682 +
60683 result = proc_pid_instantiate(dir, dentry, task, NULL);
60684 +out_put_task:
60685 put_task_struct(task);
60686 out:
60687 return result;
60688 @@ -2948,6 +3086,8 @@ static int proc_pid_fill_cache(struct file *filp, void *dirent, filldir_t filldi
60689 static int fake_filldir(void *buf, const char *name, int namelen,
60690 loff_t offset, u64 ino, unsigned d_type)
60691 {
60692 + struct getdents_callback * __buf = (struct getdents_callback *) buf;
60693 + __buf->error = -EINVAL;
60694 return 0;
60695 }
60696
60697 @@ -3007,7 +3147,7 @@ static const struct pid_entry tid_base_stuff[] = {
60698 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
60699 #endif
60700 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
60701 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
60702 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
60703 INF("syscall", S_IRUGO, proc_pid_syscall),
60704 #endif
60705 INF("cmdline", S_IRUGO, proc_pid_cmdline),
60706 @@ -3034,10 +3174,10 @@ static const struct pid_entry tid_base_stuff[] = {
60707 #ifdef CONFIG_SECURITY
60708 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
60709 #endif
60710 -#ifdef CONFIG_KALLSYMS
60711 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60712 INF("wchan", S_IRUGO, proc_pid_wchan),
60713 #endif
60714 -#ifdef CONFIG_STACKTRACE
60715 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60716 ONE("stack", S_IRUGO, proc_pid_stack),
60717 #endif
60718 #ifdef CONFIG_SCHEDSTATS
60719 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
60720 index 82676e3..5f8518a 100644
60721 --- a/fs/proc/cmdline.c
60722 +++ b/fs/proc/cmdline.c
60723 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
60724
60725 static int __init proc_cmdline_init(void)
60726 {
60727 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
60728 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
60729 +#else
60730 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
60731 +#endif
60732 return 0;
60733 }
60734 module_init(proc_cmdline_init);
60735 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
60736 index b143471..bb105e5 100644
60737 --- a/fs/proc/devices.c
60738 +++ b/fs/proc/devices.c
60739 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
60740
60741 static int __init proc_devices_init(void)
60742 {
60743 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
60744 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
60745 +#else
60746 proc_create("devices", 0, NULL, &proc_devinfo_operations);
60747 +#endif
60748 return 0;
60749 }
60750 module_init(proc_devices_init);
60751 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
60752 index d7a4a28..0201742 100644
60753 --- a/fs/proc/fd.c
60754 +++ b/fs/proc/fd.c
60755 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
60756 if (!task)
60757 return -ENOENT;
60758
60759 - files = get_files_struct(task);
60760 + if (!gr_acl_handle_procpidmem(task))
60761 + files = get_files_struct(task);
60762 put_task_struct(task);
60763
60764 if (files) {
60765 @@ -302,11 +303,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
60766 */
60767 int proc_fd_permission(struct inode *inode, int mask)
60768 {
60769 + struct task_struct *task;
60770 int rv = generic_permission(inode, mask);
60771 - if (rv == 0)
60772 - return 0;
60773 +
60774 if (task_pid(current) == proc_pid(inode))
60775 rv = 0;
60776 +
60777 + task = get_proc_task(inode);
60778 + if (task == NULL)
60779 + return rv;
60780 +
60781 + if (gr_acl_handle_procpidmem(task))
60782 + rv = -EACCES;
60783 +
60784 + put_task_struct(task);
60785 +
60786 return rv;
60787 }
60788
60789 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
60790 index 073aea6..0630370 100644
60791 --- a/fs/proc/inode.c
60792 +++ b/fs/proc/inode.c
60793 @@ -23,11 +23,17 @@
60794 #include <linux/slab.h>
60795 #include <linux/mount.h>
60796 #include <linux/magic.h>
60797 +#include <linux/grsecurity.h>
60798
60799 #include <asm/uaccess.h>
60800
60801 #include "internal.h"
60802
60803 +#ifdef CONFIG_PROC_SYSCTL
60804 +extern const struct inode_operations proc_sys_inode_operations;
60805 +extern const struct inode_operations proc_sys_dir_operations;
60806 +#endif
60807 +
60808 static void proc_evict_inode(struct inode *inode)
60809 {
60810 struct proc_dir_entry *de;
60811 @@ -55,6 +61,13 @@ static void proc_evict_inode(struct inode *inode)
60812 ns = PROC_I(inode)->ns.ns;
60813 if (ns_ops && ns)
60814 ns_ops->put(ns);
60815 +
60816 +#ifdef CONFIG_PROC_SYSCTL
60817 + if (inode->i_op == &proc_sys_inode_operations ||
60818 + inode->i_op == &proc_sys_dir_operations)
60819 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
60820 +#endif
60821 +
60822 }
60823
60824 static struct kmem_cache * proc_inode_cachep;
60825 @@ -385,7 +398,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
60826 if (de->mode) {
60827 inode->i_mode = de->mode;
60828 inode->i_uid = de->uid;
60829 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
60830 + inode->i_gid = grsec_proc_gid;
60831 +#else
60832 inode->i_gid = de->gid;
60833 +#endif
60834 }
60835 if (de->size)
60836 inode->i_size = de->size;
60837 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
60838 index d600fb0..3b495fe 100644
60839 --- a/fs/proc/internal.h
60840 +++ b/fs/proc/internal.h
60841 @@ -155,6 +155,9 @@ extern int proc_pid_status(struct seq_file *, struct pid_namespace *,
60842 struct pid *, struct task_struct *);
60843 extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
60844 struct pid *, struct task_struct *);
60845 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
60846 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
60847 +#endif
60848
60849 /*
60850 * base.c
60851 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
60852 index 0a22194..a9fc8c1 100644
60853 --- a/fs/proc/kcore.c
60854 +++ b/fs/proc/kcore.c
60855 @@ -484,9 +484,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
60856 * the addresses in the elf_phdr on our list.
60857 */
60858 start = kc_offset_to_vaddr(*fpos - elf_buflen);
60859 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
60860 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
60861 + if (tsz > buflen)
60862 tsz = buflen;
60863 -
60864 +
60865 while (buflen) {
60866 struct kcore_list *m;
60867
60868 @@ -515,20 +516,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
60869 kfree(elf_buf);
60870 } else {
60871 if (kern_addr_valid(start)) {
60872 - unsigned long n;
60873 + char *elf_buf;
60874 + mm_segment_t oldfs;
60875
60876 - n = copy_to_user(buffer, (char *)start, tsz);
60877 - /*
60878 - * We cannot distinguish between fault on source
60879 - * and fault on destination. When this happens
60880 - * we clear too and hope it will trigger the
60881 - * EFAULT again.
60882 - */
60883 - if (n) {
60884 - if (clear_user(buffer + tsz - n,
60885 - n))
60886 + elf_buf = kmalloc(tsz, GFP_KERNEL);
60887 + if (!elf_buf)
60888 + return -ENOMEM;
60889 + oldfs = get_fs();
60890 + set_fs(KERNEL_DS);
60891 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
60892 + set_fs(oldfs);
60893 + if (copy_to_user(buffer, elf_buf, tsz)) {
60894 + kfree(elf_buf);
60895 return -EFAULT;
60896 + }
60897 }
60898 + set_fs(oldfs);
60899 + kfree(elf_buf);
60900 } else {
60901 if (clear_user(buffer, tsz))
60902 return -EFAULT;
60903 @@ -548,6 +552,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
60904
60905 static int open_kcore(struct inode *inode, struct file *filp)
60906 {
60907 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
60908 + return -EPERM;
60909 +#endif
60910 if (!capable(CAP_SYS_RAWIO))
60911 return -EPERM;
60912 if (kcore_need_update)
60913 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
60914 index 5aa847a..f77c8d4 100644
60915 --- a/fs/proc/meminfo.c
60916 +++ b/fs/proc/meminfo.c
60917 @@ -159,7 +159,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
60918 vmi.used >> 10,
60919 vmi.largest_chunk >> 10
60920 #ifdef CONFIG_MEMORY_FAILURE
60921 - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
60922 + ,atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
60923 #endif
60924 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
60925 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
60926 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
60927 index ccfd99b..1b7e255 100644
60928 --- a/fs/proc/nommu.c
60929 +++ b/fs/proc/nommu.c
60930 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
60931 if (len < 1)
60932 len = 1;
60933 seq_printf(m, "%*c", len, ' ');
60934 - seq_path(m, &file->f_path, "");
60935 + seq_path(m, &file->f_path, "\n\\");
60936 }
60937
60938 seq_putc(m, '\n');
60939 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
60940 index 986e832..6e8e859 100644
60941 --- a/fs/proc/proc_net.c
60942 +++ b/fs/proc/proc_net.c
60943 @@ -23,6 +23,7 @@
60944 #include <linux/nsproxy.h>
60945 #include <net/net_namespace.h>
60946 #include <linux/seq_file.h>
60947 +#include <linux/grsecurity.h>
60948
60949 #include "internal.h"
60950
60951 @@ -109,6 +110,17 @@ static struct net *get_proc_task_net(struct inode *dir)
60952 struct task_struct *task;
60953 struct nsproxy *ns;
60954 struct net *net = NULL;
60955 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60956 + const struct cred *cred = current_cred();
60957 +#endif
60958 +
60959 +#ifdef CONFIG_GRKERNSEC_PROC_USER
60960 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
60961 + return net;
60962 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60963 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
60964 + return net;
60965 +#endif
60966
60967 rcu_read_lock();
60968 task = pid_task(proc_pid(dir), PIDTYPE_PID);
60969 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
60970 index ac05f33..1e6dc7e 100644
60971 --- a/fs/proc/proc_sysctl.c
60972 +++ b/fs/proc/proc_sysctl.c
60973 @@ -13,11 +13,15 @@
60974 #include <linux/module.h>
60975 #include "internal.h"
60976
60977 +extern int gr_handle_chroot_sysctl(const int op);
60978 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
60979 + const int op);
60980 +
60981 static const struct dentry_operations proc_sys_dentry_operations;
60982 static const struct file_operations proc_sys_file_operations;
60983 -static const struct inode_operations proc_sys_inode_operations;
60984 +const struct inode_operations proc_sys_inode_operations;
60985 static const struct file_operations proc_sys_dir_file_operations;
60986 -static const struct inode_operations proc_sys_dir_operations;
60987 +const struct inode_operations proc_sys_dir_operations;
60988
60989 void proc_sys_poll_notify(struct ctl_table_poll *poll)
60990 {
60991 @@ -467,6 +471,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
60992
60993 err = NULL;
60994 d_set_d_op(dentry, &proc_sys_dentry_operations);
60995 +
60996 + gr_handle_proc_create(dentry, inode);
60997 +
60998 d_add(dentry, inode);
60999
61000 out:
61001 @@ -482,6 +489,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
61002 struct inode *inode = file_inode(filp);
61003 struct ctl_table_header *head = grab_header(inode);
61004 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
61005 + int op = write ? MAY_WRITE : MAY_READ;
61006 ssize_t error;
61007 size_t res;
61008
61009 @@ -493,7 +501,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
61010 * and won't be until we finish.
61011 */
61012 error = -EPERM;
61013 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
61014 + if (sysctl_perm(head, table, op))
61015 goto out;
61016
61017 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
61018 @@ -501,6 +509,22 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
61019 if (!table->proc_handler)
61020 goto out;
61021
61022 +#ifdef CONFIG_GRKERNSEC
61023 + error = -EPERM;
61024 + if (gr_handle_chroot_sysctl(op))
61025 + goto out;
61026 + dget(filp->f_path.dentry);
61027 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
61028 + dput(filp->f_path.dentry);
61029 + goto out;
61030 + }
61031 + dput(filp->f_path.dentry);
61032 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
61033 + goto out;
61034 + if (write && !capable(CAP_SYS_ADMIN))
61035 + goto out;
61036 +#endif
61037 +
61038 /* careful: calling conventions are nasty here */
61039 res = count;
61040 error = table->proc_handler(table, write, buf, &res, ppos);
61041 @@ -598,6 +622,9 @@ static int proc_sys_fill_cache(struct file *filp, void *dirent,
61042 return -ENOMEM;
61043 } else {
61044 d_set_d_op(child, &proc_sys_dentry_operations);
61045 +
61046 + gr_handle_proc_create(child, inode);
61047 +
61048 d_add(child, inode);
61049 }
61050 } else {
61051 @@ -641,6 +668,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
61052 if ((*pos)++ < file->f_pos)
61053 return 0;
61054
61055 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
61056 + return 0;
61057 +
61058 if (unlikely(S_ISLNK(table->mode)))
61059 res = proc_sys_link_fill_cache(file, dirent, filldir, head, table);
61060 else
61061 @@ -751,6 +781,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
61062 if (IS_ERR(head))
61063 return PTR_ERR(head);
61064
61065 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
61066 + return -ENOENT;
61067 +
61068 generic_fillattr(inode, stat);
61069 if (table)
61070 stat->mode = (stat->mode & S_IFMT) | table->mode;
61071 @@ -773,13 +806,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
61072 .llseek = generic_file_llseek,
61073 };
61074
61075 -static const struct inode_operations proc_sys_inode_operations = {
61076 +const struct inode_operations proc_sys_inode_operations = {
61077 .permission = proc_sys_permission,
61078 .setattr = proc_sys_setattr,
61079 .getattr = proc_sys_getattr,
61080 };
61081
61082 -static const struct inode_operations proc_sys_dir_operations = {
61083 +const struct inode_operations proc_sys_dir_operations = {
61084 .lookup = proc_sys_lookup,
61085 .permission = proc_sys_permission,
61086 .setattr = proc_sys_setattr,
61087 @@ -855,7 +888,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
61088 static struct ctl_dir *new_dir(struct ctl_table_set *set,
61089 const char *name, int namelen)
61090 {
61091 - struct ctl_table *table;
61092 + ctl_table_no_const *table;
61093 struct ctl_dir *new;
61094 struct ctl_node *node;
61095 char *new_name;
61096 @@ -867,7 +900,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
61097 return NULL;
61098
61099 node = (struct ctl_node *)(new + 1);
61100 - table = (struct ctl_table *)(node + 1);
61101 + table = (ctl_table_no_const *)(node + 1);
61102 new_name = (char *)(table + 2);
61103 memcpy(new_name, name, namelen);
61104 new_name[namelen] = '\0';
61105 @@ -1036,7 +1069,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
61106 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
61107 struct ctl_table_root *link_root)
61108 {
61109 - struct ctl_table *link_table, *entry, *link;
61110 + ctl_table_no_const *link_table, *link;
61111 + struct ctl_table *entry;
61112 struct ctl_table_header *links;
61113 struct ctl_node *node;
61114 char *link_name;
61115 @@ -1059,7 +1093,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
61116 return NULL;
61117
61118 node = (struct ctl_node *)(links + 1);
61119 - link_table = (struct ctl_table *)(node + nr_entries);
61120 + link_table = (ctl_table_no_const *)(node + nr_entries);
61121 link_name = (char *)&link_table[nr_entries + 1];
61122
61123 for (link = link_table, entry = table; entry->procname; link++, entry++) {
61124 @@ -1307,8 +1341,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
61125 struct ctl_table_header ***subheader, struct ctl_table_set *set,
61126 struct ctl_table *table)
61127 {
61128 - struct ctl_table *ctl_table_arg = NULL;
61129 - struct ctl_table *entry, *files;
61130 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
61131 + struct ctl_table *entry;
61132 int nr_files = 0;
61133 int nr_dirs = 0;
61134 int err = -ENOMEM;
61135 @@ -1320,10 +1354,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
61136 nr_files++;
61137 }
61138
61139 - files = table;
61140 /* If there are mixed files and directories we need a new table */
61141 if (nr_dirs && nr_files) {
61142 - struct ctl_table *new;
61143 + ctl_table_no_const *new;
61144 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
61145 GFP_KERNEL);
61146 if (!files)
61147 @@ -1341,7 +1374,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
61148 /* Register everything except a directory full of subdirectories */
61149 if (nr_files || !nr_dirs) {
61150 struct ctl_table_header *header;
61151 - header = __register_sysctl_table(set, path, files);
61152 + header = __register_sysctl_table(set, path, files ? files : table);
61153 if (!header) {
61154 kfree(ctl_table_arg);
61155 goto out;
61156 diff --git a/fs/proc/root.c b/fs/proc/root.c
61157 index 41a6ea9..23eaa92 100644
61158 --- a/fs/proc/root.c
61159 +++ b/fs/proc/root.c
61160 @@ -182,7 +182,15 @@ void __init proc_root_init(void)
61161 #ifdef CONFIG_PROC_DEVICETREE
61162 proc_device_tree_init();
61163 #endif
61164 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
61165 +#ifdef CONFIG_GRKERNSEC_PROC_USER
61166 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
61167 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61168 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
61169 +#endif
61170 +#else
61171 proc_mkdir("bus", NULL);
61172 +#endif
61173 proc_sys_init();
61174 }
61175
61176 diff --git a/fs/proc/self.c b/fs/proc/self.c
61177 index 6b6a993..807cccc 100644
61178 --- a/fs/proc/self.c
61179 +++ b/fs/proc/self.c
61180 @@ -39,7 +39,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
61181 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
61182 void *cookie)
61183 {
61184 - char *s = nd_get_link(nd);
61185 + const char *s = nd_get_link(nd);
61186 if (!IS_ERR(s))
61187 kfree(s);
61188 }
61189 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
61190 index 65fc60a..350cc48 100644
61191 --- a/fs/proc/task_mmu.c
61192 +++ b/fs/proc/task_mmu.c
61193 @@ -11,12 +11,19 @@
61194 #include <linux/rmap.h>
61195 #include <linux/swap.h>
61196 #include <linux/swapops.h>
61197 +#include <linux/grsecurity.h>
61198
61199 #include <asm/elf.h>
61200 #include <asm/uaccess.h>
61201 #include <asm/tlbflush.h>
61202 #include "internal.h"
61203
61204 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61205 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
61206 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
61207 + _mm->pax_flags & MF_PAX_SEGMEXEC))
61208 +#endif
61209 +
61210 void task_mem(struct seq_file *m, struct mm_struct *mm)
61211 {
61212 unsigned long data, text, lib, swap;
61213 @@ -52,8 +59,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
61214 "VmExe:\t%8lu kB\n"
61215 "VmLib:\t%8lu kB\n"
61216 "VmPTE:\t%8lu kB\n"
61217 - "VmSwap:\t%8lu kB\n",
61218 - hiwater_vm << (PAGE_SHIFT-10),
61219 + "VmSwap:\t%8lu kB\n"
61220 +
61221 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
61222 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
61223 +#endif
61224 +
61225 + ,hiwater_vm << (PAGE_SHIFT-10),
61226 total_vm << (PAGE_SHIFT-10),
61227 mm->locked_vm << (PAGE_SHIFT-10),
61228 mm->pinned_vm << (PAGE_SHIFT-10),
61229 @@ -62,7 +74,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
61230 data << (PAGE_SHIFT-10),
61231 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
61232 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
61233 - swap << (PAGE_SHIFT-10));
61234 + swap << (PAGE_SHIFT-10)
61235 +
61236 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
61237 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61238 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
61239 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
61240 +#else
61241 + , mm->context.user_cs_base
61242 + , mm->context.user_cs_limit
61243 +#endif
61244 +#endif
61245 +
61246 + );
61247 }
61248
61249 unsigned long task_vsize(struct mm_struct *mm)
61250 @@ -277,13 +301,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
61251 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
61252 }
61253
61254 - /* We don't show the stack guard page in /proc/maps */
61255 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61256 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
61257 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
61258 +#else
61259 start = vma->vm_start;
61260 - if (stack_guard_page_start(vma, start))
61261 - start += PAGE_SIZE;
61262 end = vma->vm_end;
61263 - if (stack_guard_page_end(vma, end))
61264 - end -= PAGE_SIZE;
61265 +#endif
61266
61267 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
61268 start,
61269 @@ -292,7 +316,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
61270 flags & VM_WRITE ? 'w' : '-',
61271 flags & VM_EXEC ? 'x' : '-',
61272 flags & VM_MAYSHARE ? 's' : 'p',
61273 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61274 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
61275 +#else
61276 pgoff,
61277 +#endif
61278 MAJOR(dev), MINOR(dev), ino, &len);
61279
61280 /*
61281 @@ -301,7 +329,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
61282 */
61283 if (file) {
61284 pad_len_spaces(m, len);
61285 - seq_path(m, &file->f_path, "\n");
61286 + seq_path(m, &file->f_path, "\n\\");
61287 goto done;
61288 }
61289
61290 @@ -327,8 +355,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
61291 * Thread stack in /proc/PID/task/TID/maps or
61292 * the main process stack.
61293 */
61294 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
61295 - vma->vm_end >= mm->start_stack)) {
61296 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
61297 + (vma->vm_start <= mm->start_stack &&
61298 + vma->vm_end >= mm->start_stack)) {
61299 name = "[stack]";
61300 } else {
61301 /* Thread stack in /proc/PID/maps */
61302 @@ -352,6 +381,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
61303 struct proc_maps_private *priv = m->private;
61304 struct task_struct *task = priv->task;
61305
61306 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61307 + if (current->exec_id != m->exec_id) {
61308 + gr_log_badprocpid("maps");
61309 + return 0;
61310 + }
61311 +#endif
61312 +
61313 show_map_vma(m, vma, is_pid);
61314
61315 if (m->count < m->size) /* vma is copied successfully */
61316 @@ -589,12 +625,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
61317 .private = &mss,
61318 };
61319
61320 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61321 + if (current->exec_id != m->exec_id) {
61322 + gr_log_badprocpid("smaps");
61323 + return 0;
61324 + }
61325 +#endif
61326 memset(&mss, 0, sizeof mss);
61327 - mss.vma = vma;
61328 - /* mmap_sem is held in m_start */
61329 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
61330 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
61331 -
61332 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61333 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
61334 +#endif
61335 + mss.vma = vma;
61336 + /* mmap_sem is held in m_start */
61337 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
61338 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
61339 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61340 + }
61341 +#endif
61342 show_map_vma(m, vma, is_pid);
61343
61344 seq_printf(m,
61345 @@ -612,7 +659,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
61346 "KernelPageSize: %8lu kB\n"
61347 "MMUPageSize: %8lu kB\n"
61348 "Locked: %8lu kB\n",
61349 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61350 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
61351 +#else
61352 (vma->vm_end - vma->vm_start) >> 10,
61353 +#endif
61354 mss.resident >> 10,
61355 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
61356 mss.shared_clean >> 10,
61357 @@ -1264,6 +1315,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
61358 int n;
61359 char buffer[50];
61360
61361 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61362 + if (current->exec_id != m->exec_id) {
61363 + gr_log_badprocpid("numa_maps");
61364 + return 0;
61365 + }
61366 +#endif
61367 +
61368 if (!mm)
61369 return 0;
61370
61371 @@ -1281,11 +1339,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
61372 mpol_to_str(buffer, sizeof(buffer), pol);
61373 mpol_cond_put(pol);
61374
61375 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61376 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
61377 +#else
61378 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
61379 +#endif
61380
61381 if (file) {
61382 seq_printf(m, " file=");
61383 - seq_path(m, &file->f_path, "\n\t= ");
61384 + seq_path(m, &file->f_path, "\n\t\\= ");
61385 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
61386 seq_printf(m, " heap");
61387 } else {
61388 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
61389 index 56123a6..5a2f6ec 100644
61390 --- a/fs/proc/task_nommu.c
61391 +++ b/fs/proc/task_nommu.c
61392 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
61393 else
61394 bytes += kobjsize(mm);
61395
61396 - if (current->fs && current->fs->users > 1)
61397 + if (current->fs && atomic_read(&current->fs->users) > 1)
61398 sbytes += kobjsize(current->fs);
61399 else
61400 bytes += kobjsize(current->fs);
61401 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
61402
61403 if (file) {
61404 pad_len_spaces(m, len);
61405 - seq_path(m, &file->f_path, "");
61406 + seq_path(m, &file->f_path, "\n\\");
61407 } else if (mm) {
61408 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
61409
61410 diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
61411 index 17f7e08..e4b1529 100644
61412 --- a/fs/proc/vmcore.c
61413 +++ b/fs/proc/vmcore.c
61414 @@ -99,9 +99,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
61415 nr_bytes = count;
61416
61417 /* If pfn is not ram, return zeros for sparse dump files */
61418 - if (pfn_is_ram(pfn) == 0)
61419 - memset(buf, 0, nr_bytes);
61420 - else {
61421 + if (pfn_is_ram(pfn) == 0) {
61422 + if (userbuf) {
61423 + if (clear_user((char __force_user *)buf, nr_bytes))
61424 + return -EFAULT;
61425 + } else
61426 + memset(buf, 0, nr_bytes);
61427 + } else {
61428 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
61429 offset, userbuf);
61430 if (tmp < 0)
61431 @@ -186,7 +190,7 @@ static ssize_t read_vmcore(struct file *file, char __user *buffer,
61432 if (tsz > nr_bytes)
61433 tsz = nr_bytes;
61434
61435 - tmp = read_from_oldmem(buffer, tsz, &start, 1);
61436 + tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, 1);
61437 if (tmp < 0)
61438 return tmp;
61439 buflen -= tsz;
61440 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
61441 index b00fcc9..e0c6381 100644
61442 --- a/fs/qnx6/qnx6.h
61443 +++ b/fs/qnx6/qnx6.h
61444 @@ -74,7 +74,7 @@ enum {
61445 BYTESEX_BE,
61446 };
61447
61448 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
61449 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
61450 {
61451 if (sbi->s_bytesex == BYTESEX_LE)
61452 return le64_to_cpu((__force __le64)n);
61453 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
61454 return (__force __fs64)cpu_to_be64(n);
61455 }
61456
61457 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
61458 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
61459 {
61460 if (sbi->s_bytesex == BYTESEX_LE)
61461 return le32_to_cpu((__force __le32)n);
61462 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
61463 index 16e8abb..2dcf914 100644
61464 --- a/fs/quota/netlink.c
61465 +++ b/fs/quota/netlink.c
61466 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
61467 void quota_send_warning(struct kqid qid, dev_t dev,
61468 const char warntype)
61469 {
61470 - static atomic_t seq;
61471 + static atomic_unchecked_t seq;
61472 struct sk_buff *skb;
61473 void *msg_head;
61474 int ret;
61475 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
61476 "VFS: Not enough memory to send quota warning.\n");
61477 return;
61478 }
61479 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
61480 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
61481 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
61482 if (!msg_head) {
61483 printk(KERN_ERR
61484 diff --git a/fs/read_write.c b/fs/read_write.c
61485 index 2cefa41..c7e2fe0 100644
61486 --- a/fs/read_write.c
61487 +++ b/fs/read_write.c
61488 @@ -411,7 +411,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
61489
61490 old_fs = get_fs();
61491 set_fs(get_ds());
61492 - p = (__force const char __user *)buf;
61493 + p = (const char __force_user *)buf;
61494 if (count > MAX_RW_COUNT)
61495 count = MAX_RW_COUNT;
61496 if (file->f_op->write)
61497 diff --git a/fs/readdir.c b/fs/readdir.c
61498 index fee38e0..12fdf47 100644
61499 --- a/fs/readdir.c
61500 +++ b/fs/readdir.c
61501 @@ -17,6 +17,7 @@
61502 #include <linux/security.h>
61503 #include <linux/syscalls.h>
61504 #include <linux/unistd.h>
61505 +#include <linux/namei.h>
61506
61507 #include <asm/uaccess.h>
61508
61509 @@ -67,6 +68,7 @@ struct old_linux_dirent {
61510
61511 struct readdir_callback {
61512 struct old_linux_dirent __user * dirent;
61513 + struct file * file;
61514 int result;
61515 };
61516
61517 @@ -84,6 +86,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
61518 buf->result = -EOVERFLOW;
61519 return -EOVERFLOW;
61520 }
61521 +
61522 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
61523 + return 0;
61524 +
61525 buf->result++;
61526 dirent = buf->dirent;
61527 if (!access_ok(VERIFY_WRITE, dirent,
61528 @@ -114,6 +120,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
61529
61530 buf.result = 0;
61531 buf.dirent = dirent;
61532 + buf.file = f.file;
61533
61534 error = vfs_readdir(f.file, fillonedir, &buf);
61535 if (buf.result)
61536 @@ -139,6 +146,7 @@ struct linux_dirent {
61537 struct getdents_callback {
61538 struct linux_dirent __user * current_dir;
61539 struct linux_dirent __user * previous;
61540 + struct file * file;
61541 int count;
61542 int error;
61543 };
61544 @@ -160,6 +168,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
61545 buf->error = -EOVERFLOW;
61546 return -EOVERFLOW;
61547 }
61548 +
61549 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
61550 + return 0;
61551 +
61552 dirent = buf->previous;
61553 if (dirent) {
61554 if (__put_user(offset, &dirent->d_off))
61555 @@ -205,6 +217,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
61556 buf.previous = NULL;
61557 buf.count = count;
61558 buf.error = 0;
61559 + buf.file = f.file;
61560
61561 error = vfs_readdir(f.file, filldir, &buf);
61562 if (error >= 0)
61563 @@ -223,6 +236,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
61564 struct getdents_callback64 {
61565 struct linux_dirent64 __user * current_dir;
61566 struct linux_dirent64 __user * previous;
61567 + struct file *file;
61568 int count;
61569 int error;
61570 };
61571 @@ -238,6 +252,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
61572 buf->error = -EINVAL; /* only used if we fail.. */
61573 if (reclen > buf->count)
61574 return -EINVAL;
61575 +
61576 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
61577 + return 0;
61578 +
61579 dirent = buf->previous;
61580 if (dirent) {
61581 if (__put_user(offset, &dirent->d_off))
61582 @@ -283,6 +301,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
61583
61584 buf.current_dir = dirent;
61585 buf.previous = NULL;
61586 + buf.file = f.file;
61587 buf.count = count;
61588 buf.error = 0;
61589
61590 @@ -291,7 +310,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
61591 error = buf.error;
61592 lastdirent = buf.previous;
61593 if (lastdirent) {
61594 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
61595 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
61596 if (__put_user(d_off, &lastdirent->d_off))
61597 error = -EFAULT;
61598 else
61599 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
61600 index 2b7882b..1c5ef48 100644
61601 --- a/fs/reiserfs/do_balan.c
61602 +++ b/fs/reiserfs/do_balan.c
61603 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
61604 return;
61605 }
61606
61607 - atomic_inc(&(fs_generation(tb->tb_sb)));
61608 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
61609 do_balance_starts(tb);
61610
61611 /* balance leaf returns 0 except if combining L R and S into
61612 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
61613 index 1d48974..2f8f4e0 100644
61614 --- a/fs/reiserfs/procfs.c
61615 +++ b/fs/reiserfs/procfs.c
61616 @@ -114,7 +114,7 @@ static int show_super(struct seq_file *m, void *unused)
61617 "SMALL_TAILS " : "NO_TAILS ",
61618 replay_only(sb) ? "REPLAY_ONLY " : "",
61619 convert_reiserfs(sb) ? "CONV " : "",
61620 - atomic_read(&r->s_generation_counter),
61621 + atomic_read_unchecked(&r->s_generation_counter),
61622 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
61623 SF(s_do_balance), SF(s_unneeded_left_neighbor),
61624 SF(s_good_search_by_key_reada), SF(s_bmaps),
61625 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
61626 index 157e474..65a6114 100644
61627 --- a/fs/reiserfs/reiserfs.h
61628 +++ b/fs/reiserfs/reiserfs.h
61629 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
61630 /* Comment? -Hans */
61631 wait_queue_head_t s_wait;
61632 /* To be obsoleted soon by per buffer seals.. -Hans */
61633 - atomic_t s_generation_counter; // increased by one every time the
61634 + atomic_unchecked_t s_generation_counter; // increased by one every time the
61635 // tree gets re-balanced
61636 unsigned long s_properties; /* File system properties. Currently holds
61637 on-disk FS format */
61638 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
61639 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
61640
61641 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
61642 -#define get_generation(s) atomic_read (&fs_generation(s))
61643 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
61644 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
61645 #define __fs_changed(gen,s) (gen != get_generation (s))
61646 #define fs_changed(gen,s) \
61647 diff --git a/fs/select.c b/fs/select.c
61648 index 8c1c96c..a0f9b6d 100644
61649 --- a/fs/select.c
61650 +++ b/fs/select.c
61651 @@ -20,6 +20,7 @@
61652 #include <linux/export.h>
61653 #include <linux/slab.h>
61654 #include <linux/poll.h>
61655 +#include <linux/security.h>
61656 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
61657 #include <linux/file.h>
61658 #include <linux/fdtable.h>
61659 @@ -827,6 +828,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
61660 struct poll_list *walk = head;
61661 unsigned long todo = nfds;
61662
61663 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
61664 if (nfds > rlimit(RLIMIT_NOFILE))
61665 return -EINVAL;
61666
61667 diff --git a/fs/seq_file.c b/fs/seq_file.c
61668 index 774c1eb..b67582a 100644
61669 --- a/fs/seq_file.c
61670 +++ b/fs/seq_file.c
61671 @@ -10,6 +10,7 @@
61672 #include <linux/seq_file.h>
61673 #include <linux/slab.h>
61674 #include <linux/cred.h>
61675 +#include <linux/sched.h>
61676
61677 #include <asm/uaccess.h>
61678 #include <asm/page.h>
61679 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
61680 #ifdef CONFIG_USER_NS
61681 p->user_ns = file->f_cred->user_ns;
61682 #endif
61683 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61684 + p->exec_id = current->exec_id;
61685 +#endif
61686
61687 /*
61688 * Wrappers around seq_open(e.g. swaps_open) need to be
61689 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
61690 return 0;
61691 }
61692 if (!m->buf) {
61693 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
61694 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
61695 if (!m->buf)
61696 return -ENOMEM;
61697 }
61698 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
61699 Eoverflow:
61700 m->op->stop(m, p);
61701 kfree(m->buf);
61702 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
61703 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
61704 return !m->buf ? -ENOMEM : -EAGAIN;
61705 }
61706
61707 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
61708
61709 /* grab buffer if we didn't have one */
61710 if (!m->buf) {
61711 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
61712 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
61713 if (!m->buf)
61714 goto Enomem;
61715 }
61716 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
61717 goto Fill;
61718 m->op->stop(m, p);
61719 kfree(m->buf);
61720 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
61721 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
61722 if (!m->buf)
61723 goto Enomem;
61724 m->count = 0;
61725 @@ -581,7 +585,7 @@ static void single_stop(struct seq_file *p, void *v)
61726 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
61727 void *data)
61728 {
61729 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
61730 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
61731 int res = -ENOMEM;
61732
61733 if (op) {
61734 diff --git a/fs/splice.c b/fs/splice.c
61735 index d37431d..81c3044 100644
61736 --- a/fs/splice.c
61737 +++ b/fs/splice.c
61738 @@ -196,7 +196,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
61739 pipe_lock(pipe);
61740
61741 for (;;) {
61742 - if (!pipe->readers) {
61743 + if (!atomic_read(&pipe->readers)) {
61744 send_sig(SIGPIPE, current, 0);
61745 if (!ret)
61746 ret = -EPIPE;
61747 @@ -219,7 +219,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
61748 page_nr++;
61749 ret += buf->len;
61750
61751 - if (pipe->files)
61752 + if (atomic_read(&pipe->files))
61753 do_wakeup = 1;
61754
61755 if (!--spd->nr_pages)
61756 @@ -250,9 +250,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
61757 do_wakeup = 0;
61758 }
61759
61760 - pipe->waiting_writers++;
61761 + atomic_inc(&pipe->waiting_writers);
61762 pipe_wait(pipe);
61763 - pipe->waiting_writers--;
61764 + atomic_dec(&pipe->waiting_writers);
61765 }
61766
61767 pipe_unlock(pipe);
61768 @@ -565,7 +565,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
61769 old_fs = get_fs();
61770 set_fs(get_ds());
61771 /* The cast to a user pointer is valid due to the set_fs() */
61772 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
61773 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
61774 set_fs(old_fs);
61775
61776 return res;
61777 @@ -580,7 +580,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
61778 old_fs = get_fs();
61779 set_fs(get_ds());
61780 /* The cast to a user pointer is valid due to the set_fs() */
61781 - res = vfs_write(file, (__force const char __user *)buf, count, &pos);
61782 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
61783 set_fs(old_fs);
61784
61785 return res;
61786 @@ -633,7 +633,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
61787 goto err;
61788
61789 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
61790 - vec[i].iov_base = (void __user *) page_address(page);
61791 + vec[i].iov_base = (void __force_user *) page_address(page);
61792 vec[i].iov_len = this_len;
61793 spd.pages[i] = page;
61794 spd.nr_pages++;
61795 @@ -829,7 +829,7 @@ int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_desc *sd,
61796 ops->release(pipe, buf);
61797 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);
61798 pipe->nrbufs--;
61799 - if (pipe->files)
61800 + if (atomic_read(&pipe->files))
61801 sd->need_wakeup = true;
61802 }
61803
61804 @@ -854,10 +854,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
61805 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
61806 {
61807 while (!pipe->nrbufs) {
61808 - if (!pipe->writers)
61809 + if (!atomic_read(&pipe->writers))
61810 return 0;
61811
61812 - if (!pipe->waiting_writers && sd->num_spliced)
61813 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
61814 return 0;
61815
61816 if (sd->flags & SPLICE_F_NONBLOCK)
61817 @@ -1193,7 +1193,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
61818 * out of the pipe right after the splice_to_pipe(). So set
61819 * PIPE_READERS appropriately.
61820 */
61821 - pipe->readers = 1;
61822 + atomic_set(&pipe->readers, 1);
61823
61824 current->splice_pipe = pipe;
61825 }
61826 @@ -1769,9 +1769,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
61827 ret = -ERESTARTSYS;
61828 break;
61829 }
61830 - if (!pipe->writers)
61831 + if (!atomic_read(&pipe->writers))
61832 break;
61833 - if (!pipe->waiting_writers) {
61834 + if (!atomic_read(&pipe->waiting_writers)) {
61835 if (flags & SPLICE_F_NONBLOCK) {
61836 ret = -EAGAIN;
61837 break;
61838 @@ -1803,7 +1803,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
61839 pipe_lock(pipe);
61840
61841 while (pipe->nrbufs >= pipe->buffers) {
61842 - if (!pipe->readers) {
61843 + if (!atomic_read(&pipe->readers)) {
61844 send_sig(SIGPIPE, current, 0);
61845 ret = -EPIPE;
61846 break;
61847 @@ -1816,9 +1816,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
61848 ret = -ERESTARTSYS;
61849 break;
61850 }
61851 - pipe->waiting_writers++;
61852 + atomic_inc(&pipe->waiting_writers);
61853 pipe_wait(pipe);
61854 - pipe->waiting_writers--;
61855 + atomic_dec(&pipe->waiting_writers);
61856 }
61857
61858 pipe_unlock(pipe);
61859 @@ -1854,14 +1854,14 @@ retry:
61860 pipe_double_lock(ipipe, opipe);
61861
61862 do {
61863 - if (!opipe->readers) {
61864 + if (!atomic_read(&opipe->readers)) {
61865 send_sig(SIGPIPE, current, 0);
61866 if (!ret)
61867 ret = -EPIPE;
61868 break;
61869 }
61870
61871 - if (!ipipe->nrbufs && !ipipe->writers)
61872 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
61873 break;
61874
61875 /*
61876 @@ -1958,7 +1958,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
61877 pipe_double_lock(ipipe, opipe);
61878
61879 do {
61880 - if (!opipe->readers) {
61881 + if (!atomic_read(&opipe->readers)) {
61882 send_sig(SIGPIPE, current, 0);
61883 if (!ret)
61884 ret = -EPIPE;
61885 @@ -2003,7 +2003,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
61886 * return EAGAIN if we have the potential of some data in the
61887 * future, otherwise just return 0
61888 */
61889 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
61890 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
61891 ret = -EAGAIN;
61892
61893 pipe_unlock(ipipe);
61894 diff --git a/fs/stat.c b/fs/stat.c
61895 index 04ce1ac..a13dd1e 100644
61896 --- a/fs/stat.c
61897 +++ b/fs/stat.c
61898 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
61899 stat->gid = inode->i_gid;
61900 stat->rdev = inode->i_rdev;
61901 stat->size = i_size_read(inode);
61902 - stat->atime = inode->i_atime;
61903 - stat->mtime = inode->i_mtime;
61904 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
61905 + stat->atime = inode->i_ctime;
61906 + stat->mtime = inode->i_ctime;
61907 + } else {
61908 + stat->atime = inode->i_atime;
61909 + stat->mtime = inode->i_mtime;
61910 + }
61911 stat->ctime = inode->i_ctime;
61912 stat->blksize = (1 << inode->i_blkbits);
61913 stat->blocks = inode->i_blocks;
61914 @@ -46,8 +51,14 @@ int vfs_getattr(struct path *path, struct kstat *stat)
61915 if (retval)
61916 return retval;
61917
61918 - if (inode->i_op->getattr)
61919 - return inode->i_op->getattr(path->mnt, path->dentry, stat);
61920 + if (inode->i_op->getattr) {
61921 + retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
61922 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
61923 + stat->atime = stat->ctime;
61924 + stat->mtime = stat->ctime;
61925 + }
61926 + return retval;
61927 + }
61928
61929 generic_fillattr(inode, stat);
61930 return 0;
61931 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
61932 index 15c68f9..36a8b3e 100644
61933 --- a/fs/sysfs/bin.c
61934 +++ b/fs/sysfs/bin.c
61935 @@ -235,13 +235,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
61936 return ret;
61937 }
61938
61939 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
61940 - void *buf, int len, int write)
61941 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
61942 + void *buf, size_t len, int write)
61943 {
61944 struct file *file = vma->vm_file;
61945 struct bin_buffer *bb = file->private_data;
61946 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
61947 - int ret;
61948 + ssize_t ret;
61949
61950 if (!bb->vm_ops)
61951 return -EINVAL;
61952 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
61953 index e8e0e71..79c28ac5 100644
61954 --- a/fs/sysfs/dir.c
61955 +++ b/fs/sysfs/dir.c
61956 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
61957 *
61958 * Returns 31 bit hash of ns + name (so it fits in an off_t )
61959 */
61960 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
61961 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
61962 {
61963 unsigned long hash = init_name_hash();
61964 unsigned int len = strlen(name);
61965 @@ -679,6 +679,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
61966 struct sysfs_dirent *sd;
61967 int rc;
61968
61969 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
61970 + const char *parent_name = parent_sd->s_name;
61971 +
61972 + mode = S_IFDIR | S_IRWXU;
61973 +
61974 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
61975 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
61976 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse") || !strcmp(name, "ecryptfs"))) ||
61977 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
61978 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
61979 +#endif
61980 +
61981 /* allocate */
61982 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
61983 if (!sd)
61984 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
61985 index 602f56d..6853db8 100644
61986 --- a/fs/sysfs/file.c
61987 +++ b/fs/sysfs/file.c
61988 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
61989
61990 struct sysfs_open_dirent {
61991 atomic_t refcnt;
61992 - atomic_t event;
61993 + atomic_unchecked_t event;
61994 wait_queue_head_t poll;
61995 struct list_head buffers; /* goes through sysfs_buffer.list */
61996 };
61997 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
61998 if (!sysfs_get_active(attr_sd))
61999 return -ENODEV;
62000
62001 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
62002 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
62003 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
62004
62005 sysfs_put_active(attr_sd);
62006 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
62007 return -ENOMEM;
62008
62009 atomic_set(&new_od->refcnt, 0);
62010 - atomic_set(&new_od->event, 1);
62011 + atomic_set_unchecked(&new_od->event, 1);
62012 init_waitqueue_head(&new_od->poll);
62013 INIT_LIST_HEAD(&new_od->buffers);
62014 goto retry;
62015 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
62016
62017 sysfs_put_active(attr_sd);
62018
62019 - if (buffer->event != atomic_read(&od->event))
62020 + if (buffer->event != atomic_read_unchecked(&od->event))
62021 goto trigger;
62022
62023 return DEFAULT_POLLMASK;
62024 @@ -451,7 +451,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
62025
62026 od = sd->s_attr.open;
62027 if (od) {
62028 - atomic_inc(&od->event);
62029 + atomic_inc_unchecked(&od->event);
62030 wake_up_interruptible(&od->poll);
62031 }
62032
62033 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
62034 index 8c940df..25b733e 100644
62035 --- a/fs/sysfs/symlink.c
62036 +++ b/fs/sysfs/symlink.c
62037 @@ -305,7 +305,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
62038
62039 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
62040 {
62041 - char *page = nd_get_link(nd);
62042 + const char *page = nd_get_link(nd);
62043 if (!IS_ERR(page))
62044 free_page((unsigned long)page);
62045 }
62046 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
62047 index 69d4889..a810bd4 100644
62048 --- a/fs/sysv/sysv.h
62049 +++ b/fs/sysv/sysv.h
62050 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
62051 #endif
62052 }
62053
62054 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
62055 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
62056 {
62057 if (sbi->s_bytesex == BYTESEX_PDP)
62058 return PDP_swab((__force __u32)n);
62059 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
62060 index e18b988..f1d4ad0f 100644
62061 --- a/fs/ubifs/io.c
62062 +++ b/fs/ubifs/io.c
62063 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
62064 return err;
62065 }
62066
62067 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
62068 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
62069 {
62070 int err;
62071
62072 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
62073 index c175b4d..8f36a16 100644
62074 --- a/fs/udf/misc.c
62075 +++ b/fs/udf/misc.c
62076 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
62077
62078 u8 udf_tag_checksum(const struct tag *t)
62079 {
62080 - u8 *data = (u8 *)t;
62081 + const u8 *data = (const u8 *)t;
62082 u8 checksum = 0;
62083 int i;
62084 for (i = 0; i < sizeof(struct tag); ++i)
62085 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
62086 index 8d974c4..b82f6ec 100644
62087 --- a/fs/ufs/swab.h
62088 +++ b/fs/ufs/swab.h
62089 @@ -22,7 +22,7 @@ enum {
62090 BYTESEX_BE
62091 };
62092
62093 -static inline u64
62094 +static inline u64 __intentional_overflow(-1)
62095 fs64_to_cpu(struct super_block *sbp, __fs64 n)
62096 {
62097 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
62098 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
62099 return (__force __fs64)cpu_to_be64(n);
62100 }
62101
62102 -static inline u32
62103 +static inline u32 __intentional_overflow(-1)
62104 fs32_to_cpu(struct super_block *sbp, __fs32 n)
62105 {
62106 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
62107 diff --git a/fs/utimes.c b/fs/utimes.c
62108 index f4fb7ec..3fe03c0 100644
62109 --- a/fs/utimes.c
62110 +++ b/fs/utimes.c
62111 @@ -1,6 +1,7 @@
62112 #include <linux/compiler.h>
62113 #include <linux/file.h>
62114 #include <linux/fs.h>
62115 +#include <linux/security.h>
62116 #include <linux/linkage.h>
62117 #include <linux/mount.h>
62118 #include <linux/namei.h>
62119 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
62120 goto mnt_drop_write_and_out;
62121 }
62122 }
62123 +
62124 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
62125 + error = -EACCES;
62126 + goto mnt_drop_write_and_out;
62127 + }
62128 +
62129 mutex_lock(&inode->i_mutex);
62130 error = notify_change(path->dentry, &newattrs);
62131 mutex_unlock(&inode->i_mutex);
62132 diff --git a/fs/xattr.c b/fs/xattr.c
62133 index 3377dff..4d074d9 100644
62134 --- a/fs/xattr.c
62135 +++ b/fs/xattr.c
62136 @@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
62137 return rc;
62138 }
62139
62140 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
62141 +ssize_t
62142 +pax_getxattr(struct dentry *dentry, void *value, size_t size)
62143 +{
62144 + struct inode *inode = dentry->d_inode;
62145 + ssize_t error;
62146 +
62147 + error = inode_permission(inode, MAY_EXEC);
62148 + if (error)
62149 + return error;
62150 +
62151 + if (inode->i_op->getxattr)
62152 + error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
62153 + else
62154 + error = -EOPNOTSUPP;
62155 +
62156 + return error;
62157 +}
62158 +EXPORT_SYMBOL(pax_getxattr);
62159 +#endif
62160 +
62161 ssize_t
62162 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
62163 {
62164 @@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
62165 * Extended attribute SET operations
62166 */
62167 static long
62168 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
62169 +setxattr(struct path *path, const char __user *name, const void __user *value,
62170 size_t size, int flags)
62171 {
62172 int error;
62173 @@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
62174 posix_acl_fix_xattr_from_user(kvalue, size);
62175 }
62176
62177 - error = vfs_setxattr(d, kname, kvalue, size, flags);
62178 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
62179 + error = -EACCES;
62180 + goto out;
62181 + }
62182 +
62183 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
62184 out:
62185 if (vvalue)
62186 vfree(vvalue);
62187 @@ -377,7 +403,7 @@ retry:
62188 return error;
62189 error = mnt_want_write(path.mnt);
62190 if (!error) {
62191 - error = setxattr(path.dentry, name, value, size, flags);
62192 + error = setxattr(&path, name, value, size, flags);
62193 mnt_drop_write(path.mnt);
62194 }
62195 path_put(&path);
62196 @@ -401,7 +427,7 @@ retry:
62197 return error;
62198 error = mnt_want_write(path.mnt);
62199 if (!error) {
62200 - error = setxattr(path.dentry, name, value, size, flags);
62201 + error = setxattr(&path, name, value, size, flags);
62202 mnt_drop_write(path.mnt);
62203 }
62204 path_put(&path);
62205 @@ -416,16 +442,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
62206 const void __user *,value, size_t, size, int, flags)
62207 {
62208 struct fd f = fdget(fd);
62209 - struct dentry *dentry;
62210 int error = -EBADF;
62211
62212 if (!f.file)
62213 return error;
62214 - dentry = f.file->f_path.dentry;
62215 - audit_inode(NULL, dentry, 0);
62216 + audit_inode(NULL, f.file->f_path.dentry, 0);
62217 error = mnt_want_write_file(f.file);
62218 if (!error) {
62219 - error = setxattr(dentry, name, value, size, flags);
62220 + error = setxattr(&f.file->f_path, name, value, size, flags);
62221 mnt_drop_write_file(f.file);
62222 }
62223 fdput(f);
62224 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
62225 index 9fbea87..6b19972 100644
62226 --- a/fs/xattr_acl.c
62227 +++ b/fs/xattr_acl.c
62228 @@ -76,8 +76,8 @@ struct posix_acl *
62229 posix_acl_from_xattr(struct user_namespace *user_ns,
62230 const void *value, size_t size)
62231 {
62232 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
62233 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
62234 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
62235 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
62236 int count;
62237 struct posix_acl *acl;
62238 struct posix_acl_entry *acl_e;
62239 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
62240 index 8904284..ee0e14b 100644
62241 --- a/fs/xfs/xfs_bmap.c
62242 +++ b/fs/xfs/xfs_bmap.c
62243 @@ -765,7 +765,7 @@ xfs_bmap_validate_ret(
62244
62245 #else
62246 #define xfs_bmap_check_leaf_extents(cur, ip, whichfork) do { } while (0)
62247 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
62248 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do { } while (0)
62249 #endif /* DEBUG */
62250
62251 /*
62252 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
62253 index 6157424..ac98f6d 100644
62254 --- a/fs/xfs/xfs_dir2_sf.c
62255 +++ b/fs/xfs/xfs_dir2_sf.c
62256 @@ -851,7 +851,15 @@ xfs_dir2_sf_getdents(
62257 }
62258
62259 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
62260 - if (filldir(dirent, (char *)sfep->name, sfep->namelen,
62261 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
62262 + char name[sfep->namelen];
62263 + memcpy(name, sfep->name, sfep->namelen);
62264 + if (filldir(dirent, name, sfep->namelen,
62265 + off & 0x7fffffff, ino, DT_UNKNOWN)) {
62266 + *offset = off & 0x7fffffff;
62267 + return 0;
62268 + }
62269 + } else if (filldir(dirent, (char *)sfep->name, sfep->namelen,
62270 off & 0x7fffffff, ino, DT_UNKNOWN)) {
62271 *offset = off & 0x7fffffff;
62272 return 0;
62273 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
62274 index 5e99968..45bd327 100644
62275 --- a/fs/xfs/xfs_ioctl.c
62276 +++ b/fs/xfs/xfs_ioctl.c
62277 @@ -127,7 +127,7 @@ xfs_find_handle(
62278 }
62279
62280 error = -EFAULT;
62281 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
62282 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
62283 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
62284 goto out_put;
62285
62286 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
62287 index ca9ecaa..60100c7 100644
62288 --- a/fs/xfs/xfs_iops.c
62289 +++ b/fs/xfs/xfs_iops.c
62290 @@ -395,7 +395,7 @@ xfs_vn_put_link(
62291 struct nameidata *nd,
62292 void *p)
62293 {
62294 - char *s = nd_get_link(nd);
62295 + const char *s = nd_get_link(nd);
62296
62297 if (!IS_ERR(s))
62298 kfree(s);
62299 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
62300 new file mode 100644
62301 index 0000000..76e84b9
62302 --- /dev/null
62303 +++ b/grsecurity/Kconfig
62304 @@ -0,0 +1,1063 @@
62305 +#
62306 +# grecurity configuration
62307 +#
62308 +menu "Memory Protections"
62309 +depends on GRKERNSEC
62310 +
62311 +config GRKERNSEC_KMEM
62312 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
62313 + default y if GRKERNSEC_CONFIG_AUTO
62314 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
62315 + help
62316 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
62317 + be written to or read from to modify or leak the contents of the running
62318 + kernel. /dev/port will also not be allowed to be opened and support
62319 + for /dev/cpu/*/msr will be removed. If you have module
62320 + support disabled, enabling this will close up five ways that are
62321 + currently used to insert malicious code into the running kernel.
62322 +
62323 + Even with all these features enabled, we still highly recommend that
62324 + you use the RBAC system, as it is still possible for an attacker to
62325 + modify the running kernel through privileged I/O granted by ioperm/iopl.
62326 +
62327 + If you are not using XFree86, you may be able to stop this additional
62328 + case by enabling the 'Disable privileged I/O' option. Though nothing
62329 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
62330 + but only to video memory, which is the only writing we allow in this
62331 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
62332 + not be allowed to mprotect it with PROT_WRITE later.
62333 + Enabling this feature will prevent the "cpupower" and "powertop" tools
62334 + from working.
62335 +
62336 + It is highly recommended that you say Y here if you meet all the
62337 + conditions above.
62338 +
62339 +config GRKERNSEC_VM86
62340 + bool "Restrict VM86 mode"
62341 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
62342 + depends on X86_32
62343 +
62344 + help
62345 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
62346 + make use of a special execution mode on 32bit x86 processors called
62347 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
62348 + video cards and will still work with this option enabled. The purpose
62349 + of the option is to prevent exploitation of emulation errors in
62350 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
62351 + Nearly all users should be able to enable this option.
62352 +
62353 +config GRKERNSEC_IO
62354 + bool "Disable privileged I/O"
62355 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
62356 + depends on X86
62357 + select RTC_CLASS
62358 + select RTC_INTF_DEV
62359 + select RTC_DRV_CMOS
62360 +
62361 + help
62362 + If you say Y here, all ioperm and iopl calls will return an error.
62363 + Ioperm and iopl can be used to modify the running kernel.
62364 + Unfortunately, some programs need this access to operate properly,
62365 + the most notable of which are XFree86 and hwclock. hwclock can be
62366 + remedied by having RTC support in the kernel, so real-time
62367 + clock support is enabled if this option is enabled, to ensure
62368 + that hwclock operates correctly. XFree86 still will not
62369 + operate correctly with this option enabled, so DO NOT CHOOSE Y
62370 + IF YOU USE XFree86. If you use XFree86 and you still want to
62371 + protect your kernel against modification, use the RBAC system.
62372 +
62373 +config GRKERNSEC_JIT_HARDEN
62374 + bool "Harden BPF JIT against spray attacks"
62375 + default y if GRKERNSEC_CONFIG_AUTO
62376 + depends on BPF_JIT
62377 + help
62378 + If you say Y here, the native code generated by the kernel's Berkeley
62379 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
62380 + attacks that attempt to fit attacker-beneficial instructions in
62381 + 32bit immediate fields of JIT-generated native instructions. The
62382 + attacker will generally aim to cause an unintended instruction sequence
62383 + of JIT-generated native code to execute by jumping into the middle of
62384 + a generated instruction. This feature effectively randomizes the 32bit
62385 + immediate constants present in the generated code to thwart such attacks.
62386 +
62387 + If you're using KERNEXEC, it's recommended that you enable this option
62388 + to supplement the hardening of the kernel.
62389 +
62390 +config GRKERNSEC_PERF_HARDEN
62391 + bool "Disable unprivileged PERF_EVENTS usage by default"
62392 + default y if GRKERNSEC_CONFIG_AUTO
62393 + depends on PERF_EVENTS
62394 + help
62395 + If you say Y here, the range of acceptable values for the
62396 + /proc/sys/kernel/perf_event_paranoid sysctl will be expanded to allow and
62397 + default to a new value: 3. When the sysctl is set to this value, no
62398 + unprivileged use of the PERF_EVENTS syscall interface will be permitted.
62399 +
62400 + Though PERF_EVENTS can be used legitimately for performance monitoring
62401 + and low-level application profiling, it is forced on regardless of
62402 + configuration, has been at fault for several vulnerabilities, and
62403 + creates new opportunities for side channels and other information leaks.
62404 +
62405 + This feature puts PERF_EVENTS into a secure default state and permits
62406 + the administrator to change out of it temporarily if unprivileged
62407 + application profiling is needed.
62408 +
62409 +config GRKERNSEC_RAND_THREADSTACK
62410 + bool "Insert random gaps between thread stacks"
62411 + default y if GRKERNSEC_CONFIG_AUTO
62412 + depends on PAX_RANDMMAP && !PPC
62413 + help
62414 + If you say Y here, a random-sized gap will be enforced between allocated
62415 + thread stacks. Glibc's NPTL and other threading libraries that
62416 + pass MAP_STACK to the kernel for thread stack allocation are supported.
62417 + The implementation currently provides 8 bits of entropy for the gap.
62418 +
62419 + Many distributions do not compile threaded remote services with the
62420 + -fstack-check argument to GCC, causing the variable-sized stack-based
62421 + allocator, alloca(), to not probe the stack on allocation. This
62422 + permits an unbounded alloca() to skip over any guard page and potentially
62423 + modify another thread's stack reliably. An enforced random gap
62424 + reduces the reliability of such an attack and increases the chance
62425 + that such a read/write to another thread's stack instead lands in
62426 + an unmapped area, causing a crash and triggering grsecurity's
62427 + anti-bruteforcing logic.
62428 +
62429 +config GRKERNSEC_PROC_MEMMAP
62430 + bool "Harden ASLR against information leaks and entropy reduction"
62431 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
62432 + depends on PAX_NOEXEC || PAX_ASLR
62433 + help
62434 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
62435 + give no information about the addresses of its mappings if
62436 + PaX features that rely on random addresses are enabled on the task.
62437 + In addition to sanitizing this information and disabling other
62438 + dangerous sources of information, this option causes reads of sensitive
62439 + /proc/<pid> entries where the file descriptor was opened in a different
62440 + task than the one performing the read. Such attempts are logged.
62441 + This option also limits argv/env strings for suid/sgid binaries
62442 + to 512KB to prevent a complete exhaustion of the stack entropy provided
62443 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
62444 + binaries to prevent alternative mmap layouts from being abused.
62445 +
62446 + If you use PaX it is essential that you say Y here as it closes up
62447 + several holes that make full ASLR useless locally.
62448 +
62449 +config GRKERNSEC_BRUTE
62450 + bool "Deter exploit bruteforcing"
62451 + default y if GRKERNSEC_CONFIG_AUTO
62452 + help
62453 + If you say Y here, attempts to bruteforce exploits against forking
62454 + daemons such as apache or sshd, as well as against suid/sgid binaries
62455 + will be deterred. When a child of a forking daemon is killed by PaX
62456 + or crashes due to an illegal instruction or other suspicious signal,
62457 + the parent process will be delayed 30 seconds upon every subsequent
62458 + fork until the administrator is able to assess the situation and
62459 + restart the daemon.
62460 + In the suid/sgid case, the attempt is logged, the user has all their
62461 + existing instances of the suid/sgid binary terminated and will
62462 + be unable to execute any suid/sgid binaries for 15 minutes.
62463 +
62464 + It is recommended that you also enable signal logging in the auditing
62465 + section so that logs are generated when a process triggers a suspicious
62466 + signal.
62467 + If the sysctl option is enabled, a sysctl option with name
62468 + "deter_bruteforce" is created.
62469 +
62470 +
62471 +config GRKERNSEC_MODHARDEN
62472 + bool "Harden module auto-loading"
62473 + default y if GRKERNSEC_CONFIG_AUTO
62474 + depends on MODULES
62475 + help
62476 + If you say Y here, module auto-loading in response to use of some
62477 + feature implemented by an unloaded module will be restricted to
62478 + root users. Enabling this option helps defend against attacks
62479 + by unprivileged users who abuse the auto-loading behavior to
62480 + cause a vulnerable module to load that is then exploited.
62481 +
62482 + If this option prevents a legitimate use of auto-loading for a
62483 + non-root user, the administrator can execute modprobe manually
62484 + with the exact name of the module mentioned in the alert log.
62485 + Alternatively, the administrator can add the module to the list
62486 + of modules loaded at boot by modifying init scripts.
62487 +
62488 + Modification of init scripts will most likely be needed on
62489 + Ubuntu servers with encrypted home directory support enabled,
62490 + as the first non-root user logging in will cause the ecb(aes),
62491 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
62492 +
62493 +config GRKERNSEC_HIDESYM
62494 + bool "Hide kernel symbols"
62495 + default y if GRKERNSEC_CONFIG_AUTO
62496 + select PAX_USERCOPY_SLABS
62497 + help
62498 + If you say Y here, getting information on loaded modules, and
62499 + displaying all kernel symbols through a syscall will be restricted
62500 + to users with CAP_SYS_MODULE. For software compatibility reasons,
62501 + /proc/kallsyms will be restricted to the root user. The RBAC
62502 + system can hide that entry even from root.
62503 +
62504 + This option also prevents leaking of kernel addresses through
62505 + several /proc entries.
62506 +
62507 + Note that this option is only effective provided the following
62508 + conditions are met:
62509 + 1) The kernel using grsecurity is not precompiled by some distribution
62510 + 2) You have also enabled GRKERNSEC_DMESG
62511 + 3) You are using the RBAC system and hiding other files such as your
62512 + kernel image and System.map. Alternatively, enabling this option
62513 + causes the permissions on /boot, /lib/modules, and the kernel
62514 + source directory to change at compile time to prevent
62515 + reading by non-root users.
62516 + If the above conditions are met, this option will aid in providing a
62517 + useful protection against local kernel exploitation of overflows
62518 + and arbitrary read/write vulnerabilities.
62519 +
62520 + It is highly recommended that you enable GRKERNSEC_PERF_HARDEN
62521 + in addition to this feature.
62522 +
62523 +config GRKERNSEC_KERN_LOCKOUT
62524 + bool "Active kernel exploit response"
62525 + default y if GRKERNSEC_CONFIG_AUTO
62526 + depends on X86 || ARM || PPC || SPARC
62527 + help
62528 + If you say Y here, when a PaX alert is triggered due to suspicious
62529 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
62530 + or an OOPS occurs due to bad memory accesses, instead of just
62531 + terminating the offending process (and potentially allowing
62532 + a subsequent exploit from the same user), we will take one of two
62533 + actions:
62534 + If the user was root, we will panic the system
62535 + If the user was non-root, we will log the attempt, terminate
62536 + all processes owned by the user, then prevent them from creating
62537 + any new processes until the system is restarted
62538 + This deters repeated kernel exploitation/bruteforcing attempts
62539 + and is useful for later forensics.
62540 +
62541 +endmenu
62542 +menu "Role Based Access Control Options"
62543 +depends on GRKERNSEC
62544 +
62545 +config GRKERNSEC_RBAC_DEBUG
62546 + bool
62547 +
62548 +config GRKERNSEC_NO_RBAC
62549 + bool "Disable RBAC system"
62550 + help
62551 + If you say Y here, the /dev/grsec device will be removed from the kernel,
62552 + preventing the RBAC system from being enabled. You should only say Y
62553 + here if you have no intention of using the RBAC system, so as to prevent
62554 + an attacker with root access from misusing the RBAC system to hide files
62555 + and processes when loadable module support and /dev/[k]mem have been
62556 + locked down.
62557 +
62558 +config GRKERNSEC_ACL_HIDEKERN
62559 + bool "Hide kernel processes"
62560 + help
62561 + If you say Y here, all kernel threads will be hidden to all
62562 + processes but those whose subject has the "view hidden processes"
62563 + flag.
62564 +
62565 +config GRKERNSEC_ACL_MAXTRIES
62566 + int "Maximum tries before password lockout"
62567 + default 3
62568 + help
62569 + This option enforces the maximum number of times a user can attempt
62570 + to authorize themselves with the grsecurity RBAC system before being
62571 + denied the ability to attempt authorization again for a specified time.
62572 + The lower the number, the harder it will be to brute-force a password.
62573 +
62574 +config GRKERNSEC_ACL_TIMEOUT
62575 + int "Time to wait after max password tries, in seconds"
62576 + default 30
62577 + help
62578 + This option specifies the time the user must wait after attempting to
62579 + authorize to the RBAC system with the maximum number of invalid
62580 + passwords. The higher the number, the harder it will be to brute-force
62581 + a password.
62582 +
62583 +endmenu
62584 +menu "Filesystem Protections"
62585 +depends on GRKERNSEC
62586 +
62587 +config GRKERNSEC_PROC
62588 + bool "Proc restrictions"
62589 + default y if GRKERNSEC_CONFIG_AUTO
62590 + help
62591 + If you say Y here, the permissions of the /proc filesystem
62592 + will be altered to enhance system security and privacy. You MUST
62593 + choose either a user only restriction or a user and group restriction.
62594 + Depending upon the option you choose, you can either restrict users to
62595 + see only the processes they themselves run, or choose a group that can
62596 + view all processes and files normally restricted to root if you choose
62597 + the "restrict to user only" option. NOTE: If you're running identd or
62598 + ntpd as a non-root user, you will have to run it as the group you
62599 + specify here.
62600 +
62601 +config GRKERNSEC_PROC_USER
62602 + bool "Restrict /proc to user only"
62603 + depends on GRKERNSEC_PROC
62604 + help
62605 + If you say Y here, non-root users will only be able to view their own
62606 + processes, and restricts them from viewing network-related information,
62607 + and viewing kernel symbol and module information.
62608 +
62609 +config GRKERNSEC_PROC_USERGROUP
62610 + bool "Allow special group"
62611 + default y if GRKERNSEC_CONFIG_AUTO
62612 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
62613 + help
62614 + If you say Y here, you will be able to select a group that will be
62615 + able to view all processes and network-related information. If you've
62616 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
62617 + remain hidden. This option is useful if you want to run identd as
62618 + a non-root user. The group you select may also be chosen at boot time
62619 + via "grsec_proc_gid=" on the kernel commandline.
62620 +
62621 +config GRKERNSEC_PROC_GID
62622 + int "GID for special group"
62623 + depends on GRKERNSEC_PROC_USERGROUP
62624 + default 1001
62625 +
62626 +config GRKERNSEC_PROC_ADD
62627 + bool "Additional restrictions"
62628 + default y if GRKERNSEC_CONFIG_AUTO
62629 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
62630 + help
62631 + If you say Y here, additional restrictions will be placed on
62632 + /proc that keep normal users from viewing device information and
62633 + slabinfo information that could be useful for exploits.
62634 +
62635 +config GRKERNSEC_LINK
62636 + bool "Linking restrictions"
62637 + default y if GRKERNSEC_CONFIG_AUTO
62638 + help
62639 + If you say Y here, /tmp race exploits will be prevented, since users
62640 + will no longer be able to follow symlinks owned by other users in
62641 + world-writable +t directories (e.g. /tmp), unless the owner of the
62642 + symlink is the owner of the directory. users will also not be
62643 + able to hardlink to files they do not own. If the sysctl option is
62644 + enabled, a sysctl option with name "linking_restrictions" is created.
62645 +
62646 +config GRKERNSEC_SYMLINKOWN
62647 + bool "Kernel-enforced SymlinksIfOwnerMatch"
62648 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
62649 + help
62650 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
62651 + that prevents it from being used as a security feature. As Apache
62652 + verifies the symlink by performing a stat() against the target of
62653 + the symlink before it is followed, an attacker can setup a symlink
62654 + to point to a same-owned file, then replace the symlink with one
62655 + that targets another user's file just after Apache "validates" the
62656 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
62657 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
62658 + will be in place for the group you specify. If the sysctl option
62659 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
62660 + created.
62661 +
62662 +config GRKERNSEC_SYMLINKOWN_GID
62663 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
62664 + depends on GRKERNSEC_SYMLINKOWN
62665 + default 1006
62666 + help
62667 + Setting this GID determines what group kernel-enforced
62668 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
62669 + is enabled, a sysctl option with name "symlinkown_gid" is created.
62670 +
62671 +config GRKERNSEC_FIFO
62672 + bool "FIFO restrictions"
62673 + default y if GRKERNSEC_CONFIG_AUTO
62674 + help
62675 + If you say Y here, users will not be able to write to FIFOs they don't
62676 + own in world-writable +t directories (e.g. /tmp), unless the owner of
62677 + the FIFO is the same owner of the directory it's held in. If the sysctl
62678 + option is enabled, a sysctl option with name "fifo_restrictions" is
62679 + created.
62680 +
62681 +config GRKERNSEC_SYSFS_RESTRICT
62682 + bool "Sysfs/debugfs restriction"
62683 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
62684 + depends on SYSFS
62685 + help
62686 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
62687 + any filesystem normally mounted under it (e.g. debugfs) will be
62688 + mostly accessible only by root. These filesystems generally provide access
62689 + to hardware and debug information that isn't appropriate for unprivileged
62690 + users of the system. Sysfs and debugfs have also become a large source
62691 + of new vulnerabilities, ranging from infoleaks to local compromise.
62692 + There has been very little oversight with an eye toward security involved
62693 + in adding new exporters of information to these filesystems, so their
62694 + use is discouraged.
62695 + For reasons of compatibility, a few directories have been whitelisted
62696 + for access by non-root users:
62697 + /sys/fs/selinux
62698 + /sys/fs/fuse
62699 + /sys/devices/system/cpu
62700 +
62701 +config GRKERNSEC_ROFS
62702 + bool "Runtime read-only mount protection"
62703 + help
62704 + If you say Y here, a sysctl option with name "romount_protect" will
62705 + be created. By setting this option to 1 at runtime, filesystems
62706 + will be protected in the following ways:
62707 + * No new writable mounts will be allowed
62708 + * Existing read-only mounts won't be able to be remounted read/write
62709 + * Write operations will be denied on all block devices
62710 + This option acts independently of grsec_lock: once it is set to 1,
62711 + it cannot be turned off. Therefore, please be mindful of the resulting
62712 + behavior if this option is enabled in an init script on a read-only
62713 + filesystem. This feature is mainly intended for secure embedded systems.
62714 +
62715 +config GRKERNSEC_DEVICE_SIDECHANNEL
62716 + bool "Eliminate stat/notify-based device sidechannels"
62717 + default y if GRKERNSEC_CONFIG_AUTO
62718 + help
62719 + If you say Y here, timing analyses on block or character
62720 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
62721 + will be thwarted for unprivileged users. If a process without
62722 + CAP_MKNOD stats such a device, the last access and last modify times
62723 + will match the device's create time. No access or modify events
62724 + will be triggered through inotify/dnotify/fanotify for such devices.
62725 + This feature will prevent attacks that may at a minimum
62726 + allow an attacker to determine the administrator's password length.
62727 +
62728 +config GRKERNSEC_CHROOT
62729 + bool "Chroot jail restrictions"
62730 + default y if GRKERNSEC_CONFIG_AUTO
62731 + help
62732 + If you say Y here, you will be able to choose several options that will
62733 + make breaking out of a chrooted jail much more difficult. If you
62734 + encounter no software incompatibilities with the following options, it
62735 + is recommended that you enable each one.
62736 +
62737 +config GRKERNSEC_CHROOT_MOUNT
62738 + bool "Deny mounts"
62739 + default y if GRKERNSEC_CONFIG_AUTO
62740 + depends on GRKERNSEC_CHROOT
62741 + help
62742 + If you say Y here, processes inside a chroot will not be able to
62743 + mount or remount filesystems. If the sysctl option is enabled, a
62744 + sysctl option with name "chroot_deny_mount" is created.
62745 +
62746 +config GRKERNSEC_CHROOT_DOUBLE
62747 + bool "Deny double-chroots"
62748 + default y if GRKERNSEC_CONFIG_AUTO
62749 + depends on GRKERNSEC_CHROOT
62750 + help
62751 + If you say Y here, processes inside a chroot will not be able to chroot
62752 + again outside the chroot. This is a widely used method of breaking
62753 + out of a chroot jail and should not be allowed. If the sysctl
62754 + option is enabled, a sysctl option with name
62755 + "chroot_deny_chroot" is created.
62756 +
62757 +config GRKERNSEC_CHROOT_PIVOT
62758 + bool "Deny pivot_root in chroot"
62759 + default y if GRKERNSEC_CONFIG_AUTO
62760 + depends on GRKERNSEC_CHROOT
62761 + help
62762 + If you say Y here, processes inside a chroot will not be able to use
62763 + a function called pivot_root() that was introduced in Linux 2.3.41. It
62764 + works similar to chroot in that it changes the root filesystem. This
62765 + function could be misused in a chrooted process to attempt to break out
62766 + of the chroot, and therefore should not be allowed. If the sysctl
62767 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
62768 + created.
62769 +
62770 +config GRKERNSEC_CHROOT_CHDIR
62771 + bool "Enforce chdir(\"/\") on all chroots"
62772 + default y if GRKERNSEC_CONFIG_AUTO
62773 + depends on GRKERNSEC_CHROOT
62774 + help
62775 + If you say Y here, the current working directory of all newly-chrooted
62776 + applications will be set to the the root directory of the chroot.
62777 + The man page on chroot(2) states:
62778 + Note that this call does not change the current working
62779 + directory, so that `.' can be outside the tree rooted at
62780 + `/'. In particular, the super-user can escape from a
62781 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
62782 +
62783 + It is recommended that you say Y here, since it's not known to break
62784 + any software. If the sysctl option is enabled, a sysctl option with
62785 + name "chroot_enforce_chdir" is created.
62786 +
62787 +config GRKERNSEC_CHROOT_CHMOD
62788 + bool "Deny (f)chmod +s"
62789 + default y if GRKERNSEC_CONFIG_AUTO
62790 + depends on GRKERNSEC_CHROOT
62791 + help
62792 + If you say Y here, processes inside a chroot will not be able to chmod
62793 + or fchmod files to make them have suid or sgid bits. This protects
62794 + against another published method of breaking a chroot. If the sysctl
62795 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
62796 + created.
62797 +
62798 +config GRKERNSEC_CHROOT_FCHDIR
62799 + bool "Deny fchdir out of chroot"
62800 + default y if GRKERNSEC_CONFIG_AUTO
62801 + depends on GRKERNSEC_CHROOT
62802 + help
62803 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
62804 + to a file descriptor of the chrooting process that points to a directory
62805 + outside the filesystem will be stopped. If the sysctl option
62806 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
62807 +
62808 +config GRKERNSEC_CHROOT_MKNOD
62809 + bool "Deny mknod"
62810 + default y if GRKERNSEC_CONFIG_AUTO
62811 + depends on GRKERNSEC_CHROOT
62812 + help
62813 + If you say Y here, processes inside a chroot will not be allowed to
62814 + mknod. The problem with using mknod inside a chroot is that it
62815 + would allow an attacker to create a device entry that is the same
62816 + as one on the physical root of your system, which could range from
62817 + anything from the console device to a device for your harddrive (which
62818 + they could then use to wipe the drive or steal data). It is recommended
62819 + that you say Y here, unless you run into software incompatibilities.
62820 + If the sysctl option is enabled, a sysctl option with name
62821 + "chroot_deny_mknod" is created.
62822 +
62823 +config GRKERNSEC_CHROOT_SHMAT
62824 + bool "Deny shmat() out of chroot"
62825 + default y if GRKERNSEC_CONFIG_AUTO
62826 + depends on GRKERNSEC_CHROOT
62827 + help
62828 + If you say Y here, processes inside a chroot will not be able to attach
62829 + to shared memory segments that were created outside of the chroot jail.
62830 + It is recommended that you say Y here. If the sysctl option is enabled,
62831 + a sysctl option with name "chroot_deny_shmat" is created.
62832 +
62833 +config GRKERNSEC_CHROOT_UNIX
62834 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
62835 + default y if GRKERNSEC_CONFIG_AUTO
62836 + depends on GRKERNSEC_CHROOT
62837 + help
62838 + If you say Y here, processes inside a chroot will not be able to
62839 + connect to abstract (meaning not belonging to a filesystem) Unix
62840 + domain sockets that were bound outside of a chroot. It is recommended
62841 + that you say Y here. If the sysctl option is enabled, a sysctl option
62842 + with name "chroot_deny_unix" is created.
62843 +
62844 +config GRKERNSEC_CHROOT_FINDTASK
62845 + bool "Protect outside processes"
62846 + default y if GRKERNSEC_CONFIG_AUTO
62847 + depends on GRKERNSEC_CHROOT
62848 + help
62849 + If you say Y here, processes inside a chroot will not be able to
62850 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
62851 + getsid, or view any process outside of the chroot. If the sysctl
62852 + option is enabled, a sysctl option with name "chroot_findtask" is
62853 + created.
62854 +
62855 +config GRKERNSEC_CHROOT_NICE
62856 + bool "Restrict priority changes"
62857 + default y if GRKERNSEC_CONFIG_AUTO
62858 + depends on GRKERNSEC_CHROOT
62859 + help
62860 + If you say Y here, processes inside a chroot will not be able to raise
62861 + the priority of processes in the chroot, or alter the priority of
62862 + processes outside the chroot. This provides more security than simply
62863 + removing CAP_SYS_NICE from the process' capability set. If the
62864 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
62865 + is created.
62866 +
62867 +config GRKERNSEC_CHROOT_SYSCTL
62868 + bool "Deny sysctl writes"
62869 + default y if GRKERNSEC_CONFIG_AUTO
62870 + depends on GRKERNSEC_CHROOT
62871 + help
62872 + If you say Y here, an attacker in a chroot will not be able to
62873 + write to sysctl entries, either by sysctl(2) or through a /proc
62874 + interface. It is strongly recommended that you say Y here. If the
62875 + sysctl option is enabled, a sysctl option with name
62876 + "chroot_deny_sysctl" is created.
62877 +
62878 +config GRKERNSEC_CHROOT_CAPS
62879 + bool "Capability restrictions"
62880 + default y if GRKERNSEC_CONFIG_AUTO
62881 + depends on GRKERNSEC_CHROOT
62882 + help
62883 + If you say Y here, the capabilities on all processes within a
62884 + chroot jail will be lowered to stop module insertion, raw i/o,
62885 + system and net admin tasks, rebooting the system, modifying immutable
62886 + files, modifying IPC owned by another, and changing the system time.
62887 + This is left an option because it can break some apps. Disable this
62888 + if your chrooted apps are having problems performing those kinds of
62889 + tasks. If the sysctl option is enabled, a sysctl option with
62890 + name "chroot_caps" is created.
62891 +
62892 +config GRKERNSEC_CHROOT_INITRD
62893 + bool "Exempt initrd tasks from restrictions"
62894 + default y if GRKERNSEC_CONFIG_AUTO
62895 + depends on GRKERNSEC_CHROOT && BLK_DEV_RAM
62896 + help
62897 + If you say Y here, tasks started prior to init will be exempted from
62898 + grsecurity's chroot restrictions. This option is mainly meant to
62899 + resolve Plymouth's performing privileged operations unnecessarily
62900 + in a chroot.
62901 +
62902 +endmenu
62903 +menu "Kernel Auditing"
62904 +depends on GRKERNSEC
62905 +
62906 +config GRKERNSEC_AUDIT_GROUP
62907 + bool "Single group for auditing"
62908 + help
62909 + If you say Y here, the exec and chdir logging features will only operate
62910 + on a group you specify. This option is recommended if you only want to
62911 + watch certain users instead of having a large amount of logs from the
62912 + entire system. If the sysctl option is enabled, a sysctl option with
62913 + name "audit_group" is created.
62914 +
62915 +config GRKERNSEC_AUDIT_GID
62916 + int "GID for auditing"
62917 + depends on GRKERNSEC_AUDIT_GROUP
62918 + default 1007
62919 +
62920 +config GRKERNSEC_EXECLOG
62921 + bool "Exec logging"
62922 + help
62923 + If you say Y here, all execve() calls will be logged (since the
62924 + other exec*() calls are frontends to execve(), all execution
62925 + will be logged). Useful for shell-servers that like to keep track
62926 + of their users. If the sysctl option is enabled, a sysctl option with
62927 + name "exec_logging" is created.
62928 + WARNING: This option when enabled will produce a LOT of logs, especially
62929 + on an active system.
62930 +
62931 +config GRKERNSEC_RESLOG
62932 + bool "Resource logging"
62933 + default y if GRKERNSEC_CONFIG_AUTO
62934 + help
62935 + If you say Y here, all attempts to overstep resource limits will
62936 + be logged with the resource name, the requested size, and the current
62937 + limit. It is highly recommended that you say Y here. If the sysctl
62938 + option is enabled, a sysctl option with name "resource_logging" is
62939 + created. If the RBAC system is enabled, the sysctl value is ignored.
62940 +
62941 +config GRKERNSEC_CHROOT_EXECLOG
62942 + bool "Log execs within chroot"
62943 + help
62944 + If you say Y here, all executions inside a chroot jail will be logged
62945 + to syslog. This can cause a large amount of logs if certain
62946 + applications (eg. djb's daemontools) are installed on the system, and
62947 + is therefore left as an option. If the sysctl option is enabled, a
62948 + sysctl option with name "chroot_execlog" is created.
62949 +
62950 +config GRKERNSEC_AUDIT_PTRACE
62951 + bool "Ptrace logging"
62952 + help
62953 + If you say Y here, all attempts to attach to a process via ptrace
62954 + will be logged. If the sysctl option is enabled, a sysctl option
62955 + with name "audit_ptrace" is created.
62956 +
62957 +config GRKERNSEC_AUDIT_CHDIR
62958 + bool "Chdir logging"
62959 + help
62960 + If you say Y here, all chdir() calls will be logged. If the sysctl
62961 + option is enabled, a sysctl option with name "audit_chdir" is created.
62962 +
62963 +config GRKERNSEC_AUDIT_MOUNT
62964 + bool "(Un)Mount logging"
62965 + help
62966 + If you say Y here, all mounts and unmounts will be logged. If the
62967 + sysctl option is enabled, a sysctl option with name "audit_mount" is
62968 + created.
62969 +
62970 +config GRKERNSEC_SIGNAL
62971 + bool "Signal logging"
62972 + default y if GRKERNSEC_CONFIG_AUTO
62973 + help
62974 + If you say Y here, certain important signals will be logged, such as
62975 + SIGSEGV, which will as a result inform you of when a error in a program
62976 + occurred, which in some cases could mean a possible exploit attempt.
62977 + If the sysctl option is enabled, a sysctl option with name
62978 + "signal_logging" is created.
62979 +
62980 +config GRKERNSEC_FORKFAIL
62981 + bool "Fork failure logging"
62982 + help
62983 + If you say Y here, all failed fork() attempts will be logged.
62984 + This could suggest a fork bomb, or someone attempting to overstep
62985 + their process limit. If the sysctl option is enabled, a sysctl option
62986 + with name "forkfail_logging" is created.
62987 +
62988 +config GRKERNSEC_TIME
62989 + bool "Time change logging"
62990 + default y if GRKERNSEC_CONFIG_AUTO
62991 + help
62992 + If you say Y here, any changes of the system clock will be logged.
62993 + If the sysctl option is enabled, a sysctl option with name
62994 + "timechange_logging" is created.
62995 +
62996 +config GRKERNSEC_PROC_IPADDR
62997 + bool "/proc/<pid>/ipaddr support"
62998 + default y if GRKERNSEC_CONFIG_AUTO
62999 + help
63000 + If you say Y here, a new entry will be added to each /proc/<pid>
63001 + directory that contains the IP address of the person using the task.
63002 + The IP is carried across local TCP and AF_UNIX stream sockets.
63003 + This information can be useful for IDS/IPSes to perform remote response
63004 + to a local attack. The entry is readable by only the owner of the
63005 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
63006 + the RBAC system), and thus does not create privacy concerns.
63007 +
63008 +config GRKERNSEC_RWXMAP_LOG
63009 + bool 'Denied RWX mmap/mprotect logging'
63010 + default y if GRKERNSEC_CONFIG_AUTO
63011 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
63012 + help
63013 + If you say Y here, calls to mmap() and mprotect() with explicit
63014 + usage of PROT_WRITE and PROT_EXEC together will be logged when
63015 + denied by the PAX_MPROTECT feature. This feature will also
63016 + log other problematic scenarios that can occur when PAX_MPROTECT
63017 + is enabled on a binary, like textrels and PT_GNU_STACK. If the
63018 + sysctl option is enabled, a sysctl option with name "rwxmap_logging"
63019 + is created.
63020 +
63021 +endmenu
63022 +
63023 +menu "Executable Protections"
63024 +depends on GRKERNSEC
63025 +
63026 +config GRKERNSEC_DMESG
63027 + bool "Dmesg(8) restriction"
63028 + default y if GRKERNSEC_CONFIG_AUTO
63029 + help
63030 + If you say Y here, non-root users will not be able to use dmesg(8)
63031 + to view the contents of the kernel's circular log buffer.
63032 + The kernel's log buffer often contains kernel addresses and other
63033 + identifying information useful to an attacker in fingerprinting a
63034 + system for a targeted exploit.
63035 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
63036 + created.
63037 +
63038 +config GRKERNSEC_HARDEN_PTRACE
63039 + bool "Deter ptrace-based process snooping"
63040 + default y if GRKERNSEC_CONFIG_AUTO
63041 + help
63042 + If you say Y here, TTY sniffers and other malicious monitoring
63043 + programs implemented through ptrace will be defeated. If you
63044 + have been using the RBAC system, this option has already been
63045 + enabled for several years for all users, with the ability to make
63046 + fine-grained exceptions.
63047 +
63048 + This option only affects the ability of non-root users to ptrace
63049 + processes that are not a descendent of the ptracing process.
63050 + This means that strace ./binary and gdb ./binary will still work,
63051 + but attaching to arbitrary processes will not. If the sysctl
63052 + option is enabled, a sysctl option with name "harden_ptrace" is
63053 + created.
63054 +
63055 +config GRKERNSEC_PTRACE_READEXEC
63056 + bool "Require read access to ptrace sensitive binaries"
63057 + default y if GRKERNSEC_CONFIG_AUTO
63058 + help
63059 + If you say Y here, unprivileged users will not be able to ptrace unreadable
63060 + binaries. This option is useful in environments that
63061 + remove the read bits (e.g. file mode 4711) from suid binaries to
63062 + prevent infoleaking of their contents. This option adds
63063 + consistency to the use of that file mode, as the binary could normally
63064 + be read out when run without privileges while ptracing.
63065 +
63066 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
63067 + is created.
63068 +
63069 +config GRKERNSEC_SETXID
63070 + bool "Enforce consistent multithreaded privileges"
63071 + default y if GRKERNSEC_CONFIG_AUTO
63072 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
63073 + help
63074 + If you say Y here, a change from a root uid to a non-root uid
63075 + in a multithreaded application will cause the resulting uids,
63076 + gids, supplementary groups, and capabilities in that thread
63077 + to be propagated to the other threads of the process. In most
63078 + cases this is unnecessary, as glibc will emulate this behavior
63079 + on behalf of the application. Other libcs do not act in the
63080 + same way, allowing the other threads of the process to continue
63081 + running with root privileges. If the sysctl option is enabled,
63082 + a sysctl option with name "consistent_setxid" is created.
63083 +
63084 +config GRKERNSEC_TPE
63085 + bool "Trusted Path Execution (TPE)"
63086 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
63087 + help
63088 + If you say Y here, you will be able to choose a gid to add to the
63089 + supplementary groups of users you want to mark as "untrusted."
63090 + These users will not be able to execute any files that are not in
63091 + root-owned directories writable only by root. If the sysctl option
63092 + is enabled, a sysctl option with name "tpe" is created.
63093 +
63094 +config GRKERNSEC_TPE_ALL
63095 + bool "Partially restrict all non-root users"
63096 + depends on GRKERNSEC_TPE
63097 + help
63098 + If you say Y here, all non-root users will be covered under
63099 + a weaker TPE restriction. This is separate from, and in addition to,
63100 + the main TPE options that you have selected elsewhere. Thus, if a
63101 + "trusted" GID is chosen, this restriction applies to even that GID.
63102 + Under this restriction, all non-root users will only be allowed to
63103 + execute files in directories they own that are not group or
63104 + world-writable, or in directories owned by root and writable only by
63105 + root. If the sysctl option is enabled, a sysctl option with name
63106 + "tpe_restrict_all" is created.
63107 +
63108 +config GRKERNSEC_TPE_INVERT
63109 + bool "Invert GID option"
63110 + depends on GRKERNSEC_TPE
63111 + help
63112 + If you say Y here, the group you specify in the TPE configuration will
63113 + decide what group TPE restrictions will be *disabled* for. This
63114 + option is useful if you want TPE restrictions to be applied to most
63115 + users on the system. If the sysctl option is enabled, a sysctl option
63116 + with name "tpe_invert" is created. Unlike other sysctl options, this
63117 + entry will default to on for backward-compatibility.
63118 +
63119 +config GRKERNSEC_TPE_GID
63120 + int
63121 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
63122 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
63123 +
63124 +config GRKERNSEC_TPE_UNTRUSTED_GID
63125 + int "GID for TPE-untrusted users"
63126 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
63127 + default 1005
63128 + help
63129 + Setting this GID determines what group TPE restrictions will be
63130 + *enabled* for. If the sysctl option is enabled, a sysctl option
63131 + with name "tpe_gid" is created.
63132 +
63133 +config GRKERNSEC_TPE_TRUSTED_GID
63134 + int "GID for TPE-trusted users"
63135 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
63136 + default 1005
63137 + help
63138 + Setting this GID determines what group TPE restrictions will be
63139 + *disabled* for. If the sysctl option is enabled, a sysctl option
63140 + with name "tpe_gid" is created.
63141 +
63142 +endmenu
63143 +menu "Network Protections"
63144 +depends on GRKERNSEC
63145 +
63146 +config GRKERNSEC_RANDNET
63147 + bool "Larger entropy pools"
63148 + default y if GRKERNSEC_CONFIG_AUTO
63149 + help
63150 + If you say Y here, the entropy pools used for many features of Linux
63151 + and grsecurity will be doubled in size. Since several grsecurity
63152 + features use additional randomness, it is recommended that you say Y
63153 + here. Saying Y here has a similar effect as modifying
63154 + /proc/sys/kernel/random/poolsize.
63155 +
63156 +config GRKERNSEC_BLACKHOLE
63157 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
63158 + default y if GRKERNSEC_CONFIG_AUTO
63159 + depends on NET
63160 + help
63161 + If you say Y here, neither TCP resets nor ICMP
63162 + destination-unreachable packets will be sent in response to packets
63163 + sent to ports for which no associated listening process exists.
63164 + This feature supports both IPV4 and IPV6 and exempts the
63165 + loopback interface from blackholing. Enabling this feature
63166 + makes a host more resilient to DoS attacks and reduces network
63167 + visibility against scanners.
63168 +
63169 + The blackhole feature as-implemented is equivalent to the FreeBSD
63170 + blackhole feature, as it prevents RST responses to all packets, not
63171 + just SYNs. Under most application behavior this causes no
63172 + problems, but applications (like haproxy) may not close certain
63173 + connections in a way that cleanly terminates them on the remote
63174 + end, leaving the remote host in LAST_ACK state. Because of this
63175 + side-effect and to prevent intentional LAST_ACK DoSes, this
63176 + feature also adds automatic mitigation against such attacks.
63177 + The mitigation drastically reduces the amount of time a socket
63178 + can spend in LAST_ACK state. If you're using haproxy and not
63179 + all servers it connects to have this option enabled, consider
63180 + disabling this feature on the haproxy host.
63181 +
63182 + If the sysctl option is enabled, two sysctl options with names
63183 + "ip_blackhole" and "lastack_retries" will be created.
63184 + While "ip_blackhole" takes the standard zero/non-zero on/off
63185 + toggle, "lastack_retries" uses the same kinds of values as
63186 + "tcp_retries1" and "tcp_retries2". The default value of 4
63187 + prevents a socket from lasting more than 45 seconds in LAST_ACK
63188 + state.
63189 +
63190 +config GRKERNSEC_NO_SIMULT_CONNECT
63191 + bool "Disable TCP Simultaneous Connect"
63192 + default y if GRKERNSEC_CONFIG_AUTO
63193 + depends on NET
63194 + help
63195 + If you say Y here, a feature by Willy Tarreau will be enabled that
63196 + removes a weakness in Linux's strict implementation of TCP that
63197 + allows two clients to connect to each other without either entering
63198 + a listening state. The weakness allows an attacker to easily prevent
63199 + a client from connecting to a known server provided the source port
63200 + for the connection is guessed correctly.
63201 +
63202 + As the weakness could be used to prevent an antivirus or IPS from
63203 + fetching updates, or prevent an SSL gateway from fetching a CRL,
63204 + it should be eliminated by enabling this option. Though Linux is
63205 + one of few operating systems supporting simultaneous connect, it
63206 + has no legitimate use in practice and is rarely supported by firewalls.
63207 +
63208 +config GRKERNSEC_SOCKET
63209 + bool "Socket restrictions"
63210 + depends on NET
63211 + help
63212 + If you say Y here, you will be able to choose from several options.
63213 + If you assign a GID on your system and add it to the supplementary
63214 + groups of users you want to restrict socket access to, this patch
63215 + will perform up to three things, based on the option(s) you choose.
63216 +
63217 +config GRKERNSEC_SOCKET_ALL
63218 + bool "Deny any sockets to group"
63219 + depends on GRKERNSEC_SOCKET
63220 + help
63221 + If you say Y here, you will be able to choose a GID of whose users will
63222 + be unable to connect to other hosts from your machine or run server
63223 + applications from your machine. If the sysctl option is enabled, a
63224 + sysctl option with name "socket_all" is created.
63225 +
63226 +config GRKERNSEC_SOCKET_ALL_GID
63227 + int "GID to deny all sockets for"
63228 + depends on GRKERNSEC_SOCKET_ALL
63229 + default 1004
63230 + help
63231 + Here you can choose the GID to disable socket access for. Remember to
63232 + add the users you want socket access disabled for to the GID
63233 + specified here. If the sysctl option is enabled, a sysctl option
63234 + with name "socket_all_gid" is created.
63235 +
63236 +config GRKERNSEC_SOCKET_CLIENT
63237 + bool "Deny client sockets to group"
63238 + depends on GRKERNSEC_SOCKET
63239 + help
63240 + If you say Y here, you will be able to choose a GID of whose users will
63241 + be unable to connect to other hosts from your machine, but will be
63242 + able to run servers. If this option is enabled, all users in the group
63243 + you specify will have to use passive mode when initiating ftp transfers
63244 + from the shell on your machine. If the sysctl option is enabled, a
63245 + sysctl option with name "socket_client" is created.
63246 +
63247 +config GRKERNSEC_SOCKET_CLIENT_GID
63248 + int "GID to deny client sockets for"
63249 + depends on GRKERNSEC_SOCKET_CLIENT
63250 + default 1003
63251 + help
63252 + Here you can choose the GID to disable client socket access for.
63253 + Remember to add the users you want client socket access disabled for to
63254 + the GID specified here. If the sysctl option is enabled, a sysctl
63255 + option with name "socket_client_gid" is created.
63256 +
63257 +config GRKERNSEC_SOCKET_SERVER
63258 + bool "Deny server sockets to group"
63259 + depends on GRKERNSEC_SOCKET
63260 + help
63261 + If you say Y here, you will be able to choose a GID of whose users will
63262 + be unable to run server applications from your machine. If the sysctl
63263 + option is enabled, a sysctl option with name "socket_server" is created.
63264 +
63265 +config GRKERNSEC_SOCKET_SERVER_GID
63266 + int "GID to deny server sockets for"
63267 + depends on GRKERNSEC_SOCKET_SERVER
63268 + default 1002
63269 + help
63270 + Here you can choose the GID to disable server socket access for.
63271 + Remember to add the users you want server socket access disabled for to
63272 + the GID specified here. If the sysctl option is enabled, a sysctl
63273 + option with name "socket_server_gid" is created.
63274 +
63275 +endmenu
63276 +
63277 +menu "Physical Protections"
63278 +depends on GRKERNSEC
63279 +
63280 +config GRKERNSEC_DENYUSB
63281 + bool "Deny new USB connections after toggle"
63282 + default y if GRKERNSEC_CONFIG_AUTO
63283 + help
63284 + If you say Y here, a new sysctl option with name "deny_new_usb"
63285 + will be created. Setting its value to 1 will prevent any new
63286 + USB devices from being recognized by the OS. Any attempted USB
63287 + device insertion will be logged. This option is intended to be
63288 + used against custom USB devices designed to exploit vulnerabilities
63289 + in various USB device drivers.
63290 +
63291 + For greatest effectiveness, this sysctl should be set after any
63292 + relevant init scripts. Once set, it cannot be unset.
63293 +
63294 +endmenu
63295 +
63296 +menu "Sysctl Support"
63297 +depends on GRKERNSEC && SYSCTL
63298 +
63299 +config GRKERNSEC_SYSCTL
63300 + bool "Sysctl support"
63301 + default y if GRKERNSEC_CONFIG_AUTO
63302 + help
63303 + If you say Y here, you will be able to change the options that
63304 + grsecurity runs with at bootup, without having to recompile your
63305 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
63306 + to enable (1) or disable (0) various features. All the sysctl entries
63307 + are mutable until the "grsec_lock" entry is set to a non-zero value.
63308 + All features enabled in the kernel configuration are disabled at boot
63309 + if you do not say Y to the "Turn on features by default" option.
63310 + All options should be set at startup, and the grsec_lock entry should
63311 + be set to a non-zero value after all the options are set.
63312 + *THIS IS EXTREMELY IMPORTANT*
63313 +
63314 +config GRKERNSEC_SYSCTL_DISTRO
63315 + bool "Extra sysctl support for distro makers (READ HELP)"
63316 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
63317 + help
63318 + If you say Y here, additional sysctl options will be created
63319 + for features that affect processes running as root. Therefore,
63320 + it is critical when using this option that the grsec_lock entry be
63321 + enabled after boot. Only distros with prebuilt kernel packages
63322 + with this option enabled that can ensure grsec_lock is enabled
63323 + after boot should use this option.
63324 + *Failure to set grsec_lock after boot makes all grsec features
63325 + this option covers useless*
63326 +
63327 + Currently this option creates the following sysctl entries:
63328 + "Disable Privileged I/O": "disable_priv_io"
63329 +
63330 +config GRKERNSEC_SYSCTL_ON
63331 + bool "Turn on features by default"
63332 + default y if GRKERNSEC_CONFIG_AUTO
63333 + depends on GRKERNSEC_SYSCTL
63334 + help
63335 + If you say Y here, instead of having all features enabled in the
63336 + kernel configuration disabled at boot time, the features will be
63337 + enabled at boot time. It is recommended you say Y here unless
63338 + there is some reason you would want all sysctl-tunable features to
63339 + be disabled by default. As mentioned elsewhere, it is important
63340 + to enable the grsec_lock entry once you have finished modifying
63341 + the sysctl entries.
63342 +
63343 +endmenu
63344 +menu "Logging Options"
63345 +depends on GRKERNSEC
63346 +
63347 +config GRKERNSEC_FLOODTIME
63348 + int "Seconds in between log messages (minimum)"
63349 + default 10
63350 + help
63351 + This option allows you to enforce the number of seconds between
63352 + grsecurity log messages. The default should be suitable for most
63353 + people, however, if you choose to change it, choose a value small enough
63354 + to allow informative logs to be produced, but large enough to
63355 + prevent flooding.
63356 +
63357 +config GRKERNSEC_FLOODBURST
63358 + int "Number of messages in a burst (maximum)"
63359 + default 6
63360 + help
63361 + This option allows you to choose the maximum number of messages allowed
63362 + within the flood time interval you chose in a separate option. The
63363 + default should be suitable for most people, however if you find that
63364 + many of your logs are being interpreted as flooding, you may want to
63365 + raise this value.
63366 +
63367 +endmenu
63368 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
63369 new file mode 100644
63370 index 0000000..b0b77d5
63371 --- /dev/null
63372 +++ b/grsecurity/Makefile
63373 @@ -0,0 +1,43 @@
63374 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
63375 +# during 2001-2009 it has been completely redesigned by Brad Spengler
63376 +# into an RBAC system
63377 +#
63378 +# All code in this directory and various hooks inserted throughout the kernel
63379 +# are copyright Brad Spengler - Open Source Security, Inc., and released
63380 +# under the GPL v2 or higher
63381 +
63382 +KBUILD_CFLAGS += -Werror
63383 +
63384 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
63385 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
63386 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o \
63387 + grsec_usb.o
63388 +
63389 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
63390 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
63391 + gracl_learn.o grsec_log.o
63392 +ifdef CONFIG_COMPAT
63393 +obj-$(CONFIG_GRKERNSEC) += gracl_compat.o
63394 +endif
63395 +
63396 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
63397 +
63398 +ifdef CONFIG_NET
63399 +obj-y += grsec_sock.o
63400 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
63401 +endif
63402 +
63403 +ifndef CONFIG_GRKERNSEC
63404 +obj-y += grsec_disabled.o
63405 +endif
63406 +
63407 +ifdef CONFIG_GRKERNSEC_HIDESYM
63408 +extra-y := grsec_hidesym.o
63409 +$(obj)/grsec_hidesym.o:
63410 + @-chmod -f 500 /boot
63411 + @-chmod -f 500 /lib/modules
63412 + @-chmod -f 500 /lib64/modules
63413 + @-chmod -f 500 /lib32/modules
63414 + @-chmod -f 700 .
63415 + @echo ' grsec: protected kernel image paths'
63416 +endif
63417 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
63418 new file mode 100644
63419 index 0000000..c0793fd
63420 --- /dev/null
63421 +++ b/grsecurity/gracl.c
63422 @@ -0,0 +1,4178 @@
63423 +#include <linux/kernel.h>
63424 +#include <linux/module.h>
63425 +#include <linux/sched.h>
63426 +#include <linux/mm.h>
63427 +#include <linux/file.h>
63428 +#include <linux/fs.h>
63429 +#include <linux/namei.h>
63430 +#include <linux/mount.h>
63431 +#include <linux/tty.h>
63432 +#include <linux/proc_fs.h>
63433 +#include <linux/lglock.h>
63434 +#include <linux/slab.h>
63435 +#include <linux/vmalloc.h>
63436 +#include <linux/types.h>
63437 +#include <linux/sysctl.h>
63438 +#include <linux/netdevice.h>
63439 +#include <linux/ptrace.h>
63440 +#include <linux/gracl.h>
63441 +#include <linux/gralloc.h>
63442 +#include <linux/security.h>
63443 +#include <linux/grinternal.h>
63444 +#include <linux/pid_namespace.h>
63445 +#include <linux/stop_machine.h>
63446 +#include <linux/fdtable.h>
63447 +#include <linux/percpu.h>
63448 +#include <linux/lglock.h>
63449 +#include <linux/hugetlb.h>
63450 +#include <linux/posix-timers.h>
63451 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
63452 +#include <linux/magic.h>
63453 +#include <linux/pagemap.h>
63454 +#include "../fs/btrfs/async-thread.h"
63455 +#include "../fs/btrfs/ctree.h"
63456 +#include "../fs/btrfs/btrfs_inode.h"
63457 +#endif
63458 +#include "../fs/mount.h"
63459 +
63460 +#include <asm/uaccess.h>
63461 +#include <asm/errno.h>
63462 +#include <asm/mman.h>
63463 +
63464 +extern struct lglock vfsmount_lock;
63465 +
63466 +static struct acl_role_db acl_role_set;
63467 +static struct name_db name_set;
63468 +static struct inodev_db inodev_set;
63469 +
63470 +/* for keeping track of userspace pointers used for subjects, so we
63471 + can share references in the kernel as well
63472 +*/
63473 +
63474 +static struct path real_root;
63475 +
63476 +static struct acl_subj_map_db subj_map_set;
63477 +
63478 +static struct acl_role_label *default_role;
63479 +
63480 +static struct acl_role_label *role_list;
63481 +
63482 +static u16 acl_sp_role_value;
63483 +
63484 +extern char *gr_shared_page[4];
63485 +static DEFINE_MUTEX(gr_dev_mutex);
63486 +DEFINE_RWLOCK(gr_inode_lock);
63487 +
63488 +struct gr_arg *gr_usermode;
63489 +
63490 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
63491 +
63492 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
63493 +extern void gr_clear_learn_entries(void);
63494 +
63495 +unsigned char *gr_system_salt;
63496 +unsigned char *gr_system_sum;
63497 +
63498 +static struct sprole_pw **acl_special_roles = NULL;
63499 +static __u16 num_sprole_pws = 0;
63500 +
63501 +static struct acl_role_label *kernel_role = NULL;
63502 +
63503 +static unsigned int gr_auth_attempts = 0;
63504 +static unsigned long gr_auth_expires = 0UL;
63505 +
63506 +#ifdef CONFIG_NET
63507 +extern struct vfsmount *sock_mnt;
63508 +#endif
63509 +
63510 +extern struct vfsmount *pipe_mnt;
63511 +extern struct vfsmount *shm_mnt;
63512 +
63513 +#ifdef CONFIG_HUGETLBFS
63514 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
63515 +#endif
63516 +
63517 +static struct acl_object_label *fakefs_obj_rw;
63518 +static struct acl_object_label *fakefs_obj_rwx;
63519 +
63520 +extern int gr_init_uidset(void);
63521 +extern void gr_free_uidset(void);
63522 +extern void gr_remove_uid(uid_t uid);
63523 +extern int gr_find_uid(uid_t uid);
63524 +
63525 +static int copy_acl_object_label_normal(struct acl_object_label *obj, const struct acl_object_label *userp)
63526 +{
63527 + if (copy_from_user(obj, userp, sizeof(struct acl_object_label)))
63528 + return -EFAULT;
63529 +
63530 + return 0;
63531 +}
63532 +
63533 +static int copy_acl_ip_label_normal(struct acl_ip_label *ip, const struct acl_ip_label *userp)
63534 +{
63535 + if (copy_from_user(ip, userp, sizeof(struct acl_ip_label)))
63536 + return -EFAULT;
63537 +
63538 + return 0;
63539 +}
63540 +
63541 +static int copy_acl_subject_label_normal(struct acl_subject_label *subj, const struct acl_subject_label *userp)
63542 +{
63543 + if (copy_from_user(subj, userp, sizeof(struct acl_subject_label)))
63544 + return -EFAULT;
63545 +
63546 + return 0;
63547 +}
63548 +
63549 +static int copy_acl_role_label_normal(struct acl_role_label *role, const struct acl_role_label *userp)
63550 +{
63551 + if (copy_from_user(role, userp, sizeof(struct acl_role_label)))
63552 + return -EFAULT;
63553 +
63554 + return 0;
63555 +}
63556 +
63557 +static int copy_role_allowed_ip_normal(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
63558 +{
63559 + if (copy_from_user(roleip, userp, sizeof(struct role_allowed_ip)))
63560 + return -EFAULT;
63561 +
63562 + return 0;
63563 +}
63564 +
63565 +static int copy_sprole_pw_normal(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
63566 +{
63567 + if (copy_from_user(pw, userp + idx, sizeof(struct sprole_pw)))
63568 + return -EFAULT;
63569 +
63570 + return 0;
63571 +}
63572 +
63573 +static int copy_gr_hash_struct_normal(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
63574 +{
63575 + if (copy_from_user(hash, userp, sizeof(struct gr_hash_struct)))
63576 + return -EFAULT;
63577 +
63578 + return 0;
63579 +}
63580 +
63581 +static int copy_role_transition_normal(struct role_transition *trans, const struct role_transition *userp)
63582 +{
63583 + if (copy_from_user(trans, userp, sizeof(struct role_transition)))
63584 + return -EFAULT;
63585 +
63586 + return 0;
63587 +}
63588 +
63589 +int copy_pointer_from_array_normal(void *ptr, unsigned long idx, const void *userp)
63590 +{
63591 + if (copy_from_user(ptr, userp + (idx * sizeof(void *)), sizeof(void *)))
63592 + return -EFAULT;
63593 +
63594 + return 0;
63595 +}
63596 +
63597 +static int copy_gr_arg_wrapper_normal(const char __user *buf, struct gr_arg_wrapper *uwrap)
63598 +{
63599 + if (copy_from_user(uwrap, buf, sizeof (struct gr_arg_wrapper)))
63600 + return -EFAULT;
63601 +
63602 + if ((uwrap->version != GRSECURITY_VERSION) || (uwrap->size != sizeof(struct gr_arg)))
63603 + return -EINVAL;
63604 +
63605 + return 0;
63606 +}
63607 +
63608 +static int copy_gr_arg_normal(const struct gr_arg __user *buf, struct gr_arg *arg)
63609 +{
63610 + if (copy_from_user(arg, buf, sizeof (struct gr_arg)))
63611 + return -EFAULT;
63612 +
63613 + return 0;
63614 +}
63615 +
63616 +static size_t get_gr_arg_wrapper_size_normal(void)
63617 +{
63618 + return sizeof(struct gr_arg_wrapper);
63619 +}
63620 +
63621 +#ifdef CONFIG_COMPAT
63622 +extern int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap);
63623 +extern int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg);
63624 +extern int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp);
63625 +extern int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp);
63626 +extern int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp);
63627 +extern int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp);
63628 +extern int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp);
63629 +extern int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp);
63630 +extern int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp);
63631 +extern int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp);
63632 +extern int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp);
63633 +extern size_t get_gr_arg_wrapper_size_compat(void);
63634 +
63635 +int (* copy_gr_arg_wrapper)(const char *buf, struct gr_arg_wrapper *uwrap) __read_only;
63636 +int (* copy_gr_arg)(const struct gr_arg *buf, struct gr_arg *arg) __read_only;
63637 +int (* copy_acl_object_label)(struct acl_object_label *obj, const struct acl_object_label *userp) __read_only;
63638 +int (* copy_acl_subject_label)(struct acl_subject_label *subj, const struct acl_subject_label *userp) __read_only;
63639 +int (* copy_acl_role_label)(struct acl_role_label *role, const struct acl_role_label *userp) __read_only;
63640 +int (* copy_acl_ip_label)(struct acl_ip_label *ip, const struct acl_ip_label *userp) __read_only;
63641 +int (* copy_pointer_from_array)(void *ptr, unsigned long idx, const void *userp) __read_only;
63642 +int (* copy_sprole_pw)(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp) __read_only;
63643 +int (* copy_gr_hash_struct)(struct gr_hash_struct *hash, const struct gr_hash_struct *userp) __read_only;
63644 +int (* copy_role_transition)(struct role_transition *trans, const struct role_transition *userp) __read_only;
63645 +int (* copy_role_allowed_ip)(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp) __read_only;
63646 +size_t (* get_gr_arg_wrapper_size)(void) __read_only;
63647 +
63648 +#else
63649 +#define copy_gr_arg_wrapper copy_gr_arg_wrapper_normal
63650 +#define copy_gr_arg copy_gr_arg_normal
63651 +#define copy_gr_hash_struct copy_gr_hash_struct_normal
63652 +#define copy_acl_object_label copy_acl_object_label_normal
63653 +#define copy_acl_subject_label copy_acl_subject_label_normal
63654 +#define copy_acl_role_label copy_acl_role_label_normal
63655 +#define copy_acl_ip_label copy_acl_ip_label_normal
63656 +#define copy_pointer_from_array copy_pointer_from_array_normal
63657 +#define copy_sprole_pw copy_sprole_pw_normal
63658 +#define copy_role_transition copy_role_transition_normal
63659 +#define copy_role_allowed_ip copy_role_allowed_ip_normal
63660 +#define get_gr_arg_wrapper_size get_gr_arg_wrapper_size_normal
63661 +#endif
63662 +
63663 +__inline__ int
63664 +gr_acl_is_enabled(void)
63665 +{
63666 + return (gr_status & GR_READY);
63667 +}
63668 +
63669 +static inline dev_t __get_dev(const struct dentry *dentry)
63670 +{
63671 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
63672 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
63673 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
63674 + else
63675 +#endif
63676 + return dentry->d_sb->s_dev;
63677 +}
63678 +
63679 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
63680 +{
63681 + return __get_dev(dentry);
63682 +}
63683 +
63684 +static char gr_task_roletype_to_char(struct task_struct *task)
63685 +{
63686 + switch (task->role->roletype &
63687 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
63688 + GR_ROLE_SPECIAL)) {
63689 + case GR_ROLE_DEFAULT:
63690 + return 'D';
63691 + case GR_ROLE_USER:
63692 + return 'U';
63693 + case GR_ROLE_GROUP:
63694 + return 'G';
63695 + case GR_ROLE_SPECIAL:
63696 + return 'S';
63697 + }
63698 +
63699 + return 'X';
63700 +}
63701 +
63702 +char gr_roletype_to_char(void)
63703 +{
63704 + return gr_task_roletype_to_char(current);
63705 +}
63706 +
63707 +__inline__ int
63708 +gr_acl_tpe_check(void)
63709 +{
63710 + if (unlikely(!(gr_status & GR_READY)))
63711 + return 0;
63712 + if (current->role->roletype & GR_ROLE_TPE)
63713 + return 1;
63714 + else
63715 + return 0;
63716 +}
63717 +
63718 +int
63719 +gr_handle_rawio(const struct inode *inode)
63720 +{
63721 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63722 + if (inode && S_ISBLK(inode->i_mode) &&
63723 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
63724 + !capable(CAP_SYS_RAWIO))
63725 + return 1;
63726 +#endif
63727 + return 0;
63728 +}
63729 +
63730 +static int
63731 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
63732 +{
63733 + if (likely(lena != lenb))
63734 + return 0;
63735 +
63736 + return !memcmp(a, b, lena);
63737 +}
63738 +
63739 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
63740 +{
63741 + *buflen -= namelen;
63742 + if (*buflen < 0)
63743 + return -ENAMETOOLONG;
63744 + *buffer -= namelen;
63745 + memcpy(*buffer, str, namelen);
63746 + return 0;
63747 +}
63748 +
63749 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
63750 +{
63751 + return prepend(buffer, buflen, name->name, name->len);
63752 +}
63753 +
63754 +static int prepend_path(const struct path *path, struct path *root,
63755 + char **buffer, int *buflen)
63756 +{
63757 + struct dentry *dentry = path->dentry;
63758 + struct vfsmount *vfsmnt = path->mnt;
63759 + struct mount *mnt = real_mount(vfsmnt);
63760 + bool slash = false;
63761 + int error = 0;
63762 +
63763 + while (dentry != root->dentry || vfsmnt != root->mnt) {
63764 + struct dentry * parent;
63765 +
63766 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
63767 + /* Global root? */
63768 + if (!mnt_has_parent(mnt)) {
63769 + goto out;
63770 + }
63771 + dentry = mnt->mnt_mountpoint;
63772 + mnt = mnt->mnt_parent;
63773 + vfsmnt = &mnt->mnt;
63774 + continue;
63775 + }
63776 + parent = dentry->d_parent;
63777 + prefetch(parent);
63778 + spin_lock(&dentry->d_lock);
63779 + error = prepend_name(buffer, buflen, &dentry->d_name);
63780 + spin_unlock(&dentry->d_lock);
63781 + if (!error)
63782 + error = prepend(buffer, buflen, "/", 1);
63783 + if (error)
63784 + break;
63785 +
63786 + slash = true;
63787 + dentry = parent;
63788 + }
63789 +
63790 +out:
63791 + if (!error && !slash)
63792 + error = prepend(buffer, buflen, "/", 1);
63793 +
63794 + return error;
63795 +}
63796 +
63797 +/* this must be called with vfsmount_lock and rename_lock held */
63798 +
63799 +static char *__our_d_path(const struct path *path, struct path *root,
63800 + char *buf, int buflen)
63801 +{
63802 + char *res = buf + buflen;
63803 + int error;
63804 +
63805 + prepend(&res, &buflen, "\0", 1);
63806 + error = prepend_path(path, root, &res, &buflen);
63807 + if (error)
63808 + return ERR_PTR(error);
63809 +
63810 + return res;
63811 +}
63812 +
63813 +static char *
63814 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
63815 +{
63816 + char *retval;
63817 +
63818 + retval = __our_d_path(path, root, buf, buflen);
63819 + if (unlikely(IS_ERR(retval)))
63820 + retval = strcpy(buf, "<path too long>");
63821 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
63822 + retval[1] = '\0';
63823 +
63824 + return retval;
63825 +}
63826 +
63827 +static char *
63828 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
63829 + char *buf, int buflen)
63830 +{
63831 + struct path path;
63832 + char *res;
63833 +
63834 + path.dentry = (struct dentry *)dentry;
63835 + path.mnt = (struct vfsmount *)vfsmnt;
63836 +
63837 + /* we can use real_root.dentry, real_root.mnt, because this is only called
63838 + by the RBAC system */
63839 + res = gen_full_path(&path, &real_root, buf, buflen);
63840 +
63841 + return res;
63842 +}
63843 +
63844 +static char *
63845 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
63846 + char *buf, int buflen)
63847 +{
63848 + char *res;
63849 + struct path path;
63850 + struct path root;
63851 + struct task_struct *reaper = init_pid_ns.child_reaper;
63852 +
63853 + path.dentry = (struct dentry *)dentry;
63854 + path.mnt = (struct vfsmount *)vfsmnt;
63855 +
63856 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
63857 + get_fs_root(reaper->fs, &root);
63858 +
63859 + br_read_lock(&vfsmount_lock);
63860 + write_seqlock(&rename_lock);
63861 + res = gen_full_path(&path, &root, buf, buflen);
63862 + write_sequnlock(&rename_lock);
63863 + br_read_unlock(&vfsmount_lock);
63864 +
63865 + path_put(&root);
63866 + return res;
63867 +}
63868 +
63869 +static char *
63870 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
63871 +{
63872 + char *ret;
63873 + br_read_lock(&vfsmount_lock);
63874 + write_seqlock(&rename_lock);
63875 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
63876 + PAGE_SIZE);
63877 + write_sequnlock(&rename_lock);
63878 + br_read_unlock(&vfsmount_lock);
63879 + return ret;
63880 +}
63881 +
63882 +static char *
63883 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
63884 +{
63885 + char *ret;
63886 + char *buf;
63887 + int buflen;
63888 +
63889 + br_read_lock(&vfsmount_lock);
63890 + write_seqlock(&rename_lock);
63891 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
63892 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
63893 + buflen = (int)(ret - buf);
63894 + if (buflen >= 5)
63895 + prepend(&ret, &buflen, "/proc", 5);
63896 + else
63897 + ret = strcpy(buf, "<path too long>");
63898 + write_sequnlock(&rename_lock);
63899 + br_read_unlock(&vfsmount_lock);
63900 + return ret;
63901 +}
63902 +
63903 +char *
63904 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
63905 +{
63906 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
63907 + PAGE_SIZE);
63908 +}
63909 +
63910 +char *
63911 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
63912 +{
63913 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
63914 + PAGE_SIZE);
63915 +}
63916 +
63917 +char *
63918 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
63919 +{
63920 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
63921 + PAGE_SIZE);
63922 +}
63923 +
63924 +char *
63925 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
63926 +{
63927 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
63928 + PAGE_SIZE);
63929 +}
63930 +
63931 +char *
63932 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
63933 +{
63934 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
63935 + PAGE_SIZE);
63936 +}
63937 +
63938 +__inline__ __u32
63939 +to_gr_audit(const __u32 reqmode)
63940 +{
63941 + /* masks off auditable permission flags, then shifts them to create
63942 + auditing flags, and adds the special case of append auditing if
63943 + we're requesting write */
63944 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
63945 +}
63946 +
63947 +struct acl_subject_label *
63948 +lookup_subject_map(const struct acl_subject_label *userp)
63949 +{
63950 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
63951 + struct subject_map *match;
63952 +
63953 + match = subj_map_set.s_hash[index];
63954 +
63955 + while (match && match->user != userp)
63956 + match = match->next;
63957 +
63958 + if (match != NULL)
63959 + return match->kernel;
63960 + else
63961 + return NULL;
63962 +}
63963 +
63964 +static void
63965 +insert_subj_map_entry(struct subject_map *subjmap)
63966 +{
63967 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
63968 + struct subject_map **curr;
63969 +
63970 + subjmap->prev = NULL;
63971 +
63972 + curr = &subj_map_set.s_hash[index];
63973 + if (*curr != NULL)
63974 + (*curr)->prev = subjmap;
63975 +
63976 + subjmap->next = *curr;
63977 + *curr = subjmap;
63978 +
63979 + return;
63980 +}
63981 +
63982 +static struct acl_role_label *
63983 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
63984 + const gid_t gid)
63985 +{
63986 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
63987 + struct acl_role_label *match;
63988 + struct role_allowed_ip *ipp;
63989 + unsigned int x;
63990 + u32 curr_ip = task->signal->curr_ip;
63991 +
63992 + task->signal->saved_ip = curr_ip;
63993 +
63994 + match = acl_role_set.r_hash[index];
63995 +
63996 + while (match) {
63997 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
63998 + for (x = 0; x < match->domain_child_num; x++) {
63999 + if (match->domain_children[x] == uid)
64000 + goto found;
64001 + }
64002 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
64003 + break;
64004 + match = match->next;
64005 + }
64006 +found:
64007 + if (match == NULL) {
64008 + try_group:
64009 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
64010 + match = acl_role_set.r_hash[index];
64011 +
64012 + while (match) {
64013 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
64014 + for (x = 0; x < match->domain_child_num; x++) {
64015 + if (match->domain_children[x] == gid)
64016 + goto found2;
64017 + }
64018 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
64019 + break;
64020 + match = match->next;
64021 + }
64022 +found2:
64023 + if (match == NULL)
64024 + match = default_role;
64025 + if (match->allowed_ips == NULL)
64026 + return match;
64027 + else {
64028 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
64029 + if (likely
64030 + ((ntohl(curr_ip) & ipp->netmask) ==
64031 + (ntohl(ipp->addr) & ipp->netmask)))
64032 + return match;
64033 + }
64034 + match = default_role;
64035 + }
64036 + } else if (match->allowed_ips == NULL) {
64037 + return match;
64038 + } else {
64039 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
64040 + if (likely
64041 + ((ntohl(curr_ip) & ipp->netmask) ==
64042 + (ntohl(ipp->addr) & ipp->netmask)))
64043 + return match;
64044 + }
64045 + goto try_group;
64046 + }
64047 +
64048 + return match;
64049 +}
64050 +
64051 +struct acl_subject_label *
64052 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
64053 + const struct acl_role_label *role)
64054 +{
64055 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
64056 + struct acl_subject_label *match;
64057 +
64058 + match = role->subj_hash[index];
64059 +
64060 + while (match && (match->inode != ino || match->device != dev ||
64061 + (match->mode & GR_DELETED))) {
64062 + match = match->next;
64063 + }
64064 +
64065 + if (match && !(match->mode & GR_DELETED))
64066 + return match;
64067 + else
64068 + return NULL;
64069 +}
64070 +
64071 +struct acl_subject_label *
64072 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
64073 + const struct acl_role_label *role)
64074 +{
64075 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
64076 + struct acl_subject_label *match;
64077 +
64078 + match = role->subj_hash[index];
64079 +
64080 + while (match && (match->inode != ino || match->device != dev ||
64081 + !(match->mode & GR_DELETED))) {
64082 + match = match->next;
64083 + }
64084 +
64085 + if (match && (match->mode & GR_DELETED))
64086 + return match;
64087 + else
64088 + return NULL;
64089 +}
64090 +
64091 +static struct acl_object_label *
64092 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
64093 + const struct acl_subject_label *subj)
64094 +{
64095 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
64096 + struct acl_object_label *match;
64097 +
64098 + match = subj->obj_hash[index];
64099 +
64100 + while (match && (match->inode != ino || match->device != dev ||
64101 + (match->mode & GR_DELETED))) {
64102 + match = match->next;
64103 + }
64104 +
64105 + if (match && !(match->mode & GR_DELETED))
64106 + return match;
64107 + else
64108 + return NULL;
64109 +}
64110 +
64111 +static struct acl_object_label *
64112 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
64113 + const struct acl_subject_label *subj)
64114 +{
64115 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
64116 + struct acl_object_label *match;
64117 +
64118 + match = subj->obj_hash[index];
64119 +
64120 + while (match && (match->inode != ino || match->device != dev ||
64121 + !(match->mode & GR_DELETED))) {
64122 + match = match->next;
64123 + }
64124 +
64125 + if (match && (match->mode & GR_DELETED))
64126 + return match;
64127 +
64128 + match = subj->obj_hash[index];
64129 +
64130 + while (match && (match->inode != ino || match->device != dev ||
64131 + (match->mode & GR_DELETED))) {
64132 + match = match->next;
64133 + }
64134 +
64135 + if (match && !(match->mode & GR_DELETED))
64136 + return match;
64137 + else
64138 + return NULL;
64139 +}
64140 +
64141 +static struct name_entry *
64142 +lookup_name_entry(const char *name)
64143 +{
64144 + unsigned int len = strlen(name);
64145 + unsigned int key = full_name_hash(name, len);
64146 + unsigned int index = key % name_set.n_size;
64147 + struct name_entry *match;
64148 +
64149 + match = name_set.n_hash[index];
64150 +
64151 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
64152 + match = match->next;
64153 +
64154 + return match;
64155 +}
64156 +
64157 +static struct name_entry *
64158 +lookup_name_entry_create(const char *name)
64159 +{
64160 + unsigned int len = strlen(name);
64161 + unsigned int key = full_name_hash(name, len);
64162 + unsigned int index = key % name_set.n_size;
64163 + struct name_entry *match;
64164 +
64165 + match = name_set.n_hash[index];
64166 +
64167 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
64168 + !match->deleted))
64169 + match = match->next;
64170 +
64171 + if (match && match->deleted)
64172 + return match;
64173 +
64174 + match = name_set.n_hash[index];
64175 +
64176 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
64177 + match->deleted))
64178 + match = match->next;
64179 +
64180 + if (match && !match->deleted)
64181 + return match;
64182 + else
64183 + return NULL;
64184 +}
64185 +
64186 +static struct inodev_entry *
64187 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
64188 +{
64189 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
64190 + struct inodev_entry *match;
64191 +
64192 + match = inodev_set.i_hash[index];
64193 +
64194 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
64195 + match = match->next;
64196 +
64197 + return match;
64198 +}
64199 +
64200 +static void
64201 +insert_inodev_entry(struct inodev_entry *entry)
64202 +{
64203 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
64204 + inodev_set.i_size);
64205 + struct inodev_entry **curr;
64206 +
64207 + entry->prev = NULL;
64208 +
64209 + curr = &inodev_set.i_hash[index];
64210 + if (*curr != NULL)
64211 + (*curr)->prev = entry;
64212 +
64213 + entry->next = *curr;
64214 + *curr = entry;
64215 +
64216 + return;
64217 +}
64218 +
64219 +static void
64220 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
64221 +{
64222 + unsigned int index =
64223 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
64224 + struct acl_role_label **curr;
64225 + struct acl_role_label *tmp, *tmp2;
64226 +
64227 + curr = &acl_role_set.r_hash[index];
64228 +
64229 + /* simple case, slot is empty, just set it to our role */
64230 + if (*curr == NULL) {
64231 + *curr = role;
64232 + } else {
64233 + /* example:
64234 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
64235 + 2 -> 3
64236 + */
64237 + /* first check to see if we can already be reached via this slot */
64238 + tmp = *curr;
64239 + while (tmp && tmp != role)
64240 + tmp = tmp->next;
64241 + if (tmp == role) {
64242 + /* we don't need to add ourselves to this slot's chain */
64243 + return;
64244 + }
64245 + /* we need to add ourselves to this chain, two cases */
64246 + if (role->next == NULL) {
64247 + /* simple case, append the current chain to our role */
64248 + role->next = *curr;
64249 + *curr = role;
64250 + } else {
64251 + /* 1 -> 2 -> 3 -> 4
64252 + 2 -> 3 -> 4
64253 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
64254 + */
64255 + /* trickier case: walk our role's chain until we find
64256 + the role for the start of the current slot's chain */
64257 + tmp = role;
64258 + tmp2 = *curr;
64259 + while (tmp->next && tmp->next != tmp2)
64260 + tmp = tmp->next;
64261 + if (tmp->next == tmp2) {
64262 + /* from example above, we found 3, so just
64263 + replace this slot's chain with ours */
64264 + *curr = role;
64265 + } else {
64266 + /* we didn't find a subset of our role's chain
64267 + in the current slot's chain, so append their
64268 + chain to ours, and set us as the first role in
64269 + the slot's chain
64270 +
64271 + we could fold this case with the case above,
64272 + but making it explicit for clarity
64273 + */
64274 + tmp->next = tmp2;
64275 + *curr = role;
64276 + }
64277 + }
64278 + }
64279 +
64280 + return;
64281 +}
64282 +
64283 +static void
64284 +insert_acl_role_label(struct acl_role_label *role)
64285 +{
64286 + int i;
64287 +
64288 + if (role_list == NULL) {
64289 + role_list = role;
64290 + role->prev = NULL;
64291 + } else {
64292 + role->prev = role_list;
64293 + role_list = role;
64294 + }
64295 +
64296 + /* used for hash chains */
64297 + role->next = NULL;
64298 +
64299 + if (role->roletype & GR_ROLE_DOMAIN) {
64300 + for (i = 0; i < role->domain_child_num; i++)
64301 + __insert_acl_role_label(role, role->domain_children[i]);
64302 + } else
64303 + __insert_acl_role_label(role, role->uidgid);
64304 +}
64305 +
64306 +static int
64307 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
64308 +{
64309 + struct name_entry **curr, *nentry;
64310 + struct inodev_entry *ientry;
64311 + unsigned int len = strlen(name);
64312 + unsigned int key = full_name_hash(name, len);
64313 + unsigned int index = key % name_set.n_size;
64314 +
64315 + curr = &name_set.n_hash[index];
64316 +
64317 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
64318 + curr = &((*curr)->next);
64319 +
64320 + if (*curr != NULL)
64321 + return 1;
64322 +
64323 + nentry = acl_alloc(sizeof (struct name_entry));
64324 + if (nentry == NULL)
64325 + return 0;
64326 + ientry = acl_alloc(sizeof (struct inodev_entry));
64327 + if (ientry == NULL)
64328 + return 0;
64329 + ientry->nentry = nentry;
64330 +
64331 + nentry->key = key;
64332 + nentry->name = name;
64333 + nentry->inode = inode;
64334 + nentry->device = device;
64335 + nentry->len = len;
64336 + nentry->deleted = deleted;
64337 +
64338 + nentry->prev = NULL;
64339 + curr = &name_set.n_hash[index];
64340 + if (*curr != NULL)
64341 + (*curr)->prev = nentry;
64342 + nentry->next = *curr;
64343 + *curr = nentry;
64344 +
64345 + /* insert us into the table searchable by inode/dev */
64346 + insert_inodev_entry(ientry);
64347 +
64348 + return 1;
64349 +}
64350 +
64351 +static void
64352 +insert_acl_obj_label(struct acl_object_label *obj,
64353 + struct acl_subject_label *subj)
64354 +{
64355 + unsigned int index =
64356 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
64357 + struct acl_object_label **curr;
64358 +
64359 +
64360 + obj->prev = NULL;
64361 +
64362 + curr = &subj->obj_hash[index];
64363 + if (*curr != NULL)
64364 + (*curr)->prev = obj;
64365 +
64366 + obj->next = *curr;
64367 + *curr = obj;
64368 +
64369 + return;
64370 +}
64371 +
64372 +static void
64373 +insert_acl_subj_label(struct acl_subject_label *obj,
64374 + struct acl_role_label *role)
64375 +{
64376 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
64377 + struct acl_subject_label **curr;
64378 +
64379 + obj->prev = NULL;
64380 +
64381 + curr = &role->subj_hash[index];
64382 + if (*curr != NULL)
64383 + (*curr)->prev = obj;
64384 +
64385 + obj->next = *curr;
64386 + *curr = obj;
64387 +
64388 + return;
64389 +}
64390 +
64391 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
64392 +
64393 +static void *
64394 +create_table(__u32 * len, int elementsize)
64395 +{
64396 + unsigned int table_sizes[] = {
64397 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
64398 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
64399 + 4194301, 8388593, 16777213, 33554393, 67108859
64400 + };
64401 + void *newtable = NULL;
64402 + unsigned int pwr = 0;
64403 +
64404 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
64405 + table_sizes[pwr] <= *len)
64406 + pwr++;
64407 +
64408 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
64409 + return newtable;
64410 +
64411 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
64412 + newtable =
64413 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
64414 + else
64415 + newtable = vmalloc(table_sizes[pwr] * elementsize);
64416 +
64417 + *len = table_sizes[pwr];
64418 +
64419 + return newtable;
64420 +}
64421 +
64422 +static int
64423 +init_variables(const struct gr_arg *arg)
64424 +{
64425 + struct task_struct *reaper = init_pid_ns.child_reaper;
64426 + unsigned int stacksize;
64427 +
64428 + subj_map_set.s_size = arg->role_db.num_subjects;
64429 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
64430 + name_set.n_size = arg->role_db.num_objects;
64431 + inodev_set.i_size = arg->role_db.num_objects;
64432 +
64433 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
64434 + !name_set.n_size || !inodev_set.i_size)
64435 + return 1;
64436 +
64437 + if (!gr_init_uidset())
64438 + return 1;
64439 +
64440 + /* set up the stack that holds allocation info */
64441 +
64442 + stacksize = arg->role_db.num_pointers + 5;
64443 +
64444 + if (!acl_alloc_stack_init(stacksize))
64445 + return 1;
64446 +
64447 + /* grab reference for the real root dentry and vfsmount */
64448 + get_fs_root(reaper->fs, &real_root);
64449 +
64450 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
64451 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
64452 +#endif
64453 +
64454 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
64455 + if (fakefs_obj_rw == NULL)
64456 + return 1;
64457 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
64458 +
64459 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
64460 + if (fakefs_obj_rwx == NULL)
64461 + return 1;
64462 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
64463 +
64464 + subj_map_set.s_hash =
64465 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
64466 + acl_role_set.r_hash =
64467 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
64468 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
64469 + inodev_set.i_hash =
64470 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
64471 +
64472 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
64473 + !name_set.n_hash || !inodev_set.i_hash)
64474 + return 1;
64475 +
64476 + memset(subj_map_set.s_hash, 0,
64477 + sizeof(struct subject_map *) * subj_map_set.s_size);
64478 + memset(acl_role_set.r_hash, 0,
64479 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
64480 + memset(name_set.n_hash, 0,
64481 + sizeof (struct name_entry *) * name_set.n_size);
64482 + memset(inodev_set.i_hash, 0,
64483 + sizeof (struct inodev_entry *) * inodev_set.i_size);
64484 +
64485 + return 0;
64486 +}
64487 +
64488 +/* free information not needed after startup
64489 + currently contains user->kernel pointer mappings for subjects
64490 +*/
64491 +
64492 +static void
64493 +free_init_variables(void)
64494 +{
64495 + __u32 i;
64496 +
64497 + if (subj_map_set.s_hash) {
64498 + for (i = 0; i < subj_map_set.s_size; i++) {
64499 + if (subj_map_set.s_hash[i]) {
64500 + kfree(subj_map_set.s_hash[i]);
64501 + subj_map_set.s_hash[i] = NULL;
64502 + }
64503 + }
64504 +
64505 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
64506 + PAGE_SIZE)
64507 + kfree(subj_map_set.s_hash);
64508 + else
64509 + vfree(subj_map_set.s_hash);
64510 + }
64511 +
64512 + return;
64513 +}
64514 +
64515 +static void
64516 +free_variables(void)
64517 +{
64518 + struct acl_subject_label *s;
64519 + struct acl_role_label *r;
64520 + struct task_struct *task, *task2;
64521 + unsigned int x;
64522 +
64523 + gr_clear_learn_entries();
64524 +
64525 + read_lock(&tasklist_lock);
64526 + do_each_thread(task2, task) {
64527 + task->acl_sp_role = 0;
64528 + task->acl_role_id = 0;
64529 + task->acl = NULL;
64530 + task->role = NULL;
64531 + } while_each_thread(task2, task);
64532 + read_unlock(&tasklist_lock);
64533 +
64534 + /* release the reference to the real root dentry and vfsmount */
64535 + path_put(&real_root);
64536 + memset(&real_root, 0, sizeof(real_root));
64537 +
64538 + /* free all object hash tables */
64539 +
64540 + FOR_EACH_ROLE_START(r)
64541 + if (r->subj_hash == NULL)
64542 + goto next_role;
64543 + FOR_EACH_SUBJECT_START(r, s, x)
64544 + if (s->obj_hash == NULL)
64545 + break;
64546 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
64547 + kfree(s->obj_hash);
64548 + else
64549 + vfree(s->obj_hash);
64550 + FOR_EACH_SUBJECT_END(s, x)
64551 + FOR_EACH_NESTED_SUBJECT_START(r, s)
64552 + if (s->obj_hash == NULL)
64553 + break;
64554 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
64555 + kfree(s->obj_hash);
64556 + else
64557 + vfree(s->obj_hash);
64558 + FOR_EACH_NESTED_SUBJECT_END(s)
64559 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
64560 + kfree(r->subj_hash);
64561 + else
64562 + vfree(r->subj_hash);
64563 + r->subj_hash = NULL;
64564 +next_role:
64565 + FOR_EACH_ROLE_END(r)
64566 +
64567 + acl_free_all();
64568 +
64569 + if (acl_role_set.r_hash) {
64570 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
64571 + PAGE_SIZE)
64572 + kfree(acl_role_set.r_hash);
64573 + else
64574 + vfree(acl_role_set.r_hash);
64575 + }
64576 + if (name_set.n_hash) {
64577 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
64578 + PAGE_SIZE)
64579 + kfree(name_set.n_hash);
64580 + else
64581 + vfree(name_set.n_hash);
64582 + }
64583 +
64584 + if (inodev_set.i_hash) {
64585 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
64586 + PAGE_SIZE)
64587 + kfree(inodev_set.i_hash);
64588 + else
64589 + vfree(inodev_set.i_hash);
64590 + }
64591 +
64592 + gr_free_uidset();
64593 +
64594 + memset(&name_set, 0, sizeof (struct name_db));
64595 + memset(&inodev_set, 0, sizeof (struct inodev_db));
64596 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
64597 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
64598 +
64599 + default_role = NULL;
64600 + kernel_role = NULL;
64601 + role_list = NULL;
64602 +
64603 + return;
64604 +}
64605 +
64606 +static struct acl_subject_label *
64607 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
64608 +
64609 +static int alloc_and_copy_string(char **name, unsigned int maxlen)
64610 +{
64611 + unsigned int len = strnlen_user(*name, maxlen);
64612 + char *tmp;
64613 +
64614 + if (!len || len >= maxlen)
64615 + return -EINVAL;
64616 +
64617 + if ((tmp = (char *) acl_alloc(len)) == NULL)
64618 + return -ENOMEM;
64619 +
64620 + if (copy_from_user(tmp, *name, len))
64621 + return -EFAULT;
64622 +
64623 + tmp[len-1] = '\0';
64624 + *name = tmp;
64625 +
64626 + return 0;
64627 +}
64628 +
64629 +static int
64630 +copy_user_glob(struct acl_object_label *obj)
64631 +{
64632 + struct acl_object_label *g_tmp, **guser;
64633 + int error;
64634 +
64635 + if (obj->globbed == NULL)
64636 + return 0;
64637 +
64638 + guser = &obj->globbed;
64639 + while (*guser) {
64640 + g_tmp = (struct acl_object_label *)
64641 + acl_alloc(sizeof (struct acl_object_label));
64642 + if (g_tmp == NULL)
64643 + return -ENOMEM;
64644 +
64645 + if (copy_acl_object_label(g_tmp, *guser))
64646 + return -EFAULT;
64647 +
64648 + error = alloc_and_copy_string(&g_tmp->filename, PATH_MAX);
64649 + if (error)
64650 + return error;
64651 +
64652 + *guser = g_tmp;
64653 + guser = &(g_tmp->next);
64654 + }
64655 +
64656 + return 0;
64657 +}
64658 +
64659 +static int
64660 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
64661 + struct acl_role_label *role)
64662 +{
64663 + struct acl_object_label *o_tmp;
64664 + int ret;
64665 +
64666 + while (userp) {
64667 + if ((o_tmp = (struct acl_object_label *)
64668 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
64669 + return -ENOMEM;
64670 +
64671 + if (copy_acl_object_label(o_tmp, userp))
64672 + return -EFAULT;
64673 +
64674 + userp = o_tmp->prev;
64675 +
64676 + ret = alloc_and_copy_string(&o_tmp->filename, PATH_MAX);
64677 + if (ret)
64678 + return ret;
64679 +
64680 + insert_acl_obj_label(o_tmp, subj);
64681 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
64682 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
64683 + return -ENOMEM;
64684 +
64685 + ret = copy_user_glob(o_tmp);
64686 + if (ret)
64687 + return ret;
64688 +
64689 + if (o_tmp->nested) {
64690 + int already_copied;
64691 +
64692 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
64693 + if (IS_ERR(o_tmp->nested))
64694 + return PTR_ERR(o_tmp->nested);
64695 +
64696 + /* insert into nested subject list if we haven't copied this one yet
64697 + to prevent duplicate entries */
64698 + if (!already_copied) {
64699 + o_tmp->nested->next = role->hash->first;
64700 + role->hash->first = o_tmp->nested;
64701 + }
64702 + }
64703 + }
64704 +
64705 + return 0;
64706 +}
64707 +
64708 +static __u32
64709 +count_user_subjs(struct acl_subject_label *userp)
64710 +{
64711 + struct acl_subject_label s_tmp;
64712 + __u32 num = 0;
64713 +
64714 + while (userp) {
64715 + if (copy_acl_subject_label(&s_tmp, userp))
64716 + break;
64717 +
64718 + userp = s_tmp.prev;
64719 + }
64720 +
64721 + return num;
64722 +}
64723 +
64724 +static int
64725 +copy_user_allowedips(struct acl_role_label *rolep)
64726 +{
64727 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
64728 +
64729 + ruserip = rolep->allowed_ips;
64730 +
64731 + while (ruserip) {
64732 + rlast = rtmp;
64733 +
64734 + if ((rtmp = (struct role_allowed_ip *)
64735 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
64736 + return -ENOMEM;
64737 +
64738 + if (copy_role_allowed_ip(rtmp, ruserip))
64739 + return -EFAULT;
64740 +
64741 + ruserip = rtmp->prev;
64742 +
64743 + if (!rlast) {
64744 + rtmp->prev = NULL;
64745 + rolep->allowed_ips = rtmp;
64746 + } else {
64747 + rlast->next = rtmp;
64748 + rtmp->prev = rlast;
64749 + }
64750 +
64751 + if (!ruserip)
64752 + rtmp->next = NULL;
64753 + }
64754 +
64755 + return 0;
64756 +}
64757 +
64758 +static int
64759 +copy_user_transitions(struct acl_role_label *rolep)
64760 +{
64761 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
64762 + int error;
64763 +
64764 + rusertp = rolep->transitions;
64765 +
64766 + while (rusertp) {
64767 + rlast = rtmp;
64768 +
64769 + if ((rtmp = (struct role_transition *)
64770 + acl_alloc(sizeof (struct role_transition))) == NULL)
64771 + return -ENOMEM;
64772 +
64773 + if (copy_role_transition(rtmp, rusertp))
64774 + return -EFAULT;
64775 +
64776 + rusertp = rtmp->prev;
64777 +
64778 + error = alloc_and_copy_string(&rtmp->rolename, GR_SPROLE_LEN);
64779 + if (error)
64780 + return error;
64781 +
64782 + if (!rlast) {
64783 + rtmp->prev = NULL;
64784 + rolep->transitions = rtmp;
64785 + } else {
64786 + rlast->next = rtmp;
64787 + rtmp->prev = rlast;
64788 + }
64789 +
64790 + if (!rusertp)
64791 + rtmp->next = NULL;
64792 + }
64793 +
64794 + return 0;
64795 +}
64796 +
64797 +static __u32 count_user_objs(const struct acl_object_label __user *userp)
64798 +{
64799 + struct acl_object_label o_tmp;
64800 + __u32 num = 0;
64801 +
64802 + while (userp) {
64803 + if (copy_acl_object_label(&o_tmp, userp))
64804 + break;
64805 +
64806 + userp = o_tmp.prev;
64807 + num++;
64808 + }
64809 +
64810 + return num;
64811 +}
64812 +
64813 +static struct acl_subject_label *
64814 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
64815 +{
64816 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
64817 + __u32 num_objs;
64818 + struct acl_ip_label **i_tmp, *i_utmp2;
64819 + struct gr_hash_struct ghash;
64820 + struct subject_map *subjmap;
64821 + unsigned int i_num;
64822 + int err;
64823 +
64824 + if (already_copied != NULL)
64825 + *already_copied = 0;
64826 +
64827 + s_tmp = lookup_subject_map(userp);
64828 +
64829 + /* we've already copied this subject into the kernel, just return
64830 + the reference to it, and don't copy it over again
64831 + */
64832 + if (s_tmp) {
64833 + if (already_copied != NULL)
64834 + *already_copied = 1;
64835 + return(s_tmp);
64836 + }
64837 +
64838 + if ((s_tmp = (struct acl_subject_label *)
64839 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
64840 + return ERR_PTR(-ENOMEM);
64841 +
64842 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
64843 + if (subjmap == NULL)
64844 + return ERR_PTR(-ENOMEM);
64845 +
64846 + subjmap->user = userp;
64847 + subjmap->kernel = s_tmp;
64848 + insert_subj_map_entry(subjmap);
64849 +
64850 + if (copy_acl_subject_label(s_tmp, userp))
64851 + return ERR_PTR(-EFAULT);
64852 +
64853 + err = alloc_and_copy_string(&s_tmp->filename, PATH_MAX);
64854 + if (err)
64855 + return ERR_PTR(err);
64856 +
64857 + if (!strcmp(s_tmp->filename, "/"))
64858 + role->root_label = s_tmp;
64859 +
64860 + if (copy_gr_hash_struct(&ghash, s_tmp->hash))
64861 + return ERR_PTR(-EFAULT);
64862 +
64863 + /* copy user and group transition tables */
64864 +
64865 + if (s_tmp->user_trans_num) {
64866 + uid_t *uidlist;
64867 +
64868 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
64869 + if (uidlist == NULL)
64870 + return ERR_PTR(-ENOMEM);
64871 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
64872 + return ERR_PTR(-EFAULT);
64873 +
64874 + s_tmp->user_transitions = uidlist;
64875 + }
64876 +
64877 + if (s_tmp->group_trans_num) {
64878 + gid_t *gidlist;
64879 +
64880 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
64881 + if (gidlist == NULL)
64882 + return ERR_PTR(-ENOMEM);
64883 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
64884 + return ERR_PTR(-EFAULT);
64885 +
64886 + s_tmp->group_transitions = gidlist;
64887 + }
64888 +
64889 + /* set up object hash table */
64890 + num_objs = count_user_objs(ghash.first);
64891 +
64892 + s_tmp->obj_hash_size = num_objs;
64893 + s_tmp->obj_hash =
64894 + (struct acl_object_label **)
64895 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
64896 +
64897 + if (!s_tmp->obj_hash)
64898 + return ERR_PTR(-ENOMEM);
64899 +
64900 + memset(s_tmp->obj_hash, 0,
64901 + s_tmp->obj_hash_size *
64902 + sizeof (struct acl_object_label *));
64903 +
64904 + /* add in objects */
64905 + err = copy_user_objs(ghash.first, s_tmp, role);
64906 +
64907 + if (err)
64908 + return ERR_PTR(err);
64909 +
64910 + /* set pointer for parent subject */
64911 + if (s_tmp->parent_subject) {
64912 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
64913 +
64914 + if (IS_ERR(s_tmp2))
64915 + return s_tmp2;
64916 +
64917 + s_tmp->parent_subject = s_tmp2;
64918 + }
64919 +
64920 + /* add in ip acls */
64921 +
64922 + if (!s_tmp->ip_num) {
64923 + s_tmp->ips = NULL;
64924 + goto insert;
64925 + }
64926 +
64927 + i_tmp =
64928 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
64929 + sizeof (struct acl_ip_label *));
64930 +
64931 + if (!i_tmp)
64932 + return ERR_PTR(-ENOMEM);
64933 +
64934 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
64935 + *(i_tmp + i_num) =
64936 + (struct acl_ip_label *)
64937 + acl_alloc(sizeof (struct acl_ip_label));
64938 + if (!*(i_tmp + i_num))
64939 + return ERR_PTR(-ENOMEM);
64940 +
64941 + if (copy_pointer_from_array(&i_utmp2, i_num, s_tmp->ips))
64942 + return ERR_PTR(-EFAULT);
64943 +
64944 + if (copy_acl_ip_label(*(i_tmp + i_num), i_utmp2))
64945 + return ERR_PTR(-EFAULT);
64946 +
64947 + if ((*(i_tmp + i_num))->iface == NULL)
64948 + continue;
64949 +
64950 + err = alloc_and_copy_string(&(*(i_tmp + i_num))->iface, IFNAMSIZ);
64951 + if (err)
64952 + return ERR_PTR(err);
64953 + }
64954 +
64955 + s_tmp->ips = i_tmp;
64956 +
64957 +insert:
64958 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
64959 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
64960 + return ERR_PTR(-ENOMEM);
64961 +
64962 + return s_tmp;
64963 +}
64964 +
64965 +static int
64966 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
64967 +{
64968 + struct acl_subject_label s_pre;
64969 + struct acl_subject_label * ret;
64970 + int err;
64971 +
64972 + while (userp) {
64973 + if (copy_acl_subject_label(&s_pre, userp))
64974 + return -EFAULT;
64975 +
64976 + ret = do_copy_user_subj(userp, role, NULL);
64977 +
64978 + err = PTR_ERR(ret);
64979 + if (IS_ERR(ret))
64980 + return err;
64981 +
64982 + insert_acl_subj_label(ret, role);
64983 +
64984 + userp = s_pre.prev;
64985 + }
64986 +
64987 + return 0;
64988 +}
64989 +
64990 +static int
64991 +copy_user_acl(struct gr_arg *arg)
64992 +{
64993 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
64994 + struct acl_subject_label *subj_list;
64995 + struct sprole_pw *sptmp;
64996 + struct gr_hash_struct *ghash;
64997 + uid_t *domainlist;
64998 + unsigned int r_num;
64999 + int err = 0;
65000 + __u16 i;
65001 + __u32 num_subjs;
65002 +
65003 + /* we need a default and kernel role */
65004 + if (arg->role_db.num_roles < 2)
65005 + return -EINVAL;
65006 +
65007 + /* copy special role authentication info from userspace */
65008 +
65009 + num_sprole_pws = arg->num_sprole_pws;
65010 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
65011 +
65012 + if (!acl_special_roles && num_sprole_pws)
65013 + return -ENOMEM;
65014 +
65015 + for (i = 0; i < num_sprole_pws; i++) {
65016 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
65017 + if (!sptmp)
65018 + return -ENOMEM;
65019 + if (copy_sprole_pw(sptmp, i, arg->sprole_pws))
65020 + return -EFAULT;
65021 +
65022 + err = alloc_and_copy_string((char **)&sptmp->rolename, GR_SPROLE_LEN);
65023 + if (err)
65024 + return err;
65025 +
65026 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
65027 + printk(KERN_ALERT "Copying special role %s\n", sptmp->rolename);
65028 +#endif
65029 +
65030 + acl_special_roles[i] = sptmp;
65031 + }
65032 +
65033 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
65034 +
65035 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
65036 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
65037 +
65038 + if (!r_tmp)
65039 + return -ENOMEM;
65040 +
65041 + if (copy_pointer_from_array(&r_utmp2, r_num, r_utmp))
65042 + return -EFAULT;
65043 +
65044 + if (copy_acl_role_label(r_tmp, r_utmp2))
65045 + return -EFAULT;
65046 +
65047 + err = alloc_and_copy_string(&r_tmp->rolename, GR_SPROLE_LEN);
65048 + if (err)
65049 + return err;
65050 +
65051 + if (!strcmp(r_tmp->rolename, "default")
65052 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
65053 + default_role = r_tmp;
65054 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
65055 + kernel_role = r_tmp;
65056 + }
65057 +
65058 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
65059 + return -ENOMEM;
65060 +
65061 + if (copy_gr_hash_struct(ghash, r_tmp->hash))
65062 + return -EFAULT;
65063 +
65064 + r_tmp->hash = ghash;
65065 +
65066 + num_subjs = count_user_subjs(r_tmp->hash->first);
65067 +
65068 + r_tmp->subj_hash_size = num_subjs;
65069 + r_tmp->subj_hash =
65070 + (struct acl_subject_label **)
65071 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
65072 +
65073 + if (!r_tmp->subj_hash)
65074 + return -ENOMEM;
65075 +
65076 + err = copy_user_allowedips(r_tmp);
65077 + if (err)
65078 + return err;
65079 +
65080 + /* copy domain info */
65081 + if (r_tmp->domain_children != NULL) {
65082 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
65083 + if (domainlist == NULL)
65084 + return -ENOMEM;
65085 +
65086 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
65087 + return -EFAULT;
65088 +
65089 + r_tmp->domain_children = domainlist;
65090 + }
65091 +
65092 + err = copy_user_transitions(r_tmp);
65093 + if (err)
65094 + return err;
65095 +
65096 + memset(r_tmp->subj_hash, 0,
65097 + r_tmp->subj_hash_size *
65098 + sizeof (struct acl_subject_label *));
65099 +
65100 + /* acquire the list of subjects, then NULL out
65101 + the list prior to parsing the subjects for this role,
65102 + as during this parsing the list is replaced with a list
65103 + of *nested* subjects for the role
65104 + */
65105 + subj_list = r_tmp->hash->first;
65106 +
65107 + /* set nested subject list to null */
65108 + r_tmp->hash->first = NULL;
65109 +
65110 + err = copy_user_subjs(subj_list, r_tmp);
65111 +
65112 + if (err)
65113 + return err;
65114 +
65115 + insert_acl_role_label(r_tmp);
65116 + }
65117 +
65118 + if (default_role == NULL || kernel_role == NULL)
65119 + return -EINVAL;
65120 +
65121 + return err;
65122 +}
65123 +
65124 +static int
65125 +gracl_init(struct gr_arg *args)
65126 +{
65127 + int error = 0;
65128 +
65129 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
65130 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
65131 +
65132 + if (init_variables(args)) {
65133 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
65134 + error = -ENOMEM;
65135 + free_variables();
65136 + goto out;
65137 + }
65138 +
65139 + error = copy_user_acl(args);
65140 + free_init_variables();
65141 + if (error) {
65142 + free_variables();
65143 + goto out;
65144 + }
65145 +
65146 + if ((error = gr_set_acls(0))) {
65147 + free_variables();
65148 + goto out;
65149 + }
65150 +
65151 + pax_open_kernel();
65152 + gr_status |= GR_READY;
65153 + pax_close_kernel();
65154 +
65155 + out:
65156 + return error;
65157 +}
65158 +
65159 +/* derived from glibc fnmatch() 0: match, 1: no match*/
65160 +
65161 +static int
65162 +glob_match(const char *p, const char *n)
65163 +{
65164 + char c;
65165 +
65166 + while ((c = *p++) != '\0') {
65167 + switch (c) {
65168 + case '?':
65169 + if (*n == '\0')
65170 + return 1;
65171 + else if (*n == '/')
65172 + return 1;
65173 + break;
65174 + case '\\':
65175 + if (*n != c)
65176 + return 1;
65177 + break;
65178 + case '*':
65179 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
65180 + if (*n == '/')
65181 + return 1;
65182 + else if (c == '?') {
65183 + if (*n == '\0')
65184 + return 1;
65185 + else
65186 + ++n;
65187 + }
65188 + }
65189 + if (c == '\0') {
65190 + return 0;
65191 + } else {
65192 + const char *endp;
65193 +
65194 + if ((endp = strchr(n, '/')) == NULL)
65195 + endp = n + strlen(n);
65196 +
65197 + if (c == '[') {
65198 + for (--p; n < endp; ++n)
65199 + if (!glob_match(p, n))
65200 + return 0;
65201 + } else if (c == '/') {
65202 + while (*n != '\0' && *n != '/')
65203 + ++n;
65204 + if (*n == '/' && !glob_match(p, n + 1))
65205 + return 0;
65206 + } else {
65207 + for (--p; n < endp; ++n)
65208 + if (*n == c && !glob_match(p, n))
65209 + return 0;
65210 + }
65211 +
65212 + return 1;
65213 + }
65214 + case '[':
65215 + {
65216 + int not;
65217 + char cold;
65218 +
65219 + if (*n == '\0' || *n == '/')
65220 + return 1;
65221 +
65222 + not = (*p == '!' || *p == '^');
65223 + if (not)
65224 + ++p;
65225 +
65226 + c = *p++;
65227 + for (;;) {
65228 + unsigned char fn = (unsigned char)*n;
65229 +
65230 + if (c == '\0')
65231 + return 1;
65232 + else {
65233 + if (c == fn)
65234 + goto matched;
65235 + cold = c;
65236 + c = *p++;
65237 +
65238 + if (c == '-' && *p != ']') {
65239 + unsigned char cend = *p++;
65240 +
65241 + if (cend == '\0')
65242 + return 1;
65243 +
65244 + if (cold <= fn && fn <= cend)
65245 + goto matched;
65246 +
65247 + c = *p++;
65248 + }
65249 + }
65250 +
65251 + if (c == ']')
65252 + break;
65253 + }
65254 + if (!not)
65255 + return 1;
65256 + break;
65257 + matched:
65258 + while (c != ']') {
65259 + if (c == '\0')
65260 + return 1;
65261 +
65262 + c = *p++;
65263 + }
65264 + if (not)
65265 + return 1;
65266 + }
65267 + break;
65268 + default:
65269 + if (c != *n)
65270 + return 1;
65271 + }
65272 +
65273 + ++n;
65274 + }
65275 +
65276 + if (*n == '\0')
65277 + return 0;
65278 +
65279 + if (*n == '/')
65280 + return 0;
65281 +
65282 + return 1;
65283 +}
65284 +
65285 +static struct acl_object_label *
65286 +chk_glob_label(struct acl_object_label *globbed,
65287 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
65288 +{
65289 + struct acl_object_label *tmp;
65290 +
65291 + if (*path == NULL)
65292 + *path = gr_to_filename_nolock(dentry, mnt);
65293 +
65294 + tmp = globbed;
65295 +
65296 + while (tmp) {
65297 + if (!glob_match(tmp->filename, *path))
65298 + return tmp;
65299 + tmp = tmp->next;
65300 + }
65301 +
65302 + return NULL;
65303 +}
65304 +
65305 +static struct acl_object_label *
65306 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
65307 + const ino_t curr_ino, const dev_t curr_dev,
65308 + const struct acl_subject_label *subj, char **path, const int checkglob)
65309 +{
65310 + struct acl_subject_label *tmpsubj;
65311 + struct acl_object_label *retval;
65312 + struct acl_object_label *retval2;
65313 +
65314 + tmpsubj = (struct acl_subject_label *) subj;
65315 + read_lock(&gr_inode_lock);
65316 + do {
65317 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
65318 + if (retval) {
65319 + if (checkglob && retval->globbed) {
65320 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
65321 + if (retval2)
65322 + retval = retval2;
65323 + }
65324 + break;
65325 + }
65326 + } while ((tmpsubj = tmpsubj->parent_subject));
65327 + read_unlock(&gr_inode_lock);
65328 +
65329 + return retval;
65330 +}
65331 +
65332 +static __inline__ struct acl_object_label *
65333 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
65334 + struct dentry *curr_dentry,
65335 + const struct acl_subject_label *subj, char **path, const int checkglob)
65336 +{
65337 + int newglob = checkglob;
65338 + ino_t inode;
65339 + dev_t device;
65340 +
65341 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
65342 + as we don't want a / * rule to match instead of the / object
65343 + don't do this for create lookups that call this function though, since they're looking up
65344 + on the parent and thus need globbing checks on all paths
65345 + */
65346 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
65347 + newglob = GR_NO_GLOB;
65348 +
65349 + spin_lock(&curr_dentry->d_lock);
65350 + inode = curr_dentry->d_inode->i_ino;
65351 + device = __get_dev(curr_dentry);
65352 + spin_unlock(&curr_dentry->d_lock);
65353 +
65354 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
65355 +}
65356 +
65357 +#ifdef CONFIG_HUGETLBFS
65358 +static inline bool
65359 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
65360 +{
65361 + int i;
65362 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
65363 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
65364 + return true;
65365 + }
65366 +
65367 + return false;
65368 +}
65369 +#endif
65370 +
65371 +static struct acl_object_label *
65372 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
65373 + const struct acl_subject_label *subj, char *path, const int checkglob)
65374 +{
65375 + struct dentry *dentry = (struct dentry *) l_dentry;
65376 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
65377 + struct mount *real_mnt = real_mount(mnt);
65378 + struct acl_object_label *retval;
65379 + struct dentry *parent;
65380 +
65381 + br_read_lock(&vfsmount_lock);
65382 + write_seqlock(&rename_lock);
65383 +
65384 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
65385 +#ifdef CONFIG_NET
65386 + mnt == sock_mnt ||
65387 +#endif
65388 +#ifdef CONFIG_HUGETLBFS
65389 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
65390 +#endif
65391 + /* ignore Eric Biederman */
65392 + IS_PRIVATE(l_dentry->d_inode))) {
65393 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
65394 + goto out;
65395 + }
65396 +
65397 + for (;;) {
65398 + if (dentry == real_root.dentry && mnt == real_root.mnt)
65399 + break;
65400 +
65401 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
65402 + if (!mnt_has_parent(real_mnt))
65403 + break;
65404 +
65405 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
65406 + if (retval != NULL)
65407 + goto out;
65408 +
65409 + dentry = real_mnt->mnt_mountpoint;
65410 + real_mnt = real_mnt->mnt_parent;
65411 + mnt = &real_mnt->mnt;
65412 + continue;
65413 + }
65414 +
65415 + parent = dentry->d_parent;
65416 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
65417 + if (retval != NULL)
65418 + goto out;
65419 +
65420 + dentry = parent;
65421 + }
65422 +
65423 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
65424 +
65425 + /* real_root is pinned so we don't have to hold a reference */
65426 + if (retval == NULL)
65427 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
65428 +out:
65429 + write_sequnlock(&rename_lock);
65430 + br_read_unlock(&vfsmount_lock);
65431 +
65432 + BUG_ON(retval == NULL);
65433 +
65434 + return retval;
65435 +}
65436 +
65437 +static __inline__ struct acl_object_label *
65438 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
65439 + const struct acl_subject_label *subj)
65440 +{
65441 + char *path = NULL;
65442 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
65443 +}
65444 +
65445 +static __inline__ struct acl_object_label *
65446 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
65447 + const struct acl_subject_label *subj)
65448 +{
65449 + char *path = NULL;
65450 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
65451 +}
65452 +
65453 +static __inline__ struct acl_object_label *
65454 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
65455 + const struct acl_subject_label *subj, char *path)
65456 +{
65457 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
65458 +}
65459 +
65460 +static struct acl_subject_label *
65461 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
65462 + const struct acl_role_label *role)
65463 +{
65464 + struct dentry *dentry = (struct dentry *) l_dentry;
65465 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
65466 + struct mount *real_mnt = real_mount(mnt);
65467 + struct acl_subject_label *retval;
65468 + struct dentry *parent;
65469 +
65470 + br_read_lock(&vfsmount_lock);
65471 + write_seqlock(&rename_lock);
65472 +
65473 + for (;;) {
65474 + if (dentry == real_root.dentry && mnt == real_root.mnt)
65475 + break;
65476 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
65477 + if (!mnt_has_parent(real_mnt))
65478 + break;
65479 +
65480 + spin_lock(&dentry->d_lock);
65481 + read_lock(&gr_inode_lock);
65482 + retval =
65483 + lookup_acl_subj_label(dentry->d_inode->i_ino,
65484 + __get_dev(dentry), role);
65485 + read_unlock(&gr_inode_lock);
65486 + spin_unlock(&dentry->d_lock);
65487 + if (retval != NULL)
65488 + goto out;
65489 +
65490 + dentry = real_mnt->mnt_mountpoint;
65491 + real_mnt = real_mnt->mnt_parent;
65492 + mnt = &real_mnt->mnt;
65493 + continue;
65494 + }
65495 +
65496 + spin_lock(&dentry->d_lock);
65497 + read_lock(&gr_inode_lock);
65498 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
65499 + __get_dev(dentry), role);
65500 + read_unlock(&gr_inode_lock);
65501 + parent = dentry->d_parent;
65502 + spin_unlock(&dentry->d_lock);
65503 +
65504 + if (retval != NULL)
65505 + goto out;
65506 +
65507 + dentry = parent;
65508 + }
65509 +
65510 + spin_lock(&dentry->d_lock);
65511 + read_lock(&gr_inode_lock);
65512 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
65513 + __get_dev(dentry), role);
65514 + read_unlock(&gr_inode_lock);
65515 + spin_unlock(&dentry->d_lock);
65516 +
65517 + if (unlikely(retval == NULL)) {
65518 + /* real_root is pinned, we don't need to hold a reference */
65519 + read_lock(&gr_inode_lock);
65520 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
65521 + __get_dev(real_root.dentry), role);
65522 + read_unlock(&gr_inode_lock);
65523 + }
65524 +out:
65525 + write_sequnlock(&rename_lock);
65526 + br_read_unlock(&vfsmount_lock);
65527 +
65528 + BUG_ON(retval == NULL);
65529 +
65530 + return retval;
65531 +}
65532 +
65533 +static void
65534 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
65535 +{
65536 + struct task_struct *task = current;
65537 + const struct cred *cred = current_cred();
65538 +
65539 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
65540 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
65541 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
65542 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
65543 +
65544 + return;
65545 +}
65546 +
65547 +static void
65548 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
65549 +{
65550 + struct task_struct *task = current;
65551 + const struct cred *cred = current_cred();
65552 +
65553 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
65554 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
65555 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
65556 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
65557 +
65558 + return;
65559 +}
65560 +
65561 +static void
65562 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
65563 +{
65564 + struct task_struct *task = current;
65565 + const struct cred *cred = current_cred();
65566 +
65567 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
65568 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
65569 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
65570 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
65571 +
65572 + return;
65573 +}
65574 +
65575 +__u32
65576 +gr_search_file(const struct dentry * dentry, const __u32 mode,
65577 + const struct vfsmount * mnt)
65578 +{
65579 + __u32 retval = mode;
65580 + struct acl_subject_label *curracl;
65581 + struct acl_object_label *currobj;
65582 +
65583 + if (unlikely(!(gr_status & GR_READY)))
65584 + return (mode & ~GR_AUDITS);
65585 +
65586 + curracl = current->acl;
65587 +
65588 + currobj = chk_obj_label(dentry, mnt, curracl);
65589 + retval = currobj->mode & mode;
65590 +
65591 + /* if we're opening a specified transfer file for writing
65592 + (e.g. /dev/initctl), then transfer our role to init
65593 + */
65594 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
65595 + current->role->roletype & GR_ROLE_PERSIST)) {
65596 + struct task_struct *task = init_pid_ns.child_reaper;
65597 +
65598 + if (task->role != current->role) {
65599 + task->acl_sp_role = 0;
65600 + task->acl_role_id = current->acl_role_id;
65601 + task->role = current->role;
65602 + rcu_read_lock();
65603 + read_lock(&grsec_exec_file_lock);
65604 + gr_apply_subject_to_task(task);
65605 + read_unlock(&grsec_exec_file_lock);
65606 + rcu_read_unlock();
65607 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
65608 + }
65609 + }
65610 +
65611 + if (unlikely
65612 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
65613 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
65614 + __u32 new_mode = mode;
65615 +
65616 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
65617 +
65618 + retval = new_mode;
65619 +
65620 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
65621 + new_mode |= GR_INHERIT;
65622 +
65623 + if (!(mode & GR_NOLEARN))
65624 + gr_log_learn(dentry, mnt, new_mode);
65625 + }
65626 +
65627 + return retval;
65628 +}
65629 +
65630 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
65631 + const struct dentry *parent,
65632 + const struct vfsmount *mnt)
65633 +{
65634 + struct name_entry *match;
65635 + struct acl_object_label *matchpo;
65636 + struct acl_subject_label *curracl;
65637 + char *path;
65638 +
65639 + if (unlikely(!(gr_status & GR_READY)))
65640 + return NULL;
65641 +
65642 + preempt_disable();
65643 + path = gr_to_filename_rbac(new_dentry, mnt);
65644 + match = lookup_name_entry_create(path);
65645 +
65646 + curracl = current->acl;
65647 +
65648 + if (match) {
65649 + read_lock(&gr_inode_lock);
65650 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
65651 + read_unlock(&gr_inode_lock);
65652 +
65653 + if (matchpo) {
65654 + preempt_enable();
65655 + return matchpo;
65656 + }
65657 + }
65658 +
65659 + // lookup parent
65660 +
65661 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
65662 +
65663 + preempt_enable();
65664 + return matchpo;
65665 +}
65666 +
65667 +__u32
65668 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
65669 + const struct vfsmount * mnt, const __u32 mode)
65670 +{
65671 + struct acl_object_label *matchpo;
65672 + __u32 retval;
65673 +
65674 + if (unlikely(!(gr_status & GR_READY)))
65675 + return (mode & ~GR_AUDITS);
65676 +
65677 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
65678 +
65679 + retval = matchpo->mode & mode;
65680 +
65681 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
65682 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
65683 + __u32 new_mode = mode;
65684 +
65685 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
65686 +
65687 + gr_log_learn(new_dentry, mnt, new_mode);
65688 + return new_mode;
65689 + }
65690 +
65691 + return retval;
65692 +}
65693 +
65694 +__u32
65695 +gr_check_link(const struct dentry * new_dentry,
65696 + const struct dentry * parent_dentry,
65697 + const struct vfsmount * parent_mnt,
65698 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
65699 +{
65700 + struct acl_object_label *obj;
65701 + __u32 oldmode, newmode;
65702 + __u32 needmode;
65703 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
65704 + GR_DELETE | GR_INHERIT;
65705 +
65706 + if (unlikely(!(gr_status & GR_READY)))
65707 + return (GR_CREATE | GR_LINK);
65708 +
65709 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
65710 + oldmode = obj->mode;
65711 +
65712 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
65713 + newmode = obj->mode;
65714 +
65715 + needmode = newmode & checkmodes;
65716 +
65717 + // old name for hardlink must have at least the permissions of the new name
65718 + if ((oldmode & needmode) != needmode)
65719 + goto bad;
65720 +
65721 + // if old name had restrictions/auditing, make sure the new name does as well
65722 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
65723 +
65724 + // don't allow hardlinking of suid/sgid/fcapped files without permission
65725 + if (is_privileged_binary(old_dentry))
65726 + needmode |= GR_SETID;
65727 +
65728 + if ((newmode & needmode) != needmode)
65729 + goto bad;
65730 +
65731 + // enforce minimum permissions
65732 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
65733 + return newmode;
65734 +bad:
65735 + needmode = oldmode;
65736 + if (is_privileged_binary(old_dentry))
65737 + needmode |= GR_SETID;
65738 +
65739 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
65740 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
65741 + return (GR_CREATE | GR_LINK);
65742 + } else if (newmode & GR_SUPPRESS)
65743 + return GR_SUPPRESS;
65744 + else
65745 + return 0;
65746 +}
65747 +
65748 +int
65749 +gr_check_hidden_task(const struct task_struct *task)
65750 +{
65751 + if (unlikely(!(gr_status & GR_READY)))
65752 + return 0;
65753 +
65754 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
65755 + return 1;
65756 +
65757 + return 0;
65758 +}
65759 +
65760 +int
65761 +gr_check_protected_task(const struct task_struct *task)
65762 +{
65763 + if (unlikely(!(gr_status & GR_READY) || !task))
65764 + return 0;
65765 +
65766 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
65767 + task->acl != current->acl)
65768 + return 1;
65769 +
65770 + return 0;
65771 +}
65772 +
65773 +int
65774 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
65775 +{
65776 + struct task_struct *p;
65777 + int ret = 0;
65778 +
65779 + if (unlikely(!(gr_status & GR_READY) || !pid))
65780 + return ret;
65781 +
65782 + read_lock(&tasklist_lock);
65783 + do_each_pid_task(pid, type, p) {
65784 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
65785 + p->acl != current->acl) {
65786 + ret = 1;
65787 + goto out;
65788 + }
65789 + } while_each_pid_task(pid, type, p);
65790 +out:
65791 + read_unlock(&tasklist_lock);
65792 +
65793 + return ret;
65794 +}
65795 +
65796 +void
65797 +gr_copy_label(struct task_struct *tsk)
65798 +{
65799 + tsk->signal->used_accept = 0;
65800 + tsk->acl_sp_role = 0;
65801 + tsk->acl_role_id = current->acl_role_id;
65802 + tsk->acl = current->acl;
65803 + tsk->role = current->role;
65804 + tsk->signal->curr_ip = current->signal->curr_ip;
65805 + tsk->signal->saved_ip = current->signal->saved_ip;
65806 + if (current->exec_file)
65807 + get_file(current->exec_file);
65808 + tsk->exec_file = current->exec_file;
65809 + tsk->is_writable = current->is_writable;
65810 + if (unlikely(current->signal->used_accept)) {
65811 + current->signal->curr_ip = 0;
65812 + current->signal->saved_ip = 0;
65813 + }
65814 +
65815 + return;
65816 +}
65817 +
65818 +static void
65819 +gr_set_proc_res(struct task_struct *task)
65820 +{
65821 + struct acl_subject_label *proc;
65822 + unsigned short i;
65823 +
65824 + proc = task->acl;
65825 +
65826 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
65827 + return;
65828 +
65829 + for (i = 0; i < RLIM_NLIMITS; i++) {
65830 + if (!(proc->resmask & (1U << i)))
65831 + continue;
65832 +
65833 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
65834 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
65835 +
65836 + if (i == RLIMIT_CPU)
65837 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
65838 + }
65839 +
65840 + return;
65841 +}
65842 +
65843 +extern int gr_process_kernel_setuid_ban(struct user_struct *user);
65844 +
65845 +int
65846 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
65847 +{
65848 + unsigned int i;
65849 + __u16 num;
65850 + uid_t *uidlist;
65851 + uid_t curuid;
65852 + int realok = 0;
65853 + int effectiveok = 0;
65854 + int fsok = 0;
65855 + uid_t globalreal, globaleffective, globalfs;
65856 +
65857 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT)
65858 + struct user_struct *user;
65859 +
65860 + if (!uid_valid(real))
65861 + goto skipit;
65862 +
65863 + /* find user based on global namespace */
65864 +
65865 + globalreal = GR_GLOBAL_UID(real);
65866 +
65867 + user = find_user(make_kuid(&init_user_ns, globalreal));
65868 + if (user == NULL)
65869 + goto skipit;
65870 +
65871 + if (gr_process_kernel_setuid_ban(user)) {
65872 + /* for find_user */
65873 + free_uid(user);
65874 + return 1;
65875 + }
65876 +
65877 + /* for find_user */
65878 + free_uid(user);
65879 +
65880 +skipit:
65881 +#endif
65882 +
65883 + if (unlikely(!(gr_status & GR_READY)))
65884 + return 0;
65885 +
65886 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
65887 + gr_log_learn_uid_change(real, effective, fs);
65888 +
65889 + num = current->acl->user_trans_num;
65890 + uidlist = current->acl->user_transitions;
65891 +
65892 + if (uidlist == NULL)
65893 + return 0;
65894 +
65895 + if (!uid_valid(real)) {
65896 + realok = 1;
65897 + globalreal = (uid_t)-1;
65898 + } else {
65899 + globalreal = GR_GLOBAL_UID(real);
65900 + }
65901 + if (!uid_valid(effective)) {
65902 + effectiveok = 1;
65903 + globaleffective = (uid_t)-1;
65904 + } else {
65905 + globaleffective = GR_GLOBAL_UID(effective);
65906 + }
65907 + if (!uid_valid(fs)) {
65908 + fsok = 1;
65909 + globalfs = (uid_t)-1;
65910 + } else {
65911 + globalfs = GR_GLOBAL_UID(fs);
65912 + }
65913 +
65914 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
65915 + for (i = 0; i < num; i++) {
65916 + curuid = uidlist[i];
65917 + if (globalreal == curuid)
65918 + realok = 1;
65919 + if (globaleffective == curuid)
65920 + effectiveok = 1;
65921 + if (globalfs == curuid)
65922 + fsok = 1;
65923 + }
65924 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
65925 + for (i = 0; i < num; i++) {
65926 + curuid = uidlist[i];
65927 + if (globalreal == curuid)
65928 + break;
65929 + if (globaleffective == curuid)
65930 + break;
65931 + if (globalfs == curuid)
65932 + break;
65933 + }
65934 + /* not in deny list */
65935 + if (i == num) {
65936 + realok = 1;
65937 + effectiveok = 1;
65938 + fsok = 1;
65939 + }
65940 + }
65941 +
65942 + if (realok && effectiveok && fsok)
65943 + return 0;
65944 + else {
65945 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
65946 + return 1;
65947 + }
65948 +}
65949 +
65950 +int
65951 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
65952 +{
65953 + unsigned int i;
65954 + __u16 num;
65955 + gid_t *gidlist;
65956 + gid_t curgid;
65957 + int realok = 0;
65958 + int effectiveok = 0;
65959 + int fsok = 0;
65960 + gid_t globalreal, globaleffective, globalfs;
65961 +
65962 + if (unlikely(!(gr_status & GR_READY)))
65963 + return 0;
65964 +
65965 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
65966 + gr_log_learn_gid_change(real, effective, fs);
65967 +
65968 + num = current->acl->group_trans_num;
65969 + gidlist = current->acl->group_transitions;
65970 +
65971 + if (gidlist == NULL)
65972 + return 0;
65973 +
65974 + if (!gid_valid(real)) {
65975 + realok = 1;
65976 + globalreal = (gid_t)-1;
65977 + } else {
65978 + globalreal = GR_GLOBAL_GID(real);
65979 + }
65980 + if (!gid_valid(effective)) {
65981 + effectiveok = 1;
65982 + globaleffective = (gid_t)-1;
65983 + } else {
65984 + globaleffective = GR_GLOBAL_GID(effective);
65985 + }
65986 + if (!gid_valid(fs)) {
65987 + fsok = 1;
65988 + globalfs = (gid_t)-1;
65989 + } else {
65990 + globalfs = GR_GLOBAL_GID(fs);
65991 + }
65992 +
65993 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
65994 + for (i = 0; i < num; i++) {
65995 + curgid = gidlist[i];
65996 + if (globalreal == curgid)
65997 + realok = 1;
65998 + if (globaleffective == curgid)
65999 + effectiveok = 1;
66000 + if (globalfs == curgid)
66001 + fsok = 1;
66002 + }
66003 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
66004 + for (i = 0; i < num; i++) {
66005 + curgid = gidlist[i];
66006 + if (globalreal == curgid)
66007 + break;
66008 + if (globaleffective == curgid)
66009 + break;
66010 + if (globalfs == curgid)
66011 + break;
66012 + }
66013 + /* not in deny list */
66014 + if (i == num) {
66015 + realok = 1;
66016 + effectiveok = 1;
66017 + fsok = 1;
66018 + }
66019 + }
66020 +
66021 + if (realok && effectiveok && fsok)
66022 + return 0;
66023 + else {
66024 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
66025 + return 1;
66026 + }
66027 +}
66028 +
66029 +extern int gr_acl_is_capable(const int cap);
66030 +
66031 +void
66032 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
66033 +{
66034 + struct acl_role_label *role = task->role;
66035 + struct acl_subject_label *subj = NULL;
66036 + struct acl_object_label *obj;
66037 + struct file *filp;
66038 + uid_t uid;
66039 + gid_t gid;
66040 +
66041 + if (unlikely(!(gr_status & GR_READY)))
66042 + return;
66043 +
66044 + uid = GR_GLOBAL_UID(kuid);
66045 + gid = GR_GLOBAL_GID(kgid);
66046 +
66047 + filp = task->exec_file;
66048 +
66049 + /* kernel process, we'll give them the kernel role */
66050 + if (unlikely(!filp)) {
66051 + task->role = kernel_role;
66052 + task->acl = kernel_role->root_label;
66053 + return;
66054 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
66055 + role = lookup_acl_role_label(task, uid, gid);
66056 +
66057 + /* don't change the role if we're not a privileged process */
66058 + if (role && task->role != role &&
66059 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
66060 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
66061 + return;
66062 +
66063 + /* perform subject lookup in possibly new role
66064 + we can use this result below in the case where role == task->role
66065 + */
66066 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
66067 +
66068 + /* if we changed uid/gid, but result in the same role
66069 + and are using inheritance, don't lose the inherited subject
66070 + if current subject is other than what normal lookup
66071 + would result in, we arrived via inheritance, don't
66072 + lose subject
66073 + */
66074 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
66075 + (subj == task->acl)))
66076 + task->acl = subj;
66077 +
66078 + task->role = role;
66079 +
66080 + task->is_writable = 0;
66081 +
66082 + /* ignore additional mmap checks for processes that are writable
66083 + by the default ACL */
66084 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
66085 + if (unlikely(obj->mode & GR_WRITE))
66086 + task->is_writable = 1;
66087 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
66088 + if (unlikely(obj->mode & GR_WRITE))
66089 + task->is_writable = 1;
66090 +
66091 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
66092 + 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);
66093 +#endif
66094 +
66095 + gr_set_proc_res(task);
66096 +
66097 + return;
66098 +}
66099 +
66100 +int
66101 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
66102 + const int unsafe_flags)
66103 +{
66104 + struct task_struct *task = current;
66105 + struct acl_subject_label *newacl;
66106 + struct acl_object_label *obj;
66107 + __u32 retmode;
66108 +
66109 + if (unlikely(!(gr_status & GR_READY)))
66110 + return 0;
66111 +
66112 + newacl = chk_subj_label(dentry, mnt, task->role);
66113 +
66114 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
66115 + did an exec
66116 + */
66117 + rcu_read_lock();
66118 + read_lock(&tasklist_lock);
66119 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
66120 + (task->parent->acl->mode & GR_POVERRIDE))) {
66121 + read_unlock(&tasklist_lock);
66122 + rcu_read_unlock();
66123 + goto skip_check;
66124 + }
66125 + read_unlock(&tasklist_lock);
66126 + rcu_read_unlock();
66127 +
66128 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
66129 + !(task->role->roletype & GR_ROLE_GOD) &&
66130 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
66131 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
66132 + if (unsafe_flags & LSM_UNSAFE_SHARE)
66133 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
66134 + else
66135 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
66136 + return -EACCES;
66137 + }
66138 +
66139 +skip_check:
66140 +
66141 + obj = chk_obj_label(dentry, mnt, task->acl);
66142 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
66143 +
66144 + if (!(task->acl->mode & GR_INHERITLEARN) &&
66145 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
66146 + if (obj->nested)
66147 + task->acl = obj->nested;
66148 + else
66149 + task->acl = newacl;
66150 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
66151 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
66152 +
66153 + task->is_writable = 0;
66154 +
66155 + /* ignore additional mmap checks for processes that are writable
66156 + by the default ACL */
66157 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
66158 + if (unlikely(obj->mode & GR_WRITE))
66159 + task->is_writable = 1;
66160 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
66161 + if (unlikely(obj->mode & GR_WRITE))
66162 + task->is_writable = 1;
66163 +
66164 + gr_set_proc_res(task);
66165 +
66166 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
66167 + 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);
66168 +#endif
66169 + return 0;
66170 +}
66171 +
66172 +/* always called with valid inodev ptr */
66173 +static void
66174 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
66175 +{
66176 + struct acl_object_label *matchpo;
66177 + struct acl_subject_label *matchps;
66178 + struct acl_subject_label *subj;
66179 + struct acl_role_label *role;
66180 + unsigned int x;
66181 +
66182 + FOR_EACH_ROLE_START(role)
66183 + FOR_EACH_SUBJECT_START(role, subj, x)
66184 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
66185 + matchpo->mode |= GR_DELETED;
66186 + FOR_EACH_SUBJECT_END(subj,x)
66187 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
66188 + /* nested subjects aren't in the role's subj_hash table */
66189 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
66190 + matchpo->mode |= GR_DELETED;
66191 + FOR_EACH_NESTED_SUBJECT_END(subj)
66192 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
66193 + matchps->mode |= GR_DELETED;
66194 + FOR_EACH_ROLE_END(role)
66195 +
66196 + inodev->nentry->deleted = 1;
66197 +
66198 + return;
66199 +}
66200 +
66201 +void
66202 +gr_handle_delete(const ino_t ino, const dev_t dev)
66203 +{
66204 + struct inodev_entry *inodev;
66205 +
66206 + if (unlikely(!(gr_status & GR_READY)))
66207 + return;
66208 +
66209 + write_lock(&gr_inode_lock);
66210 + inodev = lookup_inodev_entry(ino, dev);
66211 + if (inodev != NULL)
66212 + do_handle_delete(inodev, ino, dev);
66213 + write_unlock(&gr_inode_lock);
66214 +
66215 + return;
66216 +}
66217 +
66218 +static void
66219 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
66220 + const ino_t newinode, const dev_t newdevice,
66221 + struct acl_subject_label *subj)
66222 +{
66223 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
66224 + struct acl_object_label *match;
66225 +
66226 + match = subj->obj_hash[index];
66227 +
66228 + while (match && (match->inode != oldinode ||
66229 + match->device != olddevice ||
66230 + !(match->mode & GR_DELETED)))
66231 + match = match->next;
66232 +
66233 + if (match && (match->inode == oldinode)
66234 + && (match->device == olddevice)
66235 + && (match->mode & GR_DELETED)) {
66236 + if (match->prev == NULL) {
66237 + subj->obj_hash[index] = match->next;
66238 + if (match->next != NULL)
66239 + match->next->prev = NULL;
66240 + } else {
66241 + match->prev->next = match->next;
66242 + if (match->next != NULL)
66243 + match->next->prev = match->prev;
66244 + }
66245 + match->prev = NULL;
66246 + match->next = NULL;
66247 + match->inode = newinode;
66248 + match->device = newdevice;
66249 + match->mode &= ~GR_DELETED;
66250 +
66251 + insert_acl_obj_label(match, subj);
66252 + }
66253 +
66254 + return;
66255 +}
66256 +
66257 +static void
66258 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
66259 + const ino_t newinode, const dev_t newdevice,
66260 + struct acl_role_label *role)
66261 +{
66262 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
66263 + struct acl_subject_label *match;
66264 +
66265 + match = role->subj_hash[index];
66266 +
66267 + while (match && (match->inode != oldinode ||
66268 + match->device != olddevice ||
66269 + !(match->mode & GR_DELETED)))
66270 + match = match->next;
66271 +
66272 + if (match && (match->inode == oldinode)
66273 + && (match->device == olddevice)
66274 + && (match->mode & GR_DELETED)) {
66275 + if (match->prev == NULL) {
66276 + role->subj_hash[index] = match->next;
66277 + if (match->next != NULL)
66278 + match->next->prev = NULL;
66279 + } else {
66280 + match->prev->next = match->next;
66281 + if (match->next != NULL)
66282 + match->next->prev = match->prev;
66283 + }
66284 + match->prev = NULL;
66285 + match->next = NULL;
66286 + match->inode = newinode;
66287 + match->device = newdevice;
66288 + match->mode &= ~GR_DELETED;
66289 +
66290 + insert_acl_subj_label(match, role);
66291 + }
66292 +
66293 + return;
66294 +}
66295 +
66296 +static void
66297 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
66298 + const ino_t newinode, const dev_t newdevice)
66299 +{
66300 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
66301 + struct inodev_entry *match;
66302 +
66303 + match = inodev_set.i_hash[index];
66304 +
66305 + while (match && (match->nentry->inode != oldinode ||
66306 + match->nentry->device != olddevice || !match->nentry->deleted))
66307 + match = match->next;
66308 +
66309 + if (match && (match->nentry->inode == oldinode)
66310 + && (match->nentry->device == olddevice) &&
66311 + match->nentry->deleted) {
66312 + if (match->prev == NULL) {
66313 + inodev_set.i_hash[index] = match->next;
66314 + if (match->next != NULL)
66315 + match->next->prev = NULL;
66316 + } else {
66317 + match->prev->next = match->next;
66318 + if (match->next != NULL)
66319 + match->next->prev = match->prev;
66320 + }
66321 + match->prev = NULL;
66322 + match->next = NULL;
66323 + match->nentry->inode = newinode;
66324 + match->nentry->device = newdevice;
66325 + match->nentry->deleted = 0;
66326 +
66327 + insert_inodev_entry(match);
66328 + }
66329 +
66330 + return;
66331 +}
66332 +
66333 +static void
66334 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
66335 +{
66336 + struct acl_subject_label *subj;
66337 + struct acl_role_label *role;
66338 + unsigned int x;
66339 +
66340 + FOR_EACH_ROLE_START(role)
66341 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
66342 +
66343 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
66344 + if ((subj->inode == ino) && (subj->device == dev)) {
66345 + subj->inode = ino;
66346 + subj->device = dev;
66347 + }
66348 + /* nested subjects aren't in the role's subj_hash table */
66349 + update_acl_obj_label(matchn->inode, matchn->device,
66350 + ino, dev, subj);
66351 + FOR_EACH_NESTED_SUBJECT_END(subj)
66352 + FOR_EACH_SUBJECT_START(role, subj, x)
66353 + update_acl_obj_label(matchn->inode, matchn->device,
66354 + ino, dev, subj);
66355 + FOR_EACH_SUBJECT_END(subj,x)
66356 + FOR_EACH_ROLE_END(role)
66357 +
66358 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
66359 +
66360 + return;
66361 +}
66362 +
66363 +static void
66364 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
66365 + const struct vfsmount *mnt)
66366 +{
66367 + ino_t ino = dentry->d_inode->i_ino;
66368 + dev_t dev = __get_dev(dentry);
66369 +
66370 + __do_handle_create(matchn, ino, dev);
66371 +
66372 + return;
66373 +}
66374 +
66375 +void
66376 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
66377 +{
66378 + struct name_entry *matchn;
66379 +
66380 + if (unlikely(!(gr_status & GR_READY)))
66381 + return;
66382 +
66383 + preempt_disable();
66384 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
66385 +
66386 + if (unlikely((unsigned long)matchn)) {
66387 + write_lock(&gr_inode_lock);
66388 + do_handle_create(matchn, dentry, mnt);
66389 + write_unlock(&gr_inode_lock);
66390 + }
66391 + preempt_enable();
66392 +
66393 + return;
66394 +}
66395 +
66396 +void
66397 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
66398 +{
66399 + struct name_entry *matchn;
66400 +
66401 + if (unlikely(!(gr_status & GR_READY)))
66402 + return;
66403 +
66404 + preempt_disable();
66405 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
66406 +
66407 + if (unlikely((unsigned long)matchn)) {
66408 + write_lock(&gr_inode_lock);
66409 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
66410 + write_unlock(&gr_inode_lock);
66411 + }
66412 + preempt_enable();
66413 +
66414 + return;
66415 +}
66416 +
66417 +void
66418 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
66419 + struct dentry *old_dentry,
66420 + struct dentry *new_dentry,
66421 + struct vfsmount *mnt, const __u8 replace)
66422 +{
66423 + struct name_entry *matchn;
66424 + struct inodev_entry *inodev;
66425 + struct inode *inode = new_dentry->d_inode;
66426 + ino_t old_ino = old_dentry->d_inode->i_ino;
66427 + dev_t old_dev = __get_dev(old_dentry);
66428 +
66429 + /* vfs_rename swaps the name and parent link for old_dentry and
66430 + new_dentry
66431 + at this point, old_dentry has the new name, parent link, and inode
66432 + for the renamed file
66433 + if a file is being replaced by a rename, new_dentry has the inode
66434 + and name for the replaced file
66435 + */
66436 +
66437 + if (unlikely(!(gr_status & GR_READY)))
66438 + return;
66439 +
66440 + preempt_disable();
66441 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
66442 +
66443 + /* we wouldn't have to check d_inode if it weren't for
66444 + NFS silly-renaming
66445 + */
66446 +
66447 + write_lock(&gr_inode_lock);
66448 + if (unlikely(replace && inode)) {
66449 + ino_t new_ino = inode->i_ino;
66450 + dev_t new_dev = __get_dev(new_dentry);
66451 +
66452 + inodev = lookup_inodev_entry(new_ino, new_dev);
66453 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
66454 + do_handle_delete(inodev, new_ino, new_dev);
66455 + }
66456 +
66457 + inodev = lookup_inodev_entry(old_ino, old_dev);
66458 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
66459 + do_handle_delete(inodev, old_ino, old_dev);
66460 +
66461 + if (unlikely((unsigned long)matchn))
66462 + do_handle_create(matchn, old_dentry, mnt);
66463 +
66464 + write_unlock(&gr_inode_lock);
66465 + preempt_enable();
66466 +
66467 + return;
66468 +}
66469 +
66470 +static int
66471 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
66472 + unsigned char **sum)
66473 +{
66474 + struct acl_role_label *r;
66475 + struct role_allowed_ip *ipp;
66476 + struct role_transition *trans;
66477 + unsigned int i;
66478 + int found = 0;
66479 + u32 curr_ip = current->signal->curr_ip;
66480 +
66481 + current->signal->saved_ip = curr_ip;
66482 +
66483 + /* check transition table */
66484 +
66485 + for (trans = current->role->transitions; trans; trans = trans->next) {
66486 + if (!strcmp(rolename, trans->rolename)) {
66487 + found = 1;
66488 + break;
66489 + }
66490 + }
66491 +
66492 + if (!found)
66493 + return 0;
66494 +
66495 + /* handle special roles that do not require authentication
66496 + and check ip */
66497 +
66498 + FOR_EACH_ROLE_START(r)
66499 + if (!strcmp(rolename, r->rolename) &&
66500 + (r->roletype & GR_ROLE_SPECIAL)) {
66501 + found = 0;
66502 + if (r->allowed_ips != NULL) {
66503 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
66504 + if ((ntohl(curr_ip) & ipp->netmask) ==
66505 + (ntohl(ipp->addr) & ipp->netmask))
66506 + found = 1;
66507 + }
66508 + } else
66509 + found = 2;
66510 + if (!found)
66511 + return 0;
66512 +
66513 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
66514 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
66515 + *salt = NULL;
66516 + *sum = NULL;
66517 + return 1;
66518 + }
66519 + }
66520 + FOR_EACH_ROLE_END(r)
66521 +
66522 + for (i = 0; i < num_sprole_pws; i++) {
66523 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
66524 + *salt = acl_special_roles[i]->salt;
66525 + *sum = acl_special_roles[i]->sum;
66526 + return 1;
66527 + }
66528 + }
66529 +
66530 + return 0;
66531 +}
66532 +
66533 +static void
66534 +assign_special_role(char *rolename)
66535 +{
66536 + struct acl_object_label *obj;
66537 + struct acl_role_label *r;
66538 + struct acl_role_label *assigned = NULL;
66539 + struct task_struct *tsk;
66540 + struct file *filp;
66541 +
66542 + FOR_EACH_ROLE_START(r)
66543 + if (!strcmp(rolename, r->rolename) &&
66544 + (r->roletype & GR_ROLE_SPECIAL)) {
66545 + assigned = r;
66546 + break;
66547 + }
66548 + FOR_EACH_ROLE_END(r)
66549 +
66550 + if (!assigned)
66551 + return;
66552 +
66553 + read_lock(&tasklist_lock);
66554 + read_lock(&grsec_exec_file_lock);
66555 +
66556 + tsk = current->real_parent;
66557 + if (tsk == NULL)
66558 + goto out_unlock;
66559 +
66560 + filp = tsk->exec_file;
66561 + if (filp == NULL)
66562 + goto out_unlock;
66563 +
66564 + tsk->is_writable = 0;
66565 +
66566 + tsk->acl_sp_role = 1;
66567 + tsk->acl_role_id = ++acl_sp_role_value;
66568 + tsk->role = assigned;
66569 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
66570 +
66571 + /* ignore additional mmap checks for processes that are writable
66572 + by the default ACL */
66573 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
66574 + if (unlikely(obj->mode & GR_WRITE))
66575 + tsk->is_writable = 1;
66576 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
66577 + if (unlikely(obj->mode & GR_WRITE))
66578 + tsk->is_writable = 1;
66579 +
66580 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
66581 + printk(KERN_ALERT "Assigning special role:%s subject:%s to process (%s:%d)\n", tsk->role->rolename, tsk->acl->filename, tsk->comm, task_pid_nr(tsk));
66582 +#endif
66583 +
66584 +out_unlock:
66585 + read_unlock(&grsec_exec_file_lock);
66586 + read_unlock(&tasklist_lock);
66587 + return;
66588 +}
66589 +
66590 +int gr_check_secure_terminal(struct task_struct *task)
66591 +{
66592 + struct task_struct *p, *p2, *p3;
66593 + struct files_struct *files;
66594 + struct fdtable *fdt;
66595 + struct file *our_file = NULL, *file;
66596 + int i;
66597 +
66598 + if (task->signal->tty == NULL)
66599 + return 1;
66600 +
66601 + files = get_files_struct(task);
66602 + if (files != NULL) {
66603 + rcu_read_lock();
66604 + fdt = files_fdtable(files);
66605 + for (i=0; i < fdt->max_fds; i++) {
66606 + file = fcheck_files(files, i);
66607 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
66608 + get_file(file);
66609 + our_file = file;
66610 + }
66611 + }
66612 + rcu_read_unlock();
66613 + put_files_struct(files);
66614 + }
66615 +
66616 + if (our_file == NULL)
66617 + return 1;
66618 +
66619 + read_lock(&tasklist_lock);
66620 + do_each_thread(p2, p) {
66621 + files = get_files_struct(p);
66622 + if (files == NULL ||
66623 + (p->signal && p->signal->tty == task->signal->tty)) {
66624 + if (files != NULL)
66625 + put_files_struct(files);
66626 + continue;
66627 + }
66628 + rcu_read_lock();
66629 + fdt = files_fdtable(files);
66630 + for (i=0; i < fdt->max_fds; i++) {
66631 + file = fcheck_files(files, i);
66632 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
66633 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
66634 + p3 = task;
66635 + while (task_pid_nr(p3) > 0) {
66636 + if (p3 == p)
66637 + break;
66638 + p3 = p3->real_parent;
66639 + }
66640 + if (p3 == p)
66641 + break;
66642 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
66643 + gr_handle_alertkill(p);
66644 + rcu_read_unlock();
66645 + put_files_struct(files);
66646 + read_unlock(&tasklist_lock);
66647 + fput(our_file);
66648 + return 0;
66649 + }
66650 + }
66651 + rcu_read_unlock();
66652 + put_files_struct(files);
66653 + } while_each_thread(p2, p);
66654 + read_unlock(&tasklist_lock);
66655 +
66656 + fput(our_file);
66657 + return 1;
66658 +}
66659 +
66660 +static int gr_rbac_disable(void *unused)
66661 +{
66662 + pax_open_kernel();
66663 + gr_status &= ~GR_READY;
66664 + pax_close_kernel();
66665 +
66666 + return 0;
66667 +}
66668 +
66669 +ssize_t
66670 +write_grsec_handler(struct file *file, const char __user * buf, size_t count, loff_t *ppos)
66671 +{
66672 + struct gr_arg_wrapper uwrap;
66673 + unsigned char *sprole_salt = NULL;
66674 + unsigned char *sprole_sum = NULL;
66675 + int error = 0;
66676 + int error2 = 0;
66677 + size_t req_count = 0;
66678 +
66679 + mutex_lock(&gr_dev_mutex);
66680 +
66681 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
66682 + error = -EPERM;
66683 + goto out;
66684 + }
66685 +
66686 +#ifdef CONFIG_COMPAT
66687 + pax_open_kernel();
66688 + if (is_compat_task()) {
66689 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_compat;
66690 + copy_gr_arg = &copy_gr_arg_compat;
66691 + copy_acl_object_label = &copy_acl_object_label_compat;
66692 + copy_acl_subject_label = &copy_acl_subject_label_compat;
66693 + copy_acl_role_label = &copy_acl_role_label_compat;
66694 + copy_acl_ip_label = &copy_acl_ip_label_compat;
66695 + copy_role_allowed_ip = &copy_role_allowed_ip_compat;
66696 + copy_role_transition = &copy_role_transition_compat;
66697 + copy_sprole_pw = &copy_sprole_pw_compat;
66698 + copy_gr_hash_struct = &copy_gr_hash_struct_compat;
66699 + copy_pointer_from_array = &copy_pointer_from_array_compat;
66700 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_compat;
66701 + } else {
66702 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_normal;
66703 + copy_gr_arg = &copy_gr_arg_normal;
66704 + copy_acl_object_label = &copy_acl_object_label_normal;
66705 + copy_acl_subject_label = &copy_acl_subject_label_normal;
66706 + copy_acl_role_label = &copy_acl_role_label_normal;
66707 + copy_acl_ip_label = &copy_acl_ip_label_normal;
66708 + copy_role_allowed_ip = &copy_role_allowed_ip_normal;
66709 + copy_role_transition = &copy_role_transition_normal;
66710 + copy_sprole_pw = &copy_sprole_pw_normal;
66711 + copy_gr_hash_struct = &copy_gr_hash_struct_normal;
66712 + copy_pointer_from_array = &copy_pointer_from_array_normal;
66713 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_normal;
66714 + }
66715 + pax_close_kernel();
66716 +#endif
66717 +
66718 + req_count = get_gr_arg_wrapper_size();
66719 +
66720 + if (count != req_count) {
66721 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)req_count);
66722 + error = -EINVAL;
66723 + goto out;
66724 + }
66725 +
66726 +
66727 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
66728 + gr_auth_expires = 0;
66729 + gr_auth_attempts = 0;
66730 + }
66731 +
66732 + error = copy_gr_arg_wrapper(buf, &uwrap);
66733 + if (error)
66734 + goto out;
66735 +
66736 + error = copy_gr_arg(uwrap.arg, gr_usermode);
66737 + if (error)
66738 + goto out;
66739 +
66740 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
66741 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
66742 + time_after(gr_auth_expires, get_seconds())) {
66743 + error = -EBUSY;
66744 + goto out;
66745 + }
66746 +
66747 + /* if non-root trying to do anything other than use a special role,
66748 + do not attempt authentication, do not count towards authentication
66749 + locking
66750 + */
66751 +
66752 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
66753 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
66754 + gr_is_global_nonroot(current_uid())) {
66755 + error = -EPERM;
66756 + goto out;
66757 + }
66758 +
66759 + /* ensure pw and special role name are null terminated */
66760 +
66761 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
66762 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
66763 +
66764 + /* Okay.
66765 + * We have our enough of the argument structure..(we have yet
66766 + * to copy_from_user the tables themselves) . Copy the tables
66767 + * only if we need them, i.e. for loading operations. */
66768 +
66769 + switch (gr_usermode->mode) {
66770 + case GR_STATUS:
66771 + if (gr_status & GR_READY) {
66772 + error = 1;
66773 + if (!gr_check_secure_terminal(current))
66774 + error = 3;
66775 + } else
66776 + error = 2;
66777 + goto out;
66778 + case GR_SHUTDOWN:
66779 + if ((gr_status & GR_READY)
66780 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
66781 + stop_machine(gr_rbac_disable, NULL, NULL);
66782 + free_variables();
66783 + memset(gr_usermode, 0, sizeof (struct gr_arg));
66784 + memset(gr_system_salt, 0, GR_SALT_LEN);
66785 + memset(gr_system_sum, 0, GR_SHA_LEN);
66786 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
66787 + } else if (gr_status & GR_READY) {
66788 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
66789 + error = -EPERM;
66790 + } else {
66791 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
66792 + error = -EAGAIN;
66793 + }
66794 + break;
66795 + case GR_ENABLE:
66796 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
66797 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
66798 + else {
66799 + if (gr_status & GR_READY)
66800 + error = -EAGAIN;
66801 + else
66802 + error = error2;
66803 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
66804 + }
66805 + break;
66806 + case GR_RELOAD:
66807 + if (!(gr_status & GR_READY)) {
66808 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
66809 + error = -EAGAIN;
66810 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
66811 + stop_machine(gr_rbac_disable, NULL, NULL);
66812 + free_variables();
66813 + error2 = gracl_init(gr_usermode);
66814 + if (!error2)
66815 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
66816 + else {
66817 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
66818 + error = error2;
66819 + }
66820 + } else {
66821 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
66822 + error = -EPERM;
66823 + }
66824 + break;
66825 + case GR_SEGVMOD:
66826 + if (unlikely(!(gr_status & GR_READY))) {
66827 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
66828 + error = -EAGAIN;
66829 + break;
66830 + }
66831 +
66832 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
66833 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
66834 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
66835 + struct acl_subject_label *segvacl;
66836 + segvacl =
66837 + lookup_acl_subj_label(gr_usermode->segv_inode,
66838 + gr_usermode->segv_device,
66839 + current->role);
66840 + if (segvacl) {
66841 + segvacl->crashes = 0;
66842 + segvacl->expires = 0;
66843 + }
66844 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
66845 + gr_remove_uid(gr_usermode->segv_uid);
66846 + }
66847 + } else {
66848 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
66849 + error = -EPERM;
66850 + }
66851 + break;
66852 + case GR_SPROLE:
66853 + case GR_SPROLEPAM:
66854 + if (unlikely(!(gr_status & GR_READY))) {
66855 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
66856 + error = -EAGAIN;
66857 + break;
66858 + }
66859 +
66860 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
66861 + current->role->expires = 0;
66862 + current->role->auth_attempts = 0;
66863 + }
66864 +
66865 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
66866 + time_after(current->role->expires, get_seconds())) {
66867 + error = -EBUSY;
66868 + goto out;
66869 + }
66870 +
66871 + if (lookup_special_role_auth
66872 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
66873 + && ((!sprole_salt && !sprole_sum)
66874 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
66875 + char *p = "";
66876 + assign_special_role(gr_usermode->sp_role);
66877 + read_lock(&tasklist_lock);
66878 + if (current->real_parent)
66879 + p = current->real_parent->role->rolename;
66880 + read_unlock(&tasklist_lock);
66881 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
66882 + p, acl_sp_role_value);
66883 + } else {
66884 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
66885 + error = -EPERM;
66886 + if(!(current->role->auth_attempts++))
66887 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
66888 +
66889 + goto out;
66890 + }
66891 + break;
66892 + case GR_UNSPROLE:
66893 + if (unlikely(!(gr_status & GR_READY))) {
66894 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
66895 + error = -EAGAIN;
66896 + break;
66897 + }
66898 +
66899 + if (current->role->roletype & GR_ROLE_SPECIAL) {
66900 + char *p = "";
66901 + int i = 0;
66902 +
66903 + read_lock(&tasklist_lock);
66904 + if (current->real_parent) {
66905 + p = current->real_parent->role->rolename;
66906 + i = current->real_parent->acl_role_id;
66907 + }
66908 + read_unlock(&tasklist_lock);
66909 +
66910 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
66911 + gr_set_acls(1);
66912 + } else {
66913 + error = -EPERM;
66914 + goto out;
66915 + }
66916 + break;
66917 + default:
66918 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
66919 + error = -EINVAL;
66920 + break;
66921 + }
66922 +
66923 + if (error != -EPERM)
66924 + goto out;
66925 +
66926 + if(!(gr_auth_attempts++))
66927 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
66928 +
66929 + out:
66930 + mutex_unlock(&gr_dev_mutex);
66931 +
66932 + if (!error)
66933 + error = req_count;
66934 +
66935 + return error;
66936 +}
66937 +
66938 +/* must be called with
66939 + rcu_read_lock();
66940 + read_lock(&tasklist_lock);
66941 + read_lock(&grsec_exec_file_lock);
66942 +*/
66943 +int gr_apply_subject_to_task(struct task_struct *task)
66944 +{
66945 + struct acl_object_label *obj;
66946 + char *tmpname;
66947 + struct acl_subject_label *tmpsubj;
66948 + struct file *filp;
66949 + struct name_entry *nmatch;
66950 +
66951 + filp = task->exec_file;
66952 + if (filp == NULL)
66953 + return 0;
66954 +
66955 + /* the following is to apply the correct subject
66956 + on binaries running when the RBAC system
66957 + is enabled, when the binaries have been
66958 + replaced or deleted since their execution
66959 + -----
66960 + when the RBAC system starts, the inode/dev
66961 + from exec_file will be one the RBAC system
66962 + is unaware of. It only knows the inode/dev
66963 + of the present file on disk, or the absence
66964 + of it.
66965 + */
66966 + preempt_disable();
66967 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
66968 +
66969 + nmatch = lookup_name_entry(tmpname);
66970 + preempt_enable();
66971 + tmpsubj = NULL;
66972 + if (nmatch) {
66973 + if (nmatch->deleted)
66974 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
66975 + else
66976 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
66977 + if (tmpsubj != NULL)
66978 + task->acl = tmpsubj;
66979 + }
66980 + if (tmpsubj == NULL)
66981 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
66982 + task->role);
66983 + if (task->acl) {
66984 + task->is_writable = 0;
66985 + /* ignore additional mmap checks for processes that are writable
66986 + by the default ACL */
66987 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
66988 + if (unlikely(obj->mode & GR_WRITE))
66989 + task->is_writable = 1;
66990 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
66991 + if (unlikely(obj->mode & GR_WRITE))
66992 + task->is_writable = 1;
66993 +
66994 + gr_set_proc_res(task);
66995 +
66996 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
66997 + 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);
66998 +#endif
66999 + } else {
67000 + return 1;
67001 + }
67002 +
67003 + return 0;
67004 +}
67005 +
67006 +int
67007 +gr_set_acls(const int type)
67008 +{
67009 + struct task_struct *task, *task2;
67010 + struct acl_role_label *role = current->role;
67011 + __u16 acl_role_id = current->acl_role_id;
67012 + const struct cred *cred;
67013 + int ret;
67014 +
67015 + rcu_read_lock();
67016 + read_lock(&tasklist_lock);
67017 + read_lock(&grsec_exec_file_lock);
67018 + do_each_thread(task2, task) {
67019 + /* check to see if we're called from the exit handler,
67020 + if so, only replace ACLs that have inherited the admin
67021 + ACL */
67022 +
67023 + if (type && (task->role != role ||
67024 + task->acl_role_id != acl_role_id))
67025 + continue;
67026 +
67027 + task->acl_role_id = 0;
67028 + task->acl_sp_role = 0;
67029 +
67030 + if (task->exec_file) {
67031 + cred = __task_cred(task);
67032 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
67033 + ret = gr_apply_subject_to_task(task);
67034 + if (ret) {
67035 + read_unlock(&grsec_exec_file_lock);
67036 + read_unlock(&tasklist_lock);
67037 + rcu_read_unlock();
67038 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
67039 + return ret;
67040 + }
67041 + } else {
67042 + // it's a kernel process
67043 + task->role = kernel_role;
67044 + task->acl = kernel_role->root_label;
67045 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
67046 + task->acl->mode &= ~GR_PROCFIND;
67047 +#endif
67048 + }
67049 + } while_each_thread(task2, task);
67050 + read_unlock(&grsec_exec_file_lock);
67051 + read_unlock(&tasklist_lock);
67052 + rcu_read_unlock();
67053 +
67054 + return 0;
67055 +}
67056 +
67057 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
67058 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
67059 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
67060 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
67061 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
67062 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
67063 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
67064 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
67065 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
67066 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
67067 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
67068 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
67069 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
67070 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
67071 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
67072 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
67073 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
67074 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
67075 +};
67076 +
67077 +void
67078 +gr_learn_resource(const struct task_struct *task,
67079 + const int res, const unsigned long wanted, const int gt)
67080 +{
67081 + struct acl_subject_label *acl;
67082 + const struct cred *cred;
67083 +
67084 + if (unlikely((gr_status & GR_READY) &&
67085 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
67086 + goto skip_reslog;
67087 +
67088 + gr_log_resource(task, res, wanted, gt);
67089 +skip_reslog:
67090 +
67091 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
67092 + return;
67093 +
67094 + acl = task->acl;
67095 +
67096 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
67097 + !(acl->resmask & (1U << (unsigned short) res))))
67098 + return;
67099 +
67100 + if (wanted >= acl->res[res].rlim_cur) {
67101 + unsigned long res_add;
67102 +
67103 + res_add = wanted + res_learn_bumps[res];
67104 +
67105 + acl->res[res].rlim_cur = res_add;
67106 +
67107 + if (wanted > acl->res[res].rlim_max)
67108 + acl->res[res].rlim_max = res_add;
67109 +
67110 + /* only log the subject filename, since resource logging is supported for
67111 + single-subject learning only */
67112 + rcu_read_lock();
67113 + cred = __task_cred(task);
67114 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
67115 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
67116 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
67117 + "", (unsigned long) res, &task->signal->saved_ip);
67118 + rcu_read_unlock();
67119 + }
67120 +
67121 + return;
67122 +}
67123 +EXPORT_SYMBOL(gr_learn_resource);
67124 +#endif
67125 +
67126 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
67127 +void
67128 +pax_set_initial_flags(struct linux_binprm *bprm)
67129 +{
67130 + struct task_struct *task = current;
67131 + struct acl_subject_label *proc;
67132 + unsigned long flags;
67133 +
67134 + if (unlikely(!(gr_status & GR_READY)))
67135 + return;
67136 +
67137 + flags = pax_get_flags(task);
67138 +
67139 + proc = task->acl;
67140 +
67141 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
67142 + flags &= ~MF_PAX_PAGEEXEC;
67143 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
67144 + flags &= ~MF_PAX_SEGMEXEC;
67145 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
67146 + flags &= ~MF_PAX_RANDMMAP;
67147 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
67148 + flags &= ~MF_PAX_EMUTRAMP;
67149 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
67150 + flags &= ~MF_PAX_MPROTECT;
67151 +
67152 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
67153 + flags |= MF_PAX_PAGEEXEC;
67154 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
67155 + flags |= MF_PAX_SEGMEXEC;
67156 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
67157 + flags |= MF_PAX_RANDMMAP;
67158 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
67159 + flags |= MF_PAX_EMUTRAMP;
67160 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
67161 + flags |= MF_PAX_MPROTECT;
67162 +
67163 + pax_set_flags(task, flags);
67164 +
67165 + return;
67166 +}
67167 +#endif
67168 +
67169 +int
67170 +gr_handle_proc_ptrace(struct task_struct *task)
67171 +{
67172 + struct file *filp;
67173 + struct task_struct *tmp = task;
67174 + struct task_struct *curtemp = current;
67175 + __u32 retmode;
67176 +
67177 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
67178 + if (unlikely(!(gr_status & GR_READY)))
67179 + return 0;
67180 +#endif
67181 +
67182 + read_lock(&tasklist_lock);
67183 + read_lock(&grsec_exec_file_lock);
67184 + filp = task->exec_file;
67185 +
67186 + while (task_pid_nr(tmp) > 0) {
67187 + if (tmp == curtemp)
67188 + break;
67189 + tmp = tmp->real_parent;
67190 + }
67191 +
67192 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
67193 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
67194 + read_unlock(&grsec_exec_file_lock);
67195 + read_unlock(&tasklist_lock);
67196 + return 1;
67197 + }
67198 +
67199 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
67200 + if (!(gr_status & GR_READY)) {
67201 + read_unlock(&grsec_exec_file_lock);
67202 + read_unlock(&tasklist_lock);
67203 + return 0;
67204 + }
67205 +#endif
67206 +
67207 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
67208 + read_unlock(&grsec_exec_file_lock);
67209 + read_unlock(&tasklist_lock);
67210 +
67211 + if (retmode & GR_NOPTRACE)
67212 + return 1;
67213 +
67214 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
67215 + && (current->acl != task->acl || (current->acl != current->role->root_label
67216 + && task_pid_nr(current) != task_pid_nr(task))))
67217 + return 1;
67218 +
67219 + return 0;
67220 +}
67221 +
67222 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
67223 +{
67224 + if (unlikely(!(gr_status & GR_READY)))
67225 + return;
67226 +
67227 + if (!(current->role->roletype & GR_ROLE_GOD))
67228 + return;
67229 +
67230 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
67231 + p->role->rolename, gr_task_roletype_to_char(p),
67232 + p->acl->filename);
67233 +}
67234 +
67235 +int
67236 +gr_handle_ptrace(struct task_struct *task, const long request)
67237 +{
67238 + struct task_struct *tmp = task;
67239 + struct task_struct *curtemp = current;
67240 + __u32 retmode;
67241 +
67242 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
67243 + if (unlikely(!(gr_status & GR_READY)))
67244 + return 0;
67245 +#endif
67246 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
67247 + read_lock(&tasklist_lock);
67248 + while (task_pid_nr(tmp) > 0) {
67249 + if (tmp == curtemp)
67250 + break;
67251 + tmp = tmp->real_parent;
67252 + }
67253 +
67254 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
67255 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
67256 + read_unlock(&tasklist_lock);
67257 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
67258 + return 1;
67259 + }
67260 + read_unlock(&tasklist_lock);
67261 + }
67262 +
67263 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
67264 + if (!(gr_status & GR_READY))
67265 + return 0;
67266 +#endif
67267 +
67268 + read_lock(&grsec_exec_file_lock);
67269 + if (unlikely(!task->exec_file)) {
67270 + read_unlock(&grsec_exec_file_lock);
67271 + return 0;
67272 + }
67273 +
67274 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
67275 + read_unlock(&grsec_exec_file_lock);
67276 +
67277 + if (retmode & GR_NOPTRACE) {
67278 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
67279 + return 1;
67280 + }
67281 +
67282 + if (retmode & GR_PTRACERD) {
67283 + switch (request) {
67284 + case PTRACE_SEIZE:
67285 + case PTRACE_POKETEXT:
67286 + case PTRACE_POKEDATA:
67287 + case PTRACE_POKEUSR:
67288 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
67289 + case PTRACE_SETREGS:
67290 + case PTRACE_SETFPREGS:
67291 +#endif
67292 +#ifdef CONFIG_X86
67293 + case PTRACE_SETFPXREGS:
67294 +#endif
67295 +#ifdef CONFIG_ALTIVEC
67296 + case PTRACE_SETVRREGS:
67297 +#endif
67298 + return 1;
67299 + default:
67300 + return 0;
67301 + }
67302 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
67303 + !(current->role->roletype & GR_ROLE_GOD) &&
67304 + (current->acl != task->acl)) {
67305 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
67306 + return 1;
67307 + }
67308 +
67309 + return 0;
67310 +}
67311 +
67312 +static int is_writable_mmap(const struct file *filp)
67313 +{
67314 + struct task_struct *task = current;
67315 + struct acl_object_label *obj, *obj2;
67316 +
67317 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
67318 + !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))) {
67319 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
67320 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
67321 + task->role->root_label);
67322 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
67323 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
67324 + return 1;
67325 + }
67326 + }
67327 + return 0;
67328 +}
67329 +
67330 +int
67331 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
67332 +{
67333 + __u32 mode;
67334 +
67335 + if (unlikely(!file || !(prot & PROT_EXEC)))
67336 + return 1;
67337 +
67338 + if (is_writable_mmap(file))
67339 + return 0;
67340 +
67341 + mode =
67342 + gr_search_file(file->f_path.dentry,
67343 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
67344 + file->f_path.mnt);
67345 +
67346 + if (!gr_tpe_allow(file))
67347 + return 0;
67348 +
67349 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
67350 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
67351 + return 0;
67352 + } else if (unlikely(!(mode & GR_EXEC))) {
67353 + return 0;
67354 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
67355 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
67356 + return 1;
67357 + }
67358 +
67359 + return 1;
67360 +}
67361 +
67362 +int
67363 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
67364 +{
67365 + __u32 mode;
67366 +
67367 + if (unlikely(!file || !(prot & PROT_EXEC)))
67368 + return 1;
67369 +
67370 + if (is_writable_mmap(file))
67371 + return 0;
67372 +
67373 + mode =
67374 + gr_search_file(file->f_path.dentry,
67375 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
67376 + file->f_path.mnt);
67377 +
67378 + if (!gr_tpe_allow(file))
67379 + return 0;
67380 +
67381 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
67382 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
67383 + return 0;
67384 + } else if (unlikely(!(mode & GR_EXEC))) {
67385 + return 0;
67386 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
67387 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
67388 + return 1;
67389 + }
67390 +
67391 + return 1;
67392 +}
67393 +
67394 +void
67395 +gr_acl_handle_psacct(struct task_struct *task, const long code)
67396 +{
67397 + unsigned long runtime;
67398 + unsigned long cputime;
67399 + unsigned int wday, cday;
67400 + __u8 whr, chr;
67401 + __u8 wmin, cmin;
67402 + __u8 wsec, csec;
67403 + struct timespec timeval;
67404 +
67405 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
67406 + !(task->acl->mode & GR_PROCACCT)))
67407 + return;
67408 +
67409 + do_posix_clock_monotonic_gettime(&timeval);
67410 + runtime = timeval.tv_sec - task->start_time.tv_sec;
67411 + wday = runtime / (3600 * 24);
67412 + runtime -= wday * (3600 * 24);
67413 + whr = runtime / 3600;
67414 + runtime -= whr * 3600;
67415 + wmin = runtime / 60;
67416 + runtime -= wmin * 60;
67417 + wsec = runtime;
67418 +
67419 + cputime = (task->utime + task->stime) / HZ;
67420 + cday = cputime / (3600 * 24);
67421 + cputime -= cday * (3600 * 24);
67422 + chr = cputime / 3600;
67423 + cputime -= chr * 3600;
67424 + cmin = cputime / 60;
67425 + cputime -= cmin * 60;
67426 + csec = cputime;
67427 +
67428 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
67429 +
67430 + return;
67431 +}
67432 +
67433 +void gr_set_kernel_label(struct task_struct *task)
67434 +{
67435 + if (gr_status & GR_READY) {
67436 + task->role = kernel_role;
67437 + task->acl = kernel_role->root_label;
67438 + }
67439 + return;
67440 +}
67441 +
67442 +#ifdef CONFIG_TASKSTATS
67443 +int gr_is_taskstats_denied(int pid)
67444 +{
67445 + struct task_struct *task;
67446 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
67447 + const struct cred *cred;
67448 +#endif
67449 + int ret = 0;
67450 +
67451 + /* restrict taskstats viewing to un-chrooted root users
67452 + who have the 'view' subject flag if the RBAC system is enabled
67453 + */
67454 +
67455 + rcu_read_lock();
67456 + read_lock(&tasklist_lock);
67457 + task = find_task_by_vpid(pid);
67458 + if (task) {
67459 +#ifdef CONFIG_GRKERNSEC_CHROOT
67460 + if (proc_is_chrooted(task))
67461 + ret = -EACCES;
67462 +#endif
67463 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
67464 + cred = __task_cred(task);
67465 +#ifdef CONFIG_GRKERNSEC_PROC_USER
67466 + if (gr_is_global_nonroot(cred->uid))
67467 + ret = -EACCES;
67468 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
67469 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
67470 + ret = -EACCES;
67471 +#endif
67472 +#endif
67473 + if (gr_status & GR_READY) {
67474 + if (!(task->acl->mode & GR_VIEW))
67475 + ret = -EACCES;
67476 + }
67477 + } else
67478 + ret = -ENOENT;
67479 +
67480 + read_unlock(&tasklist_lock);
67481 + rcu_read_unlock();
67482 +
67483 + return ret;
67484 +}
67485 +#endif
67486 +
67487 +/* AUXV entries are filled via a descendant of search_binary_handler
67488 + after we've already applied the subject for the target
67489 +*/
67490 +int gr_acl_enable_at_secure(void)
67491 +{
67492 + if (unlikely(!(gr_status & GR_READY)))
67493 + return 0;
67494 +
67495 + if (current->acl->mode & GR_ATSECURE)
67496 + return 1;
67497 +
67498 + return 0;
67499 +}
67500 +
67501 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
67502 +{
67503 + struct task_struct *task = current;
67504 + struct dentry *dentry = file->f_path.dentry;
67505 + struct vfsmount *mnt = file->f_path.mnt;
67506 + struct acl_object_label *obj, *tmp;
67507 + struct acl_subject_label *subj;
67508 + unsigned int bufsize;
67509 + int is_not_root;
67510 + char *path;
67511 + dev_t dev = __get_dev(dentry);
67512 +
67513 + if (unlikely(!(gr_status & GR_READY)))
67514 + return 1;
67515 +
67516 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
67517 + return 1;
67518 +
67519 + /* ignore Eric Biederman */
67520 + if (IS_PRIVATE(dentry->d_inode))
67521 + return 1;
67522 +
67523 + subj = task->acl;
67524 + read_lock(&gr_inode_lock);
67525 + do {
67526 + obj = lookup_acl_obj_label(ino, dev, subj);
67527 + if (obj != NULL) {
67528 + read_unlock(&gr_inode_lock);
67529 + return (obj->mode & GR_FIND) ? 1 : 0;
67530 + }
67531 + } while ((subj = subj->parent_subject));
67532 + read_unlock(&gr_inode_lock);
67533 +
67534 + /* this is purely an optimization since we're looking for an object
67535 + for the directory we're doing a readdir on
67536 + if it's possible for any globbed object to match the entry we're
67537 + filling into the directory, then the object we find here will be
67538 + an anchor point with attached globbed objects
67539 + */
67540 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
67541 + if (obj->globbed == NULL)
67542 + return (obj->mode & GR_FIND) ? 1 : 0;
67543 +
67544 + is_not_root = ((obj->filename[0] == '/') &&
67545 + (obj->filename[1] == '\0')) ? 0 : 1;
67546 + bufsize = PAGE_SIZE - namelen - is_not_root;
67547 +
67548 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
67549 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
67550 + return 1;
67551 +
67552 + preempt_disable();
67553 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
67554 + bufsize);
67555 +
67556 + bufsize = strlen(path);
67557 +
67558 + /* if base is "/", don't append an additional slash */
67559 + if (is_not_root)
67560 + *(path + bufsize) = '/';
67561 + memcpy(path + bufsize + is_not_root, name, namelen);
67562 + *(path + bufsize + namelen + is_not_root) = '\0';
67563 +
67564 + tmp = obj->globbed;
67565 + while (tmp) {
67566 + if (!glob_match(tmp->filename, path)) {
67567 + preempt_enable();
67568 + return (tmp->mode & GR_FIND) ? 1 : 0;
67569 + }
67570 + tmp = tmp->next;
67571 + }
67572 + preempt_enable();
67573 + return (obj->mode & GR_FIND) ? 1 : 0;
67574 +}
67575 +
67576 +void gr_put_exec_file(struct task_struct *task)
67577 +{
67578 + struct file *filp;
67579 +
67580 + write_lock(&grsec_exec_file_lock);
67581 + filp = task->exec_file;
67582 + task->exec_file = NULL;
67583 + write_unlock(&grsec_exec_file_lock);
67584 +
67585 + if (filp)
67586 + fput(filp);
67587 +
67588 + return;
67589 +}
67590 +
67591 +
67592 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
67593 +EXPORT_SYMBOL(gr_acl_is_enabled);
67594 +#endif
67595 +EXPORT_SYMBOL(gr_set_kernel_label);
67596 +#ifdef CONFIG_SECURITY
67597 +EXPORT_SYMBOL(gr_check_user_change);
67598 +EXPORT_SYMBOL(gr_check_group_change);
67599 +#endif
67600 +
67601 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
67602 new file mode 100644
67603 index 0000000..34fefda
67604 --- /dev/null
67605 +++ b/grsecurity/gracl_alloc.c
67606 @@ -0,0 +1,105 @@
67607 +#include <linux/kernel.h>
67608 +#include <linux/mm.h>
67609 +#include <linux/slab.h>
67610 +#include <linux/vmalloc.h>
67611 +#include <linux/gracl.h>
67612 +#include <linux/grsecurity.h>
67613 +
67614 +static unsigned long alloc_stack_next = 1;
67615 +static unsigned long alloc_stack_size = 1;
67616 +static void **alloc_stack;
67617 +
67618 +static __inline__ int
67619 +alloc_pop(void)
67620 +{
67621 + if (alloc_stack_next == 1)
67622 + return 0;
67623 +
67624 + kfree(alloc_stack[alloc_stack_next - 2]);
67625 +
67626 + alloc_stack_next--;
67627 +
67628 + return 1;
67629 +}
67630 +
67631 +static __inline__ int
67632 +alloc_push(void *buf)
67633 +{
67634 + if (alloc_stack_next >= alloc_stack_size)
67635 + return 1;
67636 +
67637 + alloc_stack[alloc_stack_next - 1] = buf;
67638 +
67639 + alloc_stack_next++;
67640 +
67641 + return 0;
67642 +}
67643 +
67644 +void *
67645 +acl_alloc(unsigned long len)
67646 +{
67647 + void *ret = NULL;
67648 +
67649 + if (!len || len > PAGE_SIZE)
67650 + goto out;
67651 +
67652 + ret = kmalloc(len, GFP_KERNEL);
67653 +
67654 + if (ret) {
67655 + if (alloc_push(ret)) {
67656 + kfree(ret);
67657 + ret = NULL;
67658 + }
67659 + }
67660 +
67661 +out:
67662 + return ret;
67663 +}
67664 +
67665 +void *
67666 +acl_alloc_num(unsigned long num, unsigned long len)
67667 +{
67668 + if (!len || (num > (PAGE_SIZE / len)))
67669 + return NULL;
67670 +
67671 + return acl_alloc(num * len);
67672 +}
67673 +
67674 +void
67675 +acl_free_all(void)
67676 +{
67677 + if (gr_acl_is_enabled() || !alloc_stack)
67678 + return;
67679 +
67680 + while (alloc_pop()) ;
67681 +
67682 + if (alloc_stack) {
67683 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
67684 + kfree(alloc_stack);
67685 + else
67686 + vfree(alloc_stack);
67687 + }
67688 +
67689 + alloc_stack = NULL;
67690 + alloc_stack_size = 1;
67691 + alloc_stack_next = 1;
67692 +
67693 + return;
67694 +}
67695 +
67696 +int
67697 +acl_alloc_stack_init(unsigned long size)
67698 +{
67699 + if ((size * sizeof (void *)) <= PAGE_SIZE)
67700 + alloc_stack =
67701 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
67702 + else
67703 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
67704 +
67705 + alloc_stack_size = size;
67706 +
67707 + if (!alloc_stack)
67708 + return 0;
67709 + else
67710 + return 1;
67711 +}
67712 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
67713 new file mode 100644
67714 index 0000000..bdd51ea
67715 --- /dev/null
67716 +++ b/grsecurity/gracl_cap.c
67717 @@ -0,0 +1,110 @@
67718 +#include <linux/kernel.h>
67719 +#include <linux/module.h>
67720 +#include <linux/sched.h>
67721 +#include <linux/gracl.h>
67722 +#include <linux/grsecurity.h>
67723 +#include <linux/grinternal.h>
67724 +
67725 +extern const char *captab_log[];
67726 +extern int captab_log_entries;
67727 +
67728 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
67729 +{
67730 + struct acl_subject_label *curracl;
67731 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
67732 + kernel_cap_t cap_audit = __cap_empty_set;
67733 +
67734 + if (!gr_acl_is_enabled())
67735 + return 1;
67736 +
67737 + curracl = task->acl;
67738 +
67739 + cap_drop = curracl->cap_lower;
67740 + cap_mask = curracl->cap_mask;
67741 + cap_audit = curracl->cap_invert_audit;
67742 +
67743 + while ((curracl = curracl->parent_subject)) {
67744 + /* if the cap isn't specified in the current computed mask but is specified in the
67745 + current level subject, and is lowered in the current level subject, then add
67746 + it to the set of dropped capabilities
67747 + otherwise, add the current level subject's mask to the current computed mask
67748 + */
67749 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
67750 + cap_raise(cap_mask, cap);
67751 + if (cap_raised(curracl->cap_lower, cap))
67752 + cap_raise(cap_drop, cap);
67753 + if (cap_raised(curracl->cap_invert_audit, cap))
67754 + cap_raise(cap_audit, cap);
67755 + }
67756 + }
67757 +
67758 + if (!cap_raised(cap_drop, cap)) {
67759 + if (cap_raised(cap_audit, cap))
67760 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
67761 + return 1;
67762 + }
67763 +
67764 + curracl = task->acl;
67765 +
67766 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
67767 + && cap_raised(cred->cap_effective, cap)) {
67768 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
67769 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
67770 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
67771 + gr_to_filename(task->exec_file->f_path.dentry,
67772 + task->exec_file->f_path.mnt) : curracl->filename,
67773 + curracl->filename, 0UL,
67774 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
67775 + return 1;
67776 + }
67777 +
67778 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
67779 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
67780 +
67781 + return 0;
67782 +}
67783 +
67784 +int
67785 +gr_acl_is_capable(const int cap)
67786 +{
67787 + return gr_task_acl_is_capable(current, current_cred(), cap);
67788 +}
67789 +
67790 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
67791 +{
67792 + struct acl_subject_label *curracl;
67793 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
67794 +
67795 + if (!gr_acl_is_enabled())
67796 + return 1;
67797 +
67798 + curracl = task->acl;
67799 +
67800 + cap_drop = curracl->cap_lower;
67801 + cap_mask = curracl->cap_mask;
67802 +
67803 + while ((curracl = curracl->parent_subject)) {
67804 + /* if the cap isn't specified in the current computed mask but is specified in the
67805 + current level subject, and is lowered in the current level subject, then add
67806 + it to the set of dropped capabilities
67807 + otherwise, add the current level subject's mask to the current computed mask
67808 + */
67809 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
67810 + cap_raise(cap_mask, cap);
67811 + if (cap_raised(curracl->cap_lower, cap))
67812 + cap_raise(cap_drop, cap);
67813 + }
67814 + }
67815 +
67816 + if (!cap_raised(cap_drop, cap))
67817 + return 1;
67818 +
67819 + return 0;
67820 +}
67821 +
67822 +int
67823 +gr_acl_is_capable_nolog(const int cap)
67824 +{
67825 + return gr_task_acl_is_capable_nolog(current, cap);
67826 +}
67827 +
67828 diff --git a/grsecurity/gracl_compat.c b/grsecurity/gracl_compat.c
67829 new file mode 100644
67830 index 0000000..a43dd06
67831 --- /dev/null
67832 +++ b/grsecurity/gracl_compat.c
67833 @@ -0,0 +1,269 @@
67834 +#include <linux/kernel.h>
67835 +#include <linux/gracl.h>
67836 +#include <linux/compat.h>
67837 +#include <linux/gracl_compat.h>
67838 +
67839 +#include <asm/uaccess.h>
67840 +
67841 +int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap)
67842 +{
67843 + struct gr_arg_wrapper_compat uwrapcompat;
67844 +
67845 + if (copy_from_user(&uwrapcompat, buf, sizeof(uwrapcompat)))
67846 + return -EFAULT;
67847 +
67848 + if ((uwrapcompat.version != GRSECURITY_VERSION) ||
67849 + (uwrapcompat.size != sizeof(struct gr_arg_compat)))
67850 + return -EINVAL;
67851 +
67852 + uwrap->arg = compat_ptr(uwrapcompat.arg);
67853 + uwrap->version = uwrapcompat.version;
67854 + uwrap->size = sizeof(struct gr_arg);
67855 +
67856 + return 0;
67857 +}
67858 +
67859 +int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg)
67860 +{
67861 + struct gr_arg_compat argcompat;
67862 +
67863 + if (copy_from_user(&argcompat, buf, sizeof(argcompat)))
67864 + return -EFAULT;
67865 +
67866 + arg->role_db.r_table = compat_ptr(argcompat.role_db.r_table);
67867 + arg->role_db.num_pointers = argcompat.role_db.num_pointers;
67868 + arg->role_db.num_roles = argcompat.role_db.num_roles;
67869 + arg->role_db.num_domain_children = argcompat.role_db.num_domain_children;
67870 + arg->role_db.num_subjects = argcompat.role_db.num_subjects;
67871 + arg->role_db.num_objects = argcompat.role_db.num_objects;
67872 +
67873 + memcpy(&arg->pw, &argcompat.pw, sizeof(arg->pw));
67874 + memcpy(&arg->salt, &argcompat.salt, sizeof(arg->salt));
67875 + memcpy(&arg->sum, &argcompat.sum, sizeof(arg->sum));
67876 + memcpy(&arg->sp_role, &argcompat.sp_role, sizeof(arg->sp_role));
67877 + arg->sprole_pws = compat_ptr(argcompat.sprole_pws);
67878 + arg->segv_device = argcompat.segv_device;
67879 + arg->segv_inode = argcompat.segv_inode;
67880 + arg->segv_uid = argcompat.segv_uid;
67881 + arg->num_sprole_pws = argcompat.num_sprole_pws;
67882 + arg->mode = argcompat.mode;
67883 +
67884 + return 0;
67885 +}
67886 +
67887 +int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp)
67888 +{
67889 + struct acl_object_label_compat objcompat;
67890 +
67891 + if (copy_from_user(&objcompat, userp, sizeof(objcompat)))
67892 + return -EFAULT;
67893 +
67894 + obj->filename = compat_ptr(objcompat.filename);
67895 + obj->inode = objcompat.inode;
67896 + obj->device = objcompat.device;
67897 + obj->mode = objcompat.mode;
67898 +
67899 + obj->nested = compat_ptr(objcompat.nested);
67900 + obj->globbed = compat_ptr(objcompat.globbed);
67901 +
67902 + obj->prev = compat_ptr(objcompat.prev);
67903 + obj->next = compat_ptr(objcompat.next);
67904 +
67905 + return 0;
67906 +}
67907 +
67908 +int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp)
67909 +{
67910 + unsigned int i;
67911 + struct acl_subject_label_compat subjcompat;
67912 +
67913 + if (copy_from_user(&subjcompat, userp, sizeof(subjcompat)))
67914 + return -EFAULT;
67915 +
67916 + subj->filename = compat_ptr(subjcompat.filename);
67917 + subj->inode = subjcompat.inode;
67918 + subj->device = subjcompat.device;
67919 + subj->mode = subjcompat.mode;
67920 + subj->cap_mask = subjcompat.cap_mask;
67921 + subj->cap_lower = subjcompat.cap_lower;
67922 + subj->cap_invert_audit = subjcompat.cap_invert_audit;
67923 +
67924 + for (i = 0; i < GR_NLIMITS; i++) {
67925 + if (subjcompat.res[i].rlim_cur == COMPAT_RLIM_INFINITY)
67926 + subj->res[i].rlim_cur = RLIM_INFINITY;
67927 + else
67928 + subj->res[i].rlim_cur = subjcompat.res[i].rlim_cur;
67929 + if (subjcompat.res[i].rlim_max == COMPAT_RLIM_INFINITY)
67930 + subj->res[i].rlim_max = RLIM_INFINITY;
67931 + else
67932 + subj->res[i].rlim_max = subjcompat.res[i].rlim_max;
67933 + }
67934 + subj->resmask = subjcompat.resmask;
67935 +
67936 + subj->user_trans_type = subjcompat.user_trans_type;
67937 + subj->group_trans_type = subjcompat.group_trans_type;
67938 + subj->user_transitions = compat_ptr(subjcompat.user_transitions);
67939 + subj->group_transitions = compat_ptr(subjcompat.group_transitions);
67940 + subj->user_trans_num = subjcompat.user_trans_num;
67941 + subj->group_trans_num = subjcompat.group_trans_num;
67942 +
67943 + memcpy(&subj->sock_families, &subjcompat.sock_families, sizeof(subj->sock_families));
67944 + memcpy(&subj->ip_proto, &subjcompat.ip_proto, sizeof(subj->ip_proto));
67945 + subj->ip_type = subjcompat.ip_type;
67946 + subj->ips = compat_ptr(subjcompat.ips);
67947 + subj->ip_num = subjcompat.ip_num;
67948 + subj->inaddr_any_override = subjcompat.inaddr_any_override;
67949 +
67950 + subj->crashes = subjcompat.crashes;
67951 + subj->expires = subjcompat.expires;
67952 +
67953 + subj->parent_subject = compat_ptr(subjcompat.parent_subject);
67954 + subj->hash = compat_ptr(subjcompat.hash);
67955 + subj->prev = compat_ptr(subjcompat.prev);
67956 + subj->next = compat_ptr(subjcompat.next);
67957 +
67958 + subj->obj_hash = compat_ptr(subjcompat.obj_hash);
67959 + subj->obj_hash_size = subjcompat.obj_hash_size;
67960 + subj->pax_flags = subjcompat.pax_flags;
67961 +
67962 + return 0;
67963 +}
67964 +
67965 +int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp)
67966 +{
67967 + struct acl_role_label_compat rolecompat;
67968 +
67969 + if (copy_from_user(&rolecompat, userp, sizeof(rolecompat)))
67970 + return -EFAULT;
67971 +
67972 + role->rolename = compat_ptr(rolecompat.rolename);
67973 + role->uidgid = rolecompat.uidgid;
67974 + role->roletype = rolecompat.roletype;
67975 +
67976 + role->auth_attempts = rolecompat.auth_attempts;
67977 + role->expires = rolecompat.expires;
67978 +
67979 + role->root_label = compat_ptr(rolecompat.root_label);
67980 + role->hash = compat_ptr(rolecompat.hash);
67981 +
67982 + role->prev = compat_ptr(rolecompat.prev);
67983 + role->next = compat_ptr(rolecompat.next);
67984 +
67985 + role->transitions = compat_ptr(rolecompat.transitions);
67986 + role->allowed_ips = compat_ptr(rolecompat.allowed_ips);
67987 + role->domain_children = compat_ptr(rolecompat.domain_children);
67988 + role->domain_child_num = rolecompat.domain_child_num;
67989 +
67990 + role->umask = rolecompat.umask;
67991 +
67992 + role->subj_hash = compat_ptr(rolecompat.subj_hash);
67993 + role->subj_hash_size = rolecompat.subj_hash_size;
67994 +
67995 + return 0;
67996 +}
67997 +
67998 +int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
67999 +{
68000 + struct role_allowed_ip_compat roleip_compat;
68001 +
68002 + if (copy_from_user(&roleip_compat, userp, sizeof(roleip_compat)))
68003 + return -EFAULT;
68004 +
68005 + roleip->addr = roleip_compat.addr;
68006 + roleip->netmask = roleip_compat.netmask;
68007 +
68008 + roleip->prev = compat_ptr(roleip_compat.prev);
68009 + roleip->next = compat_ptr(roleip_compat.next);
68010 +
68011 + return 0;
68012 +}
68013 +
68014 +int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp)
68015 +{
68016 + struct role_transition_compat trans_compat;
68017 +
68018 + if (copy_from_user(&trans_compat, userp, sizeof(trans_compat)))
68019 + return -EFAULT;
68020 +
68021 + trans->rolename = compat_ptr(trans_compat.rolename);
68022 +
68023 + trans->prev = compat_ptr(trans_compat.prev);
68024 + trans->next = compat_ptr(trans_compat.next);
68025 +
68026 + return 0;
68027 +
68028 +}
68029 +
68030 +int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
68031 +{
68032 + struct gr_hash_struct_compat hash_compat;
68033 +
68034 + if (copy_from_user(&hash_compat, userp, sizeof(hash_compat)))
68035 + return -EFAULT;
68036 +
68037 + hash->table = compat_ptr(hash_compat.table);
68038 + hash->nametable = compat_ptr(hash_compat.nametable);
68039 + hash->first = compat_ptr(hash_compat.first);
68040 +
68041 + hash->table_size = hash_compat.table_size;
68042 + hash->used_size = hash_compat.used_size;
68043 +
68044 + hash->type = hash_compat.type;
68045 +
68046 + return 0;
68047 +}
68048 +
68049 +int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp)
68050 +{
68051 + compat_uptr_t ptrcompat;
68052 +
68053 + if (copy_from_user(&ptrcompat, userp + (idx * sizeof(ptrcompat)), sizeof(ptrcompat)))
68054 + return -EFAULT;
68055 +
68056 + *(void **)ptr = compat_ptr(ptrcompat);
68057 +
68058 + return 0;
68059 +}
68060 +
68061 +int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp)
68062 +{
68063 + struct acl_ip_label_compat ip_compat;
68064 +
68065 + if (copy_from_user(&ip_compat, userp, sizeof(ip_compat)))
68066 + return -EFAULT;
68067 +
68068 + ip->iface = compat_ptr(ip_compat.iface);
68069 + ip->addr = ip_compat.addr;
68070 + ip->netmask = ip_compat.netmask;
68071 + ip->low = ip_compat.low;
68072 + ip->high = ip_compat.high;
68073 + ip->mode = ip_compat.mode;
68074 + ip->type = ip_compat.type;
68075 +
68076 + memcpy(&ip->proto, &ip_compat.proto, sizeof(ip->proto));
68077 +
68078 + ip->prev = compat_ptr(ip_compat.prev);
68079 + ip->next = compat_ptr(ip_compat.next);
68080 +
68081 + return 0;
68082 +}
68083 +
68084 +int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
68085 +{
68086 + struct sprole_pw_compat pw_compat;
68087 +
68088 + if (copy_from_user(&pw_compat, (const void *)userp + (sizeof(pw_compat) * idx), sizeof(pw_compat)))
68089 + return -EFAULT;
68090 +
68091 + pw->rolename = compat_ptr(pw_compat.rolename);
68092 + memcpy(&pw->salt, pw_compat.salt, sizeof(pw->salt));
68093 + memcpy(&pw->sum, pw_compat.sum, sizeof(pw->sum));
68094 +
68095 + return 0;
68096 +}
68097 +
68098 +size_t get_gr_arg_wrapper_size_compat(void)
68099 +{
68100 + return sizeof(struct gr_arg_wrapper_compat);
68101 +}
68102 +
68103 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
68104 new file mode 100644
68105 index 0000000..a340c17
68106 --- /dev/null
68107 +++ b/grsecurity/gracl_fs.c
68108 @@ -0,0 +1,431 @@
68109 +#include <linux/kernel.h>
68110 +#include <linux/sched.h>
68111 +#include <linux/types.h>
68112 +#include <linux/fs.h>
68113 +#include <linux/file.h>
68114 +#include <linux/stat.h>
68115 +#include <linux/grsecurity.h>
68116 +#include <linux/grinternal.h>
68117 +#include <linux/gracl.h>
68118 +
68119 +umode_t
68120 +gr_acl_umask(void)
68121 +{
68122 + if (unlikely(!gr_acl_is_enabled()))
68123 + return 0;
68124 +
68125 + return current->role->umask;
68126 +}
68127 +
68128 +__u32
68129 +gr_acl_handle_hidden_file(const struct dentry * dentry,
68130 + const struct vfsmount * mnt)
68131 +{
68132 + __u32 mode;
68133 +
68134 + if (unlikely(!dentry->d_inode))
68135 + return GR_FIND;
68136 +
68137 + mode =
68138 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
68139 +
68140 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
68141 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
68142 + return mode;
68143 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
68144 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
68145 + return 0;
68146 + } else if (unlikely(!(mode & GR_FIND)))
68147 + return 0;
68148 +
68149 + return GR_FIND;
68150 +}
68151 +
68152 +__u32
68153 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
68154 + int acc_mode)
68155 +{
68156 + __u32 reqmode = GR_FIND;
68157 + __u32 mode;
68158 +
68159 + if (unlikely(!dentry->d_inode))
68160 + return reqmode;
68161 +
68162 + if (acc_mode & MAY_APPEND)
68163 + reqmode |= GR_APPEND;
68164 + else if (acc_mode & MAY_WRITE)
68165 + reqmode |= GR_WRITE;
68166 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
68167 + reqmode |= GR_READ;
68168 +
68169 + mode =
68170 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
68171 + mnt);
68172 +
68173 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
68174 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
68175 + reqmode & GR_READ ? " reading" : "",
68176 + reqmode & GR_WRITE ? " writing" : reqmode &
68177 + GR_APPEND ? " appending" : "");
68178 + return reqmode;
68179 + } else
68180 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
68181 + {
68182 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
68183 + reqmode & GR_READ ? " reading" : "",
68184 + reqmode & GR_WRITE ? " writing" : reqmode &
68185 + GR_APPEND ? " appending" : "");
68186 + return 0;
68187 + } else if (unlikely((mode & reqmode) != reqmode))
68188 + return 0;
68189 +
68190 + return reqmode;
68191 +}
68192 +
68193 +__u32
68194 +gr_acl_handle_creat(const struct dentry * dentry,
68195 + const struct dentry * p_dentry,
68196 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
68197 + const int imode)
68198 +{
68199 + __u32 reqmode = GR_WRITE | GR_CREATE;
68200 + __u32 mode;
68201 +
68202 + if (acc_mode & MAY_APPEND)
68203 + reqmode |= GR_APPEND;
68204 + // if a directory was required or the directory already exists, then
68205 + // don't count this open as a read
68206 + if ((acc_mode & MAY_READ) &&
68207 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
68208 + reqmode |= GR_READ;
68209 + if ((open_flags & O_CREAT) &&
68210 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
68211 + reqmode |= GR_SETID;
68212 +
68213 + mode =
68214 + gr_check_create(dentry, p_dentry, p_mnt,
68215 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
68216 +
68217 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
68218 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
68219 + reqmode & GR_READ ? " reading" : "",
68220 + reqmode & GR_WRITE ? " writing" : reqmode &
68221 + GR_APPEND ? " appending" : "");
68222 + return reqmode;
68223 + } else
68224 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
68225 + {
68226 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
68227 + reqmode & GR_READ ? " reading" : "",
68228 + reqmode & GR_WRITE ? " writing" : reqmode &
68229 + GR_APPEND ? " appending" : "");
68230 + return 0;
68231 + } else if (unlikely((mode & reqmode) != reqmode))
68232 + return 0;
68233 +
68234 + return reqmode;
68235 +}
68236 +
68237 +__u32
68238 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
68239 + const int fmode)
68240 +{
68241 + __u32 mode, reqmode = GR_FIND;
68242 +
68243 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
68244 + reqmode |= GR_EXEC;
68245 + if (fmode & S_IWOTH)
68246 + reqmode |= GR_WRITE;
68247 + if (fmode & S_IROTH)
68248 + reqmode |= GR_READ;
68249 +
68250 + mode =
68251 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
68252 + mnt);
68253 +
68254 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
68255 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
68256 + reqmode & GR_READ ? " reading" : "",
68257 + reqmode & GR_WRITE ? " writing" : "",
68258 + reqmode & GR_EXEC ? " executing" : "");
68259 + return reqmode;
68260 + } else
68261 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
68262 + {
68263 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
68264 + reqmode & GR_READ ? " reading" : "",
68265 + reqmode & GR_WRITE ? " writing" : "",
68266 + reqmode & GR_EXEC ? " executing" : "");
68267 + return 0;
68268 + } else if (unlikely((mode & reqmode) != reqmode))
68269 + return 0;
68270 +
68271 + return reqmode;
68272 +}
68273 +
68274 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
68275 +{
68276 + __u32 mode;
68277 +
68278 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
68279 +
68280 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
68281 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
68282 + return mode;
68283 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
68284 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
68285 + return 0;
68286 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
68287 + return 0;
68288 +
68289 + return (reqmode);
68290 +}
68291 +
68292 +__u32
68293 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
68294 +{
68295 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
68296 +}
68297 +
68298 +__u32
68299 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
68300 +{
68301 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
68302 +}
68303 +
68304 +__u32
68305 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
68306 +{
68307 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
68308 +}
68309 +
68310 +__u32
68311 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
68312 +{
68313 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
68314 +}
68315 +
68316 +__u32
68317 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
68318 + umode_t *modeptr)
68319 +{
68320 + umode_t mode;
68321 +
68322 + *modeptr &= ~gr_acl_umask();
68323 + mode = *modeptr;
68324 +
68325 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
68326 + return 1;
68327 +
68328 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
68329 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
68330 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
68331 + GR_CHMOD_ACL_MSG);
68332 + } else {
68333 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
68334 + }
68335 +}
68336 +
68337 +__u32
68338 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
68339 +{
68340 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
68341 +}
68342 +
68343 +__u32
68344 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
68345 +{
68346 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
68347 +}
68348 +
68349 +__u32
68350 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
68351 +{
68352 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
68353 +}
68354 +
68355 +__u32
68356 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
68357 +{
68358 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
68359 + GR_UNIXCONNECT_ACL_MSG);
68360 +}
68361 +
68362 +/* hardlinks require at minimum create and link permission,
68363 + any additional privilege required is based on the
68364 + privilege of the file being linked to
68365 +*/
68366 +__u32
68367 +gr_acl_handle_link(const struct dentry * new_dentry,
68368 + const struct dentry * parent_dentry,
68369 + const struct vfsmount * parent_mnt,
68370 + const struct dentry * old_dentry,
68371 + const struct vfsmount * old_mnt, const struct filename *to)
68372 +{
68373 + __u32 mode;
68374 + __u32 needmode = GR_CREATE | GR_LINK;
68375 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
68376 +
68377 + mode =
68378 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
68379 + old_mnt);
68380 +
68381 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
68382 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
68383 + return mode;
68384 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
68385 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
68386 + return 0;
68387 + } else if (unlikely((mode & needmode) != needmode))
68388 + return 0;
68389 +
68390 + return 1;
68391 +}
68392 +
68393 +__u32
68394 +gr_acl_handle_symlink(const struct dentry * new_dentry,
68395 + const struct dentry * parent_dentry,
68396 + const struct vfsmount * parent_mnt, const struct filename *from)
68397 +{
68398 + __u32 needmode = GR_WRITE | GR_CREATE;
68399 + __u32 mode;
68400 +
68401 + mode =
68402 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
68403 + GR_CREATE | GR_AUDIT_CREATE |
68404 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
68405 +
68406 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
68407 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
68408 + return mode;
68409 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
68410 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
68411 + return 0;
68412 + } else if (unlikely((mode & needmode) != needmode))
68413 + return 0;
68414 +
68415 + return (GR_WRITE | GR_CREATE);
68416 +}
68417 +
68418 +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)
68419 +{
68420 + __u32 mode;
68421 +
68422 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
68423 +
68424 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
68425 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
68426 + return mode;
68427 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
68428 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
68429 + return 0;
68430 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
68431 + return 0;
68432 +
68433 + return (reqmode);
68434 +}
68435 +
68436 +__u32
68437 +gr_acl_handle_mknod(const struct dentry * new_dentry,
68438 + const struct dentry * parent_dentry,
68439 + const struct vfsmount * parent_mnt,
68440 + const int mode)
68441 +{
68442 + __u32 reqmode = GR_WRITE | GR_CREATE;
68443 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
68444 + reqmode |= GR_SETID;
68445 +
68446 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
68447 + reqmode, GR_MKNOD_ACL_MSG);
68448 +}
68449 +
68450 +__u32
68451 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
68452 + const struct dentry *parent_dentry,
68453 + const struct vfsmount *parent_mnt)
68454 +{
68455 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
68456 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
68457 +}
68458 +
68459 +#define RENAME_CHECK_SUCCESS(old, new) \
68460 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
68461 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
68462 +
68463 +int
68464 +gr_acl_handle_rename(struct dentry *new_dentry,
68465 + struct dentry *parent_dentry,
68466 + const struct vfsmount *parent_mnt,
68467 + struct dentry *old_dentry,
68468 + struct inode *old_parent_inode,
68469 + struct vfsmount *old_mnt, const struct filename *newname)
68470 +{
68471 + __u32 comp1, comp2;
68472 + int error = 0;
68473 +
68474 + if (unlikely(!gr_acl_is_enabled()))
68475 + return 0;
68476 +
68477 + if (!new_dentry->d_inode) {
68478 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
68479 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
68480 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
68481 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
68482 + GR_DELETE | GR_AUDIT_DELETE |
68483 + GR_AUDIT_READ | GR_AUDIT_WRITE |
68484 + GR_SUPPRESS, old_mnt);
68485 + } else {
68486 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
68487 + GR_CREATE | GR_DELETE |
68488 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
68489 + GR_AUDIT_READ | GR_AUDIT_WRITE |
68490 + GR_SUPPRESS, parent_mnt);
68491 + comp2 =
68492 + gr_search_file(old_dentry,
68493 + GR_READ | GR_WRITE | GR_AUDIT_READ |
68494 + GR_DELETE | GR_AUDIT_DELETE |
68495 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
68496 + }
68497 +
68498 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
68499 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
68500 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
68501 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
68502 + && !(comp2 & GR_SUPPRESS)) {
68503 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
68504 + error = -EACCES;
68505 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
68506 + error = -EACCES;
68507 +
68508 + return error;
68509 +}
68510 +
68511 +void
68512 +gr_acl_handle_exit(void)
68513 +{
68514 + u16 id;
68515 + char *rolename;
68516 +
68517 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
68518 + !(current->role->roletype & GR_ROLE_PERSIST))) {
68519 + id = current->acl_role_id;
68520 + rolename = current->role->rolename;
68521 + gr_set_acls(1);
68522 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
68523 + }
68524 +
68525 + gr_put_exec_file(current);
68526 + return;
68527 +}
68528 +
68529 +int
68530 +gr_acl_handle_procpidmem(const struct task_struct *task)
68531 +{
68532 + if (unlikely(!gr_acl_is_enabled()))
68533 + return 0;
68534 +
68535 + if (task != current && task->acl->mode & GR_PROTPROCFD)
68536 + return -EACCES;
68537 +
68538 + return 0;
68539 +}
68540 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
68541 new file mode 100644
68542 index 0000000..8132048
68543 --- /dev/null
68544 +++ b/grsecurity/gracl_ip.c
68545 @@ -0,0 +1,387 @@
68546 +#include <linux/kernel.h>
68547 +#include <asm/uaccess.h>
68548 +#include <asm/errno.h>
68549 +#include <net/sock.h>
68550 +#include <linux/file.h>
68551 +#include <linux/fs.h>
68552 +#include <linux/net.h>
68553 +#include <linux/in.h>
68554 +#include <linux/skbuff.h>
68555 +#include <linux/ip.h>
68556 +#include <linux/udp.h>
68557 +#include <linux/types.h>
68558 +#include <linux/sched.h>
68559 +#include <linux/netdevice.h>
68560 +#include <linux/inetdevice.h>
68561 +#include <linux/gracl.h>
68562 +#include <linux/grsecurity.h>
68563 +#include <linux/grinternal.h>
68564 +
68565 +#define GR_BIND 0x01
68566 +#define GR_CONNECT 0x02
68567 +#define GR_INVERT 0x04
68568 +#define GR_BINDOVERRIDE 0x08
68569 +#define GR_CONNECTOVERRIDE 0x10
68570 +#define GR_SOCK_FAMILY 0x20
68571 +
68572 +static const char * gr_protocols[IPPROTO_MAX] = {
68573 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
68574 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
68575 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
68576 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
68577 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
68578 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
68579 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
68580 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
68581 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
68582 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
68583 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
68584 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
68585 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
68586 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
68587 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
68588 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
68589 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
68590 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
68591 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
68592 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
68593 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
68594 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
68595 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
68596 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
68597 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
68598 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
68599 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
68600 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
68601 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
68602 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
68603 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
68604 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
68605 + };
68606 +
68607 +static const char * gr_socktypes[SOCK_MAX] = {
68608 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
68609 + "unknown:7", "unknown:8", "unknown:9", "packet"
68610 + };
68611 +
68612 +static const char * gr_sockfamilies[AF_MAX+1] = {
68613 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
68614 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
68615 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
68616 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
68617 + };
68618 +
68619 +const char *
68620 +gr_proto_to_name(unsigned char proto)
68621 +{
68622 + return gr_protocols[proto];
68623 +}
68624 +
68625 +const char *
68626 +gr_socktype_to_name(unsigned char type)
68627 +{
68628 + return gr_socktypes[type];
68629 +}
68630 +
68631 +const char *
68632 +gr_sockfamily_to_name(unsigned char family)
68633 +{
68634 + return gr_sockfamilies[family];
68635 +}
68636 +
68637 +int
68638 +gr_search_socket(const int domain, const int type, const int protocol)
68639 +{
68640 + struct acl_subject_label *curr;
68641 + const struct cred *cred = current_cred();
68642 +
68643 + if (unlikely(!gr_acl_is_enabled()))
68644 + goto exit;
68645 +
68646 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
68647 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
68648 + goto exit; // let the kernel handle it
68649 +
68650 + curr = current->acl;
68651 +
68652 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
68653 + /* the family is allowed, if this is PF_INET allow it only if
68654 + the extra sock type/protocol checks pass */
68655 + if (domain == PF_INET)
68656 + goto inet_check;
68657 + goto exit;
68658 + } else {
68659 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
68660 + __u32 fakeip = 0;
68661 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
68662 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
68663 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
68664 + gr_to_filename(current->exec_file->f_path.dentry,
68665 + current->exec_file->f_path.mnt) :
68666 + curr->filename, curr->filename,
68667 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
68668 + &current->signal->saved_ip);
68669 + goto exit;
68670 + }
68671 + goto exit_fail;
68672 + }
68673 +
68674 +inet_check:
68675 + /* the rest of this checking is for IPv4 only */
68676 + if (!curr->ips)
68677 + goto exit;
68678 +
68679 + if ((curr->ip_type & (1U << type)) &&
68680 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
68681 + goto exit;
68682 +
68683 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
68684 + /* we don't place acls on raw sockets , and sometimes
68685 + dgram/ip sockets are opened for ioctl and not
68686 + bind/connect, so we'll fake a bind learn log */
68687 + if (type == SOCK_RAW || type == SOCK_PACKET) {
68688 + __u32 fakeip = 0;
68689 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
68690 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
68691 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
68692 + gr_to_filename(current->exec_file->f_path.dentry,
68693 + current->exec_file->f_path.mnt) :
68694 + curr->filename, curr->filename,
68695 + &fakeip, 0, type,
68696 + protocol, GR_CONNECT, &current->signal->saved_ip);
68697 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
68698 + __u32 fakeip = 0;
68699 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
68700 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
68701 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
68702 + gr_to_filename(current->exec_file->f_path.dentry,
68703 + current->exec_file->f_path.mnt) :
68704 + curr->filename, curr->filename,
68705 + &fakeip, 0, type,
68706 + protocol, GR_BIND, &current->signal->saved_ip);
68707 + }
68708 + /* we'll log when they use connect or bind */
68709 + goto exit;
68710 + }
68711 +
68712 +exit_fail:
68713 + if (domain == PF_INET)
68714 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
68715 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
68716 + else
68717 +#ifndef CONFIG_IPV6
68718 + if (domain != PF_INET6)
68719 +#endif
68720 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
68721 + gr_socktype_to_name(type), protocol);
68722 +
68723 + return 0;
68724 +exit:
68725 + return 1;
68726 +}
68727 +
68728 +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)
68729 +{
68730 + if ((ip->mode & mode) &&
68731 + (ip_port >= ip->low) &&
68732 + (ip_port <= ip->high) &&
68733 + ((ntohl(ip_addr) & our_netmask) ==
68734 + (ntohl(our_addr) & our_netmask))
68735 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
68736 + && (ip->type & (1U << type))) {
68737 + if (ip->mode & GR_INVERT)
68738 + return 2; // specifically denied
68739 + else
68740 + return 1; // allowed
68741 + }
68742 +
68743 + return 0; // not specifically allowed, may continue parsing
68744 +}
68745 +
68746 +static int
68747 +gr_search_connectbind(const int full_mode, struct sock *sk,
68748 + struct sockaddr_in *addr, const int type)
68749 +{
68750 + char iface[IFNAMSIZ] = {0};
68751 + struct acl_subject_label *curr;
68752 + struct acl_ip_label *ip;
68753 + struct inet_sock *isk;
68754 + struct net_device *dev;
68755 + struct in_device *idev;
68756 + unsigned long i;
68757 + int ret;
68758 + int mode = full_mode & (GR_BIND | GR_CONNECT);
68759 + __u32 ip_addr = 0;
68760 + __u32 our_addr;
68761 + __u32 our_netmask;
68762 + char *p;
68763 + __u16 ip_port = 0;
68764 + const struct cred *cred = current_cred();
68765 +
68766 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
68767 + return 0;
68768 +
68769 + curr = current->acl;
68770 + isk = inet_sk(sk);
68771 +
68772 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
68773 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
68774 + addr->sin_addr.s_addr = curr->inaddr_any_override;
68775 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
68776 + struct sockaddr_in saddr;
68777 + int err;
68778 +
68779 + saddr.sin_family = AF_INET;
68780 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
68781 + saddr.sin_port = isk->inet_sport;
68782 +
68783 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
68784 + if (err)
68785 + return err;
68786 +
68787 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
68788 + if (err)
68789 + return err;
68790 + }
68791 +
68792 + if (!curr->ips)
68793 + return 0;
68794 +
68795 + ip_addr = addr->sin_addr.s_addr;
68796 + ip_port = ntohs(addr->sin_port);
68797 +
68798 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
68799 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
68800 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
68801 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
68802 + gr_to_filename(current->exec_file->f_path.dentry,
68803 + current->exec_file->f_path.mnt) :
68804 + curr->filename, curr->filename,
68805 + &ip_addr, ip_port, type,
68806 + sk->sk_protocol, mode, &current->signal->saved_ip);
68807 + return 0;
68808 + }
68809 +
68810 + for (i = 0; i < curr->ip_num; i++) {
68811 + ip = *(curr->ips + i);
68812 + if (ip->iface != NULL) {
68813 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
68814 + p = strchr(iface, ':');
68815 + if (p != NULL)
68816 + *p = '\0';
68817 + dev = dev_get_by_name(sock_net(sk), iface);
68818 + if (dev == NULL)
68819 + continue;
68820 + idev = in_dev_get(dev);
68821 + if (idev == NULL) {
68822 + dev_put(dev);
68823 + continue;
68824 + }
68825 + rcu_read_lock();
68826 + for_ifa(idev) {
68827 + if (!strcmp(ip->iface, ifa->ifa_label)) {
68828 + our_addr = ifa->ifa_address;
68829 + our_netmask = 0xffffffff;
68830 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
68831 + if (ret == 1) {
68832 + rcu_read_unlock();
68833 + in_dev_put(idev);
68834 + dev_put(dev);
68835 + return 0;
68836 + } else if (ret == 2) {
68837 + rcu_read_unlock();
68838 + in_dev_put(idev);
68839 + dev_put(dev);
68840 + goto denied;
68841 + }
68842 + }
68843 + } endfor_ifa(idev);
68844 + rcu_read_unlock();
68845 + in_dev_put(idev);
68846 + dev_put(dev);
68847 + } else {
68848 + our_addr = ip->addr;
68849 + our_netmask = ip->netmask;
68850 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
68851 + if (ret == 1)
68852 + return 0;
68853 + else if (ret == 2)
68854 + goto denied;
68855 + }
68856 + }
68857 +
68858 +denied:
68859 + if (mode == GR_BIND)
68860 + 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));
68861 + else if (mode == GR_CONNECT)
68862 + 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));
68863 +
68864 + return -EACCES;
68865 +}
68866 +
68867 +int
68868 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
68869 +{
68870 + /* always allow disconnection of dgram sockets with connect */
68871 + if (addr->sin_family == AF_UNSPEC)
68872 + return 0;
68873 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
68874 +}
68875 +
68876 +int
68877 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
68878 +{
68879 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
68880 +}
68881 +
68882 +int gr_search_listen(struct socket *sock)
68883 +{
68884 + struct sock *sk = sock->sk;
68885 + struct sockaddr_in addr;
68886 +
68887 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
68888 + addr.sin_port = inet_sk(sk)->inet_sport;
68889 +
68890 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
68891 +}
68892 +
68893 +int gr_search_accept(struct socket *sock)
68894 +{
68895 + struct sock *sk = sock->sk;
68896 + struct sockaddr_in addr;
68897 +
68898 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
68899 + addr.sin_port = inet_sk(sk)->inet_sport;
68900 +
68901 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
68902 +}
68903 +
68904 +int
68905 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
68906 +{
68907 + if (addr)
68908 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
68909 + else {
68910 + struct sockaddr_in sin;
68911 + const struct inet_sock *inet = inet_sk(sk);
68912 +
68913 + sin.sin_addr.s_addr = inet->inet_daddr;
68914 + sin.sin_port = inet->inet_dport;
68915 +
68916 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
68917 + }
68918 +}
68919 +
68920 +int
68921 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
68922 +{
68923 + struct sockaddr_in sin;
68924 +
68925 + if (unlikely(skb->len < sizeof (struct udphdr)))
68926 + return 0; // skip this packet
68927 +
68928 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
68929 + sin.sin_port = udp_hdr(skb)->source;
68930 +
68931 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
68932 +}
68933 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
68934 new file mode 100644
68935 index 0000000..25f54ef
68936 --- /dev/null
68937 +++ b/grsecurity/gracl_learn.c
68938 @@ -0,0 +1,207 @@
68939 +#include <linux/kernel.h>
68940 +#include <linux/mm.h>
68941 +#include <linux/sched.h>
68942 +#include <linux/poll.h>
68943 +#include <linux/string.h>
68944 +#include <linux/file.h>
68945 +#include <linux/types.h>
68946 +#include <linux/vmalloc.h>
68947 +#include <linux/grinternal.h>
68948 +
68949 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
68950 + size_t count, loff_t *ppos);
68951 +extern int gr_acl_is_enabled(void);
68952 +
68953 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
68954 +static int gr_learn_attached;
68955 +
68956 +/* use a 512k buffer */
68957 +#define LEARN_BUFFER_SIZE (512 * 1024)
68958 +
68959 +static DEFINE_SPINLOCK(gr_learn_lock);
68960 +static DEFINE_MUTEX(gr_learn_user_mutex);
68961 +
68962 +/* we need to maintain two buffers, so that the kernel context of grlearn
68963 + uses a semaphore around the userspace copying, and the other kernel contexts
68964 + use a spinlock when copying into the buffer, since they cannot sleep
68965 +*/
68966 +static char *learn_buffer;
68967 +static char *learn_buffer_user;
68968 +static int learn_buffer_len;
68969 +static int learn_buffer_user_len;
68970 +
68971 +static ssize_t
68972 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
68973 +{
68974 + DECLARE_WAITQUEUE(wait, current);
68975 + ssize_t retval = 0;
68976 +
68977 + add_wait_queue(&learn_wait, &wait);
68978 + set_current_state(TASK_INTERRUPTIBLE);
68979 + do {
68980 + mutex_lock(&gr_learn_user_mutex);
68981 + spin_lock(&gr_learn_lock);
68982 + if (learn_buffer_len)
68983 + break;
68984 + spin_unlock(&gr_learn_lock);
68985 + mutex_unlock(&gr_learn_user_mutex);
68986 + if (file->f_flags & O_NONBLOCK) {
68987 + retval = -EAGAIN;
68988 + goto out;
68989 + }
68990 + if (signal_pending(current)) {
68991 + retval = -ERESTARTSYS;
68992 + goto out;
68993 + }
68994 +
68995 + schedule();
68996 + } while (1);
68997 +
68998 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
68999 + learn_buffer_user_len = learn_buffer_len;
69000 + retval = learn_buffer_len;
69001 + learn_buffer_len = 0;
69002 +
69003 + spin_unlock(&gr_learn_lock);
69004 +
69005 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
69006 + retval = -EFAULT;
69007 +
69008 + mutex_unlock(&gr_learn_user_mutex);
69009 +out:
69010 + set_current_state(TASK_RUNNING);
69011 + remove_wait_queue(&learn_wait, &wait);
69012 + return retval;
69013 +}
69014 +
69015 +static unsigned int
69016 +poll_learn(struct file * file, poll_table * wait)
69017 +{
69018 + poll_wait(file, &learn_wait, wait);
69019 +
69020 + if (learn_buffer_len)
69021 + return (POLLIN | POLLRDNORM);
69022 +
69023 + return 0;
69024 +}
69025 +
69026 +void
69027 +gr_clear_learn_entries(void)
69028 +{
69029 + char *tmp;
69030 +
69031 + mutex_lock(&gr_learn_user_mutex);
69032 + spin_lock(&gr_learn_lock);
69033 + tmp = learn_buffer;
69034 + learn_buffer = NULL;
69035 + spin_unlock(&gr_learn_lock);
69036 + if (tmp)
69037 + vfree(tmp);
69038 + if (learn_buffer_user != NULL) {
69039 + vfree(learn_buffer_user);
69040 + learn_buffer_user = NULL;
69041 + }
69042 + learn_buffer_len = 0;
69043 + mutex_unlock(&gr_learn_user_mutex);
69044 +
69045 + return;
69046 +}
69047 +
69048 +void
69049 +gr_add_learn_entry(const char *fmt, ...)
69050 +{
69051 + va_list args;
69052 + unsigned int len;
69053 +
69054 + if (!gr_learn_attached)
69055 + return;
69056 +
69057 + spin_lock(&gr_learn_lock);
69058 +
69059 + /* leave a gap at the end so we know when it's "full" but don't have to
69060 + compute the exact length of the string we're trying to append
69061 + */
69062 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
69063 + spin_unlock(&gr_learn_lock);
69064 + wake_up_interruptible(&learn_wait);
69065 + return;
69066 + }
69067 + if (learn_buffer == NULL) {
69068 + spin_unlock(&gr_learn_lock);
69069 + return;
69070 + }
69071 +
69072 + va_start(args, fmt);
69073 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
69074 + va_end(args);
69075 +
69076 + learn_buffer_len += len + 1;
69077 +
69078 + spin_unlock(&gr_learn_lock);
69079 + wake_up_interruptible(&learn_wait);
69080 +
69081 + return;
69082 +}
69083 +
69084 +static int
69085 +open_learn(struct inode *inode, struct file *file)
69086 +{
69087 + if (file->f_mode & FMODE_READ && gr_learn_attached)
69088 + return -EBUSY;
69089 + if (file->f_mode & FMODE_READ) {
69090 + int retval = 0;
69091 + mutex_lock(&gr_learn_user_mutex);
69092 + if (learn_buffer == NULL)
69093 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
69094 + if (learn_buffer_user == NULL)
69095 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
69096 + if (learn_buffer == NULL) {
69097 + retval = -ENOMEM;
69098 + goto out_error;
69099 + }
69100 + if (learn_buffer_user == NULL) {
69101 + retval = -ENOMEM;
69102 + goto out_error;
69103 + }
69104 + learn_buffer_len = 0;
69105 + learn_buffer_user_len = 0;
69106 + gr_learn_attached = 1;
69107 +out_error:
69108 + mutex_unlock(&gr_learn_user_mutex);
69109 + return retval;
69110 + }
69111 + return 0;
69112 +}
69113 +
69114 +static int
69115 +close_learn(struct inode *inode, struct file *file)
69116 +{
69117 + if (file->f_mode & FMODE_READ) {
69118 + char *tmp = NULL;
69119 + mutex_lock(&gr_learn_user_mutex);
69120 + spin_lock(&gr_learn_lock);
69121 + tmp = learn_buffer;
69122 + learn_buffer = NULL;
69123 + spin_unlock(&gr_learn_lock);
69124 + if (tmp)
69125 + vfree(tmp);
69126 + if (learn_buffer_user != NULL) {
69127 + vfree(learn_buffer_user);
69128 + learn_buffer_user = NULL;
69129 + }
69130 + learn_buffer_len = 0;
69131 + learn_buffer_user_len = 0;
69132 + gr_learn_attached = 0;
69133 + mutex_unlock(&gr_learn_user_mutex);
69134 + }
69135 +
69136 + return 0;
69137 +}
69138 +
69139 +const struct file_operations grsec_fops = {
69140 + .read = read_learn,
69141 + .write = write_grsec_handler,
69142 + .open = open_learn,
69143 + .release = close_learn,
69144 + .poll = poll_learn,
69145 +};
69146 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
69147 new file mode 100644
69148 index 0000000..39645c9
69149 --- /dev/null
69150 +++ b/grsecurity/gracl_res.c
69151 @@ -0,0 +1,68 @@
69152 +#include <linux/kernel.h>
69153 +#include <linux/sched.h>
69154 +#include <linux/gracl.h>
69155 +#include <linux/grinternal.h>
69156 +
69157 +static const char *restab_log[] = {
69158 + [RLIMIT_CPU] = "RLIMIT_CPU",
69159 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
69160 + [RLIMIT_DATA] = "RLIMIT_DATA",
69161 + [RLIMIT_STACK] = "RLIMIT_STACK",
69162 + [RLIMIT_CORE] = "RLIMIT_CORE",
69163 + [RLIMIT_RSS] = "RLIMIT_RSS",
69164 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
69165 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
69166 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
69167 + [RLIMIT_AS] = "RLIMIT_AS",
69168 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
69169 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
69170 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
69171 + [RLIMIT_NICE] = "RLIMIT_NICE",
69172 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
69173 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
69174 + [GR_CRASH_RES] = "RLIMIT_CRASH"
69175 +};
69176 +
69177 +void
69178 +gr_log_resource(const struct task_struct *task,
69179 + const int res, const unsigned long wanted, const int gt)
69180 +{
69181 + const struct cred *cred;
69182 + unsigned long rlim;
69183 +
69184 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
69185 + return;
69186 +
69187 + // not yet supported resource
69188 + if (unlikely(!restab_log[res]))
69189 + return;
69190 +
69191 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
69192 + rlim = task_rlimit_max(task, res);
69193 + else
69194 + rlim = task_rlimit(task, res);
69195 +
69196 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
69197 + return;
69198 +
69199 + rcu_read_lock();
69200 + cred = __task_cred(task);
69201 +
69202 + if (res == RLIMIT_NPROC &&
69203 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
69204 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
69205 + goto out_rcu_unlock;
69206 + else if (res == RLIMIT_MEMLOCK &&
69207 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
69208 + goto out_rcu_unlock;
69209 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
69210 + goto out_rcu_unlock;
69211 + rcu_read_unlock();
69212 +
69213 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
69214 +
69215 + return;
69216 +out_rcu_unlock:
69217 + rcu_read_unlock();
69218 + return;
69219 +}
69220 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
69221 new file mode 100644
69222 index 0000000..3c38bfe
69223 --- /dev/null
69224 +++ b/grsecurity/gracl_segv.c
69225 @@ -0,0 +1,305 @@
69226 +#include <linux/kernel.h>
69227 +#include <linux/mm.h>
69228 +#include <asm/uaccess.h>
69229 +#include <asm/errno.h>
69230 +#include <asm/mman.h>
69231 +#include <net/sock.h>
69232 +#include <linux/file.h>
69233 +#include <linux/fs.h>
69234 +#include <linux/net.h>
69235 +#include <linux/in.h>
69236 +#include <linux/slab.h>
69237 +#include <linux/types.h>
69238 +#include <linux/sched.h>
69239 +#include <linux/timer.h>
69240 +#include <linux/gracl.h>
69241 +#include <linux/grsecurity.h>
69242 +#include <linux/grinternal.h>
69243 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
69244 +#include <linux/magic.h>
69245 +#include <linux/pagemap.h>
69246 +#include "../fs/btrfs/async-thread.h"
69247 +#include "../fs/btrfs/ctree.h"
69248 +#include "../fs/btrfs/btrfs_inode.h"
69249 +#endif
69250 +
69251 +static struct crash_uid *uid_set;
69252 +static unsigned short uid_used;
69253 +static DEFINE_SPINLOCK(gr_uid_lock);
69254 +extern rwlock_t gr_inode_lock;
69255 +extern struct acl_subject_label *
69256 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
69257 + struct acl_role_label *role);
69258 +
69259 +static inline dev_t __get_dev(const struct dentry *dentry)
69260 +{
69261 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
69262 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
69263 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
69264 + else
69265 +#endif
69266 + return dentry->d_sb->s_dev;
69267 +}
69268 +
69269 +int
69270 +gr_init_uidset(void)
69271 +{
69272 + uid_set =
69273 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
69274 + uid_used = 0;
69275 +
69276 + return uid_set ? 1 : 0;
69277 +}
69278 +
69279 +void
69280 +gr_free_uidset(void)
69281 +{
69282 + if (uid_set)
69283 + kfree(uid_set);
69284 +
69285 + return;
69286 +}
69287 +
69288 +int
69289 +gr_find_uid(const uid_t uid)
69290 +{
69291 + struct crash_uid *tmp = uid_set;
69292 + uid_t buid;
69293 + int low = 0, high = uid_used - 1, mid;
69294 +
69295 + while (high >= low) {
69296 + mid = (low + high) >> 1;
69297 + buid = tmp[mid].uid;
69298 + if (buid == uid)
69299 + return mid;
69300 + if (buid > uid)
69301 + high = mid - 1;
69302 + if (buid < uid)
69303 + low = mid + 1;
69304 + }
69305 +
69306 + return -1;
69307 +}
69308 +
69309 +static __inline__ void
69310 +gr_insertsort(void)
69311 +{
69312 + unsigned short i, j;
69313 + struct crash_uid index;
69314 +
69315 + for (i = 1; i < uid_used; i++) {
69316 + index = uid_set[i];
69317 + j = i;
69318 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
69319 + uid_set[j] = uid_set[j - 1];
69320 + j--;
69321 + }
69322 + uid_set[j] = index;
69323 + }
69324 +
69325 + return;
69326 +}
69327 +
69328 +static __inline__ void
69329 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
69330 +{
69331 + int loc;
69332 + uid_t uid = GR_GLOBAL_UID(kuid);
69333 +
69334 + if (uid_used == GR_UIDTABLE_MAX)
69335 + return;
69336 +
69337 + loc = gr_find_uid(uid);
69338 +
69339 + if (loc >= 0) {
69340 + uid_set[loc].expires = expires;
69341 + return;
69342 + }
69343 +
69344 + uid_set[uid_used].uid = uid;
69345 + uid_set[uid_used].expires = expires;
69346 + uid_used++;
69347 +
69348 + gr_insertsort();
69349 +
69350 + return;
69351 +}
69352 +
69353 +void
69354 +gr_remove_uid(const unsigned short loc)
69355 +{
69356 + unsigned short i;
69357 +
69358 + for (i = loc + 1; i < uid_used; i++)
69359 + uid_set[i - 1] = uid_set[i];
69360 +
69361 + uid_used--;
69362 +
69363 + return;
69364 +}
69365 +
69366 +int
69367 +gr_check_crash_uid(const kuid_t kuid)
69368 +{
69369 + int loc;
69370 + int ret = 0;
69371 + uid_t uid;
69372 +
69373 + if (unlikely(!gr_acl_is_enabled()))
69374 + return 0;
69375 +
69376 + uid = GR_GLOBAL_UID(kuid);
69377 +
69378 + spin_lock(&gr_uid_lock);
69379 + loc = gr_find_uid(uid);
69380 +
69381 + if (loc < 0)
69382 + goto out_unlock;
69383 +
69384 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
69385 + gr_remove_uid(loc);
69386 + else
69387 + ret = 1;
69388 +
69389 +out_unlock:
69390 + spin_unlock(&gr_uid_lock);
69391 + return ret;
69392 +}
69393 +
69394 +static __inline__ int
69395 +proc_is_setxid(const struct cred *cred)
69396 +{
69397 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
69398 + !uid_eq(cred->uid, cred->fsuid))
69399 + return 1;
69400 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
69401 + !gid_eq(cred->gid, cred->fsgid))
69402 + return 1;
69403 +
69404 + return 0;
69405 +}
69406 +
69407 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
69408 +
69409 +void
69410 +gr_handle_crash(struct task_struct *task, const int sig)
69411 +{
69412 + struct acl_subject_label *curr;
69413 + struct task_struct *tsk, *tsk2;
69414 + const struct cred *cred;
69415 + const struct cred *cred2;
69416 +
69417 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
69418 + return;
69419 +
69420 + if (unlikely(!gr_acl_is_enabled()))
69421 + return;
69422 +
69423 + curr = task->acl;
69424 +
69425 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
69426 + return;
69427 +
69428 + if (time_before_eq(curr->expires, get_seconds())) {
69429 + curr->expires = 0;
69430 + curr->crashes = 0;
69431 + }
69432 +
69433 + curr->crashes++;
69434 +
69435 + if (!curr->expires)
69436 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
69437 +
69438 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
69439 + time_after(curr->expires, get_seconds())) {
69440 + rcu_read_lock();
69441 + cred = __task_cred(task);
69442 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
69443 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
69444 + spin_lock(&gr_uid_lock);
69445 + gr_insert_uid(cred->uid, curr->expires);
69446 + spin_unlock(&gr_uid_lock);
69447 + curr->expires = 0;
69448 + curr->crashes = 0;
69449 + read_lock(&tasklist_lock);
69450 + do_each_thread(tsk2, tsk) {
69451 + cred2 = __task_cred(tsk);
69452 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
69453 + gr_fake_force_sig(SIGKILL, tsk);
69454 + } while_each_thread(tsk2, tsk);
69455 + read_unlock(&tasklist_lock);
69456 + } else {
69457 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
69458 + read_lock(&tasklist_lock);
69459 + read_lock(&grsec_exec_file_lock);
69460 + do_each_thread(tsk2, tsk) {
69461 + if (likely(tsk != task)) {
69462 + // if this thread has the same subject as the one that triggered
69463 + // RES_CRASH and it's the same binary, kill it
69464 + if (tsk->acl == task->acl && gr_is_same_file(tsk->exec_file, task->exec_file))
69465 + gr_fake_force_sig(SIGKILL, tsk);
69466 + }
69467 + } while_each_thread(tsk2, tsk);
69468 + read_unlock(&grsec_exec_file_lock);
69469 + read_unlock(&tasklist_lock);
69470 + }
69471 + rcu_read_unlock();
69472 + }
69473 +
69474 + return;
69475 +}
69476 +
69477 +int
69478 +gr_check_crash_exec(const struct file *filp)
69479 +{
69480 + struct acl_subject_label *curr;
69481 +
69482 + if (unlikely(!gr_acl_is_enabled()))
69483 + return 0;
69484 +
69485 + read_lock(&gr_inode_lock);
69486 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
69487 + __get_dev(filp->f_path.dentry),
69488 + current->role);
69489 + read_unlock(&gr_inode_lock);
69490 +
69491 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
69492 + (!curr->crashes && !curr->expires))
69493 + return 0;
69494 +
69495 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
69496 + time_after(curr->expires, get_seconds()))
69497 + return 1;
69498 + else if (time_before_eq(curr->expires, get_seconds())) {
69499 + curr->crashes = 0;
69500 + curr->expires = 0;
69501 + }
69502 +
69503 + return 0;
69504 +}
69505 +
69506 +void
69507 +gr_handle_alertkill(struct task_struct *task)
69508 +{
69509 + struct acl_subject_label *curracl;
69510 + __u32 curr_ip;
69511 + struct task_struct *p, *p2;
69512 +
69513 + if (unlikely(!gr_acl_is_enabled()))
69514 + return;
69515 +
69516 + curracl = task->acl;
69517 + curr_ip = task->signal->curr_ip;
69518 +
69519 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
69520 + read_lock(&tasklist_lock);
69521 + do_each_thread(p2, p) {
69522 + if (p->signal->curr_ip == curr_ip)
69523 + gr_fake_force_sig(SIGKILL, p);
69524 + } while_each_thread(p2, p);
69525 + read_unlock(&tasklist_lock);
69526 + } else if (curracl->mode & GR_KILLPROC)
69527 + gr_fake_force_sig(SIGKILL, task);
69528 +
69529 + return;
69530 +}
69531 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
69532 new file mode 100644
69533 index 0000000..98011b0
69534 --- /dev/null
69535 +++ b/grsecurity/gracl_shm.c
69536 @@ -0,0 +1,40 @@
69537 +#include <linux/kernel.h>
69538 +#include <linux/mm.h>
69539 +#include <linux/sched.h>
69540 +#include <linux/file.h>
69541 +#include <linux/ipc.h>
69542 +#include <linux/gracl.h>
69543 +#include <linux/grsecurity.h>
69544 +#include <linux/grinternal.h>
69545 +
69546 +int
69547 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
69548 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
69549 +{
69550 + struct task_struct *task;
69551 +
69552 + if (!gr_acl_is_enabled())
69553 + return 1;
69554 +
69555 + rcu_read_lock();
69556 + read_lock(&tasklist_lock);
69557 +
69558 + task = find_task_by_vpid(shm_cprid);
69559 +
69560 + if (unlikely(!task))
69561 + task = find_task_by_vpid(shm_lapid);
69562 +
69563 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
69564 + (task_pid_nr(task) == shm_lapid)) &&
69565 + (task->acl->mode & GR_PROTSHM) &&
69566 + (task->acl != current->acl))) {
69567 + read_unlock(&tasklist_lock);
69568 + rcu_read_unlock();
69569 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
69570 + return 0;
69571 + }
69572 + read_unlock(&tasklist_lock);
69573 + rcu_read_unlock();
69574 +
69575 + return 1;
69576 +}
69577 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
69578 new file mode 100644
69579 index 0000000..bc0be01
69580 --- /dev/null
69581 +++ b/grsecurity/grsec_chdir.c
69582 @@ -0,0 +1,19 @@
69583 +#include <linux/kernel.h>
69584 +#include <linux/sched.h>
69585 +#include <linux/fs.h>
69586 +#include <linux/file.h>
69587 +#include <linux/grsecurity.h>
69588 +#include <linux/grinternal.h>
69589 +
69590 +void
69591 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
69592 +{
69593 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
69594 + if ((grsec_enable_chdir && grsec_enable_group &&
69595 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
69596 + !grsec_enable_group)) {
69597 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
69598 + }
69599 +#endif
69600 + return;
69601 +}
69602 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
69603 new file mode 100644
69604 index 0000000..bd6e105
69605 --- /dev/null
69606 +++ b/grsecurity/grsec_chroot.c
69607 @@ -0,0 +1,370 @@
69608 +#include <linux/kernel.h>
69609 +#include <linux/module.h>
69610 +#include <linux/sched.h>
69611 +#include <linux/file.h>
69612 +#include <linux/fs.h>
69613 +#include <linux/mount.h>
69614 +#include <linux/types.h>
69615 +#include "../fs/mount.h"
69616 +#include <linux/grsecurity.h>
69617 +#include <linux/grinternal.h>
69618 +
69619 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
69620 +static int gr_init_ran;
69621 +#endif
69622 +
69623 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
69624 +{
69625 +#ifdef CONFIG_GRKERNSEC
69626 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
69627 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
69628 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
69629 + && gr_init_ran
69630 +#endif
69631 + )
69632 + task->gr_is_chrooted = 1;
69633 + else {
69634 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
69635 + if (task_pid_nr(task) == 1 && !gr_init_ran)
69636 + gr_init_ran = 1;
69637 +#endif
69638 + task->gr_is_chrooted = 0;
69639 + }
69640 +
69641 + task->gr_chroot_dentry = path->dentry;
69642 +#endif
69643 + return;
69644 +}
69645 +
69646 +void gr_clear_chroot_entries(struct task_struct *task)
69647 +{
69648 +#ifdef CONFIG_GRKERNSEC
69649 + task->gr_is_chrooted = 0;
69650 + task->gr_chroot_dentry = NULL;
69651 +#endif
69652 + return;
69653 +}
69654 +
69655 +int
69656 +gr_handle_chroot_unix(const pid_t pid)
69657 +{
69658 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
69659 + struct task_struct *p;
69660 +
69661 + if (unlikely(!grsec_enable_chroot_unix))
69662 + return 1;
69663 +
69664 + if (likely(!proc_is_chrooted(current)))
69665 + return 1;
69666 +
69667 + rcu_read_lock();
69668 + read_lock(&tasklist_lock);
69669 + p = find_task_by_vpid_unrestricted(pid);
69670 + if (unlikely(p && !have_same_root(current, p))) {
69671 + read_unlock(&tasklist_lock);
69672 + rcu_read_unlock();
69673 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
69674 + return 0;
69675 + }
69676 + read_unlock(&tasklist_lock);
69677 + rcu_read_unlock();
69678 +#endif
69679 + return 1;
69680 +}
69681 +
69682 +int
69683 +gr_handle_chroot_nice(void)
69684 +{
69685 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
69686 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
69687 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
69688 + return -EPERM;
69689 + }
69690 +#endif
69691 + return 0;
69692 +}
69693 +
69694 +int
69695 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
69696 +{
69697 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
69698 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
69699 + && proc_is_chrooted(current)) {
69700 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
69701 + return -EACCES;
69702 + }
69703 +#endif
69704 + return 0;
69705 +}
69706 +
69707 +int
69708 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
69709 +{
69710 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69711 + struct task_struct *p;
69712 + int ret = 0;
69713 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
69714 + return ret;
69715 +
69716 + read_lock(&tasklist_lock);
69717 + do_each_pid_task(pid, type, p) {
69718 + if (!have_same_root(current, p)) {
69719 + ret = 1;
69720 + goto out;
69721 + }
69722 + } while_each_pid_task(pid, type, p);
69723 +out:
69724 + read_unlock(&tasklist_lock);
69725 + return ret;
69726 +#endif
69727 + return 0;
69728 +}
69729 +
69730 +int
69731 +gr_pid_is_chrooted(struct task_struct *p)
69732 +{
69733 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69734 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
69735 + return 0;
69736 +
69737 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
69738 + !have_same_root(current, p)) {
69739 + return 1;
69740 + }
69741 +#endif
69742 + return 0;
69743 +}
69744 +
69745 +EXPORT_SYMBOL(gr_pid_is_chrooted);
69746 +
69747 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
69748 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
69749 +{
69750 + struct path path, currentroot;
69751 + int ret = 0;
69752 +
69753 + path.dentry = (struct dentry *)u_dentry;
69754 + path.mnt = (struct vfsmount *)u_mnt;
69755 + get_fs_root(current->fs, &currentroot);
69756 + if (path_is_under(&path, &currentroot))
69757 + ret = 1;
69758 + path_put(&currentroot);
69759 +
69760 + return ret;
69761 +}
69762 +#endif
69763 +
69764 +int
69765 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
69766 +{
69767 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
69768 + if (!grsec_enable_chroot_fchdir)
69769 + return 1;
69770 +
69771 + if (!proc_is_chrooted(current))
69772 + return 1;
69773 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
69774 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
69775 + return 0;
69776 + }
69777 +#endif
69778 + return 1;
69779 +}
69780 +
69781 +int
69782 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
69783 + const time_t shm_createtime)
69784 +{
69785 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
69786 + struct task_struct *p;
69787 + time_t starttime;
69788 +
69789 + if (unlikely(!grsec_enable_chroot_shmat))
69790 + return 1;
69791 +
69792 + if (likely(!proc_is_chrooted(current)))
69793 + return 1;
69794 +
69795 + rcu_read_lock();
69796 + read_lock(&tasklist_lock);
69797 +
69798 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
69799 + starttime = p->start_time.tv_sec;
69800 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
69801 + if (have_same_root(current, p)) {
69802 + goto allow;
69803 + } else {
69804 + read_unlock(&tasklist_lock);
69805 + rcu_read_unlock();
69806 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
69807 + return 0;
69808 + }
69809 + }
69810 + /* creator exited, pid reuse, fall through to next check */
69811 + }
69812 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
69813 + if (unlikely(!have_same_root(current, p))) {
69814 + read_unlock(&tasklist_lock);
69815 + rcu_read_unlock();
69816 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
69817 + return 0;
69818 + }
69819 + }
69820 +
69821 +allow:
69822 + read_unlock(&tasklist_lock);
69823 + rcu_read_unlock();
69824 +#endif
69825 + return 1;
69826 +}
69827 +
69828 +void
69829 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
69830 +{
69831 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
69832 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
69833 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
69834 +#endif
69835 + return;
69836 +}
69837 +
69838 +int
69839 +gr_handle_chroot_mknod(const struct dentry *dentry,
69840 + const struct vfsmount *mnt, const int mode)
69841 +{
69842 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
69843 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
69844 + proc_is_chrooted(current)) {
69845 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
69846 + return -EPERM;
69847 + }
69848 +#endif
69849 + return 0;
69850 +}
69851 +
69852 +int
69853 +gr_handle_chroot_mount(const struct dentry *dentry,
69854 + const struct vfsmount *mnt, const char *dev_name)
69855 +{
69856 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
69857 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
69858 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
69859 + return -EPERM;
69860 + }
69861 +#endif
69862 + return 0;
69863 +}
69864 +
69865 +int
69866 +gr_handle_chroot_pivot(void)
69867 +{
69868 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
69869 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
69870 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
69871 + return -EPERM;
69872 + }
69873 +#endif
69874 + return 0;
69875 +}
69876 +
69877 +int
69878 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
69879 +{
69880 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
69881 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
69882 + !gr_is_outside_chroot(dentry, mnt)) {
69883 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
69884 + return -EPERM;
69885 + }
69886 +#endif
69887 + return 0;
69888 +}
69889 +
69890 +extern const char *captab_log[];
69891 +extern int captab_log_entries;
69892 +
69893 +int
69894 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
69895 +{
69896 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
69897 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
69898 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
69899 + if (cap_raised(chroot_caps, cap)) {
69900 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
69901 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
69902 + }
69903 + return 0;
69904 + }
69905 + }
69906 +#endif
69907 + return 1;
69908 +}
69909 +
69910 +int
69911 +gr_chroot_is_capable(const int cap)
69912 +{
69913 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
69914 + return gr_task_chroot_is_capable(current, current_cred(), cap);
69915 +#endif
69916 + return 1;
69917 +}
69918 +
69919 +int
69920 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
69921 +{
69922 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
69923 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
69924 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
69925 + if (cap_raised(chroot_caps, cap)) {
69926 + return 0;
69927 + }
69928 + }
69929 +#endif
69930 + return 1;
69931 +}
69932 +
69933 +int
69934 +gr_chroot_is_capable_nolog(const int cap)
69935 +{
69936 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
69937 + return gr_task_chroot_is_capable_nolog(current, cap);
69938 +#endif
69939 + return 1;
69940 +}
69941 +
69942 +int
69943 +gr_handle_chroot_sysctl(const int op)
69944 +{
69945 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
69946 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
69947 + proc_is_chrooted(current))
69948 + return -EACCES;
69949 +#endif
69950 + return 0;
69951 +}
69952 +
69953 +void
69954 +gr_handle_chroot_chdir(const struct path *path)
69955 +{
69956 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
69957 + if (grsec_enable_chroot_chdir)
69958 + set_fs_pwd(current->fs, path);
69959 +#endif
69960 + return;
69961 +}
69962 +
69963 +int
69964 +gr_handle_chroot_chmod(const struct dentry *dentry,
69965 + const struct vfsmount *mnt, const int mode)
69966 +{
69967 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
69968 + /* allow chmod +s on directories, but not files */
69969 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
69970 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
69971 + proc_is_chrooted(current)) {
69972 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
69973 + return -EPERM;
69974 + }
69975 +#endif
69976 + return 0;
69977 +}
69978 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
69979 new file mode 100644
69980 index 0000000..ce65ceb
69981 --- /dev/null
69982 +++ b/grsecurity/grsec_disabled.c
69983 @@ -0,0 +1,434 @@
69984 +#include <linux/kernel.h>
69985 +#include <linux/module.h>
69986 +#include <linux/sched.h>
69987 +#include <linux/file.h>
69988 +#include <linux/fs.h>
69989 +#include <linux/kdev_t.h>
69990 +#include <linux/net.h>
69991 +#include <linux/in.h>
69992 +#include <linux/ip.h>
69993 +#include <linux/skbuff.h>
69994 +#include <linux/sysctl.h>
69995 +
69996 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
69997 +void
69998 +pax_set_initial_flags(struct linux_binprm *bprm)
69999 +{
70000 + return;
70001 +}
70002 +#endif
70003 +
70004 +#ifdef CONFIG_SYSCTL
70005 +__u32
70006 +gr_handle_sysctl(const struct ctl_table * table, const int op)
70007 +{
70008 + return 0;
70009 +}
70010 +#endif
70011 +
70012 +#ifdef CONFIG_TASKSTATS
70013 +int gr_is_taskstats_denied(int pid)
70014 +{
70015 + return 0;
70016 +}
70017 +#endif
70018 +
70019 +int
70020 +gr_acl_is_enabled(void)
70021 +{
70022 + return 0;
70023 +}
70024 +
70025 +void
70026 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
70027 +{
70028 + return;
70029 +}
70030 +
70031 +int
70032 +gr_handle_rawio(const struct inode *inode)
70033 +{
70034 + return 0;
70035 +}
70036 +
70037 +void
70038 +gr_acl_handle_psacct(struct task_struct *task, const long code)
70039 +{
70040 + return;
70041 +}
70042 +
70043 +int
70044 +gr_handle_ptrace(struct task_struct *task, const long request)
70045 +{
70046 + return 0;
70047 +}
70048 +
70049 +int
70050 +gr_handle_proc_ptrace(struct task_struct *task)
70051 +{
70052 + return 0;
70053 +}
70054 +
70055 +int
70056 +gr_set_acls(const int type)
70057 +{
70058 + return 0;
70059 +}
70060 +
70061 +int
70062 +gr_check_hidden_task(const struct task_struct *tsk)
70063 +{
70064 + return 0;
70065 +}
70066 +
70067 +int
70068 +gr_check_protected_task(const struct task_struct *task)
70069 +{
70070 + return 0;
70071 +}
70072 +
70073 +int
70074 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
70075 +{
70076 + return 0;
70077 +}
70078 +
70079 +void
70080 +gr_copy_label(struct task_struct *tsk)
70081 +{
70082 + return;
70083 +}
70084 +
70085 +void
70086 +gr_set_pax_flags(struct task_struct *task)
70087 +{
70088 + return;
70089 +}
70090 +
70091 +int
70092 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
70093 + const int unsafe_share)
70094 +{
70095 + return 0;
70096 +}
70097 +
70098 +void
70099 +gr_handle_delete(const ino_t ino, const dev_t dev)
70100 +{
70101 + return;
70102 +}
70103 +
70104 +void
70105 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
70106 +{
70107 + return;
70108 +}
70109 +
70110 +void
70111 +gr_handle_crash(struct task_struct *task, const int sig)
70112 +{
70113 + return;
70114 +}
70115 +
70116 +int
70117 +gr_check_crash_exec(const struct file *filp)
70118 +{
70119 + return 0;
70120 +}
70121 +
70122 +int
70123 +gr_check_crash_uid(const kuid_t uid)
70124 +{
70125 + return 0;
70126 +}
70127 +
70128 +void
70129 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
70130 + struct dentry *old_dentry,
70131 + struct dentry *new_dentry,
70132 + struct vfsmount *mnt, const __u8 replace)
70133 +{
70134 + return;
70135 +}
70136 +
70137 +int
70138 +gr_search_socket(const int family, const int type, const int protocol)
70139 +{
70140 + return 1;
70141 +}
70142 +
70143 +int
70144 +gr_search_connectbind(const int mode, const struct socket *sock,
70145 + const struct sockaddr_in *addr)
70146 +{
70147 + return 0;
70148 +}
70149 +
70150 +void
70151 +gr_handle_alertkill(struct task_struct *task)
70152 +{
70153 + return;
70154 +}
70155 +
70156 +__u32
70157 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
70158 +{
70159 + return 1;
70160 +}
70161 +
70162 +__u32
70163 +gr_acl_handle_hidden_file(const struct dentry * dentry,
70164 + const struct vfsmount * mnt)
70165 +{
70166 + return 1;
70167 +}
70168 +
70169 +__u32
70170 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
70171 + int acc_mode)
70172 +{
70173 + return 1;
70174 +}
70175 +
70176 +__u32
70177 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
70178 +{
70179 + return 1;
70180 +}
70181 +
70182 +__u32
70183 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
70184 +{
70185 + return 1;
70186 +}
70187 +
70188 +int
70189 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
70190 + unsigned int *vm_flags)
70191 +{
70192 + return 1;
70193 +}
70194 +
70195 +__u32
70196 +gr_acl_handle_truncate(const struct dentry * dentry,
70197 + const struct vfsmount * mnt)
70198 +{
70199 + return 1;
70200 +}
70201 +
70202 +__u32
70203 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
70204 +{
70205 + return 1;
70206 +}
70207 +
70208 +__u32
70209 +gr_acl_handle_access(const struct dentry * dentry,
70210 + const struct vfsmount * mnt, const int fmode)
70211 +{
70212 + return 1;
70213 +}
70214 +
70215 +__u32
70216 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
70217 + umode_t *mode)
70218 +{
70219 + return 1;
70220 +}
70221 +
70222 +__u32
70223 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
70224 +{
70225 + return 1;
70226 +}
70227 +
70228 +__u32
70229 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
70230 +{
70231 + return 1;
70232 +}
70233 +
70234 +void
70235 +grsecurity_init(void)
70236 +{
70237 + return;
70238 +}
70239 +
70240 +umode_t gr_acl_umask(void)
70241 +{
70242 + return 0;
70243 +}
70244 +
70245 +__u32
70246 +gr_acl_handle_mknod(const struct dentry * new_dentry,
70247 + const struct dentry * parent_dentry,
70248 + const struct vfsmount * parent_mnt,
70249 + const int mode)
70250 +{
70251 + return 1;
70252 +}
70253 +
70254 +__u32
70255 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
70256 + const struct dentry * parent_dentry,
70257 + const struct vfsmount * parent_mnt)
70258 +{
70259 + return 1;
70260 +}
70261 +
70262 +__u32
70263 +gr_acl_handle_symlink(const struct dentry * new_dentry,
70264 + const struct dentry * parent_dentry,
70265 + const struct vfsmount * parent_mnt, const struct filename *from)
70266 +{
70267 + return 1;
70268 +}
70269 +
70270 +__u32
70271 +gr_acl_handle_link(const struct dentry * new_dentry,
70272 + const struct dentry * parent_dentry,
70273 + const struct vfsmount * parent_mnt,
70274 + const struct dentry * old_dentry,
70275 + const struct vfsmount * old_mnt, const struct filename *to)
70276 +{
70277 + return 1;
70278 +}
70279 +
70280 +int
70281 +gr_acl_handle_rename(const struct dentry *new_dentry,
70282 + const struct dentry *parent_dentry,
70283 + const struct vfsmount *parent_mnt,
70284 + const struct dentry *old_dentry,
70285 + const struct inode *old_parent_inode,
70286 + const struct vfsmount *old_mnt, const struct filename *newname)
70287 +{
70288 + return 0;
70289 +}
70290 +
70291 +int
70292 +gr_acl_handle_filldir(const struct file *file, const char *name,
70293 + const int namelen, const ino_t ino)
70294 +{
70295 + return 1;
70296 +}
70297 +
70298 +int
70299 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
70300 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
70301 +{
70302 + return 1;
70303 +}
70304 +
70305 +int
70306 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
70307 +{
70308 + return 0;
70309 +}
70310 +
70311 +int
70312 +gr_search_accept(const struct socket *sock)
70313 +{
70314 + return 0;
70315 +}
70316 +
70317 +int
70318 +gr_search_listen(const struct socket *sock)
70319 +{
70320 + return 0;
70321 +}
70322 +
70323 +int
70324 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
70325 +{
70326 + return 0;
70327 +}
70328 +
70329 +__u32
70330 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
70331 +{
70332 + return 1;
70333 +}
70334 +
70335 +__u32
70336 +gr_acl_handle_creat(const struct dentry * dentry,
70337 + const struct dentry * p_dentry,
70338 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
70339 + const int imode)
70340 +{
70341 + return 1;
70342 +}
70343 +
70344 +void
70345 +gr_acl_handle_exit(void)
70346 +{
70347 + return;
70348 +}
70349 +
70350 +int
70351 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
70352 +{
70353 + return 1;
70354 +}
70355 +
70356 +void
70357 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
70358 +{
70359 + return;
70360 +}
70361 +
70362 +int
70363 +gr_acl_handle_procpidmem(const struct task_struct *task)
70364 +{
70365 + return 0;
70366 +}
70367 +
70368 +int
70369 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
70370 +{
70371 + return 0;
70372 +}
70373 +
70374 +int
70375 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
70376 +{
70377 + return 0;
70378 +}
70379 +
70380 +void
70381 +gr_set_kernel_label(struct task_struct *task)
70382 +{
70383 + return;
70384 +}
70385 +
70386 +int
70387 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
70388 +{
70389 + return 0;
70390 +}
70391 +
70392 +int
70393 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
70394 +{
70395 + return 0;
70396 +}
70397 +
70398 +int gr_acl_enable_at_secure(void)
70399 +{
70400 + return 0;
70401 +}
70402 +
70403 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
70404 +{
70405 + return dentry->d_sb->s_dev;
70406 +}
70407 +
70408 +void gr_put_exec_file(struct task_struct *task)
70409 +{
70410 + return;
70411 +}
70412 +
70413 +EXPORT_SYMBOL(gr_set_kernel_label);
70414 +#ifdef CONFIG_SECURITY
70415 +EXPORT_SYMBOL(gr_check_user_change);
70416 +EXPORT_SYMBOL(gr_check_group_change);
70417 +#endif
70418 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
70419 new file mode 100644
70420 index 0000000..387032b
70421 --- /dev/null
70422 +++ b/grsecurity/grsec_exec.c
70423 @@ -0,0 +1,187 @@
70424 +#include <linux/kernel.h>
70425 +#include <linux/sched.h>
70426 +#include <linux/file.h>
70427 +#include <linux/binfmts.h>
70428 +#include <linux/fs.h>
70429 +#include <linux/types.h>
70430 +#include <linux/grdefs.h>
70431 +#include <linux/grsecurity.h>
70432 +#include <linux/grinternal.h>
70433 +#include <linux/capability.h>
70434 +#include <linux/module.h>
70435 +#include <linux/compat.h>
70436 +
70437 +#include <asm/uaccess.h>
70438 +
70439 +#ifdef CONFIG_GRKERNSEC_EXECLOG
70440 +static char gr_exec_arg_buf[132];
70441 +static DEFINE_MUTEX(gr_exec_arg_mutex);
70442 +#endif
70443 +
70444 +struct user_arg_ptr {
70445 +#ifdef CONFIG_COMPAT
70446 + bool is_compat;
70447 +#endif
70448 + union {
70449 + const char __user *const __user *native;
70450 +#ifdef CONFIG_COMPAT
70451 + const compat_uptr_t __user *compat;
70452 +#endif
70453 + } ptr;
70454 +};
70455 +
70456 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
70457 +
70458 +void
70459 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
70460 +{
70461 +#ifdef CONFIG_GRKERNSEC_EXECLOG
70462 + char *grarg = gr_exec_arg_buf;
70463 + unsigned int i, x, execlen = 0;
70464 + char c;
70465 +
70466 + if (!((grsec_enable_execlog && grsec_enable_group &&
70467 + in_group_p(grsec_audit_gid))
70468 + || (grsec_enable_execlog && !grsec_enable_group)))
70469 + return;
70470 +
70471 + mutex_lock(&gr_exec_arg_mutex);
70472 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
70473 +
70474 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
70475 + const char __user *p;
70476 + unsigned int len;
70477 +
70478 + p = get_user_arg_ptr(argv, i);
70479 + if (IS_ERR(p))
70480 + goto log;
70481 +
70482 + len = strnlen_user(p, 128 - execlen);
70483 + if (len > 128 - execlen)
70484 + len = 128 - execlen;
70485 + else if (len > 0)
70486 + len--;
70487 + if (copy_from_user(grarg + execlen, p, len))
70488 + goto log;
70489 +
70490 + /* rewrite unprintable characters */
70491 + for (x = 0; x < len; x++) {
70492 + c = *(grarg + execlen + x);
70493 + if (c < 32 || c > 126)
70494 + *(grarg + execlen + x) = ' ';
70495 + }
70496 +
70497 + execlen += len;
70498 + *(grarg + execlen) = ' ';
70499 + *(grarg + execlen + 1) = '\0';
70500 + execlen++;
70501 + }
70502 +
70503 + log:
70504 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
70505 + bprm->file->f_path.mnt, grarg);
70506 + mutex_unlock(&gr_exec_arg_mutex);
70507 +#endif
70508 + return;
70509 +}
70510 +
70511 +#ifdef CONFIG_GRKERNSEC
70512 +extern int gr_acl_is_capable(const int cap);
70513 +extern int gr_acl_is_capable_nolog(const int cap);
70514 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
70515 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
70516 +extern int gr_chroot_is_capable(const int cap);
70517 +extern int gr_chroot_is_capable_nolog(const int cap);
70518 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
70519 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
70520 +#endif
70521 +
70522 +const char *captab_log[] = {
70523 + "CAP_CHOWN",
70524 + "CAP_DAC_OVERRIDE",
70525 + "CAP_DAC_READ_SEARCH",
70526 + "CAP_FOWNER",
70527 + "CAP_FSETID",
70528 + "CAP_KILL",
70529 + "CAP_SETGID",
70530 + "CAP_SETUID",
70531 + "CAP_SETPCAP",
70532 + "CAP_LINUX_IMMUTABLE",
70533 + "CAP_NET_BIND_SERVICE",
70534 + "CAP_NET_BROADCAST",
70535 + "CAP_NET_ADMIN",
70536 + "CAP_NET_RAW",
70537 + "CAP_IPC_LOCK",
70538 + "CAP_IPC_OWNER",
70539 + "CAP_SYS_MODULE",
70540 + "CAP_SYS_RAWIO",
70541 + "CAP_SYS_CHROOT",
70542 + "CAP_SYS_PTRACE",
70543 + "CAP_SYS_PACCT",
70544 + "CAP_SYS_ADMIN",
70545 + "CAP_SYS_BOOT",
70546 + "CAP_SYS_NICE",
70547 + "CAP_SYS_RESOURCE",
70548 + "CAP_SYS_TIME",
70549 + "CAP_SYS_TTY_CONFIG",
70550 + "CAP_MKNOD",
70551 + "CAP_LEASE",
70552 + "CAP_AUDIT_WRITE",
70553 + "CAP_AUDIT_CONTROL",
70554 + "CAP_SETFCAP",
70555 + "CAP_MAC_OVERRIDE",
70556 + "CAP_MAC_ADMIN",
70557 + "CAP_SYSLOG",
70558 + "CAP_WAKE_ALARM"
70559 +};
70560 +
70561 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
70562 +
70563 +int gr_is_capable(const int cap)
70564 +{
70565 +#ifdef CONFIG_GRKERNSEC
70566 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
70567 + return 1;
70568 + return 0;
70569 +#else
70570 + return 1;
70571 +#endif
70572 +}
70573 +
70574 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
70575 +{
70576 +#ifdef CONFIG_GRKERNSEC
70577 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
70578 + return 1;
70579 + return 0;
70580 +#else
70581 + return 1;
70582 +#endif
70583 +}
70584 +
70585 +int gr_is_capable_nolog(const int cap)
70586 +{
70587 +#ifdef CONFIG_GRKERNSEC
70588 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
70589 + return 1;
70590 + return 0;
70591 +#else
70592 + return 1;
70593 +#endif
70594 +}
70595 +
70596 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
70597 +{
70598 +#ifdef CONFIG_GRKERNSEC
70599 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
70600 + return 1;
70601 + return 0;
70602 +#else
70603 + return 1;
70604 +#endif
70605 +}
70606 +
70607 +EXPORT_SYMBOL(gr_is_capable);
70608 +EXPORT_SYMBOL(gr_is_capable_nolog);
70609 +EXPORT_SYMBOL(gr_task_is_capable);
70610 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
70611 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
70612 new file mode 100644
70613 index 0000000..06cc6ea
70614 --- /dev/null
70615 +++ b/grsecurity/grsec_fifo.c
70616 @@ -0,0 +1,24 @@
70617 +#include <linux/kernel.h>
70618 +#include <linux/sched.h>
70619 +#include <linux/fs.h>
70620 +#include <linux/file.h>
70621 +#include <linux/grinternal.h>
70622 +
70623 +int
70624 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
70625 + const struct dentry *dir, const int flag, const int acc_mode)
70626 +{
70627 +#ifdef CONFIG_GRKERNSEC_FIFO
70628 + const struct cred *cred = current_cred();
70629 +
70630 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
70631 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
70632 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
70633 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
70634 + if (!inode_permission(dentry->d_inode, acc_mode))
70635 + 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));
70636 + return -EACCES;
70637 + }
70638 +#endif
70639 + return 0;
70640 +}
70641 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
70642 new file mode 100644
70643 index 0000000..8ca18bf
70644 --- /dev/null
70645 +++ b/grsecurity/grsec_fork.c
70646 @@ -0,0 +1,23 @@
70647 +#include <linux/kernel.h>
70648 +#include <linux/sched.h>
70649 +#include <linux/grsecurity.h>
70650 +#include <linux/grinternal.h>
70651 +#include <linux/errno.h>
70652 +
70653 +void
70654 +gr_log_forkfail(const int retval)
70655 +{
70656 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
70657 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
70658 + switch (retval) {
70659 + case -EAGAIN:
70660 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
70661 + break;
70662 + case -ENOMEM:
70663 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
70664 + break;
70665 + }
70666 + }
70667 +#endif
70668 + return;
70669 +}
70670 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
70671 new file mode 100644
70672 index 0000000..836f38f
70673 --- /dev/null
70674 +++ b/grsecurity/grsec_init.c
70675 @@ -0,0 +1,280 @@
70676 +#include <linux/kernel.h>
70677 +#include <linux/sched.h>
70678 +#include <linux/mm.h>
70679 +#include <linux/gracl.h>
70680 +#include <linux/slab.h>
70681 +#include <linux/vmalloc.h>
70682 +#include <linux/percpu.h>
70683 +#include <linux/module.h>
70684 +
70685 +int grsec_enable_ptrace_readexec;
70686 +int grsec_enable_setxid;
70687 +int grsec_enable_symlinkown;
70688 +kgid_t grsec_symlinkown_gid;
70689 +int grsec_enable_brute;
70690 +int grsec_enable_link;
70691 +int grsec_enable_dmesg;
70692 +int grsec_enable_harden_ptrace;
70693 +int grsec_enable_fifo;
70694 +int grsec_enable_execlog;
70695 +int grsec_enable_signal;
70696 +int grsec_enable_forkfail;
70697 +int grsec_enable_audit_ptrace;
70698 +int grsec_enable_time;
70699 +int grsec_enable_group;
70700 +kgid_t grsec_audit_gid;
70701 +int grsec_enable_chdir;
70702 +int grsec_enable_mount;
70703 +int grsec_enable_rofs;
70704 +int grsec_deny_new_usb;
70705 +int grsec_enable_chroot_findtask;
70706 +int grsec_enable_chroot_mount;
70707 +int grsec_enable_chroot_shmat;
70708 +int grsec_enable_chroot_fchdir;
70709 +int grsec_enable_chroot_double;
70710 +int grsec_enable_chroot_pivot;
70711 +int grsec_enable_chroot_chdir;
70712 +int grsec_enable_chroot_chmod;
70713 +int grsec_enable_chroot_mknod;
70714 +int grsec_enable_chroot_nice;
70715 +int grsec_enable_chroot_execlog;
70716 +int grsec_enable_chroot_caps;
70717 +int grsec_enable_chroot_sysctl;
70718 +int grsec_enable_chroot_unix;
70719 +int grsec_enable_tpe;
70720 +kgid_t grsec_tpe_gid;
70721 +int grsec_enable_blackhole;
70722 +#ifdef CONFIG_IPV6_MODULE
70723 +EXPORT_SYMBOL(grsec_enable_blackhole);
70724 +#endif
70725 +int grsec_lastack_retries;
70726 +int grsec_enable_tpe_all;
70727 +int grsec_enable_tpe_invert;
70728 +int grsec_enable_socket_all;
70729 +kgid_t grsec_socket_all_gid;
70730 +int grsec_enable_socket_client;
70731 +kgid_t grsec_socket_client_gid;
70732 +int grsec_enable_socket_server;
70733 +kgid_t grsec_socket_server_gid;
70734 +int grsec_resource_logging;
70735 +int grsec_disable_privio;
70736 +int grsec_enable_log_rwxmaps;
70737 +int grsec_lock;
70738 +
70739 +DEFINE_SPINLOCK(grsec_alert_lock);
70740 +unsigned long grsec_alert_wtime = 0;
70741 +unsigned long grsec_alert_fyet = 0;
70742 +
70743 +DEFINE_SPINLOCK(grsec_audit_lock);
70744 +
70745 +DEFINE_RWLOCK(grsec_exec_file_lock);
70746 +
70747 +char *gr_shared_page[4];
70748 +
70749 +char *gr_alert_log_fmt;
70750 +char *gr_audit_log_fmt;
70751 +char *gr_alert_log_buf;
70752 +char *gr_audit_log_buf;
70753 +
70754 +extern struct gr_arg *gr_usermode;
70755 +extern unsigned char *gr_system_salt;
70756 +extern unsigned char *gr_system_sum;
70757 +
70758 +void __init
70759 +grsecurity_init(void)
70760 +{
70761 + int j;
70762 + /* create the per-cpu shared pages */
70763 +
70764 +#ifdef CONFIG_X86
70765 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
70766 +#endif
70767 +
70768 + for (j = 0; j < 4; j++) {
70769 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
70770 + if (gr_shared_page[j] == NULL) {
70771 + panic("Unable to allocate grsecurity shared page");
70772 + return;
70773 + }
70774 + }
70775 +
70776 + /* allocate log buffers */
70777 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
70778 + if (!gr_alert_log_fmt) {
70779 + panic("Unable to allocate grsecurity alert log format buffer");
70780 + return;
70781 + }
70782 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
70783 + if (!gr_audit_log_fmt) {
70784 + panic("Unable to allocate grsecurity audit log format buffer");
70785 + return;
70786 + }
70787 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
70788 + if (!gr_alert_log_buf) {
70789 + panic("Unable to allocate grsecurity alert log buffer");
70790 + return;
70791 + }
70792 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
70793 + if (!gr_audit_log_buf) {
70794 + panic("Unable to allocate grsecurity audit log buffer");
70795 + return;
70796 + }
70797 +
70798 + /* allocate memory for authentication structure */
70799 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
70800 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
70801 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
70802 +
70803 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
70804 + panic("Unable to allocate grsecurity authentication structure");
70805 + return;
70806 + }
70807 +
70808 +
70809 +#ifdef CONFIG_GRKERNSEC_IO
70810 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
70811 + grsec_disable_privio = 1;
70812 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
70813 + grsec_disable_privio = 1;
70814 +#else
70815 + grsec_disable_privio = 0;
70816 +#endif
70817 +#endif
70818 +
70819 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
70820 + /* for backward compatibility, tpe_invert always defaults to on if
70821 + enabled in the kernel
70822 + */
70823 + grsec_enable_tpe_invert = 1;
70824 +#endif
70825 +
70826 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
70827 +#ifndef CONFIG_GRKERNSEC_SYSCTL
70828 + grsec_lock = 1;
70829 +#endif
70830 +
70831 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70832 + grsec_enable_log_rwxmaps = 1;
70833 +#endif
70834 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
70835 + grsec_enable_group = 1;
70836 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
70837 +#endif
70838 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
70839 + grsec_enable_ptrace_readexec = 1;
70840 +#endif
70841 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
70842 + grsec_enable_chdir = 1;
70843 +#endif
70844 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
70845 + grsec_enable_harden_ptrace = 1;
70846 +#endif
70847 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
70848 + grsec_enable_mount = 1;
70849 +#endif
70850 +#ifdef CONFIG_GRKERNSEC_LINK
70851 + grsec_enable_link = 1;
70852 +#endif
70853 +#ifdef CONFIG_GRKERNSEC_BRUTE
70854 + grsec_enable_brute = 1;
70855 +#endif
70856 +#ifdef CONFIG_GRKERNSEC_DMESG
70857 + grsec_enable_dmesg = 1;
70858 +#endif
70859 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
70860 + grsec_enable_blackhole = 1;
70861 + grsec_lastack_retries = 4;
70862 +#endif
70863 +#ifdef CONFIG_GRKERNSEC_FIFO
70864 + grsec_enable_fifo = 1;
70865 +#endif
70866 +#ifdef CONFIG_GRKERNSEC_EXECLOG
70867 + grsec_enable_execlog = 1;
70868 +#endif
70869 +#ifdef CONFIG_GRKERNSEC_SETXID
70870 + grsec_enable_setxid = 1;
70871 +#endif
70872 +#ifdef CONFIG_GRKERNSEC_SIGNAL
70873 + grsec_enable_signal = 1;
70874 +#endif
70875 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
70876 + grsec_enable_forkfail = 1;
70877 +#endif
70878 +#ifdef CONFIG_GRKERNSEC_TIME
70879 + grsec_enable_time = 1;
70880 +#endif
70881 +#ifdef CONFIG_GRKERNSEC_RESLOG
70882 + grsec_resource_logging = 1;
70883 +#endif
70884 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
70885 + grsec_enable_chroot_findtask = 1;
70886 +#endif
70887 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
70888 + grsec_enable_chroot_unix = 1;
70889 +#endif
70890 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
70891 + grsec_enable_chroot_mount = 1;
70892 +#endif
70893 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
70894 + grsec_enable_chroot_fchdir = 1;
70895 +#endif
70896 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
70897 + grsec_enable_chroot_shmat = 1;
70898 +#endif
70899 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
70900 + grsec_enable_audit_ptrace = 1;
70901 +#endif
70902 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
70903 + grsec_enable_chroot_double = 1;
70904 +#endif
70905 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
70906 + grsec_enable_chroot_pivot = 1;
70907 +#endif
70908 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
70909 + grsec_enable_chroot_chdir = 1;
70910 +#endif
70911 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
70912 + grsec_enable_chroot_chmod = 1;
70913 +#endif
70914 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
70915 + grsec_enable_chroot_mknod = 1;
70916 +#endif
70917 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
70918 + grsec_enable_chroot_nice = 1;
70919 +#endif
70920 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
70921 + grsec_enable_chroot_execlog = 1;
70922 +#endif
70923 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
70924 + grsec_enable_chroot_caps = 1;
70925 +#endif
70926 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
70927 + grsec_enable_chroot_sysctl = 1;
70928 +#endif
70929 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
70930 + grsec_enable_symlinkown = 1;
70931 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
70932 +#endif
70933 +#ifdef CONFIG_GRKERNSEC_TPE
70934 + grsec_enable_tpe = 1;
70935 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
70936 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
70937 + grsec_enable_tpe_all = 1;
70938 +#endif
70939 +#endif
70940 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
70941 + grsec_enable_socket_all = 1;
70942 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
70943 +#endif
70944 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
70945 + grsec_enable_socket_client = 1;
70946 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
70947 +#endif
70948 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
70949 + grsec_enable_socket_server = 1;
70950 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
70951 +#endif
70952 +#endif
70953 +
70954 + return;
70955 +}
70956 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
70957 new file mode 100644
70958 index 0000000..5e05e20
70959 --- /dev/null
70960 +++ b/grsecurity/grsec_link.c
70961 @@ -0,0 +1,58 @@
70962 +#include <linux/kernel.h>
70963 +#include <linux/sched.h>
70964 +#include <linux/fs.h>
70965 +#include <linux/file.h>
70966 +#include <linux/grinternal.h>
70967 +
70968 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
70969 +{
70970 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
70971 + const struct inode *link_inode = link->dentry->d_inode;
70972 +
70973 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
70974 + /* ignore root-owned links, e.g. /proc/self */
70975 + gr_is_global_nonroot(link_inode->i_uid) && target &&
70976 + !uid_eq(link_inode->i_uid, target->i_uid)) {
70977 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
70978 + return 1;
70979 + }
70980 +#endif
70981 + return 0;
70982 +}
70983 +
70984 +int
70985 +gr_handle_follow_link(const struct inode *parent,
70986 + const struct inode *inode,
70987 + const struct dentry *dentry, const struct vfsmount *mnt)
70988 +{
70989 +#ifdef CONFIG_GRKERNSEC_LINK
70990 + const struct cred *cred = current_cred();
70991 +
70992 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
70993 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
70994 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
70995 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
70996 + return -EACCES;
70997 + }
70998 +#endif
70999 + return 0;
71000 +}
71001 +
71002 +int
71003 +gr_handle_hardlink(const struct dentry *dentry,
71004 + const struct vfsmount *mnt,
71005 + struct inode *inode, const int mode, const struct filename *to)
71006 +{
71007 +#ifdef CONFIG_GRKERNSEC_LINK
71008 + const struct cred *cred = current_cred();
71009 +
71010 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
71011 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
71012 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
71013 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
71014 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
71015 + return -EPERM;
71016 + }
71017 +#endif
71018 + return 0;
71019 +}
71020 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
71021 new file mode 100644
71022 index 0000000..dbe0a6b
71023 --- /dev/null
71024 +++ b/grsecurity/grsec_log.c
71025 @@ -0,0 +1,341 @@
71026 +#include <linux/kernel.h>
71027 +#include <linux/sched.h>
71028 +#include <linux/file.h>
71029 +#include <linux/tty.h>
71030 +#include <linux/fs.h>
71031 +#include <linux/mm.h>
71032 +#include <linux/grinternal.h>
71033 +
71034 +#ifdef CONFIG_TREE_PREEMPT_RCU
71035 +#define DISABLE_PREEMPT() preempt_disable()
71036 +#define ENABLE_PREEMPT() preempt_enable()
71037 +#else
71038 +#define DISABLE_PREEMPT()
71039 +#define ENABLE_PREEMPT()
71040 +#endif
71041 +
71042 +#define BEGIN_LOCKS(x) \
71043 + DISABLE_PREEMPT(); \
71044 + rcu_read_lock(); \
71045 + read_lock(&tasklist_lock); \
71046 + read_lock(&grsec_exec_file_lock); \
71047 + if (x != GR_DO_AUDIT) \
71048 + spin_lock(&grsec_alert_lock); \
71049 + else \
71050 + spin_lock(&grsec_audit_lock)
71051 +
71052 +#define END_LOCKS(x) \
71053 + if (x != GR_DO_AUDIT) \
71054 + spin_unlock(&grsec_alert_lock); \
71055 + else \
71056 + spin_unlock(&grsec_audit_lock); \
71057 + read_unlock(&grsec_exec_file_lock); \
71058 + read_unlock(&tasklist_lock); \
71059 + rcu_read_unlock(); \
71060 + ENABLE_PREEMPT(); \
71061 + if (x == GR_DONT_AUDIT) \
71062 + gr_handle_alertkill(current)
71063 +
71064 +enum {
71065 + FLOODING,
71066 + NO_FLOODING
71067 +};
71068 +
71069 +extern char *gr_alert_log_fmt;
71070 +extern char *gr_audit_log_fmt;
71071 +extern char *gr_alert_log_buf;
71072 +extern char *gr_audit_log_buf;
71073 +
71074 +static int gr_log_start(int audit)
71075 +{
71076 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
71077 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
71078 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
71079 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
71080 + unsigned long curr_secs = get_seconds();
71081 +
71082 + if (audit == GR_DO_AUDIT)
71083 + goto set_fmt;
71084 +
71085 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
71086 + grsec_alert_wtime = curr_secs;
71087 + grsec_alert_fyet = 0;
71088 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
71089 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
71090 + grsec_alert_fyet++;
71091 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
71092 + grsec_alert_wtime = curr_secs;
71093 + grsec_alert_fyet++;
71094 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
71095 + return FLOODING;
71096 + }
71097 + else return FLOODING;
71098 +
71099 +set_fmt:
71100 +#endif
71101 + memset(buf, 0, PAGE_SIZE);
71102 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
71103 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
71104 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
71105 + } else if (current->signal->curr_ip) {
71106 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
71107 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
71108 + } else if (gr_acl_is_enabled()) {
71109 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
71110 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
71111 + } else {
71112 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
71113 + strcpy(buf, fmt);
71114 + }
71115 +
71116 + return NO_FLOODING;
71117 +}
71118 +
71119 +static void gr_log_middle(int audit, const char *msg, va_list ap)
71120 + __attribute__ ((format (printf, 2, 0)));
71121 +
71122 +static void gr_log_middle(int audit, const char *msg, va_list ap)
71123 +{
71124 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
71125 + unsigned int len = strlen(buf);
71126 +
71127 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
71128 +
71129 + return;
71130 +}
71131 +
71132 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
71133 + __attribute__ ((format (printf, 2, 3)));
71134 +
71135 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
71136 +{
71137 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
71138 + unsigned int len = strlen(buf);
71139 + va_list ap;
71140 +
71141 + va_start(ap, msg);
71142 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
71143 + va_end(ap);
71144 +
71145 + return;
71146 +}
71147 +
71148 +static void gr_log_end(int audit, int append_default)
71149 +{
71150 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
71151 + if (append_default) {
71152 + struct task_struct *task = current;
71153 + struct task_struct *parent = task->real_parent;
71154 + const struct cred *cred = __task_cred(task);
71155 + const struct cred *pcred = __task_cred(parent);
71156 + unsigned int len = strlen(buf);
71157 +
71158 + 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));
71159 + }
71160 +
71161 + printk("%s\n", buf);
71162 +
71163 + return;
71164 +}
71165 +
71166 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
71167 +{
71168 + int logtype;
71169 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
71170 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
71171 + void *voidptr = NULL;
71172 + int num1 = 0, num2 = 0;
71173 + unsigned long ulong1 = 0, ulong2 = 0;
71174 + struct dentry *dentry = NULL;
71175 + struct vfsmount *mnt = NULL;
71176 + struct file *file = NULL;
71177 + struct task_struct *task = NULL;
71178 + struct vm_area_struct *vma = NULL;
71179 + const struct cred *cred, *pcred;
71180 + va_list ap;
71181 +
71182 + BEGIN_LOCKS(audit);
71183 + logtype = gr_log_start(audit);
71184 + if (logtype == FLOODING) {
71185 + END_LOCKS(audit);
71186 + return;
71187 + }
71188 + va_start(ap, argtypes);
71189 + switch (argtypes) {
71190 + case GR_TTYSNIFF:
71191 + task = va_arg(ap, struct task_struct *);
71192 + 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));
71193 + break;
71194 + case GR_SYSCTL_HIDDEN:
71195 + str1 = va_arg(ap, char *);
71196 + gr_log_middle_varargs(audit, msg, result, str1);
71197 + break;
71198 + case GR_RBAC:
71199 + dentry = va_arg(ap, struct dentry *);
71200 + mnt = va_arg(ap, struct vfsmount *);
71201 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
71202 + break;
71203 + case GR_RBAC_STR:
71204 + dentry = va_arg(ap, struct dentry *);
71205 + mnt = va_arg(ap, struct vfsmount *);
71206 + str1 = va_arg(ap, char *);
71207 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
71208 + break;
71209 + case GR_STR_RBAC:
71210 + str1 = va_arg(ap, char *);
71211 + dentry = va_arg(ap, struct dentry *);
71212 + mnt = va_arg(ap, struct vfsmount *);
71213 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
71214 + break;
71215 + case GR_RBAC_MODE2:
71216 + dentry = va_arg(ap, struct dentry *);
71217 + mnt = va_arg(ap, struct vfsmount *);
71218 + str1 = va_arg(ap, char *);
71219 + str2 = va_arg(ap, char *);
71220 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
71221 + break;
71222 + case GR_RBAC_MODE3:
71223 + dentry = va_arg(ap, struct dentry *);
71224 + mnt = va_arg(ap, struct vfsmount *);
71225 + str1 = va_arg(ap, char *);
71226 + str2 = va_arg(ap, char *);
71227 + str3 = va_arg(ap, char *);
71228 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
71229 + break;
71230 + case GR_FILENAME:
71231 + dentry = va_arg(ap, struct dentry *);
71232 + mnt = va_arg(ap, struct vfsmount *);
71233 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
71234 + break;
71235 + case GR_STR_FILENAME:
71236 + str1 = va_arg(ap, char *);
71237 + dentry = va_arg(ap, struct dentry *);
71238 + mnt = va_arg(ap, struct vfsmount *);
71239 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
71240 + break;
71241 + case GR_FILENAME_STR:
71242 + dentry = va_arg(ap, struct dentry *);
71243 + mnt = va_arg(ap, struct vfsmount *);
71244 + str1 = va_arg(ap, char *);
71245 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
71246 + break;
71247 + case GR_FILENAME_TWO_INT:
71248 + dentry = va_arg(ap, struct dentry *);
71249 + mnt = va_arg(ap, struct vfsmount *);
71250 + num1 = va_arg(ap, int);
71251 + num2 = va_arg(ap, int);
71252 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
71253 + break;
71254 + case GR_FILENAME_TWO_INT_STR:
71255 + dentry = va_arg(ap, struct dentry *);
71256 + mnt = va_arg(ap, struct vfsmount *);
71257 + num1 = va_arg(ap, int);
71258 + num2 = va_arg(ap, int);
71259 + str1 = va_arg(ap, char *);
71260 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
71261 + break;
71262 + case GR_TEXTREL:
71263 + file = va_arg(ap, struct file *);
71264 + ulong1 = va_arg(ap, unsigned long);
71265 + ulong2 = va_arg(ap, unsigned long);
71266 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
71267 + break;
71268 + case GR_PTRACE:
71269 + task = va_arg(ap, struct task_struct *);
71270 + 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));
71271 + break;
71272 + case GR_RESOURCE:
71273 + task = va_arg(ap, struct task_struct *);
71274 + cred = __task_cred(task);
71275 + pcred = __task_cred(task->real_parent);
71276 + ulong1 = va_arg(ap, unsigned long);
71277 + str1 = va_arg(ap, char *);
71278 + ulong2 = va_arg(ap, unsigned long);
71279 + 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));
71280 + break;
71281 + case GR_CAP:
71282 + task = va_arg(ap, struct task_struct *);
71283 + cred = __task_cred(task);
71284 + pcred = __task_cred(task->real_parent);
71285 + str1 = va_arg(ap, char *);
71286 + 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));
71287 + break;
71288 + case GR_SIG:
71289 + str1 = va_arg(ap, char *);
71290 + voidptr = va_arg(ap, void *);
71291 + gr_log_middle_varargs(audit, msg, str1, voidptr);
71292 + break;
71293 + case GR_SIG2:
71294 + task = va_arg(ap, struct task_struct *);
71295 + cred = __task_cred(task);
71296 + pcred = __task_cred(task->real_parent);
71297 + num1 = va_arg(ap, int);
71298 + 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));
71299 + break;
71300 + case GR_CRASH1:
71301 + task = va_arg(ap, struct task_struct *);
71302 + cred = __task_cred(task);
71303 + pcred = __task_cred(task->real_parent);
71304 + ulong1 = va_arg(ap, unsigned long);
71305 + 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);
71306 + break;
71307 + case GR_CRASH2:
71308 + task = va_arg(ap, struct task_struct *);
71309 + cred = __task_cred(task);
71310 + pcred = __task_cred(task->real_parent);
71311 + ulong1 = va_arg(ap, unsigned long);
71312 + 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);
71313 + break;
71314 + case GR_RWXMAP:
71315 + file = va_arg(ap, struct file *);
71316 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
71317 + break;
71318 + case GR_RWXMAPVMA:
71319 + vma = va_arg(ap, struct vm_area_struct *);
71320 + if (vma->vm_file)
71321 + str1 = gr_to_filename(vma->vm_file->f_path.dentry, vma->vm_file->f_path.mnt);
71322 + else if (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
71323 + str1 = "<stack>";
71324 + else if (vma->vm_start <= current->mm->brk &&
71325 + vma->vm_end >= current->mm->start_brk)
71326 + str1 = "<heap>";
71327 + else
71328 + str1 = "<anonymous mapping>";
71329 + gr_log_middle_varargs(audit, msg, str1);
71330 + break;
71331 + case GR_PSACCT:
71332 + {
71333 + unsigned int wday, cday;
71334 + __u8 whr, chr;
71335 + __u8 wmin, cmin;
71336 + __u8 wsec, csec;
71337 + char cur_tty[64] = { 0 };
71338 + char parent_tty[64] = { 0 };
71339 +
71340 + task = va_arg(ap, struct task_struct *);
71341 + wday = va_arg(ap, unsigned int);
71342 + cday = va_arg(ap, unsigned int);
71343 + whr = va_arg(ap, int);
71344 + chr = va_arg(ap, int);
71345 + wmin = va_arg(ap, int);
71346 + cmin = va_arg(ap, int);
71347 + wsec = va_arg(ap, int);
71348 + csec = va_arg(ap, int);
71349 + ulong1 = va_arg(ap, unsigned long);
71350 + cred = __task_cred(task);
71351 + pcred = __task_cred(task->real_parent);
71352 +
71353 + 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));
71354 + }
71355 + break;
71356 + default:
71357 + gr_log_middle(audit, msg, ap);
71358 + }
71359 + va_end(ap);
71360 + // these don't need DEFAULTSECARGS printed on the end
71361 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
71362 + gr_log_end(audit, 0);
71363 + else
71364 + gr_log_end(audit, 1);
71365 + END_LOCKS(audit);
71366 +}
71367 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
71368 new file mode 100644
71369 index 0000000..f536303
71370 --- /dev/null
71371 +++ b/grsecurity/grsec_mem.c
71372 @@ -0,0 +1,40 @@
71373 +#include <linux/kernel.h>
71374 +#include <linux/sched.h>
71375 +#include <linux/mm.h>
71376 +#include <linux/mman.h>
71377 +#include <linux/grinternal.h>
71378 +
71379 +void
71380 +gr_handle_ioperm(void)
71381 +{
71382 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
71383 + return;
71384 +}
71385 +
71386 +void
71387 +gr_handle_iopl(void)
71388 +{
71389 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
71390 + return;
71391 +}
71392 +
71393 +void
71394 +gr_handle_mem_readwrite(u64 from, u64 to)
71395 +{
71396 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
71397 + return;
71398 +}
71399 +
71400 +void
71401 +gr_handle_vm86(void)
71402 +{
71403 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
71404 + return;
71405 +}
71406 +
71407 +void
71408 +gr_log_badprocpid(const char *entry)
71409 +{
71410 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
71411 + return;
71412 +}
71413 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
71414 new file mode 100644
71415 index 0000000..2131422
71416 --- /dev/null
71417 +++ b/grsecurity/grsec_mount.c
71418 @@ -0,0 +1,62 @@
71419 +#include <linux/kernel.h>
71420 +#include <linux/sched.h>
71421 +#include <linux/mount.h>
71422 +#include <linux/grsecurity.h>
71423 +#include <linux/grinternal.h>
71424 +
71425 +void
71426 +gr_log_remount(const char *devname, const int retval)
71427 +{
71428 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
71429 + if (grsec_enable_mount && (retval >= 0))
71430 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
71431 +#endif
71432 + return;
71433 +}
71434 +
71435 +void
71436 +gr_log_unmount(const char *devname, const int retval)
71437 +{
71438 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
71439 + if (grsec_enable_mount && (retval >= 0))
71440 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
71441 +#endif
71442 + return;
71443 +}
71444 +
71445 +void
71446 +gr_log_mount(const char *from, const char *to, const int retval)
71447 +{
71448 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
71449 + if (grsec_enable_mount && (retval >= 0))
71450 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
71451 +#endif
71452 + return;
71453 +}
71454 +
71455 +int
71456 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
71457 +{
71458 +#ifdef CONFIG_GRKERNSEC_ROFS
71459 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
71460 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
71461 + return -EPERM;
71462 + } else
71463 + return 0;
71464 +#endif
71465 + return 0;
71466 +}
71467 +
71468 +int
71469 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
71470 +{
71471 +#ifdef CONFIG_GRKERNSEC_ROFS
71472 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
71473 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
71474 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
71475 + return -EPERM;
71476 + } else
71477 + return 0;
71478 +#endif
71479 + return 0;
71480 +}
71481 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
71482 new file mode 100644
71483 index 0000000..6ee9d50
71484 --- /dev/null
71485 +++ b/grsecurity/grsec_pax.c
71486 @@ -0,0 +1,45 @@
71487 +#include <linux/kernel.h>
71488 +#include <linux/sched.h>
71489 +#include <linux/mm.h>
71490 +#include <linux/file.h>
71491 +#include <linux/grinternal.h>
71492 +#include <linux/grsecurity.h>
71493 +
71494 +void
71495 +gr_log_textrel(struct vm_area_struct * vma)
71496 +{
71497 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71498 + if (grsec_enable_log_rwxmaps)
71499 + gr_log_textrel_ulong_ulong(GR_DONT_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
71500 +#endif
71501 + return;
71502 +}
71503 +
71504 +void gr_log_ptgnustack(struct file *file)
71505 +{
71506 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71507 + if (grsec_enable_log_rwxmaps)
71508 + gr_log_rwxmap(GR_DONT_AUDIT, GR_PTGNUSTACK_MSG, file);
71509 +#endif
71510 + return;
71511 +}
71512 +
71513 +void
71514 +gr_log_rwxmmap(struct file *file)
71515 +{
71516 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71517 + if (grsec_enable_log_rwxmaps)
71518 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
71519 +#endif
71520 + return;
71521 +}
71522 +
71523 +void
71524 +gr_log_rwxmprotect(struct vm_area_struct *vma)
71525 +{
71526 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71527 + if (grsec_enable_log_rwxmaps)
71528 + gr_log_rwxmap_vma(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, vma);
71529 +#endif
71530 + return;
71531 +}
71532 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
71533 new file mode 100644
71534 index 0000000..f7f29aa
71535 --- /dev/null
71536 +++ b/grsecurity/grsec_ptrace.c
71537 @@ -0,0 +1,30 @@
71538 +#include <linux/kernel.h>
71539 +#include <linux/sched.h>
71540 +#include <linux/grinternal.h>
71541 +#include <linux/security.h>
71542 +
71543 +void
71544 +gr_audit_ptrace(struct task_struct *task)
71545 +{
71546 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
71547 + if (grsec_enable_audit_ptrace)
71548 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
71549 +#endif
71550 + return;
71551 +}
71552 +
71553 +int
71554 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
71555 +{
71556 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
71557 + const struct dentry *dentry = file->f_path.dentry;
71558 + const struct vfsmount *mnt = file->f_path.mnt;
71559 +
71560 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
71561 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
71562 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
71563 + return -EACCES;
71564 + }
71565 +#endif
71566 + return 0;
71567 +}
71568 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
71569 new file mode 100644
71570 index 0000000..4e29cc7
71571 --- /dev/null
71572 +++ b/grsecurity/grsec_sig.c
71573 @@ -0,0 +1,246 @@
71574 +#include <linux/kernel.h>
71575 +#include <linux/sched.h>
71576 +#include <linux/fs.h>
71577 +#include <linux/delay.h>
71578 +#include <linux/grsecurity.h>
71579 +#include <linux/grinternal.h>
71580 +#include <linux/hardirq.h>
71581 +
71582 +char *signames[] = {
71583 + [SIGSEGV] = "Segmentation fault",
71584 + [SIGILL] = "Illegal instruction",
71585 + [SIGABRT] = "Abort",
71586 + [SIGBUS] = "Invalid alignment/Bus error"
71587 +};
71588 +
71589 +void
71590 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
71591 +{
71592 +#ifdef CONFIG_GRKERNSEC_SIGNAL
71593 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
71594 + (sig == SIGABRT) || (sig == SIGBUS))) {
71595 + if (task_pid_nr(t) == task_pid_nr(current)) {
71596 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
71597 + } else {
71598 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
71599 + }
71600 + }
71601 +#endif
71602 + return;
71603 +}
71604 +
71605 +int
71606 +gr_handle_signal(const struct task_struct *p, const int sig)
71607 +{
71608 +#ifdef CONFIG_GRKERNSEC
71609 + /* ignore the 0 signal for protected task checks */
71610 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
71611 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
71612 + return -EPERM;
71613 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
71614 + return -EPERM;
71615 + }
71616 +#endif
71617 + return 0;
71618 +}
71619 +
71620 +#ifdef CONFIG_GRKERNSEC
71621 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
71622 +
71623 +int gr_fake_force_sig(int sig, struct task_struct *t)
71624 +{
71625 + unsigned long int flags;
71626 + int ret, blocked, ignored;
71627 + struct k_sigaction *action;
71628 +
71629 + spin_lock_irqsave(&t->sighand->siglock, flags);
71630 + action = &t->sighand->action[sig-1];
71631 + ignored = action->sa.sa_handler == SIG_IGN;
71632 + blocked = sigismember(&t->blocked, sig);
71633 + if (blocked || ignored) {
71634 + action->sa.sa_handler = SIG_DFL;
71635 + if (blocked) {
71636 + sigdelset(&t->blocked, sig);
71637 + recalc_sigpending_and_wake(t);
71638 + }
71639 + }
71640 + if (action->sa.sa_handler == SIG_DFL)
71641 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
71642 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
71643 +
71644 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
71645 +
71646 + return ret;
71647 +}
71648 +#endif
71649 +
71650 +#ifdef CONFIG_GRKERNSEC_BRUTE
71651 +#define GR_USER_BAN_TIME (15 * 60)
71652 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
71653 +
71654 +static int __get_dumpable(unsigned long mm_flags)
71655 +{
71656 + int ret;
71657 +
71658 + ret = mm_flags & MMF_DUMPABLE_MASK;
71659 + return (ret >= 2) ? 2 : ret;
71660 +}
71661 +#endif
71662 +
71663 +void gr_handle_brute_attach(unsigned long mm_flags)
71664 +{
71665 +#ifdef CONFIG_GRKERNSEC_BRUTE
71666 + struct task_struct *p = current;
71667 + kuid_t uid = GLOBAL_ROOT_UID;
71668 + int daemon = 0;
71669 +
71670 + if (!grsec_enable_brute)
71671 + return;
71672 +
71673 + rcu_read_lock();
71674 + read_lock(&tasklist_lock);
71675 + read_lock(&grsec_exec_file_lock);
71676 + if (p->real_parent && gr_is_same_file(p->real_parent->exec_file, p->exec_file)) {
71677 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
71678 + p->real_parent->brute = 1;
71679 + daemon = 1;
71680 + } else {
71681 + const struct cred *cred = __task_cred(p), *cred2;
71682 + struct task_struct *tsk, *tsk2;
71683 +
71684 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
71685 + struct user_struct *user;
71686 +
71687 + uid = cred->uid;
71688 +
71689 + /* this is put upon execution past expiration */
71690 + user = find_user(uid);
71691 + if (user == NULL)
71692 + goto unlock;
71693 + user->suid_banned = 1;
71694 + user->suid_ban_expires = get_seconds() + GR_USER_BAN_TIME;
71695 + if (user->suid_ban_expires == ~0UL)
71696 + user->suid_ban_expires--;
71697 +
71698 + /* only kill other threads of the same binary, from the same user */
71699 + do_each_thread(tsk2, tsk) {
71700 + cred2 = __task_cred(tsk);
71701 + if (tsk != p && uid_eq(cred2->uid, uid) && gr_is_same_file(tsk->exec_file, p->exec_file))
71702 + gr_fake_force_sig(SIGKILL, tsk);
71703 + } while_each_thread(tsk2, tsk);
71704 + }
71705 + }
71706 +unlock:
71707 + read_unlock(&grsec_exec_file_lock);
71708 + read_unlock(&tasklist_lock);
71709 + rcu_read_unlock();
71710 +
71711 + if (gr_is_global_nonroot(uid))
71712 + 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);
71713 + else if (daemon)
71714 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
71715 +
71716 +#endif
71717 + return;
71718 +}
71719 +
71720 +void gr_handle_brute_check(void)
71721 +{
71722 +#ifdef CONFIG_GRKERNSEC_BRUTE
71723 + struct task_struct *p = current;
71724 +
71725 + if (unlikely(p->brute)) {
71726 + if (!grsec_enable_brute)
71727 + p->brute = 0;
71728 + else if (time_before(get_seconds(), p->brute_expires))
71729 + msleep(30 * 1000);
71730 + }
71731 +#endif
71732 + return;
71733 +}
71734 +
71735 +void gr_handle_kernel_exploit(void)
71736 +{
71737 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
71738 + const struct cred *cred;
71739 + struct task_struct *tsk, *tsk2;
71740 + struct user_struct *user;
71741 + kuid_t uid;
71742 +
71743 + if (in_irq() || in_serving_softirq() || in_nmi())
71744 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
71745 +
71746 + uid = current_uid();
71747 +
71748 + if (gr_is_global_root(uid))
71749 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
71750 + else {
71751 + /* kill all the processes of this user, hold a reference
71752 + to their creds struct, and prevent them from creating
71753 + another process until system reset
71754 + */
71755 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
71756 + GR_GLOBAL_UID(uid));
71757 + /* we intentionally leak this ref */
71758 + user = get_uid(current->cred->user);
71759 + if (user)
71760 + user->kernel_banned = 1;
71761 +
71762 + /* kill all processes of this user */
71763 + read_lock(&tasklist_lock);
71764 + do_each_thread(tsk2, tsk) {
71765 + cred = __task_cred(tsk);
71766 + if (uid_eq(cred->uid, uid))
71767 + gr_fake_force_sig(SIGKILL, tsk);
71768 + } while_each_thread(tsk2, tsk);
71769 + read_unlock(&tasklist_lock);
71770 + }
71771 +#endif
71772 +}
71773 +
71774 +#ifdef CONFIG_GRKERNSEC_BRUTE
71775 +static bool suid_ban_expired(struct user_struct *user)
71776 +{
71777 + if (user->suid_ban_expires != ~0UL && time_after_eq(get_seconds(), user->suid_ban_expires)) {
71778 + user->suid_banned = 0;
71779 + user->suid_ban_expires = 0;
71780 + free_uid(user);
71781 + return true;
71782 + }
71783 +
71784 + return false;
71785 +}
71786 +#endif
71787 +
71788 +int gr_process_kernel_exec_ban(void)
71789 +{
71790 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
71791 + if (unlikely(current->cred->user->kernel_banned))
71792 + return -EPERM;
71793 +#endif
71794 + return 0;
71795 +}
71796 +
71797 +int gr_process_kernel_setuid_ban(struct user_struct *user)
71798 +{
71799 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
71800 + if (unlikely(user->kernel_banned))
71801 + gr_fake_force_sig(SIGKILL, current);
71802 +#endif
71803 + return 0;
71804 +}
71805 +
71806 +int gr_process_suid_exec_ban(const struct linux_binprm *bprm)
71807 +{
71808 +#ifdef CONFIG_GRKERNSEC_BRUTE
71809 + struct user_struct *user = current->cred->user;
71810 + if (unlikely(user->suid_banned)) {
71811 + if (suid_ban_expired(user))
71812 + return 0;
71813 + /* disallow execution of suid binaries only */
71814 + else if (!uid_eq(bprm->cred->euid, current->cred->uid))
71815 + return -EPERM;
71816 + }
71817 +#endif
71818 + return 0;
71819 +}
71820 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
71821 new file mode 100644
71822 index 0000000..4030d57
71823 --- /dev/null
71824 +++ b/grsecurity/grsec_sock.c
71825 @@ -0,0 +1,244 @@
71826 +#include <linux/kernel.h>
71827 +#include <linux/module.h>
71828 +#include <linux/sched.h>
71829 +#include <linux/file.h>
71830 +#include <linux/net.h>
71831 +#include <linux/in.h>
71832 +#include <linux/ip.h>
71833 +#include <net/sock.h>
71834 +#include <net/inet_sock.h>
71835 +#include <linux/grsecurity.h>
71836 +#include <linux/grinternal.h>
71837 +#include <linux/gracl.h>
71838 +
71839 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
71840 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
71841 +
71842 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
71843 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
71844 +
71845 +#ifdef CONFIG_UNIX_MODULE
71846 +EXPORT_SYMBOL(gr_acl_handle_unix);
71847 +EXPORT_SYMBOL(gr_acl_handle_mknod);
71848 +EXPORT_SYMBOL(gr_handle_chroot_unix);
71849 +EXPORT_SYMBOL(gr_handle_create);
71850 +#endif
71851 +
71852 +#ifdef CONFIG_GRKERNSEC
71853 +#define gr_conn_table_size 32749
71854 +struct conn_table_entry {
71855 + struct conn_table_entry *next;
71856 + struct signal_struct *sig;
71857 +};
71858 +
71859 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
71860 +DEFINE_SPINLOCK(gr_conn_table_lock);
71861 +
71862 +extern const char * gr_socktype_to_name(unsigned char type);
71863 +extern const char * gr_proto_to_name(unsigned char proto);
71864 +extern const char * gr_sockfamily_to_name(unsigned char family);
71865 +
71866 +static __inline__ int
71867 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
71868 +{
71869 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
71870 +}
71871 +
71872 +static __inline__ int
71873 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
71874 + __u16 sport, __u16 dport)
71875 +{
71876 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
71877 + sig->gr_sport == sport && sig->gr_dport == dport))
71878 + return 1;
71879 + else
71880 + return 0;
71881 +}
71882 +
71883 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
71884 +{
71885 + struct conn_table_entry **match;
71886 + unsigned int index;
71887 +
71888 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
71889 + sig->gr_sport, sig->gr_dport,
71890 + gr_conn_table_size);
71891 +
71892 + newent->sig = sig;
71893 +
71894 + match = &gr_conn_table[index];
71895 + newent->next = *match;
71896 + *match = newent;
71897 +
71898 + return;
71899 +}
71900 +
71901 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
71902 +{
71903 + struct conn_table_entry *match, *last = NULL;
71904 + unsigned int index;
71905 +
71906 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
71907 + sig->gr_sport, sig->gr_dport,
71908 + gr_conn_table_size);
71909 +
71910 + match = gr_conn_table[index];
71911 + while (match && !conn_match(match->sig,
71912 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
71913 + sig->gr_dport)) {
71914 + last = match;
71915 + match = match->next;
71916 + }
71917 +
71918 + if (match) {
71919 + if (last)
71920 + last->next = match->next;
71921 + else
71922 + gr_conn_table[index] = NULL;
71923 + kfree(match);
71924 + }
71925 +
71926 + return;
71927 +}
71928 +
71929 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
71930 + __u16 sport, __u16 dport)
71931 +{
71932 + struct conn_table_entry *match;
71933 + unsigned int index;
71934 +
71935 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
71936 +
71937 + match = gr_conn_table[index];
71938 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
71939 + match = match->next;
71940 +
71941 + if (match)
71942 + return match->sig;
71943 + else
71944 + return NULL;
71945 +}
71946 +
71947 +#endif
71948 +
71949 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
71950 +{
71951 +#ifdef CONFIG_GRKERNSEC
71952 + struct signal_struct *sig = task->signal;
71953 + struct conn_table_entry *newent;
71954 +
71955 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
71956 + if (newent == NULL)
71957 + return;
71958 + /* no bh lock needed since we are called with bh disabled */
71959 + spin_lock(&gr_conn_table_lock);
71960 + gr_del_task_from_ip_table_nolock(sig);
71961 + sig->gr_saddr = inet->inet_rcv_saddr;
71962 + sig->gr_daddr = inet->inet_daddr;
71963 + sig->gr_sport = inet->inet_sport;
71964 + sig->gr_dport = inet->inet_dport;
71965 + gr_add_to_task_ip_table_nolock(sig, newent);
71966 + spin_unlock(&gr_conn_table_lock);
71967 +#endif
71968 + return;
71969 +}
71970 +
71971 +void gr_del_task_from_ip_table(struct task_struct *task)
71972 +{
71973 +#ifdef CONFIG_GRKERNSEC
71974 + spin_lock_bh(&gr_conn_table_lock);
71975 + gr_del_task_from_ip_table_nolock(task->signal);
71976 + spin_unlock_bh(&gr_conn_table_lock);
71977 +#endif
71978 + return;
71979 +}
71980 +
71981 +void
71982 +gr_attach_curr_ip(const struct sock *sk)
71983 +{
71984 +#ifdef CONFIG_GRKERNSEC
71985 + struct signal_struct *p, *set;
71986 + const struct inet_sock *inet = inet_sk(sk);
71987 +
71988 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
71989 + return;
71990 +
71991 + set = current->signal;
71992 +
71993 + spin_lock_bh(&gr_conn_table_lock);
71994 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
71995 + inet->inet_dport, inet->inet_sport);
71996 + if (unlikely(p != NULL)) {
71997 + set->curr_ip = p->curr_ip;
71998 + set->used_accept = 1;
71999 + gr_del_task_from_ip_table_nolock(p);
72000 + spin_unlock_bh(&gr_conn_table_lock);
72001 + return;
72002 + }
72003 + spin_unlock_bh(&gr_conn_table_lock);
72004 +
72005 + set->curr_ip = inet->inet_daddr;
72006 + set->used_accept = 1;
72007 +#endif
72008 + return;
72009 +}
72010 +
72011 +int
72012 +gr_handle_sock_all(const int family, const int type, const int protocol)
72013 +{
72014 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
72015 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
72016 + (family != AF_UNIX)) {
72017 + if (family == AF_INET)
72018 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
72019 + else
72020 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
72021 + return -EACCES;
72022 + }
72023 +#endif
72024 + return 0;
72025 +}
72026 +
72027 +int
72028 +gr_handle_sock_server(const struct sockaddr *sck)
72029 +{
72030 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
72031 + if (grsec_enable_socket_server &&
72032 + in_group_p(grsec_socket_server_gid) &&
72033 + sck && (sck->sa_family != AF_UNIX) &&
72034 + (sck->sa_family != AF_LOCAL)) {
72035 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
72036 + return -EACCES;
72037 + }
72038 +#endif
72039 + return 0;
72040 +}
72041 +
72042 +int
72043 +gr_handle_sock_server_other(const struct sock *sck)
72044 +{
72045 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
72046 + if (grsec_enable_socket_server &&
72047 + in_group_p(grsec_socket_server_gid) &&
72048 + sck && (sck->sk_family != AF_UNIX) &&
72049 + (sck->sk_family != AF_LOCAL)) {
72050 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
72051 + return -EACCES;
72052 + }
72053 +#endif
72054 + return 0;
72055 +}
72056 +
72057 +int
72058 +gr_handle_sock_client(const struct sockaddr *sck)
72059 +{
72060 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
72061 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
72062 + sck && (sck->sa_family != AF_UNIX) &&
72063 + (sck->sa_family != AF_LOCAL)) {
72064 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
72065 + return -EACCES;
72066 + }
72067 +#endif
72068 + return 0;
72069 +}
72070 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
72071 new file mode 100644
72072 index 0000000..a9e378f
72073 --- /dev/null
72074 +++ b/grsecurity/grsec_sysctl.c
72075 @@ -0,0 +1,472 @@
72076 +#include <linux/kernel.h>
72077 +#include <linux/sched.h>
72078 +#include <linux/sysctl.h>
72079 +#include <linux/grsecurity.h>
72080 +#include <linux/grinternal.h>
72081 +
72082 +int
72083 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
72084 +{
72085 +#ifdef CONFIG_GRKERNSEC_SYSCTL
72086 + if (dirname == NULL || name == NULL)
72087 + return 0;
72088 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
72089 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
72090 + return -EACCES;
72091 + }
72092 +#endif
72093 + return 0;
72094 +}
72095 +
72096 +#if defined(CONFIG_GRKERNSEC_ROFS) || defined(CONFIG_GRKERNSEC_DENYUSB)
72097 +static int __maybe_unused __read_only one = 1;
72098 +#endif
72099 +
72100 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS) || \
72101 + defined(CONFIG_GRKERNSEC_DENYUSB)
72102 +struct ctl_table grsecurity_table[] = {
72103 +#ifdef CONFIG_GRKERNSEC_SYSCTL
72104 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
72105 +#ifdef CONFIG_GRKERNSEC_IO
72106 + {
72107 + .procname = "disable_priv_io",
72108 + .data = &grsec_disable_privio,
72109 + .maxlen = sizeof(int),
72110 + .mode = 0600,
72111 + .proc_handler = &proc_dointvec,
72112 + },
72113 +#endif
72114 +#endif
72115 +#ifdef CONFIG_GRKERNSEC_LINK
72116 + {
72117 + .procname = "linking_restrictions",
72118 + .data = &grsec_enable_link,
72119 + .maxlen = sizeof(int),
72120 + .mode = 0600,
72121 + .proc_handler = &proc_dointvec,
72122 + },
72123 +#endif
72124 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
72125 + {
72126 + .procname = "enforce_symlinksifowner",
72127 + .data = &grsec_enable_symlinkown,
72128 + .maxlen = sizeof(int),
72129 + .mode = 0600,
72130 + .proc_handler = &proc_dointvec,
72131 + },
72132 + {
72133 + .procname = "symlinkown_gid",
72134 + .data = &grsec_symlinkown_gid,
72135 + .maxlen = sizeof(int),
72136 + .mode = 0600,
72137 + .proc_handler = &proc_dointvec,
72138 + },
72139 +#endif
72140 +#ifdef CONFIG_GRKERNSEC_BRUTE
72141 + {
72142 + .procname = "deter_bruteforce",
72143 + .data = &grsec_enable_brute,
72144 + .maxlen = sizeof(int),
72145 + .mode = 0600,
72146 + .proc_handler = &proc_dointvec,
72147 + },
72148 +#endif
72149 +#ifdef CONFIG_GRKERNSEC_FIFO
72150 + {
72151 + .procname = "fifo_restrictions",
72152 + .data = &grsec_enable_fifo,
72153 + .maxlen = sizeof(int),
72154 + .mode = 0600,
72155 + .proc_handler = &proc_dointvec,
72156 + },
72157 +#endif
72158 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
72159 + {
72160 + .procname = "ptrace_readexec",
72161 + .data = &grsec_enable_ptrace_readexec,
72162 + .maxlen = sizeof(int),
72163 + .mode = 0600,
72164 + .proc_handler = &proc_dointvec,
72165 + },
72166 +#endif
72167 +#ifdef CONFIG_GRKERNSEC_SETXID
72168 + {
72169 + .procname = "consistent_setxid",
72170 + .data = &grsec_enable_setxid,
72171 + .maxlen = sizeof(int),
72172 + .mode = 0600,
72173 + .proc_handler = &proc_dointvec,
72174 + },
72175 +#endif
72176 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
72177 + {
72178 + .procname = "ip_blackhole",
72179 + .data = &grsec_enable_blackhole,
72180 + .maxlen = sizeof(int),
72181 + .mode = 0600,
72182 + .proc_handler = &proc_dointvec,
72183 + },
72184 + {
72185 + .procname = "lastack_retries",
72186 + .data = &grsec_lastack_retries,
72187 + .maxlen = sizeof(int),
72188 + .mode = 0600,
72189 + .proc_handler = &proc_dointvec,
72190 + },
72191 +#endif
72192 +#ifdef CONFIG_GRKERNSEC_EXECLOG
72193 + {
72194 + .procname = "exec_logging",
72195 + .data = &grsec_enable_execlog,
72196 + .maxlen = sizeof(int),
72197 + .mode = 0600,
72198 + .proc_handler = &proc_dointvec,
72199 + },
72200 +#endif
72201 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
72202 + {
72203 + .procname = "rwxmap_logging",
72204 + .data = &grsec_enable_log_rwxmaps,
72205 + .maxlen = sizeof(int),
72206 + .mode = 0600,
72207 + .proc_handler = &proc_dointvec,
72208 + },
72209 +#endif
72210 +#ifdef CONFIG_GRKERNSEC_SIGNAL
72211 + {
72212 + .procname = "signal_logging",
72213 + .data = &grsec_enable_signal,
72214 + .maxlen = sizeof(int),
72215 + .mode = 0600,
72216 + .proc_handler = &proc_dointvec,
72217 + },
72218 +#endif
72219 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
72220 + {
72221 + .procname = "forkfail_logging",
72222 + .data = &grsec_enable_forkfail,
72223 + .maxlen = sizeof(int),
72224 + .mode = 0600,
72225 + .proc_handler = &proc_dointvec,
72226 + },
72227 +#endif
72228 +#ifdef CONFIG_GRKERNSEC_TIME
72229 + {
72230 + .procname = "timechange_logging",
72231 + .data = &grsec_enable_time,
72232 + .maxlen = sizeof(int),
72233 + .mode = 0600,
72234 + .proc_handler = &proc_dointvec,
72235 + },
72236 +#endif
72237 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
72238 + {
72239 + .procname = "chroot_deny_shmat",
72240 + .data = &grsec_enable_chroot_shmat,
72241 + .maxlen = sizeof(int),
72242 + .mode = 0600,
72243 + .proc_handler = &proc_dointvec,
72244 + },
72245 +#endif
72246 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
72247 + {
72248 + .procname = "chroot_deny_unix",
72249 + .data = &grsec_enable_chroot_unix,
72250 + .maxlen = sizeof(int),
72251 + .mode = 0600,
72252 + .proc_handler = &proc_dointvec,
72253 + },
72254 +#endif
72255 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
72256 + {
72257 + .procname = "chroot_deny_mount",
72258 + .data = &grsec_enable_chroot_mount,
72259 + .maxlen = sizeof(int),
72260 + .mode = 0600,
72261 + .proc_handler = &proc_dointvec,
72262 + },
72263 +#endif
72264 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
72265 + {
72266 + .procname = "chroot_deny_fchdir",
72267 + .data = &grsec_enable_chroot_fchdir,
72268 + .maxlen = sizeof(int),
72269 + .mode = 0600,
72270 + .proc_handler = &proc_dointvec,
72271 + },
72272 +#endif
72273 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
72274 + {
72275 + .procname = "chroot_deny_chroot",
72276 + .data = &grsec_enable_chroot_double,
72277 + .maxlen = sizeof(int),
72278 + .mode = 0600,
72279 + .proc_handler = &proc_dointvec,
72280 + },
72281 +#endif
72282 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
72283 + {
72284 + .procname = "chroot_deny_pivot",
72285 + .data = &grsec_enable_chroot_pivot,
72286 + .maxlen = sizeof(int),
72287 + .mode = 0600,
72288 + .proc_handler = &proc_dointvec,
72289 + },
72290 +#endif
72291 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
72292 + {
72293 + .procname = "chroot_enforce_chdir",
72294 + .data = &grsec_enable_chroot_chdir,
72295 + .maxlen = sizeof(int),
72296 + .mode = 0600,
72297 + .proc_handler = &proc_dointvec,
72298 + },
72299 +#endif
72300 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
72301 + {
72302 + .procname = "chroot_deny_chmod",
72303 + .data = &grsec_enable_chroot_chmod,
72304 + .maxlen = sizeof(int),
72305 + .mode = 0600,
72306 + .proc_handler = &proc_dointvec,
72307 + },
72308 +#endif
72309 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
72310 + {
72311 + .procname = "chroot_deny_mknod",
72312 + .data = &grsec_enable_chroot_mknod,
72313 + .maxlen = sizeof(int),
72314 + .mode = 0600,
72315 + .proc_handler = &proc_dointvec,
72316 + },
72317 +#endif
72318 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
72319 + {
72320 + .procname = "chroot_restrict_nice",
72321 + .data = &grsec_enable_chroot_nice,
72322 + .maxlen = sizeof(int),
72323 + .mode = 0600,
72324 + .proc_handler = &proc_dointvec,
72325 + },
72326 +#endif
72327 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
72328 + {
72329 + .procname = "chroot_execlog",
72330 + .data = &grsec_enable_chroot_execlog,
72331 + .maxlen = sizeof(int),
72332 + .mode = 0600,
72333 + .proc_handler = &proc_dointvec,
72334 + },
72335 +#endif
72336 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
72337 + {
72338 + .procname = "chroot_caps",
72339 + .data = &grsec_enable_chroot_caps,
72340 + .maxlen = sizeof(int),
72341 + .mode = 0600,
72342 + .proc_handler = &proc_dointvec,
72343 + },
72344 +#endif
72345 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
72346 + {
72347 + .procname = "chroot_deny_sysctl",
72348 + .data = &grsec_enable_chroot_sysctl,
72349 + .maxlen = sizeof(int),
72350 + .mode = 0600,
72351 + .proc_handler = &proc_dointvec,
72352 + },
72353 +#endif
72354 +#ifdef CONFIG_GRKERNSEC_TPE
72355 + {
72356 + .procname = "tpe",
72357 + .data = &grsec_enable_tpe,
72358 + .maxlen = sizeof(int),
72359 + .mode = 0600,
72360 + .proc_handler = &proc_dointvec,
72361 + },
72362 + {
72363 + .procname = "tpe_gid",
72364 + .data = &grsec_tpe_gid,
72365 + .maxlen = sizeof(int),
72366 + .mode = 0600,
72367 + .proc_handler = &proc_dointvec,
72368 + },
72369 +#endif
72370 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
72371 + {
72372 + .procname = "tpe_invert",
72373 + .data = &grsec_enable_tpe_invert,
72374 + .maxlen = sizeof(int),
72375 + .mode = 0600,
72376 + .proc_handler = &proc_dointvec,
72377 + },
72378 +#endif
72379 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
72380 + {
72381 + .procname = "tpe_restrict_all",
72382 + .data = &grsec_enable_tpe_all,
72383 + .maxlen = sizeof(int),
72384 + .mode = 0600,
72385 + .proc_handler = &proc_dointvec,
72386 + },
72387 +#endif
72388 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
72389 + {
72390 + .procname = "socket_all",
72391 + .data = &grsec_enable_socket_all,
72392 + .maxlen = sizeof(int),
72393 + .mode = 0600,
72394 + .proc_handler = &proc_dointvec,
72395 + },
72396 + {
72397 + .procname = "socket_all_gid",
72398 + .data = &grsec_socket_all_gid,
72399 + .maxlen = sizeof(int),
72400 + .mode = 0600,
72401 + .proc_handler = &proc_dointvec,
72402 + },
72403 +#endif
72404 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
72405 + {
72406 + .procname = "socket_client",
72407 + .data = &grsec_enable_socket_client,
72408 + .maxlen = sizeof(int),
72409 + .mode = 0600,
72410 + .proc_handler = &proc_dointvec,
72411 + },
72412 + {
72413 + .procname = "socket_client_gid",
72414 + .data = &grsec_socket_client_gid,
72415 + .maxlen = sizeof(int),
72416 + .mode = 0600,
72417 + .proc_handler = &proc_dointvec,
72418 + },
72419 +#endif
72420 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
72421 + {
72422 + .procname = "socket_server",
72423 + .data = &grsec_enable_socket_server,
72424 + .maxlen = sizeof(int),
72425 + .mode = 0600,
72426 + .proc_handler = &proc_dointvec,
72427 + },
72428 + {
72429 + .procname = "socket_server_gid",
72430 + .data = &grsec_socket_server_gid,
72431 + .maxlen = sizeof(int),
72432 + .mode = 0600,
72433 + .proc_handler = &proc_dointvec,
72434 + },
72435 +#endif
72436 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
72437 + {
72438 + .procname = "audit_group",
72439 + .data = &grsec_enable_group,
72440 + .maxlen = sizeof(int),
72441 + .mode = 0600,
72442 + .proc_handler = &proc_dointvec,
72443 + },
72444 + {
72445 + .procname = "audit_gid",
72446 + .data = &grsec_audit_gid,
72447 + .maxlen = sizeof(int),
72448 + .mode = 0600,
72449 + .proc_handler = &proc_dointvec,
72450 + },
72451 +#endif
72452 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
72453 + {
72454 + .procname = "audit_chdir",
72455 + .data = &grsec_enable_chdir,
72456 + .maxlen = sizeof(int),
72457 + .mode = 0600,
72458 + .proc_handler = &proc_dointvec,
72459 + },
72460 +#endif
72461 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
72462 + {
72463 + .procname = "audit_mount",
72464 + .data = &grsec_enable_mount,
72465 + .maxlen = sizeof(int),
72466 + .mode = 0600,
72467 + .proc_handler = &proc_dointvec,
72468 + },
72469 +#endif
72470 +#ifdef CONFIG_GRKERNSEC_DMESG
72471 + {
72472 + .procname = "dmesg",
72473 + .data = &grsec_enable_dmesg,
72474 + .maxlen = sizeof(int),
72475 + .mode = 0600,
72476 + .proc_handler = &proc_dointvec,
72477 + },
72478 +#endif
72479 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
72480 + {
72481 + .procname = "chroot_findtask",
72482 + .data = &grsec_enable_chroot_findtask,
72483 + .maxlen = sizeof(int),
72484 + .mode = 0600,
72485 + .proc_handler = &proc_dointvec,
72486 + },
72487 +#endif
72488 +#ifdef CONFIG_GRKERNSEC_RESLOG
72489 + {
72490 + .procname = "resource_logging",
72491 + .data = &grsec_resource_logging,
72492 + .maxlen = sizeof(int),
72493 + .mode = 0600,
72494 + .proc_handler = &proc_dointvec,
72495 + },
72496 +#endif
72497 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
72498 + {
72499 + .procname = "audit_ptrace",
72500 + .data = &grsec_enable_audit_ptrace,
72501 + .maxlen = sizeof(int),
72502 + .mode = 0600,
72503 + .proc_handler = &proc_dointvec,
72504 + },
72505 +#endif
72506 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
72507 + {
72508 + .procname = "harden_ptrace",
72509 + .data = &grsec_enable_harden_ptrace,
72510 + .maxlen = sizeof(int),
72511 + .mode = 0600,
72512 + .proc_handler = &proc_dointvec,
72513 + },
72514 +#endif
72515 + {
72516 + .procname = "grsec_lock",
72517 + .data = &grsec_lock,
72518 + .maxlen = sizeof(int),
72519 + .mode = 0600,
72520 + .proc_handler = &proc_dointvec,
72521 + },
72522 +#endif
72523 +#ifdef CONFIG_GRKERNSEC_ROFS
72524 + {
72525 + .procname = "romount_protect",
72526 + .data = &grsec_enable_rofs,
72527 + .maxlen = sizeof(int),
72528 + .mode = 0600,
72529 + .proc_handler = &proc_dointvec_minmax,
72530 + .extra1 = &one,
72531 + .extra2 = &one,
72532 + },
72533 +#endif
72534 +#ifdef CONFIG_GRKERNSEC_DENYUSB
72535 + {
72536 + .procname = "deny_new_usb",
72537 + .data = &grsec_deny_new_usb,
72538 + .maxlen = sizeof(int),
72539 + .mode = 0600,
72540 + .proc_handler = &proc_dointvec_minmax,
72541 + .extra1 = &one,
72542 + .extra2 = &one,
72543 + },
72544 +#endif
72545 + { }
72546 +};
72547 +#endif
72548 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
72549 new file mode 100644
72550 index 0000000..0dc13c3
72551 --- /dev/null
72552 +++ b/grsecurity/grsec_time.c
72553 @@ -0,0 +1,16 @@
72554 +#include <linux/kernel.h>
72555 +#include <linux/sched.h>
72556 +#include <linux/grinternal.h>
72557 +#include <linux/module.h>
72558 +
72559 +void
72560 +gr_log_timechange(void)
72561 +{
72562 +#ifdef CONFIG_GRKERNSEC_TIME
72563 + if (grsec_enable_time)
72564 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
72565 +#endif
72566 + return;
72567 +}
72568 +
72569 +EXPORT_SYMBOL(gr_log_timechange);
72570 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
72571 new file mode 100644
72572 index 0000000..ee57dcf
72573 --- /dev/null
72574 +++ b/grsecurity/grsec_tpe.c
72575 @@ -0,0 +1,73 @@
72576 +#include <linux/kernel.h>
72577 +#include <linux/sched.h>
72578 +#include <linux/file.h>
72579 +#include <linux/fs.h>
72580 +#include <linux/grinternal.h>
72581 +
72582 +extern int gr_acl_tpe_check(void);
72583 +
72584 +int
72585 +gr_tpe_allow(const struct file *file)
72586 +{
72587 +#ifdef CONFIG_GRKERNSEC
72588 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
72589 + const struct cred *cred = current_cred();
72590 + char *msg = NULL;
72591 + char *msg2 = NULL;
72592 +
72593 + // never restrict root
72594 + if (gr_is_global_root(cred->uid))
72595 + return 1;
72596 +
72597 + if (grsec_enable_tpe) {
72598 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
72599 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
72600 + msg = "not being in trusted group";
72601 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
72602 + msg = "being in untrusted group";
72603 +#else
72604 + if (in_group_p(grsec_tpe_gid))
72605 + msg = "being in untrusted group";
72606 +#endif
72607 + }
72608 + if (!msg && gr_acl_tpe_check())
72609 + msg = "being in untrusted role";
72610 +
72611 + // not in any affected group/role
72612 + if (!msg)
72613 + goto next_check;
72614 +
72615 + if (gr_is_global_nonroot(inode->i_uid))
72616 + msg2 = "file in non-root-owned directory";
72617 + else if (inode->i_mode & S_IWOTH)
72618 + msg2 = "file in world-writable directory";
72619 + else if (inode->i_mode & S_IWGRP)
72620 + msg2 = "file in group-writable directory";
72621 +
72622 + if (msg && msg2) {
72623 + char fullmsg[70] = {0};
72624 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
72625 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
72626 + return 0;
72627 + }
72628 + msg = NULL;
72629 +next_check:
72630 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
72631 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
72632 + return 1;
72633 +
72634 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
72635 + msg = "directory not owned by user";
72636 + else if (inode->i_mode & S_IWOTH)
72637 + msg = "file in world-writable directory";
72638 + else if (inode->i_mode & S_IWGRP)
72639 + msg = "file in group-writable directory";
72640 +
72641 + if (msg) {
72642 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
72643 + return 0;
72644 + }
72645 +#endif
72646 +#endif
72647 + return 1;
72648 +}
72649 diff --git a/grsecurity/grsec_usb.c b/grsecurity/grsec_usb.c
72650 new file mode 100644
72651 index 0000000..ae02d8e
72652 --- /dev/null
72653 +++ b/grsecurity/grsec_usb.c
72654 @@ -0,0 +1,15 @@
72655 +#include <linux/kernel.h>
72656 +#include <linux/grinternal.h>
72657 +#include <linux/module.h>
72658 +
72659 +int gr_handle_new_usb(void)
72660 +{
72661 +#ifdef CONFIG_GRKERNSEC_DENYUSB
72662 + if (grsec_deny_new_usb) {
72663 + printk(KERN_ALERT "grsec: denied insert of new USB device\n");
72664 + return 1;
72665 + }
72666 +#endif
72667 + return 0;
72668 +}
72669 +EXPORT_SYMBOL_GPL(gr_handle_new_usb);
72670 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
72671 new file mode 100644
72672 index 0000000..9f7b1ac
72673 --- /dev/null
72674 +++ b/grsecurity/grsum.c
72675 @@ -0,0 +1,61 @@
72676 +#include <linux/err.h>
72677 +#include <linux/kernel.h>
72678 +#include <linux/sched.h>
72679 +#include <linux/mm.h>
72680 +#include <linux/scatterlist.h>
72681 +#include <linux/crypto.h>
72682 +#include <linux/gracl.h>
72683 +
72684 +
72685 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
72686 +#error "crypto and sha256 must be built into the kernel"
72687 +#endif
72688 +
72689 +int
72690 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
72691 +{
72692 + char *p;
72693 + struct crypto_hash *tfm;
72694 + struct hash_desc desc;
72695 + struct scatterlist sg;
72696 + unsigned char temp_sum[GR_SHA_LEN];
72697 + volatile int retval = 0;
72698 + volatile int dummy = 0;
72699 + unsigned int i;
72700 +
72701 + sg_init_table(&sg, 1);
72702 +
72703 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
72704 + if (IS_ERR(tfm)) {
72705 + /* should never happen, since sha256 should be built in */
72706 + return 1;
72707 + }
72708 +
72709 + desc.tfm = tfm;
72710 + desc.flags = 0;
72711 +
72712 + crypto_hash_init(&desc);
72713 +
72714 + p = salt;
72715 + sg_set_buf(&sg, p, GR_SALT_LEN);
72716 + crypto_hash_update(&desc, &sg, sg.length);
72717 +
72718 + p = entry->pw;
72719 + sg_set_buf(&sg, p, strlen(p));
72720 +
72721 + crypto_hash_update(&desc, &sg, sg.length);
72722 +
72723 + crypto_hash_final(&desc, temp_sum);
72724 +
72725 + memset(entry->pw, 0, GR_PW_LEN);
72726 +
72727 + for (i = 0; i < GR_SHA_LEN; i++)
72728 + if (sum[i] != temp_sum[i])
72729 + retval = 1;
72730 + else
72731 + dummy = 1; // waste a cycle
72732 +
72733 + crypto_free_hash(tfm);
72734 +
72735 + return retval;
72736 +}
72737 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
72738 index 77ff547..181834f 100644
72739 --- a/include/asm-generic/4level-fixup.h
72740 +++ b/include/asm-generic/4level-fixup.h
72741 @@ -13,8 +13,10 @@
72742 #define pmd_alloc(mm, pud, address) \
72743 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
72744 NULL: pmd_offset(pud, address))
72745 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
72746
72747 #define pud_alloc(mm, pgd, address) (pgd)
72748 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
72749 #define pud_offset(pgd, start) (pgd)
72750 #define pud_none(pud) 0
72751 #define pud_bad(pud) 0
72752 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
72753 index b7babf0..04ad282 100644
72754 --- a/include/asm-generic/atomic-long.h
72755 +++ b/include/asm-generic/atomic-long.h
72756 @@ -22,6 +22,12 @@
72757
72758 typedef atomic64_t atomic_long_t;
72759
72760 +#ifdef CONFIG_PAX_REFCOUNT
72761 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
72762 +#else
72763 +typedef atomic64_t atomic_long_unchecked_t;
72764 +#endif
72765 +
72766 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
72767
72768 static inline long atomic_long_read(atomic_long_t *l)
72769 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
72770 return (long)atomic64_read(v);
72771 }
72772
72773 +#ifdef CONFIG_PAX_REFCOUNT
72774 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
72775 +{
72776 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72777 +
72778 + return (long)atomic64_read_unchecked(v);
72779 +}
72780 +#endif
72781 +
72782 static inline void atomic_long_set(atomic_long_t *l, long i)
72783 {
72784 atomic64_t *v = (atomic64_t *)l;
72785 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
72786 atomic64_set(v, i);
72787 }
72788
72789 +#ifdef CONFIG_PAX_REFCOUNT
72790 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
72791 +{
72792 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72793 +
72794 + atomic64_set_unchecked(v, i);
72795 +}
72796 +#endif
72797 +
72798 static inline void atomic_long_inc(atomic_long_t *l)
72799 {
72800 atomic64_t *v = (atomic64_t *)l;
72801 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
72802 atomic64_inc(v);
72803 }
72804
72805 +#ifdef CONFIG_PAX_REFCOUNT
72806 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
72807 +{
72808 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72809 +
72810 + atomic64_inc_unchecked(v);
72811 +}
72812 +#endif
72813 +
72814 static inline void atomic_long_dec(atomic_long_t *l)
72815 {
72816 atomic64_t *v = (atomic64_t *)l;
72817 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
72818 atomic64_dec(v);
72819 }
72820
72821 +#ifdef CONFIG_PAX_REFCOUNT
72822 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
72823 +{
72824 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72825 +
72826 + atomic64_dec_unchecked(v);
72827 +}
72828 +#endif
72829 +
72830 static inline void atomic_long_add(long i, atomic_long_t *l)
72831 {
72832 atomic64_t *v = (atomic64_t *)l;
72833 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
72834 atomic64_add(i, v);
72835 }
72836
72837 +#ifdef CONFIG_PAX_REFCOUNT
72838 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
72839 +{
72840 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72841 +
72842 + atomic64_add_unchecked(i, v);
72843 +}
72844 +#endif
72845 +
72846 static inline void atomic_long_sub(long i, atomic_long_t *l)
72847 {
72848 atomic64_t *v = (atomic64_t *)l;
72849 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
72850 atomic64_sub(i, v);
72851 }
72852
72853 +#ifdef CONFIG_PAX_REFCOUNT
72854 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
72855 +{
72856 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72857 +
72858 + atomic64_sub_unchecked(i, v);
72859 +}
72860 +#endif
72861 +
72862 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
72863 {
72864 atomic64_t *v = (atomic64_t *)l;
72865 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
72866 return (long)atomic64_add_return(i, v);
72867 }
72868
72869 +#ifdef CONFIG_PAX_REFCOUNT
72870 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
72871 +{
72872 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72873 +
72874 + return (long)atomic64_add_return_unchecked(i, v);
72875 +}
72876 +#endif
72877 +
72878 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
72879 {
72880 atomic64_t *v = (atomic64_t *)l;
72881 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
72882 return (long)atomic64_inc_return(v);
72883 }
72884
72885 +#ifdef CONFIG_PAX_REFCOUNT
72886 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
72887 +{
72888 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72889 +
72890 + return (long)atomic64_inc_return_unchecked(v);
72891 +}
72892 +#endif
72893 +
72894 static inline long atomic_long_dec_return(atomic_long_t *l)
72895 {
72896 atomic64_t *v = (atomic64_t *)l;
72897 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
72898
72899 typedef atomic_t atomic_long_t;
72900
72901 +#ifdef CONFIG_PAX_REFCOUNT
72902 +typedef atomic_unchecked_t atomic_long_unchecked_t;
72903 +#else
72904 +typedef atomic_t atomic_long_unchecked_t;
72905 +#endif
72906 +
72907 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
72908 static inline long atomic_long_read(atomic_long_t *l)
72909 {
72910 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
72911 return (long)atomic_read(v);
72912 }
72913
72914 +#ifdef CONFIG_PAX_REFCOUNT
72915 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
72916 +{
72917 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72918 +
72919 + return (long)atomic_read_unchecked(v);
72920 +}
72921 +#endif
72922 +
72923 static inline void atomic_long_set(atomic_long_t *l, long i)
72924 {
72925 atomic_t *v = (atomic_t *)l;
72926 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
72927 atomic_set(v, i);
72928 }
72929
72930 +#ifdef CONFIG_PAX_REFCOUNT
72931 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
72932 +{
72933 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72934 +
72935 + atomic_set_unchecked(v, i);
72936 +}
72937 +#endif
72938 +
72939 static inline void atomic_long_inc(atomic_long_t *l)
72940 {
72941 atomic_t *v = (atomic_t *)l;
72942 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
72943 atomic_inc(v);
72944 }
72945
72946 +#ifdef CONFIG_PAX_REFCOUNT
72947 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
72948 +{
72949 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72950 +
72951 + atomic_inc_unchecked(v);
72952 +}
72953 +#endif
72954 +
72955 static inline void atomic_long_dec(atomic_long_t *l)
72956 {
72957 atomic_t *v = (atomic_t *)l;
72958 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
72959 atomic_dec(v);
72960 }
72961
72962 +#ifdef CONFIG_PAX_REFCOUNT
72963 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
72964 +{
72965 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72966 +
72967 + atomic_dec_unchecked(v);
72968 +}
72969 +#endif
72970 +
72971 static inline void atomic_long_add(long i, atomic_long_t *l)
72972 {
72973 atomic_t *v = (atomic_t *)l;
72974 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
72975 atomic_add(i, v);
72976 }
72977
72978 +#ifdef CONFIG_PAX_REFCOUNT
72979 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
72980 +{
72981 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72982 +
72983 + atomic_add_unchecked(i, v);
72984 +}
72985 +#endif
72986 +
72987 static inline void atomic_long_sub(long i, atomic_long_t *l)
72988 {
72989 atomic_t *v = (atomic_t *)l;
72990 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
72991 atomic_sub(i, v);
72992 }
72993
72994 +#ifdef CONFIG_PAX_REFCOUNT
72995 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
72996 +{
72997 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72998 +
72999 + atomic_sub_unchecked(i, v);
73000 +}
73001 +#endif
73002 +
73003 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
73004 {
73005 atomic_t *v = (atomic_t *)l;
73006 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
73007 return (long)atomic_add_return(i, v);
73008 }
73009
73010 +#ifdef CONFIG_PAX_REFCOUNT
73011 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
73012 +{
73013 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73014 +
73015 + return (long)atomic_add_return_unchecked(i, v);
73016 +}
73017 +
73018 +#endif
73019 +
73020 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
73021 {
73022 atomic_t *v = (atomic_t *)l;
73023 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
73024 return (long)atomic_inc_return(v);
73025 }
73026
73027 +#ifdef CONFIG_PAX_REFCOUNT
73028 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
73029 +{
73030 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73031 +
73032 + return (long)atomic_inc_return_unchecked(v);
73033 +}
73034 +#endif
73035 +
73036 static inline long atomic_long_dec_return(atomic_long_t *l)
73037 {
73038 atomic_t *v = (atomic_t *)l;
73039 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
73040
73041 #endif /* BITS_PER_LONG == 64 */
73042
73043 +#ifdef CONFIG_PAX_REFCOUNT
73044 +static inline void pax_refcount_needs_these_functions(void)
73045 +{
73046 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
73047 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
73048 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
73049 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
73050 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
73051 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
73052 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
73053 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
73054 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
73055 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
73056 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
73057 +#ifdef CONFIG_X86
73058 + atomic_clear_mask_unchecked(0, NULL);
73059 + atomic_set_mask_unchecked(0, NULL);
73060 +#endif
73061 +
73062 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
73063 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
73064 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
73065 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
73066 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
73067 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
73068 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
73069 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
73070 +}
73071 +#else
73072 +#define atomic_read_unchecked(v) atomic_read(v)
73073 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
73074 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
73075 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
73076 +#define atomic_inc_unchecked(v) atomic_inc(v)
73077 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
73078 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
73079 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
73080 +#define atomic_dec_unchecked(v) atomic_dec(v)
73081 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
73082 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
73083 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
73084 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
73085 +
73086 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
73087 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
73088 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
73089 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
73090 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
73091 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
73092 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
73093 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
73094 +#endif
73095 +
73096 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
73097 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
73098 index 33bd2de..f31bff97 100644
73099 --- a/include/asm-generic/atomic.h
73100 +++ b/include/asm-generic/atomic.h
73101 @@ -153,7 +153,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
73102 * Atomically clears the bits set in @mask from @v
73103 */
73104 #ifndef atomic_clear_mask
73105 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
73106 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
73107 {
73108 unsigned long flags;
73109
73110 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
73111 index b18ce4f..2ee2843 100644
73112 --- a/include/asm-generic/atomic64.h
73113 +++ b/include/asm-generic/atomic64.h
73114 @@ -16,6 +16,8 @@ typedef struct {
73115 long long counter;
73116 } atomic64_t;
73117
73118 +typedef atomic64_t atomic64_unchecked_t;
73119 +
73120 #define ATOMIC64_INIT(i) { (i) }
73121
73122 extern long long atomic64_read(const atomic64_t *v);
73123 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
73124 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
73125 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
73126
73127 +#define atomic64_read_unchecked(v) atomic64_read(v)
73128 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
73129 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
73130 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
73131 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
73132 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
73133 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
73134 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
73135 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
73136 +
73137 #endif /* _ASM_GENERIC_ATOMIC64_H */
73138 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
73139 index 1bfcfe5..e04c5c9 100644
73140 --- a/include/asm-generic/cache.h
73141 +++ b/include/asm-generic/cache.h
73142 @@ -6,7 +6,7 @@
73143 * cache lines need to provide their own cache.h.
73144 */
73145
73146 -#define L1_CACHE_SHIFT 5
73147 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
73148 +#define L1_CACHE_SHIFT 5UL
73149 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
73150
73151 #endif /* __ASM_GENERIC_CACHE_H */
73152 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
73153 index 0d68a1e..b74a761 100644
73154 --- a/include/asm-generic/emergency-restart.h
73155 +++ b/include/asm-generic/emergency-restart.h
73156 @@ -1,7 +1,7 @@
73157 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
73158 #define _ASM_GENERIC_EMERGENCY_RESTART_H
73159
73160 -static inline void machine_emergency_restart(void)
73161 +static inline __noreturn void machine_emergency_restart(void)
73162 {
73163 machine_restart(NULL);
73164 }
73165 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
73166 index 90f99c7..00ce236 100644
73167 --- a/include/asm-generic/kmap_types.h
73168 +++ b/include/asm-generic/kmap_types.h
73169 @@ -2,9 +2,9 @@
73170 #define _ASM_GENERIC_KMAP_TYPES_H
73171
73172 #ifdef __WITH_KM_FENCE
73173 -# define KM_TYPE_NR 41
73174 +# define KM_TYPE_NR 42
73175 #else
73176 -# define KM_TYPE_NR 20
73177 +# define KM_TYPE_NR 21
73178 #endif
73179
73180 #endif
73181 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
73182 index 9ceb03b..62b0b8f 100644
73183 --- a/include/asm-generic/local.h
73184 +++ b/include/asm-generic/local.h
73185 @@ -23,24 +23,37 @@ typedef struct
73186 atomic_long_t a;
73187 } local_t;
73188
73189 +typedef struct {
73190 + atomic_long_unchecked_t a;
73191 +} local_unchecked_t;
73192 +
73193 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
73194
73195 #define local_read(l) atomic_long_read(&(l)->a)
73196 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
73197 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
73198 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
73199 #define local_inc(l) atomic_long_inc(&(l)->a)
73200 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
73201 #define local_dec(l) atomic_long_dec(&(l)->a)
73202 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
73203 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
73204 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
73205 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
73206 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
73207
73208 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
73209 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
73210 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
73211 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
73212 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
73213 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
73214 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
73215 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
73216 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
73217
73218 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
73219 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
73220 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
73221 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
73222 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
73223 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
73224 index 725612b..9cc513a 100644
73225 --- a/include/asm-generic/pgtable-nopmd.h
73226 +++ b/include/asm-generic/pgtable-nopmd.h
73227 @@ -1,14 +1,19 @@
73228 #ifndef _PGTABLE_NOPMD_H
73229 #define _PGTABLE_NOPMD_H
73230
73231 -#ifndef __ASSEMBLY__
73232 -
73233 #include <asm-generic/pgtable-nopud.h>
73234
73235 -struct mm_struct;
73236 -
73237 #define __PAGETABLE_PMD_FOLDED
73238
73239 +#define PMD_SHIFT PUD_SHIFT
73240 +#define PTRS_PER_PMD 1
73241 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
73242 +#define PMD_MASK (~(PMD_SIZE-1))
73243 +
73244 +#ifndef __ASSEMBLY__
73245 +
73246 +struct mm_struct;
73247 +
73248 /*
73249 * Having the pmd type consist of a pud gets the size right, and allows
73250 * us to conceptually access the pud entry that this pmd is folded into
73251 @@ -16,11 +21,6 @@ struct mm_struct;
73252 */
73253 typedef struct { pud_t pud; } pmd_t;
73254
73255 -#define PMD_SHIFT PUD_SHIFT
73256 -#define PTRS_PER_PMD 1
73257 -#define PMD_SIZE (1UL << PMD_SHIFT)
73258 -#define PMD_MASK (~(PMD_SIZE-1))
73259 -
73260 /*
73261 * The "pud_xxx()" functions here are trivial for a folded two-level
73262 * setup: the pmd is never bad, and a pmd always exists (as it's folded
73263 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
73264 index 810431d..0ec4804f 100644
73265 --- a/include/asm-generic/pgtable-nopud.h
73266 +++ b/include/asm-generic/pgtable-nopud.h
73267 @@ -1,10 +1,15 @@
73268 #ifndef _PGTABLE_NOPUD_H
73269 #define _PGTABLE_NOPUD_H
73270
73271 -#ifndef __ASSEMBLY__
73272 -
73273 #define __PAGETABLE_PUD_FOLDED
73274
73275 +#define PUD_SHIFT PGDIR_SHIFT
73276 +#define PTRS_PER_PUD 1
73277 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
73278 +#define PUD_MASK (~(PUD_SIZE-1))
73279 +
73280 +#ifndef __ASSEMBLY__
73281 +
73282 /*
73283 * Having the pud type consist of a pgd gets the size right, and allows
73284 * us to conceptually access the pgd entry that this pud is folded into
73285 @@ -12,11 +17,6 @@
73286 */
73287 typedef struct { pgd_t pgd; } pud_t;
73288
73289 -#define PUD_SHIFT PGDIR_SHIFT
73290 -#define PTRS_PER_PUD 1
73291 -#define PUD_SIZE (1UL << PUD_SHIFT)
73292 -#define PUD_MASK (~(PUD_SIZE-1))
73293 -
73294 /*
73295 * The "pgd_xxx()" functions here are trivial for a folded two-level
73296 * setup: the pud is never bad, and a pud always exists (as it's folded
73297 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
73298 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
73299
73300 #define pgd_populate(mm, pgd, pud) do { } while (0)
73301 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
73302 /*
73303 * (puds are folded into pgds so this doesn't get actually called,
73304 * but the define is needed for a generic inline function.)
73305 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
73306 index a59ff51..2594a70 100644
73307 --- a/include/asm-generic/pgtable.h
73308 +++ b/include/asm-generic/pgtable.h
73309 @@ -688,6 +688,14 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
73310 }
73311 #endif /* CONFIG_NUMA_BALANCING */
73312
73313 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
73314 +static inline unsigned long pax_open_kernel(void) { return 0; }
73315 +#endif
73316 +
73317 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
73318 +static inline unsigned long pax_close_kernel(void) { return 0; }
73319 +#endif
73320 +
73321 #endif /* CONFIG_MMU */
73322
73323 #endif /* !__ASSEMBLY__ */
73324 diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
73325 index c184aa8..d049942 100644
73326 --- a/include/asm-generic/uaccess.h
73327 +++ b/include/asm-generic/uaccess.h
73328 @@ -343,4 +343,12 @@ clear_user(void __user *to, unsigned long n)
73329 return __clear_user(to, n);
73330 }
73331
73332 +#ifndef __HAVE_ARCH_PAX_OPEN_USERLAND
73333 +//static inline unsigned long pax_open_userland(void) { return 0; }
73334 +#endif
73335 +
73336 +#ifndef __HAVE_ARCH_PAX_CLOSE_USERLAND
73337 +//static inline unsigned long pax_close_userland(void) { return 0; }
73338 +#endif
73339 +
73340 #endif /* __ASM_GENERIC_UACCESS_H */
73341 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
73342 index eb58d2d..df131bf 100644
73343 --- a/include/asm-generic/vmlinux.lds.h
73344 +++ b/include/asm-generic/vmlinux.lds.h
73345 @@ -239,6 +239,7 @@
73346 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
73347 VMLINUX_SYMBOL(__start_rodata) = .; \
73348 *(.rodata) *(.rodata.*) \
73349 + *(.data..read_only) \
73350 *(__vermagic) /* Kernel version magic */ \
73351 . = ALIGN(8); \
73352 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
73353 @@ -749,17 +750,18 @@
73354 * section in the linker script will go there too. @phdr should have
73355 * a leading colon.
73356 *
73357 - * Note that this macros defines __per_cpu_load as an absolute symbol.
73358 + * Note that this macros defines per_cpu_load as an absolute symbol.
73359 * If there is no need to put the percpu section at a predetermined
73360 * address, use PERCPU_SECTION.
73361 */
73362 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
73363 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
73364 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
73365 + per_cpu_load = .; \
73366 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
73367 - LOAD_OFFSET) { \
73368 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
73369 PERCPU_INPUT(cacheline) \
73370 } phdr \
73371 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
73372 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
73373
73374 /**
73375 * PERCPU_SECTION - define output section for percpu area, simple version
73376 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
73377 index 418d270..bfd2794 100644
73378 --- a/include/crypto/algapi.h
73379 +++ b/include/crypto/algapi.h
73380 @@ -34,7 +34,7 @@ struct crypto_type {
73381 unsigned int maskclear;
73382 unsigned int maskset;
73383 unsigned int tfmsize;
73384 -};
73385 +} __do_const;
73386
73387 struct crypto_instance {
73388 struct crypto_alg alg;
73389 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
73390 index 63d17ee..716de2b 100644
73391 --- a/include/drm/drmP.h
73392 +++ b/include/drm/drmP.h
73393 @@ -72,6 +72,7 @@
73394 #include <linux/workqueue.h>
73395 #include <linux/poll.h>
73396 #include <asm/pgalloc.h>
73397 +#include <asm/local.h>
73398 #include <drm/drm.h>
73399 #include <drm/drm_sarea.h>
73400
73401 @@ -296,10 +297,12 @@ do { \
73402 * \param cmd command.
73403 * \param arg argument.
73404 */
73405 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
73406 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
73407 + struct drm_file *file_priv);
73408 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
73409 struct drm_file *file_priv);
73410
73411 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
73412 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
73413 unsigned long arg);
73414
73415 #define DRM_IOCTL_NR(n) _IOC_NR(n)
73416 @@ -314,10 +317,10 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
73417 struct drm_ioctl_desc {
73418 unsigned int cmd;
73419 int flags;
73420 - drm_ioctl_t *func;
73421 + drm_ioctl_t func;
73422 unsigned int cmd_drv;
73423 const char *name;
73424 -};
73425 +} __do_const;
73426
73427 /**
73428 * Creates a driver or general drm_ioctl_desc array entry for the given
73429 @@ -1015,7 +1018,7 @@ struct drm_info_list {
73430 int (*show)(struct seq_file*, void*); /** show callback */
73431 u32 driver_features; /**< Required driver features for this entry */
73432 void *data;
73433 -};
73434 +} __do_const;
73435
73436 /**
73437 * debugfs node structure. This structure represents a debugfs file.
73438 @@ -1088,7 +1091,7 @@ struct drm_device {
73439
73440 /** \name Usage Counters */
73441 /*@{ */
73442 - int open_count; /**< Outstanding files open */
73443 + local_t open_count; /**< Outstanding files open */
73444 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
73445 atomic_t vma_count; /**< Outstanding vma areas open */
73446 int buf_use; /**< Buffers in use -- cannot alloc */
73447 @@ -1099,7 +1102,7 @@ struct drm_device {
73448 /*@{ */
73449 unsigned long counters;
73450 enum drm_stat_type types[15];
73451 - atomic_t counts[15];
73452 + atomic_unchecked_t counts[15];
73453 /*@} */
73454
73455 struct list_head filelist;
73456 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
73457 index f43d556..94d9343 100644
73458 --- a/include/drm/drm_crtc_helper.h
73459 +++ b/include/drm/drm_crtc_helper.h
73460 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
73461 struct drm_connector *connector);
73462 /* disable encoder when not in use - more explicit than dpms off */
73463 void (*disable)(struct drm_encoder *encoder);
73464 -};
73465 +} __no_const;
73466
73467 /**
73468 * drm_connector_helper_funcs - helper operations for connectors
73469 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
73470 index 72dcbe8..8db58d7 100644
73471 --- a/include/drm/ttm/ttm_memory.h
73472 +++ b/include/drm/ttm/ttm_memory.h
73473 @@ -48,7 +48,7 @@
73474
73475 struct ttm_mem_shrink {
73476 int (*do_shrink) (struct ttm_mem_shrink *);
73477 -};
73478 +} __no_const;
73479
73480 /**
73481 * struct ttm_mem_global - Global memory accounting structure.
73482 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
73483 index 4b840e8..155d235 100644
73484 --- a/include/keys/asymmetric-subtype.h
73485 +++ b/include/keys/asymmetric-subtype.h
73486 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
73487 /* Verify the signature on a key of this subtype (optional) */
73488 int (*verify_signature)(const struct key *key,
73489 const struct public_key_signature *sig);
73490 -};
73491 +} __do_const;
73492
73493 /**
73494 * asymmetric_key_subtype - Get the subtype from an asymmetric key
73495 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
73496 index c1da539..1dcec55 100644
73497 --- a/include/linux/atmdev.h
73498 +++ b/include/linux/atmdev.h
73499 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
73500 #endif
73501
73502 struct k_atm_aal_stats {
73503 -#define __HANDLE_ITEM(i) atomic_t i
73504 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
73505 __AAL_STAT_ITEMS
73506 #undef __HANDLE_ITEM
73507 };
73508 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
73509 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
73510 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
73511 struct module *owner;
73512 -};
73513 +} __do_const ;
73514
73515 struct atmphy_ops {
73516 int (*start)(struct atm_dev *dev);
73517 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
73518 index 70cf138..0418ee2 100644
73519 --- a/include/linux/binfmts.h
73520 +++ b/include/linux/binfmts.h
73521 @@ -73,8 +73,10 @@ struct linux_binfmt {
73522 int (*load_binary)(struct linux_binprm *);
73523 int (*load_shlib)(struct file *);
73524 int (*core_dump)(struct coredump_params *cprm);
73525 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
73526 + void (*handle_mmap)(struct file *);
73527 unsigned long min_coredump; /* minimal dump size */
73528 -};
73529 +} __do_const;
73530
73531 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
73532
73533 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
73534 index 2fdb4a4..54aad7e 100644
73535 --- a/include/linux/blkdev.h
73536 +++ b/include/linux/blkdev.h
73537 @@ -1526,7 +1526,7 @@ struct block_device_operations {
73538 /* this callback is with swap_lock and sometimes page table lock held */
73539 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
73540 struct module *owner;
73541 -};
73542 +} __do_const;
73543
73544 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
73545 unsigned long);
73546 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
73547 index 7c2e030..b72475d 100644
73548 --- a/include/linux/blktrace_api.h
73549 +++ b/include/linux/blktrace_api.h
73550 @@ -23,7 +23,7 @@ struct blk_trace {
73551 struct dentry *dir;
73552 struct dentry *dropped_file;
73553 struct dentry *msg_file;
73554 - atomic_t dropped;
73555 + atomic_unchecked_t dropped;
73556 };
73557
73558 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
73559 diff --git a/include/linux/cache.h b/include/linux/cache.h
73560 index 4c57065..4307975 100644
73561 --- a/include/linux/cache.h
73562 +++ b/include/linux/cache.h
73563 @@ -16,6 +16,10 @@
73564 #define __read_mostly
73565 #endif
73566
73567 +#ifndef __read_only
73568 +#define __read_only __read_mostly
73569 +#endif
73570 +
73571 #ifndef ____cacheline_aligned
73572 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
73573 #endif
73574 diff --git a/include/linux/capability.h b/include/linux/capability.h
73575 index d9a4f7f4..19f77d6 100644
73576 --- a/include/linux/capability.h
73577 +++ b/include/linux/capability.h
73578 @@ -213,8 +213,13 @@ extern bool ns_capable(struct user_namespace *ns, int cap);
73579 extern bool nsown_capable(int cap);
73580 extern bool inode_capable(const struct inode *inode, int cap);
73581 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
73582 +extern bool capable_nolog(int cap);
73583 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
73584 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
73585
73586 /* audit system wants to get cap info from files as well */
73587 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
73588
73589 +extern int is_privileged_binary(const struct dentry *dentry);
73590 +
73591 #endif /* !_LINUX_CAPABILITY_H */
73592 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
73593 index 8609d57..86e4d79 100644
73594 --- a/include/linux/cdrom.h
73595 +++ b/include/linux/cdrom.h
73596 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
73597
73598 /* driver specifications */
73599 const int capability; /* capability flags */
73600 - int n_minors; /* number of active minor devices */
73601 /* handle uniform packets for scsi type devices (scsi,atapi) */
73602 int (*generic_packet) (struct cdrom_device_info *,
73603 struct packet_command *);
73604 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
73605 index 4ce9056..86caac6 100644
73606 --- a/include/linux/cleancache.h
73607 +++ b/include/linux/cleancache.h
73608 @@ -31,7 +31,7 @@ struct cleancache_ops {
73609 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
73610 void (*invalidate_inode)(int, struct cleancache_filekey);
73611 void (*invalidate_fs)(int);
73612 -};
73613 +} __no_const;
73614
73615 extern struct cleancache_ops *
73616 cleancache_register_ops(struct cleancache_ops *ops);
73617 diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
73618 index 1186098..f87e53d 100644
73619 --- a/include/linux/clk-provider.h
73620 +++ b/include/linux/clk-provider.h
73621 @@ -132,6 +132,7 @@ struct clk_ops {
73622 unsigned long);
73623 void (*init)(struct clk_hw *hw);
73624 };
73625 +typedef struct clk_ops __no_const clk_ops_no_const;
73626
73627 /**
73628 * struct clk_init_data - holds init data that's common to all clocks and is
73629 diff --git a/include/linux/compat.h b/include/linux/compat.h
73630 index 7f0c1dd..206ac34 100644
73631 --- a/include/linux/compat.h
73632 +++ b/include/linux/compat.h
73633 @@ -312,7 +312,7 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
73634 compat_size_t __user *len_ptr);
73635
73636 asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
73637 -asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
73638 +asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
73639 asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
73640 asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
73641 compat_ssize_t msgsz, int msgflg);
73642 @@ -419,7 +419,7 @@ extern int compat_ptrace_request(struct task_struct *child,
73643 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
73644 compat_ulong_t addr, compat_ulong_t data);
73645 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
73646 - compat_long_t addr, compat_long_t data);
73647 + compat_ulong_t addr, compat_ulong_t data);
73648
73649 asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, size_t);
73650 /*
73651 @@ -669,6 +669,7 @@ asmlinkage long compat_sys_sigaltstack(const compat_stack_t __user *uss_ptr,
73652
73653 int compat_restore_altstack(const compat_stack_t __user *uss);
73654 int __compat_save_altstack(compat_stack_t __user *, unsigned long);
73655 +void __compat_save_altstack_ex(compat_stack_t __user *, unsigned long);
73656
73657 asmlinkage long compat_sys_sched_rr_get_interval(compat_pid_t pid,
73658 struct compat_timespec __user *interval);
73659 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
73660 index 842de22..7f3a41f 100644
73661 --- a/include/linux/compiler-gcc4.h
73662 +++ b/include/linux/compiler-gcc4.h
73663 @@ -39,9 +39,29 @@
73664 # define __compiletime_warning(message) __attribute__((warning(message)))
73665 # define __compiletime_error(message) __attribute__((error(message)))
73666 #endif /* __CHECKER__ */
73667 +
73668 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
73669 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
73670 +#define __bos0(ptr) __bos((ptr), 0)
73671 +#define __bos1(ptr) __bos((ptr), 1)
73672 #endif /* GCC_VERSION >= 40300 */
73673
73674 #if GCC_VERSION >= 40500
73675 +
73676 +#ifdef CONSTIFY_PLUGIN
73677 +#define __no_const __attribute__((no_const))
73678 +#define __do_const __attribute__((do_const))
73679 +#endif
73680 +
73681 +#ifdef SIZE_OVERFLOW_PLUGIN
73682 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
73683 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
73684 +#endif
73685 +
73686 +#ifdef LATENT_ENTROPY_PLUGIN
73687 +#define __latent_entropy __attribute__((latent_entropy))
73688 +#endif
73689 +
73690 /*
73691 * Mark a position in code as unreachable. This can be used to
73692 * suppress control flow warnings after asm blocks that transfer
73693 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
73694 index 92669cd..1771a15 100644
73695 --- a/include/linux/compiler.h
73696 +++ b/include/linux/compiler.h
73697 @@ -5,11 +5,14 @@
73698
73699 #ifdef __CHECKER__
73700 # define __user __attribute__((noderef, address_space(1)))
73701 +# define __force_user __force __user
73702 # define __kernel __attribute__((address_space(0)))
73703 +# define __force_kernel __force __kernel
73704 # define __safe __attribute__((safe))
73705 # define __force __attribute__((force))
73706 # define __nocast __attribute__((nocast))
73707 # define __iomem __attribute__((noderef, address_space(2)))
73708 +# define __force_iomem __force __iomem
73709 # define __must_hold(x) __attribute__((context(x,1,1)))
73710 # define __acquires(x) __attribute__((context(x,0,1)))
73711 # define __releases(x) __attribute__((context(x,1,0)))
73712 @@ -17,20 +20,37 @@
73713 # define __release(x) __context__(x,-1)
73714 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
73715 # define __percpu __attribute__((noderef, address_space(3)))
73716 +# define __force_percpu __force __percpu
73717 #ifdef CONFIG_SPARSE_RCU_POINTER
73718 # define __rcu __attribute__((noderef, address_space(4)))
73719 +# define __force_rcu __force __rcu
73720 #else
73721 # define __rcu
73722 +# define __force_rcu
73723 #endif
73724 extern void __chk_user_ptr(const volatile void __user *);
73725 extern void __chk_io_ptr(const volatile void __iomem *);
73726 #else
73727 -# define __user
73728 -# define __kernel
73729 +# ifdef CHECKER_PLUGIN
73730 +//# define __user
73731 +//# define __force_user
73732 +//# define __kernel
73733 +//# define __force_kernel
73734 +# else
73735 +# ifdef STRUCTLEAK_PLUGIN
73736 +# define __user __attribute__((user))
73737 +# else
73738 +# define __user
73739 +# endif
73740 +# define __force_user
73741 +# define __kernel
73742 +# define __force_kernel
73743 +# endif
73744 # define __safe
73745 # define __force
73746 # define __nocast
73747 # define __iomem
73748 +# define __force_iomem
73749 # define __chk_user_ptr(x) (void)0
73750 # define __chk_io_ptr(x) (void)0
73751 # define __builtin_warning(x, y...) (1)
73752 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
73753 # define __release(x) (void)0
73754 # define __cond_lock(x,c) (c)
73755 # define __percpu
73756 +# define __force_percpu
73757 # define __rcu
73758 +# define __force_rcu
73759 #endif
73760
73761 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
73762 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
73763 # define __attribute_const__ /* unimplemented */
73764 #endif
73765
73766 +#ifndef __no_const
73767 +# define __no_const
73768 +#endif
73769 +
73770 +#ifndef __do_const
73771 +# define __do_const
73772 +#endif
73773 +
73774 +#ifndef __size_overflow
73775 +# define __size_overflow(...)
73776 +#endif
73777 +
73778 +#ifndef __intentional_overflow
73779 +# define __intentional_overflow(...)
73780 +#endif
73781 +
73782 +#ifndef __latent_entropy
73783 +# define __latent_entropy
73784 +#endif
73785 +
73786 /*
73787 * Tell gcc if a function is cold. The compiler will assume any path
73788 * directly leading to the call is unlikely.
73789 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
73790 #define __cold
73791 #endif
73792
73793 +#ifndef __alloc_size
73794 +#define __alloc_size(...)
73795 +#endif
73796 +
73797 +#ifndef __bos
73798 +#define __bos(ptr, arg)
73799 +#endif
73800 +
73801 +#ifndef __bos0
73802 +#define __bos0(ptr)
73803 +#endif
73804 +
73805 +#ifndef __bos1
73806 +#define __bos1(ptr)
73807 +#endif
73808 +
73809 /* Simple shorthand for a section definition */
73810 #ifndef __section
73811 # define __section(S) __attribute__ ((__section__(#S)))
73812 @@ -349,7 +407,8 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
73813 * use is to mediate communication between process-level code and irq/NMI
73814 * handlers, all running on the same CPU.
73815 */
73816 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
73817 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
73818 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
73819
73820 /* Ignore/forbid kprobes attach on very low level functions marked by this attribute: */
73821 #ifdef CONFIG_KPROBES
73822 diff --git a/include/linux/completion.h b/include/linux/completion.h
73823 index 33f0280..35c6568 100644
73824 --- a/include/linux/completion.h
73825 +++ b/include/linux/completion.h
73826 @@ -79,15 +79,15 @@ static inline void init_completion(struct completion *x)
73827 extern void wait_for_completion(struct completion *);
73828 extern void wait_for_completion_io(struct completion *);
73829 extern int wait_for_completion_interruptible(struct completion *x);
73830 -extern int wait_for_completion_killable(struct completion *x);
73831 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
73832 extern unsigned long wait_for_completion_timeout(struct completion *x,
73833 unsigned long timeout);
73834 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
73835 unsigned long timeout);
73836 extern long wait_for_completion_interruptible_timeout(
73837 - struct completion *x, unsigned long timeout);
73838 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
73839 extern long wait_for_completion_killable_timeout(
73840 - struct completion *x, unsigned long timeout);
73841 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
73842 extern bool try_wait_for_completion(struct completion *x);
73843 extern bool completion_done(struct completion *x);
73844
73845 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
73846 index 34025df..d94bbbc 100644
73847 --- a/include/linux/configfs.h
73848 +++ b/include/linux/configfs.h
73849 @@ -125,7 +125,7 @@ struct configfs_attribute {
73850 const char *ca_name;
73851 struct module *ca_owner;
73852 umode_t ca_mode;
73853 -};
73854 +} __do_const;
73855
73856 /*
73857 * Users often need to create attribute structures for their configurable
73858 diff --git a/include/linux/cpu.h b/include/linux/cpu.h
73859 index 9f3c7e8..a18c7b6 100644
73860 --- a/include/linux/cpu.h
73861 +++ b/include/linux/cpu.h
73862 @@ -115,7 +115,7 @@ enum {
73863 /* Need to know about CPUs going up/down? */
73864 #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE)
73865 #define cpu_notifier(fn, pri) { \
73866 - static struct notifier_block fn##_nb __cpuinitdata = \
73867 + static struct notifier_block fn##_nb = \
73868 { .notifier_call = fn, .priority = pri }; \
73869 register_cpu_notifier(&fn##_nb); \
73870 }
73871 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
73872 index 037d36a..ca5fe6e 100644
73873 --- a/include/linux/cpufreq.h
73874 +++ b/include/linux/cpufreq.h
73875 @@ -262,7 +262,7 @@ struct cpufreq_driver {
73876 int (*suspend) (struct cpufreq_policy *policy);
73877 int (*resume) (struct cpufreq_policy *policy);
73878 struct freq_attr **attr;
73879 -};
73880 +} __do_const;
73881
73882 /* flags */
73883
73884 @@ -321,6 +321,7 @@ struct global_attr {
73885 ssize_t (*store)(struct kobject *a, struct attribute *b,
73886 const char *c, size_t count);
73887 };
73888 +typedef struct global_attr __no_const global_attr_no_const;
73889
73890 #define define_one_global_ro(_name) \
73891 static struct global_attr _name = \
73892 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
73893 index 8f04062..900239a 100644
73894 --- a/include/linux/cpuidle.h
73895 +++ b/include/linux/cpuidle.h
73896 @@ -52,7 +52,8 @@ struct cpuidle_state {
73897 int index);
73898
73899 int (*enter_dead) (struct cpuidle_device *dev, int index);
73900 -};
73901 +} __do_const;
73902 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
73903
73904 /* Idle State Flags */
73905 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
73906 @@ -191,7 +192,7 @@ struct cpuidle_governor {
73907 void (*reflect) (struct cpuidle_device *dev, int index);
73908
73909 struct module *owner;
73910 -};
73911 +} __do_const;
73912
73913 #ifdef CONFIG_CPU_IDLE
73914
73915 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
73916 index d08e4d2..95fad61 100644
73917 --- a/include/linux/cpumask.h
73918 +++ b/include/linux/cpumask.h
73919 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
73920 }
73921
73922 /* Valid inputs for n are -1 and 0. */
73923 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
73924 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
73925 {
73926 return n+1;
73927 }
73928
73929 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
73930 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
73931 {
73932 return n+1;
73933 }
73934
73935 -static inline unsigned int cpumask_next_and(int n,
73936 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
73937 const struct cpumask *srcp,
73938 const struct cpumask *andp)
73939 {
73940 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
73941 *
73942 * Returns >= nr_cpu_ids if no further cpus set.
73943 */
73944 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
73945 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
73946 {
73947 /* -1 is a legal arg here. */
73948 if (n != -1)
73949 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
73950 *
73951 * Returns >= nr_cpu_ids if no further cpus unset.
73952 */
73953 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
73954 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
73955 {
73956 /* -1 is a legal arg here. */
73957 if (n != -1)
73958 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
73959 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
73960 }
73961
73962 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
73963 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
73964 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
73965
73966 /**
73967 diff --git a/include/linux/cred.h b/include/linux/cred.h
73968 index 04421e8..6bce4ef 100644
73969 --- a/include/linux/cred.h
73970 +++ b/include/linux/cred.h
73971 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
73972 static inline void validate_process_creds(void)
73973 {
73974 }
73975 +static inline void validate_task_creds(struct task_struct *task)
73976 +{
73977 +}
73978 #endif
73979
73980 /**
73981 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
73982 index b92eadf..b4ecdc1 100644
73983 --- a/include/linux/crypto.h
73984 +++ b/include/linux/crypto.h
73985 @@ -373,7 +373,7 @@ struct cipher_tfm {
73986 const u8 *key, unsigned int keylen);
73987 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
73988 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
73989 -};
73990 +} __no_const;
73991
73992 struct hash_tfm {
73993 int (*init)(struct hash_desc *desc);
73994 @@ -394,13 +394,13 @@ struct compress_tfm {
73995 int (*cot_decompress)(struct crypto_tfm *tfm,
73996 const u8 *src, unsigned int slen,
73997 u8 *dst, unsigned int *dlen);
73998 -};
73999 +} __no_const;
74000
74001 struct rng_tfm {
74002 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
74003 unsigned int dlen);
74004 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
74005 -};
74006 +} __no_const;
74007
74008 #define crt_ablkcipher crt_u.ablkcipher
74009 #define crt_aead crt_u.aead
74010 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
74011 index 653589e..4ef254a 100644
74012 --- a/include/linux/ctype.h
74013 +++ b/include/linux/ctype.h
74014 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
74015 * Fast implementation of tolower() for internal usage. Do not use in your
74016 * code.
74017 */
74018 -static inline char _tolower(const char c)
74019 +static inline unsigned char _tolower(const unsigned char c)
74020 {
74021 return c | 0x20;
74022 }
74023 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
74024 index 7925bf0..d5143d2 100644
74025 --- a/include/linux/decompress/mm.h
74026 +++ b/include/linux/decompress/mm.h
74027 @@ -77,7 +77,7 @@ static void free(void *where)
74028 * warnings when not needed (indeed large_malloc / large_free are not
74029 * needed by inflate */
74030
74031 -#define malloc(a) kmalloc(a, GFP_KERNEL)
74032 +#define malloc(a) kmalloc((a), GFP_KERNEL)
74033 #define free(a) kfree(a)
74034
74035 #define large_malloc(a) vmalloc(a)
74036 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
74037 index fe8c447..bdc1f33 100644
74038 --- a/include/linux/devfreq.h
74039 +++ b/include/linux/devfreq.h
74040 @@ -114,7 +114,7 @@ struct devfreq_governor {
74041 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
74042 int (*event_handler)(struct devfreq *devfreq,
74043 unsigned int event, void *data);
74044 -};
74045 +} __do_const;
74046
74047 /**
74048 * struct devfreq - Device devfreq structure
74049 diff --git a/include/linux/device.h b/include/linux/device.h
74050 index c0a1261..dba7569 100644
74051 --- a/include/linux/device.h
74052 +++ b/include/linux/device.h
74053 @@ -290,7 +290,7 @@ struct subsys_interface {
74054 struct list_head node;
74055 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
74056 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
74057 -};
74058 +} __do_const;
74059
74060 int subsys_interface_register(struct subsys_interface *sif);
74061 void subsys_interface_unregister(struct subsys_interface *sif);
74062 @@ -473,7 +473,7 @@ struct device_type {
74063 void (*release)(struct device *dev);
74064
74065 const struct dev_pm_ops *pm;
74066 -};
74067 +} __do_const;
74068
74069 /* interface for exporting device attributes */
74070 struct device_attribute {
74071 @@ -483,11 +483,12 @@ struct device_attribute {
74072 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
74073 const char *buf, size_t count);
74074 };
74075 +typedef struct device_attribute __no_const device_attribute_no_const;
74076
74077 struct dev_ext_attribute {
74078 struct device_attribute attr;
74079 void *var;
74080 -};
74081 +} __do_const;
74082
74083 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
74084 char *buf);
74085 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
74086 index 94af418..b1ca7a2 100644
74087 --- a/include/linux/dma-mapping.h
74088 +++ b/include/linux/dma-mapping.h
74089 @@ -54,7 +54,7 @@ struct dma_map_ops {
74090 u64 (*get_required_mask)(struct device *dev);
74091 #endif
74092 int is_phys;
74093 -};
74094 +} __do_const;
74095
74096 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
74097
74098 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
74099 index 96d3e4a..dc36433 100644
74100 --- a/include/linux/dmaengine.h
74101 +++ b/include/linux/dmaengine.h
74102 @@ -1035,9 +1035,9 @@ struct dma_pinned_list {
74103 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
74104 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
74105
74106 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
74107 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
74108 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
74109 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
74110 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
74111 struct dma_pinned_list *pinned_list, struct page *page,
74112 unsigned int offset, size_t len);
74113
74114 diff --git a/include/linux/efi.h b/include/linux/efi.h
74115 index 2bc0ad7..3f7b006 100644
74116 --- a/include/linux/efi.h
74117 +++ b/include/linux/efi.h
74118 @@ -745,6 +745,7 @@ struct efivar_operations {
74119 efi_set_variable_t *set_variable;
74120 efi_query_variable_store_t *query_variable_store;
74121 };
74122 +typedef struct efivar_operations __no_const efivar_operations_no_const;
74123
74124 struct efivars {
74125 /*
74126 diff --git a/include/linux/elf.h b/include/linux/elf.h
74127 index 40a3c0e..4c45a38 100644
74128 --- a/include/linux/elf.h
74129 +++ b/include/linux/elf.h
74130 @@ -24,6 +24,7 @@ extern Elf32_Dyn _DYNAMIC [];
74131 #define elf_note elf32_note
74132 #define elf_addr_t Elf32_Off
74133 #define Elf_Half Elf32_Half
74134 +#define elf_dyn Elf32_Dyn
74135
74136 #else
74137
74138 @@ -34,6 +35,7 @@ extern Elf64_Dyn _DYNAMIC [];
74139 #define elf_note elf64_note
74140 #define elf_addr_t Elf64_Off
74141 #define Elf_Half Elf64_Half
74142 +#define elf_dyn Elf64_Dyn
74143
74144 #endif
74145
74146 diff --git a/include/linux/err.h b/include/linux/err.h
74147 index f2edce2..cc2082c 100644
74148 --- a/include/linux/err.h
74149 +++ b/include/linux/err.h
74150 @@ -19,12 +19,12 @@
74151
74152 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
74153
74154 -static inline void * __must_check ERR_PTR(long error)
74155 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
74156 {
74157 return (void *) error;
74158 }
74159
74160 -static inline long __must_check PTR_ERR(const void *ptr)
74161 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(const void *ptr)
74162 {
74163 return (long) ptr;
74164 }
74165 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
74166 index fcb51c8..bdafcf6 100644
74167 --- a/include/linux/extcon.h
74168 +++ b/include/linux/extcon.h
74169 @@ -134,7 +134,7 @@ struct extcon_dev {
74170 /* /sys/class/extcon/.../mutually_exclusive/... */
74171 struct attribute_group attr_g_muex;
74172 struct attribute **attrs_muex;
74173 - struct device_attribute *d_attrs_muex;
74174 + device_attribute_no_const *d_attrs_muex;
74175 };
74176
74177 /**
74178 diff --git a/include/linux/fb.h b/include/linux/fb.h
74179 index d49c60f..2834fbe 100644
74180 --- a/include/linux/fb.h
74181 +++ b/include/linux/fb.h
74182 @@ -304,7 +304,7 @@ struct fb_ops {
74183 /* called at KDB enter and leave time to prepare the console */
74184 int (*fb_debug_enter)(struct fb_info *info);
74185 int (*fb_debug_leave)(struct fb_info *info);
74186 -};
74187 +} __do_const;
74188
74189 #ifdef CONFIG_FB_TILEBLITTING
74190 #define FB_TILE_CURSOR_NONE 0
74191 diff --git a/include/linux/filter.h b/include/linux/filter.h
74192 index f65f5a6..2f4f93a 100644
74193 --- a/include/linux/filter.h
74194 +++ b/include/linux/filter.h
74195 @@ -20,6 +20,7 @@ struct compat_sock_fprog {
74196
74197 struct sk_buff;
74198 struct sock;
74199 +struct bpf_jit_work;
74200
74201 struct sk_filter
74202 {
74203 @@ -27,6 +28,9 @@ struct sk_filter
74204 unsigned int len; /* Number of filter blocks */
74205 unsigned int (*bpf_func)(const struct sk_buff *skb,
74206 const struct sock_filter *filter);
74207 +#ifdef CONFIG_BPF_JIT
74208 + struct bpf_jit_work *work;
74209 +#endif
74210 struct rcu_head rcu;
74211 struct sock_filter insns[0];
74212 };
74213 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
74214 index 8293262..2b3b8bd 100644
74215 --- a/include/linux/frontswap.h
74216 +++ b/include/linux/frontswap.h
74217 @@ -11,7 +11,7 @@ struct frontswap_ops {
74218 int (*load)(unsigned, pgoff_t, struct page *);
74219 void (*invalidate_page)(unsigned, pgoff_t);
74220 void (*invalidate_area)(unsigned);
74221 -};
74222 +} __no_const;
74223
74224 extern bool frontswap_enabled;
74225 extern struct frontswap_ops *
74226 diff --git a/include/linux/fs.h b/include/linux/fs.h
74227 index 65c2be2..4c53f6e 100644
74228 --- a/include/linux/fs.h
74229 +++ b/include/linux/fs.h
74230 @@ -1543,7 +1543,8 @@ struct file_operations {
74231 long (*fallocate)(struct file *file, int mode, loff_t offset,
74232 loff_t len);
74233 int (*show_fdinfo)(struct seq_file *m, struct file *f);
74234 -};
74235 +} __do_const;
74236 +typedef struct file_operations __no_const file_operations_no_const;
74237
74238 struct inode_operations {
74239 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
74240 @@ -2688,4 +2689,14 @@ static inline void inode_has_no_xattr(struct inode *inode)
74241 inode->i_flags |= S_NOSEC;
74242 }
74243
74244 +static inline bool is_sidechannel_device(const struct inode *inode)
74245 +{
74246 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
74247 + umode_t mode = inode->i_mode;
74248 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
74249 +#else
74250 + return false;
74251 +#endif
74252 +}
74253 +
74254 #endif /* _LINUX_FS_H */
74255 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
74256 index 2b93a9a..855d94a 100644
74257 --- a/include/linux/fs_struct.h
74258 +++ b/include/linux/fs_struct.h
74259 @@ -6,7 +6,7 @@
74260 #include <linux/seqlock.h>
74261
74262 struct fs_struct {
74263 - int users;
74264 + atomic_t users;
74265 spinlock_t lock;
74266 seqcount_t seq;
74267 int umask;
74268 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
74269 index 5dfa0aa..6acf322 100644
74270 --- a/include/linux/fscache-cache.h
74271 +++ b/include/linux/fscache-cache.h
74272 @@ -112,7 +112,7 @@ struct fscache_operation {
74273 fscache_operation_release_t release;
74274 };
74275
74276 -extern atomic_t fscache_op_debug_id;
74277 +extern atomic_unchecked_t fscache_op_debug_id;
74278 extern void fscache_op_work_func(struct work_struct *work);
74279
74280 extern void fscache_enqueue_operation(struct fscache_operation *);
74281 @@ -134,7 +134,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
74282 INIT_WORK(&op->work, fscache_op_work_func);
74283 atomic_set(&op->usage, 1);
74284 op->state = FSCACHE_OP_ST_INITIALISED;
74285 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
74286 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
74287 op->processor = processor;
74288 op->release = release;
74289 INIT_LIST_HEAD(&op->pend_link);
74290 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
74291 index 7a08623..4c07b0f 100644
74292 --- a/include/linux/fscache.h
74293 +++ b/include/linux/fscache.h
74294 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
74295 * - this is mandatory for any object that may have data
74296 */
74297 void (*now_uncached)(void *cookie_netfs_data);
74298 -};
74299 +} __do_const;
74300
74301 /*
74302 * fscache cached network filesystem type
74303 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
74304 index a78680a..87bd73e 100644
74305 --- a/include/linux/fsnotify.h
74306 +++ b/include/linux/fsnotify.h
74307 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
74308 struct inode *inode = path->dentry->d_inode;
74309 __u32 mask = FS_ACCESS;
74310
74311 + if (is_sidechannel_device(inode))
74312 + return;
74313 +
74314 if (S_ISDIR(inode->i_mode))
74315 mask |= FS_ISDIR;
74316
74317 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
74318 struct inode *inode = path->dentry->d_inode;
74319 __u32 mask = FS_MODIFY;
74320
74321 + if (is_sidechannel_device(inode))
74322 + return;
74323 +
74324 if (S_ISDIR(inode->i_mode))
74325 mask |= FS_ISDIR;
74326
74327 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
74328 */
74329 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
74330 {
74331 - return kstrdup(name, GFP_KERNEL);
74332 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
74333 }
74334
74335 /*
74336 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
74337 index 9f3c275..911b591 100644
74338 --- a/include/linux/genhd.h
74339 +++ b/include/linux/genhd.h
74340 @@ -194,7 +194,7 @@ struct gendisk {
74341 struct kobject *slave_dir;
74342
74343 struct timer_rand_state *random;
74344 - atomic_t sync_io; /* RAID */
74345 + atomic_unchecked_t sync_io; /* RAID */
74346 struct disk_events *ev;
74347 #ifdef CONFIG_BLK_DEV_INTEGRITY
74348 struct blk_integrity *integrity;
74349 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
74350 index 023bc34..b02b46a 100644
74351 --- a/include/linux/genl_magic_func.h
74352 +++ b/include/linux/genl_magic_func.h
74353 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
74354 },
74355
74356 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
74357 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
74358 +static struct genl_ops ZZZ_genl_ops[] = {
74359 #include GENL_MAGIC_INCLUDE_FILE
74360 };
74361
74362 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
74363 index 0f615eb..5c3832f 100644
74364 --- a/include/linux/gfp.h
74365 +++ b/include/linux/gfp.h
74366 @@ -35,6 +35,13 @@ struct vm_area_struct;
74367 #define ___GFP_NO_KSWAPD 0x400000u
74368 #define ___GFP_OTHER_NODE 0x800000u
74369 #define ___GFP_WRITE 0x1000000u
74370 +
74371 +#ifdef CONFIG_PAX_USERCOPY_SLABS
74372 +#define ___GFP_USERCOPY 0x2000000u
74373 +#else
74374 +#define ___GFP_USERCOPY 0
74375 +#endif
74376 +
74377 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
74378
74379 /*
74380 @@ -92,6 +99,7 @@ struct vm_area_struct;
74381 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
74382 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
74383 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
74384 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
74385
74386 /*
74387 * This may seem redundant, but it's a way of annotating false positives vs.
74388 @@ -99,7 +107,7 @@ struct vm_area_struct;
74389 */
74390 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
74391
74392 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
74393 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
74394 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
74395
74396 /* This equals 0, but use constants in case they ever change */
74397 @@ -153,6 +161,8 @@ struct vm_area_struct;
74398 /* 4GB DMA on some platforms */
74399 #define GFP_DMA32 __GFP_DMA32
74400
74401 +#define GFP_USERCOPY __GFP_USERCOPY
74402 +
74403 /* Convert GFP flags to their corresponding migrate type */
74404 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
74405 {
74406 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
74407 new file mode 100644
74408 index 0000000..ebe6d72
74409 --- /dev/null
74410 +++ b/include/linux/gracl.h
74411 @@ -0,0 +1,319 @@
74412 +#ifndef GR_ACL_H
74413 +#define GR_ACL_H
74414 +
74415 +#include <linux/grdefs.h>
74416 +#include <linux/resource.h>
74417 +#include <linux/capability.h>
74418 +#include <linux/dcache.h>
74419 +#include <asm/resource.h>
74420 +
74421 +/* Major status information */
74422 +
74423 +#define GR_VERSION "grsecurity 2.9.1"
74424 +#define GRSECURITY_VERSION 0x2901
74425 +
74426 +enum {
74427 + GR_SHUTDOWN = 0,
74428 + GR_ENABLE = 1,
74429 + GR_SPROLE = 2,
74430 + GR_RELOAD = 3,
74431 + GR_SEGVMOD = 4,
74432 + GR_STATUS = 5,
74433 + GR_UNSPROLE = 6,
74434 + GR_PASSSET = 7,
74435 + GR_SPROLEPAM = 8,
74436 +};
74437 +
74438 +/* Password setup definitions
74439 + * kernel/grhash.c */
74440 +enum {
74441 + GR_PW_LEN = 128,
74442 + GR_SALT_LEN = 16,
74443 + GR_SHA_LEN = 32,
74444 +};
74445 +
74446 +enum {
74447 + GR_SPROLE_LEN = 64,
74448 +};
74449 +
74450 +enum {
74451 + GR_NO_GLOB = 0,
74452 + GR_REG_GLOB,
74453 + GR_CREATE_GLOB
74454 +};
74455 +
74456 +#define GR_NLIMITS 32
74457 +
74458 +/* Begin Data Structures */
74459 +
74460 +struct sprole_pw {
74461 + unsigned char *rolename;
74462 + unsigned char salt[GR_SALT_LEN];
74463 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
74464 +};
74465 +
74466 +struct name_entry {
74467 + __u32 key;
74468 + ino_t inode;
74469 + dev_t device;
74470 + char *name;
74471 + __u16 len;
74472 + __u8 deleted;
74473 + struct name_entry *prev;
74474 + struct name_entry *next;
74475 +};
74476 +
74477 +struct inodev_entry {
74478 + struct name_entry *nentry;
74479 + struct inodev_entry *prev;
74480 + struct inodev_entry *next;
74481 +};
74482 +
74483 +struct acl_role_db {
74484 + struct acl_role_label **r_hash;
74485 + __u32 r_size;
74486 +};
74487 +
74488 +struct inodev_db {
74489 + struct inodev_entry **i_hash;
74490 + __u32 i_size;
74491 +};
74492 +
74493 +struct name_db {
74494 + struct name_entry **n_hash;
74495 + __u32 n_size;
74496 +};
74497 +
74498 +struct crash_uid {
74499 + uid_t uid;
74500 + unsigned long expires;
74501 +};
74502 +
74503 +struct gr_hash_struct {
74504 + void **table;
74505 + void **nametable;
74506 + void *first;
74507 + __u32 table_size;
74508 + __u32 used_size;
74509 + int type;
74510 +};
74511 +
74512 +/* Userspace Grsecurity ACL data structures */
74513 +
74514 +struct acl_subject_label {
74515 + char *filename;
74516 + ino_t inode;
74517 + dev_t device;
74518 + __u32 mode;
74519 + kernel_cap_t cap_mask;
74520 + kernel_cap_t cap_lower;
74521 + kernel_cap_t cap_invert_audit;
74522 +
74523 + struct rlimit res[GR_NLIMITS];
74524 + __u32 resmask;
74525 +
74526 + __u8 user_trans_type;
74527 + __u8 group_trans_type;
74528 + uid_t *user_transitions;
74529 + gid_t *group_transitions;
74530 + __u16 user_trans_num;
74531 + __u16 group_trans_num;
74532 +
74533 + __u32 sock_families[2];
74534 + __u32 ip_proto[8];
74535 + __u32 ip_type;
74536 + struct acl_ip_label **ips;
74537 + __u32 ip_num;
74538 + __u32 inaddr_any_override;
74539 +
74540 + __u32 crashes;
74541 + unsigned long expires;
74542 +
74543 + struct acl_subject_label *parent_subject;
74544 + struct gr_hash_struct *hash;
74545 + struct acl_subject_label *prev;
74546 + struct acl_subject_label *next;
74547 +
74548 + struct acl_object_label **obj_hash;
74549 + __u32 obj_hash_size;
74550 + __u16 pax_flags;
74551 +};
74552 +
74553 +struct role_allowed_ip {
74554 + __u32 addr;
74555 + __u32 netmask;
74556 +
74557 + struct role_allowed_ip *prev;
74558 + struct role_allowed_ip *next;
74559 +};
74560 +
74561 +struct role_transition {
74562 + char *rolename;
74563 +
74564 + struct role_transition *prev;
74565 + struct role_transition *next;
74566 +};
74567 +
74568 +struct acl_role_label {
74569 + char *rolename;
74570 + uid_t uidgid;
74571 + __u16 roletype;
74572 +
74573 + __u16 auth_attempts;
74574 + unsigned long expires;
74575 +
74576 + struct acl_subject_label *root_label;
74577 + struct gr_hash_struct *hash;
74578 +
74579 + struct acl_role_label *prev;
74580 + struct acl_role_label *next;
74581 +
74582 + struct role_transition *transitions;
74583 + struct role_allowed_ip *allowed_ips;
74584 + uid_t *domain_children;
74585 + __u16 domain_child_num;
74586 +
74587 + umode_t umask;
74588 +
74589 + struct acl_subject_label **subj_hash;
74590 + __u32 subj_hash_size;
74591 +};
74592 +
74593 +struct user_acl_role_db {
74594 + struct acl_role_label **r_table;
74595 + __u32 num_pointers; /* Number of allocations to track */
74596 + __u32 num_roles; /* Number of roles */
74597 + __u32 num_domain_children; /* Number of domain children */
74598 + __u32 num_subjects; /* Number of subjects */
74599 + __u32 num_objects; /* Number of objects */
74600 +};
74601 +
74602 +struct acl_object_label {
74603 + char *filename;
74604 + ino_t inode;
74605 + dev_t device;
74606 + __u32 mode;
74607 +
74608 + struct acl_subject_label *nested;
74609 + struct acl_object_label *globbed;
74610 +
74611 + /* next two structures not used */
74612 +
74613 + struct acl_object_label *prev;
74614 + struct acl_object_label *next;
74615 +};
74616 +
74617 +struct acl_ip_label {
74618 + char *iface;
74619 + __u32 addr;
74620 + __u32 netmask;
74621 + __u16 low, high;
74622 + __u8 mode;
74623 + __u32 type;
74624 + __u32 proto[8];
74625 +
74626 + /* next two structures not used */
74627 +
74628 + struct acl_ip_label *prev;
74629 + struct acl_ip_label *next;
74630 +};
74631 +
74632 +struct gr_arg {
74633 + struct user_acl_role_db role_db;
74634 + unsigned char pw[GR_PW_LEN];
74635 + unsigned char salt[GR_SALT_LEN];
74636 + unsigned char sum[GR_SHA_LEN];
74637 + unsigned char sp_role[GR_SPROLE_LEN];
74638 + struct sprole_pw *sprole_pws;
74639 + dev_t segv_device;
74640 + ino_t segv_inode;
74641 + uid_t segv_uid;
74642 + __u16 num_sprole_pws;
74643 + __u16 mode;
74644 +};
74645 +
74646 +struct gr_arg_wrapper {
74647 + struct gr_arg *arg;
74648 + __u32 version;
74649 + __u32 size;
74650 +};
74651 +
74652 +struct subject_map {
74653 + struct acl_subject_label *user;
74654 + struct acl_subject_label *kernel;
74655 + struct subject_map *prev;
74656 + struct subject_map *next;
74657 +};
74658 +
74659 +struct acl_subj_map_db {
74660 + struct subject_map **s_hash;
74661 + __u32 s_size;
74662 +};
74663 +
74664 +/* End Data Structures Section */
74665 +
74666 +/* Hash functions generated by empirical testing by Brad Spengler
74667 + Makes good use of the low bits of the inode. Generally 0-1 times
74668 + in loop for successful match. 0-3 for unsuccessful match.
74669 + Shift/add algorithm with modulus of table size and an XOR*/
74670 +
74671 +static __inline__ unsigned int
74672 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
74673 +{
74674 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
74675 +}
74676 +
74677 + static __inline__ unsigned int
74678 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
74679 +{
74680 + return ((const unsigned long)userp % sz);
74681 +}
74682 +
74683 +static __inline__ unsigned int
74684 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
74685 +{
74686 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
74687 +}
74688 +
74689 +static __inline__ unsigned int
74690 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
74691 +{
74692 + return full_name_hash((const unsigned char *)name, len) % sz;
74693 +}
74694 +
74695 +#define FOR_EACH_ROLE_START(role) \
74696 + role = role_list; \
74697 + while (role) {
74698 +
74699 +#define FOR_EACH_ROLE_END(role) \
74700 + role = role->prev; \
74701 + }
74702 +
74703 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
74704 + subj = NULL; \
74705 + iter = 0; \
74706 + while (iter < role->subj_hash_size) { \
74707 + if (subj == NULL) \
74708 + subj = role->subj_hash[iter]; \
74709 + if (subj == NULL) { \
74710 + iter++; \
74711 + continue; \
74712 + }
74713 +
74714 +#define FOR_EACH_SUBJECT_END(subj,iter) \
74715 + subj = subj->next; \
74716 + if (subj == NULL) \
74717 + iter++; \
74718 + }
74719 +
74720 +
74721 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
74722 + subj = role->hash->first; \
74723 + while (subj != NULL) {
74724 +
74725 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
74726 + subj = subj->next; \
74727 + }
74728 +
74729 +#endif
74730 +
74731 diff --git a/include/linux/gracl_compat.h b/include/linux/gracl_compat.h
74732 new file mode 100644
74733 index 0000000..33ebd1f
74734 --- /dev/null
74735 +++ b/include/linux/gracl_compat.h
74736 @@ -0,0 +1,156 @@
74737 +#ifndef GR_ACL_COMPAT_H
74738 +#define GR_ACL_COMPAT_H
74739 +
74740 +#include <linux/resource.h>
74741 +#include <asm/resource.h>
74742 +
74743 +struct sprole_pw_compat {
74744 + compat_uptr_t rolename;
74745 + unsigned char salt[GR_SALT_LEN];
74746 + unsigned char sum[GR_SHA_LEN];
74747 +};
74748 +
74749 +struct gr_hash_struct_compat {
74750 + compat_uptr_t table;
74751 + compat_uptr_t nametable;
74752 + compat_uptr_t first;
74753 + __u32 table_size;
74754 + __u32 used_size;
74755 + int type;
74756 +};
74757 +
74758 +struct acl_subject_label_compat {
74759 + compat_uptr_t filename;
74760 + compat_ino_t inode;
74761 + __u32 device;
74762 + __u32 mode;
74763 + kernel_cap_t cap_mask;
74764 + kernel_cap_t cap_lower;
74765 + kernel_cap_t cap_invert_audit;
74766 +
74767 + struct compat_rlimit res[GR_NLIMITS];
74768 + __u32 resmask;
74769 +
74770 + __u8 user_trans_type;
74771 + __u8 group_trans_type;
74772 + compat_uptr_t user_transitions;
74773 + compat_uptr_t group_transitions;
74774 + __u16 user_trans_num;
74775 + __u16 group_trans_num;
74776 +
74777 + __u32 sock_families[2];
74778 + __u32 ip_proto[8];
74779 + __u32 ip_type;
74780 + compat_uptr_t ips;
74781 + __u32 ip_num;
74782 + __u32 inaddr_any_override;
74783 +
74784 + __u32 crashes;
74785 + compat_ulong_t expires;
74786 +
74787 + compat_uptr_t parent_subject;
74788 + compat_uptr_t hash;
74789 + compat_uptr_t prev;
74790 + compat_uptr_t next;
74791 +
74792 + compat_uptr_t obj_hash;
74793 + __u32 obj_hash_size;
74794 + __u16 pax_flags;
74795 +};
74796 +
74797 +struct role_allowed_ip_compat {
74798 + __u32 addr;
74799 + __u32 netmask;
74800 +
74801 + compat_uptr_t prev;
74802 + compat_uptr_t next;
74803 +};
74804 +
74805 +struct role_transition_compat {
74806 + compat_uptr_t rolename;
74807 +
74808 + compat_uptr_t prev;
74809 + compat_uptr_t next;
74810 +};
74811 +
74812 +struct acl_role_label_compat {
74813 + compat_uptr_t rolename;
74814 + uid_t uidgid;
74815 + __u16 roletype;
74816 +
74817 + __u16 auth_attempts;
74818 + compat_ulong_t expires;
74819 +
74820 + compat_uptr_t root_label;
74821 + compat_uptr_t hash;
74822 +
74823 + compat_uptr_t prev;
74824 + compat_uptr_t next;
74825 +
74826 + compat_uptr_t transitions;
74827 + compat_uptr_t allowed_ips;
74828 + compat_uptr_t domain_children;
74829 + __u16 domain_child_num;
74830 +
74831 + umode_t umask;
74832 +
74833 + compat_uptr_t subj_hash;
74834 + __u32 subj_hash_size;
74835 +};
74836 +
74837 +struct user_acl_role_db_compat {
74838 + compat_uptr_t r_table;
74839 + __u32 num_pointers;
74840 + __u32 num_roles;
74841 + __u32 num_domain_children;
74842 + __u32 num_subjects;
74843 + __u32 num_objects;
74844 +};
74845 +
74846 +struct acl_object_label_compat {
74847 + compat_uptr_t filename;
74848 + compat_ino_t inode;
74849 + __u32 device;
74850 + __u32 mode;
74851 +
74852 + compat_uptr_t nested;
74853 + compat_uptr_t globbed;
74854 +
74855 + compat_uptr_t prev;
74856 + compat_uptr_t next;
74857 +};
74858 +
74859 +struct acl_ip_label_compat {
74860 + compat_uptr_t iface;
74861 + __u32 addr;
74862 + __u32 netmask;
74863 + __u16 low, high;
74864 + __u8 mode;
74865 + __u32 type;
74866 + __u32 proto[8];
74867 +
74868 + compat_uptr_t prev;
74869 + compat_uptr_t next;
74870 +};
74871 +
74872 +struct gr_arg_compat {
74873 + struct user_acl_role_db_compat role_db;
74874 + unsigned char pw[GR_PW_LEN];
74875 + unsigned char salt[GR_SALT_LEN];
74876 + unsigned char sum[GR_SHA_LEN];
74877 + unsigned char sp_role[GR_SPROLE_LEN];
74878 + compat_uptr_t sprole_pws;
74879 + __u32 segv_device;
74880 + compat_ino_t segv_inode;
74881 + uid_t segv_uid;
74882 + __u16 num_sprole_pws;
74883 + __u16 mode;
74884 +};
74885 +
74886 +struct gr_arg_wrapper_compat {
74887 + compat_uptr_t arg;
74888 + __u32 version;
74889 + __u32 size;
74890 +};
74891 +
74892 +#endif
74893 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
74894 new file mode 100644
74895 index 0000000..323ecf2
74896 --- /dev/null
74897 +++ b/include/linux/gralloc.h
74898 @@ -0,0 +1,9 @@
74899 +#ifndef __GRALLOC_H
74900 +#define __GRALLOC_H
74901 +
74902 +void acl_free_all(void);
74903 +int acl_alloc_stack_init(unsigned long size);
74904 +void *acl_alloc(unsigned long len);
74905 +void *acl_alloc_num(unsigned long num, unsigned long len);
74906 +
74907 +#endif
74908 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
74909 new file mode 100644
74910 index 0000000..be66033
74911 --- /dev/null
74912 +++ b/include/linux/grdefs.h
74913 @@ -0,0 +1,140 @@
74914 +#ifndef GRDEFS_H
74915 +#define GRDEFS_H
74916 +
74917 +/* Begin grsecurity status declarations */
74918 +
74919 +enum {
74920 + GR_READY = 0x01,
74921 + GR_STATUS_INIT = 0x00 // disabled state
74922 +};
74923 +
74924 +/* Begin ACL declarations */
74925 +
74926 +/* Role flags */
74927 +
74928 +enum {
74929 + GR_ROLE_USER = 0x0001,
74930 + GR_ROLE_GROUP = 0x0002,
74931 + GR_ROLE_DEFAULT = 0x0004,
74932 + GR_ROLE_SPECIAL = 0x0008,
74933 + GR_ROLE_AUTH = 0x0010,
74934 + GR_ROLE_NOPW = 0x0020,
74935 + GR_ROLE_GOD = 0x0040,
74936 + GR_ROLE_LEARN = 0x0080,
74937 + GR_ROLE_TPE = 0x0100,
74938 + GR_ROLE_DOMAIN = 0x0200,
74939 + GR_ROLE_PAM = 0x0400,
74940 + GR_ROLE_PERSIST = 0x0800
74941 +};
74942 +
74943 +/* ACL Subject and Object mode flags */
74944 +enum {
74945 + GR_DELETED = 0x80000000
74946 +};
74947 +
74948 +/* ACL Object-only mode flags */
74949 +enum {
74950 + GR_READ = 0x00000001,
74951 + GR_APPEND = 0x00000002,
74952 + GR_WRITE = 0x00000004,
74953 + GR_EXEC = 0x00000008,
74954 + GR_FIND = 0x00000010,
74955 + GR_INHERIT = 0x00000020,
74956 + GR_SETID = 0x00000040,
74957 + GR_CREATE = 0x00000080,
74958 + GR_DELETE = 0x00000100,
74959 + GR_LINK = 0x00000200,
74960 + GR_AUDIT_READ = 0x00000400,
74961 + GR_AUDIT_APPEND = 0x00000800,
74962 + GR_AUDIT_WRITE = 0x00001000,
74963 + GR_AUDIT_EXEC = 0x00002000,
74964 + GR_AUDIT_FIND = 0x00004000,
74965 + GR_AUDIT_INHERIT= 0x00008000,
74966 + GR_AUDIT_SETID = 0x00010000,
74967 + GR_AUDIT_CREATE = 0x00020000,
74968 + GR_AUDIT_DELETE = 0x00040000,
74969 + GR_AUDIT_LINK = 0x00080000,
74970 + GR_PTRACERD = 0x00100000,
74971 + GR_NOPTRACE = 0x00200000,
74972 + GR_SUPPRESS = 0x00400000,
74973 + GR_NOLEARN = 0x00800000,
74974 + GR_INIT_TRANSFER= 0x01000000
74975 +};
74976 +
74977 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
74978 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
74979 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
74980 +
74981 +/* ACL subject-only mode flags */
74982 +enum {
74983 + GR_KILL = 0x00000001,
74984 + GR_VIEW = 0x00000002,
74985 + GR_PROTECTED = 0x00000004,
74986 + GR_LEARN = 0x00000008,
74987 + GR_OVERRIDE = 0x00000010,
74988 + /* just a placeholder, this mode is only used in userspace */
74989 + GR_DUMMY = 0x00000020,
74990 + GR_PROTSHM = 0x00000040,
74991 + GR_KILLPROC = 0x00000080,
74992 + GR_KILLIPPROC = 0x00000100,
74993 + /* just a placeholder, this mode is only used in userspace */
74994 + GR_NOTROJAN = 0x00000200,
74995 + GR_PROTPROCFD = 0x00000400,
74996 + GR_PROCACCT = 0x00000800,
74997 + GR_RELAXPTRACE = 0x00001000,
74998 + //GR_NESTED = 0x00002000,
74999 + GR_INHERITLEARN = 0x00004000,
75000 + GR_PROCFIND = 0x00008000,
75001 + GR_POVERRIDE = 0x00010000,
75002 + GR_KERNELAUTH = 0x00020000,
75003 + GR_ATSECURE = 0x00040000,
75004 + GR_SHMEXEC = 0x00080000
75005 +};
75006 +
75007 +enum {
75008 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
75009 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
75010 + GR_PAX_ENABLE_MPROTECT = 0x0004,
75011 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
75012 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
75013 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
75014 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
75015 + GR_PAX_DISABLE_MPROTECT = 0x0400,
75016 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
75017 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
75018 +};
75019 +
75020 +enum {
75021 + GR_ID_USER = 0x01,
75022 + GR_ID_GROUP = 0x02,
75023 +};
75024 +
75025 +enum {
75026 + GR_ID_ALLOW = 0x01,
75027 + GR_ID_DENY = 0x02,
75028 +};
75029 +
75030 +#define GR_CRASH_RES 31
75031 +#define GR_UIDTABLE_MAX 500
75032 +
75033 +/* begin resource learning section */
75034 +enum {
75035 + GR_RLIM_CPU_BUMP = 60,
75036 + GR_RLIM_FSIZE_BUMP = 50000,
75037 + GR_RLIM_DATA_BUMP = 10000,
75038 + GR_RLIM_STACK_BUMP = 1000,
75039 + GR_RLIM_CORE_BUMP = 10000,
75040 + GR_RLIM_RSS_BUMP = 500000,
75041 + GR_RLIM_NPROC_BUMP = 1,
75042 + GR_RLIM_NOFILE_BUMP = 5,
75043 + GR_RLIM_MEMLOCK_BUMP = 50000,
75044 + GR_RLIM_AS_BUMP = 500000,
75045 + GR_RLIM_LOCKS_BUMP = 2,
75046 + GR_RLIM_SIGPENDING_BUMP = 5,
75047 + GR_RLIM_MSGQUEUE_BUMP = 10000,
75048 + GR_RLIM_NICE_BUMP = 1,
75049 + GR_RLIM_RTPRIO_BUMP = 1,
75050 + GR_RLIM_RTTIME_BUMP = 1000000
75051 +};
75052 +
75053 +#endif
75054 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
75055 new file mode 100644
75056 index 0000000..e337683
75057 --- /dev/null
75058 +++ b/include/linux/grinternal.h
75059 @@ -0,0 +1,229 @@
75060 +#ifndef __GRINTERNAL_H
75061 +#define __GRINTERNAL_H
75062 +
75063 +#ifdef CONFIG_GRKERNSEC
75064 +
75065 +#include <linux/fs.h>
75066 +#include <linux/mnt_namespace.h>
75067 +#include <linux/nsproxy.h>
75068 +#include <linux/gracl.h>
75069 +#include <linux/grdefs.h>
75070 +#include <linux/grmsg.h>
75071 +
75072 +void gr_add_learn_entry(const char *fmt, ...)
75073 + __attribute__ ((format (printf, 1, 2)));
75074 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
75075 + const struct vfsmount *mnt);
75076 +__u32 gr_check_create(const struct dentry *new_dentry,
75077 + const struct dentry *parent,
75078 + const struct vfsmount *mnt, const __u32 mode);
75079 +int gr_check_protected_task(const struct task_struct *task);
75080 +__u32 to_gr_audit(const __u32 reqmode);
75081 +int gr_set_acls(const int type);
75082 +int gr_apply_subject_to_task(struct task_struct *task);
75083 +int gr_acl_is_enabled(void);
75084 +char gr_roletype_to_char(void);
75085 +
75086 +void gr_handle_alertkill(struct task_struct *task);
75087 +char *gr_to_filename(const struct dentry *dentry,
75088 + const struct vfsmount *mnt);
75089 +char *gr_to_filename1(const struct dentry *dentry,
75090 + const struct vfsmount *mnt);
75091 +char *gr_to_filename2(const struct dentry *dentry,
75092 + const struct vfsmount *mnt);
75093 +char *gr_to_filename3(const struct dentry *dentry,
75094 + const struct vfsmount *mnt);
75095 +
75096 +extern int grsec_enable_ptrace_readexec;
75097 +extern int grsec_enable_harden_ptrace;
75098 +extern int grsec_enable_link;
75099 +extern int grsec_enable_fifo;
75100 +extern int grsec_enable_execve;
75101 +extern int grsec_enable_shm;
75102 +extern int grsec_enable_execlog;
75103 +extern int grsec_enable_signal;
75104 +extern int grsec_enable_audit_ptrace;
75105 +extern int grsec_enable_forkfail;
75106 +extern int grsec_enable_time;
75107 +extern int grsec_enable_rofs;
75108 +extern int grsec_deny_new_usb;
75109 +extern int grsec_enable_chroot_shmat;
75110 +extern int grsec_enable_chroot_mount;
75111 +extern int grsec_enable_chroot_double;
75112 +extern int grsec_enable_chroot_pivot;
75113 +extern int grsec_enable_chroot_chdir;
75114 +extern int grsec_enable_chroot_chmod;
75115 +extern int grsec_enable_chroot_mknod;
75116 +extern int grsec_enable_chroot_fchdir;
75117 +extern int grsec_enable_chroot_nice;
75118 +extern int grsec_enable_chroot_execlog;
75119 +extern int grsec_enable_chroot_caps;
75120 +extern int grsec_enable_chroot_sysctl;
75121 +extern int grsec_enable_chroot_unix;
75122 +extern int grsec_enable_symlinkown;
75123 +extern kgid_t grsec_symlinkown_gid;
75124 +extern int grsec_enable_tpe;
75125 +extern kgid_t grsec_tpe_gid;
75126 +extern int grsec_enable_tpe_all;
75127 +extern int grsec_enable_tpe_invert;
75128 +extern int grsec_enable_socket_all;
75129 +extern kgid_t grsec_socket_all_gid;
75130 +extern int grsec_enable_socket_client;
75131 +extern kgid_t grsec_socket_client_gid;
75132 +extern int grsec_enable_socket_server;
75133 +extern kgid_t grsec_socket_server_gid;
75134 +extern kgid_t grsec_audit_gid;
75135 +extern int grsec_enable_group;
75136 +extern int grsec_enable_log_rwxmaps;
75137 +extern int grsec_enable_mount;
75138 +extern int grsec_enable_chdir;
75139 +extern int grsec_resource_logging;
75140 +extern int grsec_enable_blackhole;
75141 +extern int grsec_lastack_retries;
75142 +extern int grsec_enable_brute;
75143 +extern int grsec_lock;
75144 +
75145 +extern spinlock_t grsec_alert_lock;
75146 +extern unsigned long grsec_alert_wtime;
75147 +extern unsigned long grsec_alert_fyet;
75148 +
75149 +extern spinlock_t grsec_audit_lock;
75150 +
75151 +extern rwlock_t grsec_exec_file_lock;
75152 +
75153 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
75154 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
75155 + (tsk)->exec_file->f_path.mnt) : "/")
75156 +
75157 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
75158 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
75159 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
75160 +
75161 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
75162 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
75163 + (tsk)->exec_file->f_path.mnt) : "/")
75164 +
75165 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
75166 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
75167 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
75168 +
75169 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
75170 +
75171 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
75172 +
75173 +static inline bool gr_is_same_file(const struct file *file1, const struct file *file2)
75174 +{
75175 + if (file1 && file2) {
75176 + const struct inode *inode1 = file1->f_path.dentry->d_inode;
75177 + const struct inode *inode2 = file2->f_path.dentry->d_inode;
75178 + if (inode1->i_ino == inode2->i_ino && inode1->i_sb->s_dev == inode2->i_sb->s_dev)
75179 + return true;
75180 + }
75181 +
75182 + return false;
75183 +}
75184 +
75185 +#define GR_CHROOT_CAPS {{ \
75186 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
75187 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
75188 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
75189 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
75190 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
75191 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
75192 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
75193 +
75194 +#define security_learn(normal_msg,args...) \
75195 +({ \
75196 + read_lock(&grsec_exec_file_lock); \
75197 + gr_add_learn_entry(normal_msg "\n", ## args); \
75198 + read_unlock(&grsec_exec_file_lock); \
75199 +})
75200 +
75201 +enum {
75202 + GR_DO_AUDIT,
75203 + GR_DONT_AUDIT,
75204 + /* used for non-audit messages that we shouldn't kill the task on */
75205 + GR_DONT_AUDIT_GOOD
75206 +};
75207 +
75208 +enum {
75209 + GR_TTYSNIFF,
75210 + GR_RBAC,
75211 + GR_RBAC_STR,
75212 + GR_STR_RBAC,
75213 + GR_RBAC_MODE2,
75214 + GR_RBAC_MODE3,
75215 + GR_FILENAME,
75216 + GR_SYSCTL_HIDDEN,
75217 + GR_NOARGS,
75218 + GR_ONE_INT,
75219 + GR_ONE_INT_TWO_STR,
75220 + GR_ONE_STR,
75221 + GR_STR_INT,
75222 + GR_TWO_STR_INT,
75223 + GR_TWO_INT,
75224 + GR_TWO_U64,
75225 + GR_THREE_INT,
75226 + GR_FIVE_INT_TWO_STR,
75227 + GR_TWO_STR,
75228 + GR_THREE_STR,
75229 + GR_FOUR_STR,
75230 + GR_STR_FILENAME,
75231 + GR_FILENAME_STR,
75232 + GR_FILENAME_TWO_INT,
75233 + GR_FILENAME_TWO_INT_STR,
75234 + GR_TEXTREL,
75235 + GR_PTRACE,
75236 + GR_RESOURCE,
75237 + GR_CAP,
75238 + GR_SIG,
75239 + GR_SIG2,
75240 + GR_CRASH1,
75241 + GR_CRASH2,
75242 + GR_PSACCT,
75243 + GR_RWXMAP,
75244 + GR_RWXMAPVMA
75245 +};
75246 +
75247 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
75248 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
75249 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
75250 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
75251 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
75252 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
75253 +#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)
75254 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
75255 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
75256 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
75257 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
75258 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
75259 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
75260 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
75261 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
75262 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
75263 +#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)
75264 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
75265 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
75266 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
75267 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
75268 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
75269 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
75270 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
75271 +#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)
75272 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
75273 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
75274 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
75275 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
75276 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
75277 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
75278 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
75279 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
75280 +#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)
75281 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
75282 +#define gr_log_rwxmap_vma(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAPVMA, str)
75283 +
75284 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
75285 +
75286 +#endif
75287 +
75288 +#endif
75289 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
75290 new file mode 100644
75291 index 0000000..a4396b5
75292 --- /dev/null
75293 +++ b/include/linux/grmsg.h
75294 @@ -0,0 +1,113 @@
75295 +#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"
75296 +#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"
75297 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
75298 +#define GR_STOPMOD_MSG "denied modification of module state by "
75299 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
75300 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
75301 +#define GR_IOPERM_MSG "denied use of ioperm() by "
75302 +#define GR_IOPL_MSG "denied use of iopl() by "
75303 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
75304 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
75305 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
75306 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
75307 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
75308 +#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"
75309 +#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"
75310 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
75311 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
75312 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
75313 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
75314 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
75315 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
75316 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
75317 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
75318 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
75319 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
75320 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
75321 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
75322 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
75323 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
75324 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
75325 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
75326 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
75327 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
75328 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
75329 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
75330 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
75331 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
75332 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
75333 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
75334 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
75335 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
75336 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
75337 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
75338 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
75339 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
75340 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
75341 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
75342 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
75343 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
75344 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
75345 +#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"
75346 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
75347 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
75348 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
75349 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
75350 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
75351 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
75352 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
75353 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
75354 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
75355 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
75356 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
75357 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
75358 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
75359 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
75360 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
75361 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
75362 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
75363 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
75364 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
75365 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
75366 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
75367 +#define GR_NICE_CHROOT_MSG "denied priority change by "
75368 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
75369 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
75370 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
75371 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
75372 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
75373 +#define GR_TIME_MSG "time set by "
75374 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
75375 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
75376 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
75377 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
75378 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
75379 +#define GR_BIND_MSG "denied bind() by "
75380 +#define GR_CONNECT_MSG "denied connect() by "
75381 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
75382 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
75383 +#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"
75384 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
75385 +#define GR_CAP_ACL_MSG "use of %s denied for "
75386 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
75387 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
75388 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
75389 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
75390 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
75391 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
75392 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
75393 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
75394 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
75395 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
75396 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
75397 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
75398 +#define GR_TEXTREL_AUDIT_MSG "denied text relocation in %.950s, VMA:0x%08lx 0x%08lx by "
75399 +#define GR_PTGNUSTACK_MSG "denied marking stack executable as requested by PT_GNU_STACK marking in %.950s by "
75400 +#define GR_VM86_MSG "denied use of vm86 by "
75401 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
75402 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
75403 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
75404 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
75405 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
75406 +#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 "
75407 +#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 "
75408 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
75409 new file mode 100644
75410 index 0000000..d6f5a21
75411 --- /dev/null
75412 +++ b/include/linux/grsecurity.h
75413 @@ -0,0 +1,244 @@
75414 +#ifndef GR_SECURITY_H
75415 +#define GR_SECURITY_H
75416 +#include <linux/fs.h>
75417 +#include <linux/fs_struct.h>
75418 +#include <linux/binfmts.h>
75419 +#include <linux/gracl.h>
75420 +
75421 +/* notify of brain-dead configs */
75422 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
75423 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
75424 +#endif
75425 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
75426 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
75427 +#endif
75428 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
75429 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
75430 +#endif
75431 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
75432 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
75433 +#endif
75434 +
75435 +int gr_handle_new_usb(void);
75436 +
75437 +void gr_handle_brute_attach(unsigned long mm_flags);
75438 +void gr_handle_brute_check(void);
75439 +void gr_handle_kernel_exploit(void);
75440 +
75441 +char gr_roletype_to_char(void);
75442 +
75443 +int gr_acl_enable_at_secure(void);
75444 +
75445 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
75446 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
75447 +
75448 +void gr_del_task_from_ip_table(struct task_struct *p);
75449 +
75450 +int gr_pid_is_chrooted(struct task_struct *p);
75451 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
75452 +int gr_handle_chroot_nice(void);
75453 +int gr_handle_chroot_sysctl(const int op);
75454 +int gr_handle_chroot_setpriority(struct task_struct *p,
75455 + const int niceval);
75456 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
75457 +int gr_handle_chroot_chroot(const struct dentry *dentry,
75458 + const struct vfsmount *mnt);
75459 +void gr_handle_chroot_chdir(const struct path *path);
75460 +int gr_handle_chroot_chmod(const struct dentry *dentry,
75461 + const struct vfsmount *mnt, const int mode);
75462 +int gr_handle_chroot_mknod(const struct dentry *dentry,
75463 + const struct vfsmount *mnt, const int mode);
75464 +int gr_handle_chroot_mount(const struct dentry *dentry,
75465 + const struct vfsmount *mnt,
75466 + const char *dev_name);
75467 +int gr_handle_chroot_pivot(void);
75468 +int gr_handle_chroot_unix(const pid_t pid);
75469 +
75470 +int gr_handle_rawio(const struct inode *inode);
75471 +
75472 +void gr_handle_ioperm(void);
75473 +void gr_handle_iopl(void);
75474 +
75475 +umode_t gr_acl_umask(void);
75476 +
75477 +int gr_tpe_allow(const struct file *file);
75478 +
75479 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
75480 +void gr_clear_chroot_entries(struct task_struct *task);
75481 +
75482 +void gr_log_forkfail(const int retval);
75483 +void gr_log_timechange(void);
75484 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
75485 +void gr_log_chdir(const struct dentry *dentry,
75486 + const struct vfsmount *mnt);
75487 +void gr_log_chroot_exec(const struct dentry *dentry,
75488 + const struct vfsmount *mnt);
75489 +void gr_log_remount(const char *devname, const int retval);
75490 +void gr_log_unmount(const char *devname, const int retval);
75491 +void gr_log_mount(const char *from, const char *to, const int retval);
75492 +void gr_log_textrel(struct vm_area_struct *vma);
75493 +void gr_log_ptgnustack(struct file *file);
75494 +void gr_log_rwxmmap(struct file *file);
75495 +void gr_log_rwxmprotect(struct vm_area_struct *vma);
75496 +
75497 +int gr_handle_follow_link(const struct inode *parent,
75498 + const struct inode *inode,
75499 + const struct dentry *dentry,
75500 + const struct vfsmount *mnt);
75501 +int gr_handle_fifo(const struct dentry *dentry,
75502 + const struct vfsmount *mnt,
75503 + const struct dentry *dir, const int flag,
75504 + const int acc_mode);
75505 +int gr_handle_hardlink(const struct dentry *dentry,
75506 + const struct vfsmount *mnt,
75507 + struct inode *inode,
75508 + const int mode, const struct filename *to);
75509 +
75510 +int gr_is_capable(const int cap);
75511 +int gr_is_capable_nolog(const int cap);
75512 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
75513 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
75514 +
75515 +void gr_copy_label(struct task_struct *tsk);
75516 +void gr_handle_crash(struct task_struct *task, const int sig);
75517 +int gr_handle_signal(const struct task_struct *p, const int sig);
75518 +int gr_check_crash_uid(const kuid_t uid);
75519 +int gr_check_protected_task(const struct task_struct *task);
75520 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
75521 +int gr_acl_handle_mmap(const struct file *file,
75522 + const unsigned long prot);
75523 +int gr_acl_handle_mprotect(const struct file *file,
75524 + const unsigned long prot);
75525 +int gr_check_hidden_task(const struct task_struct *tsk);
75526 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
75527 + const struct vfsmount *mnt);
75528 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
75529 + const struct vfsmount *mnt);
75530 +__u32 gr_acl_handle_access(const struct dentry *dentry,
75531 + const struct vfsmount *mnt, const int fmode);
75532 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
75533 + const struct vfsmount *mnt, umode_t *mode);
75534 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
75535 + const struct vfsmount *mnt);
75536 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
75537 + const struct vfsmount *mnt);
75538 +int gr_handle_ptrace(struct task_struct *task, const long request);
75539 +int gr_handle_proc_ptrace(struct task_struct *task);
75540 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
75541 + const struct vfsmount *mnt);
75542 +int gr_check_crash_exec(const struct file *filp);
75543 +int gr_acl_is_enabled(void);
75544 +void gr_set_kernel_label(struct task_struct *task);
75545 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
75546 + const kgid_t gid);
75547 +int gr_set_proc_label(const struct dentry *dentry,
75548 + const struct vfsmount *mnt,
75549 + const int unsafe_flags);
75550 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
75551 + const struct vfsmount *mnt);
75552 +__u32 gr_acl_handle_open(const struct dentry *dentry,
75553 + const struct vfsmount *mnt, int acc_mode);
75554 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
75555 + const struct dentry *p_dentry,
75556 + const struct vfsmount *p_mnt,
75557 + int open_flags, int acc_mode, const int imode);
75558 +void gr_handle_create(const struct dentry *dentry,
75559 + const struct vfsmount *mnt);
75560 +void gr_handle_proc_create(const struct dentry *dentry,
75561 + const struct inode *inode);
75562 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
75563 + const struct dentry *parent_dentry,
75564 + const struct vfsmount *parent_mnt,
75565 + const int mode);
75566 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
75567 + const struct dentry *parent_dentry,
75568 + const struct vfsmount *parent_mnt);
75569 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
75570 + const struct vfsmount *mnt);
75571 +void gr_handle_delete(const ino_t ino, const dev_t dev);
75572 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
75573 + const struct vfsmount *mnt);
75574 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
75575 + const struct dentry *parent_dentry,
75576 + const struct vfsmount *parent_mnt,
75577 + const struct filename *from);
75578 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
75579 + const struct dentry *parent_dentry,
75580 + const struct vfsmount *parent_mnt,
75581 + const struct dentry *old_dentry,
75582 + const struct vfsmount *old_mnt, const struct filename *to);
75583 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
75584 +int gr_acl_handle_rename(struct dentry *new_dentry,
75585 + struct dentry *parent_dentry,
75586 + const struct vfsmount *parent_mnt,
75587 + struct dentry *old_dentry,
75588 + struct inode *old_parent_inode,
75589 + struct vfsmount *old_mnt, const struct filename *newname);
75590 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
75591 + struct dentry *old_dentry,
75592 + struct dentry *new_dentry,
75593 + struct vfsmount *mnt, const __u8 replace);
75594 +__u32 gr_check_link(const struct dentry *new_dentry,
75595 + const struct dentry *parent_dentry,
75596 + const struct vfsmount *parent_mnt,
75597 + const struct dentry *old_dentry,
75598 + const struct vfsmount *old_mnt);
75599 +int gr_acl_handle_filldir(const struct file *file, const char *name,
75600 + const unsigned int namelen, const ino_t ino);
75601 +
75602 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
75603 + const struct vfsmount *mnt);
75604 +void gr_acl_handle_exit(void);
75605 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
75606 +int gr_acl_handle_procpidmem(const struct task_struct *task);
75607 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
75608 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
75609 +void gr_audit_ptrace(struct task_struct *task);
75610 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
75611 +void gr_put_exec_file(struct task_struct *task);
75612 +
75613 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
75614 +
75615 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
75616 +extern void gr_learn_resource(const struct task_struct *task, const int res,
75617 + const unsigned long wanted, const int gt);
75618 +#else
75619 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
75620 + const unsigned long wanted, const int gt)
75621 +{
75622 +}
75623 +#endif
75624 +
75625 +#ifdef CONFIG_GRKERNSEC_RESLOG
75626 +extern void gr_log_resource(const struct task_struct *task, const int res,
75627 + const unsigned long wanted, const int gt);
75628 +#else
75629 +static inline void gr_log_resource(const struct task_struct *task, const int res,
75630 + const unsigned long wanted, const int gt)
75631 +{
75632 +}
75633 +#endif
75634 +
75635 +#ifdef CONFIG_GRKERNSEC
75636 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
75637 +void gr_handle_vm86(void);
75638 +void gr_handle_mem_readwrite(u64 from, u64 to);
75639 +
75640 +void gr_log_badprocpid(const char *entry);
75641 +
75642 +extern int grsec_enable_dmesg;
75643 +extern int grsec_disable_privio;
75644 +
75645 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
75646 +extern kgid_t grsec_proc_gid;
75647 +#endif
75648 +
75649 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
75650 +extern int grsec_enable_chroot_findtask;
75651 +#endif
75652 +#ifdef CONFIG_GRKERNSEC_SETXID
75653 +extern int grsec_enable_setxid;
75654 +#endif
75655 +#endif
75656 +
75657 +#endif
75658 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
75659 new file mode 100644
75660 index 0000000..e7ffaaf
75661 --- /dev/null
75662 +++ b/include/linux/grsock.h
75663 @@ -0,0 +1,19 @@
75664 +#ifndef __GRSOCK_H
75665 +#define __GRSOCK_H
75666 +
75667 +extern void gr_attach_curr_ip(const struct sock *sk);
75668 +extern int gr_handle_sock_all(const int family, const int type,
75669 + const int protocol);
75670 +extern int gr_handle_sock_server(const struct sockaddr *sck);
75671 +extern int gr_handle_sock_server_other(const struct sock *sck);
75672 +extern int gr_handle_sock_client(const struct sockaddr *sck);
75673 +extern int gr_search_connect(struct socket * sock,
75674 + struct sockaddr_in * addr);
75675 +extern int gr_search_bind(struct socket * sock,
75676 + struct sockaddr_in * addr);
75677 +extern int gr_search_listen(struct socket * sock);
75678 +extern int gr_search_accept(struct socket * sock);
75679 +extern int gr_search_socket(const int domain, const int type,
75680 + const int protocol);
75681 +
75682 +#endif
75683 diff --git a/include/linux/hid.h b/include/linux/hid.h
75684 index 0c48991..76e41d8 100644
75685 --- a/include/linux/hid.h
75686 +++ b/include/linux/hid.h
75687 @@ -393,10 +393,12 @@ struct hid_report {
75688 struct hid_device *device; /* associated device */
75689 };
75690
75691 +#define HID_MAX_IDS 256
75692 +
75693 struct hid_report_enum {
75694 unsigned numbered;
75695 struct list_head report_list;
75696 - struct hid_report *report_id_hash[256];
75697 + struct hid_report *report_id_hash[HID_MAX_IDS];
75698 };
75699
75700 #define HID_REPORT_TYPES 3
75701 @@ -747,6 +749,10 @@ void hid_output_report(struct hid_report *report, __u8 *data);
75702 struct hid_device *hid_allocate_device(void);
75703 struct hid_report *hid_register_report(struct hid_device *device, unsigned type, unsigned id);
75704 int hid_parse_report(struct hid_device *hid, __u8 *start, unsigned size);
75705 +struct hid_report *hid_validate_report(struct hid_device *hid,
75706 + unsigned int type, unsigned int id,
75707 + unsigned int fields,
75708 + unsigned int report_counts);
75709 int hid_open_report(struct hid_device *device);
75710 int hid_check_keys_pressed(struct hid_device *hid);
75711 int hid_connect(struct hid_device *hid, unsigned int connect_mask);
75712 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
75713 index 7fb31da..08b5114 100644
75714 --- a/include/linux/highmem.h
75715 +++ b/include/linux/highmem.h
75716 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
75717 kunmap_atomic(kaddr);
75718 }
75719
75720 +static inline void sanitize_highpage(struct page *page)
75721 +{
75722 + void *kaddr;
75723 + unsigned long flags;
75724 +
75725 + local_irq_save(flags);
75726 + kaddr = kmap_atomic(page);
75727 + clear_page(kaddr);
75728 + kunmap_atomic(kaddr);
75729 + local_irq_restore(flags);
75730 +}
75731 +
75732 static inline void zero_user_segments(struct page *page,
75733 unsigned start1, unsigned end1,
75734 unsigned start2, unsigned end2)
75735 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
75736 index 1c7b89a..7f52502 100644
75737 --- a/include/linux/hwmon-sysfs.h
75738 +++ b/include/linux/hwmon-sysfs.h
75739 @@ -25,7 +25,8 @@
75740 struct sensor_device_attribute{
75741 struct device_attribute dev_attr;
75742 int index;
75743 -};
75744 +} __do_const;
75745 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
75746 #define to_sensor_dev_attr(_dev_attr) \
75747 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
75748
75749 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
75750 struct device_attribute dev_attr;
75751 u8 index;
75752 u8 nr;
75753 -};
75754 +} __do_const;
75755 #define to_sensor_dev_attr_2(_dev_attr) \
75756 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
75757
75758 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
75759 index e988fa9..ff9f17e 100644
75760 --- a/include/linux/i2c.h
75761 +++ b/include/linux/i2c.h
75762 @@ -366,6 +366,7 @@ struct i2c_algorithm {
75763 /* To determine what the adapter supports */
75764 u32 (*functionality) (struct i2c_adapter *);
75765 };
75766 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
75767
75768 /**
75769 * struct i2c_bus_recovery_info - I2C bus recovery information
75770 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
75771 index d23c3c2..eb63c81 100644
75772 --- a/include/linux/i2o.h
75773 +++ b/include/linux/i2o.h
75774 @@ -565,7 +565,7 @@ struct i2o_controller {
75775 struct i2o_device *exec; /* Executive */
75776 #if BITS_PER_LONG == 64
75777 spinlock_t context_list_lock; /* lock for context_list */
75778 - atomic_t context_list_counter; /* needed for unique contexts */
75779 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
75780 struct list_head context_list; /* list of context id's
75781 and pointers */
75782 #endif
75783 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
75784 index aff7ad8..3942bbd 100644
75785 --- a/include/linux/if_pppox.h
75786 +++ b/include/linux/if_pppox.h
75787 @@ -76,7 +76,7 @@ struct pppox_proto {
75788 int (*ioctl)(struct socket *sock, unsigned int cmd,
75789 unsigned long arg);
75790 struct module *owner;
75791 -};
75792 +} __do_const;
75793
75794 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
75795 extern void unregister_pppox_proto(int proto_num);
75796 diff --git a/include/linux/init.h b/include/linux/init.h
75797 index 8618147..0821126 100644
75798 --- a/include/linux/init.h
75799 +++ b/include/linux/init.h
75800 @@ -39,9 +39,36 @@
75801 * Also note, that this data cannot be "const".
75802 */
75803
75804 +#ifdef MODULE
75805 +#define add_init_latent_entropy
75806 +#define add_devinit_latent_entropy
75807 +#define add_cpuinit_latent_entropy
75808 +#define add_meminit_latent_entropy
75809 +#else
75810 +#define add_init_latent_entropy __latent_entropy
75811 +
75812 +#ifdef CONFIG_HOTPLUG
75813 +#define add_devinit_latent_entropy
75814 +#else
75815 +#define add_devinit_latent_entropy __latent_entropy
75816 +#endif
75817 +
75818 +#ifdef CONFIG_HOTPLUG_CPU
75819 +#define add_cpuinit_latent_entropy
75820 +#else
75821 +#define add_cpuinit_latent_entropy __latent_entropy
75822 +#endif
75823 +
75824 +#ifdef CONFIG_MEMORY_HOTPLUG
75825 +#define add_meminit_latent_entropy
75826 +#else
75827 +#define add_meminit_latent_entropy __latent_entropy
75828 +#endif
75829 +#endif
75830 +
75831 /* These are for everybody (although not all archs will actually
75832 discard it in modules) */
75833 -#define __init __section(.init.text) __cold notrace
75834 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
75835 #define __initdata __section(.init.data)
75836 #define __initconst __constsection(.init.rodata)
75837 #define __exitdata __section(.exit.data)
75838 @@ -94,7 +121,7 @@
75839 #define __exit __section(.exit.text) __exitused __cold notrace
75840
75841 /* Used for HOTPLUG_CPU */
75842 -#define __cpuinit __section(.cpuinit.text) __cold notrace
75843 +#define __cpuinit __section(.cpuinit.text) __cold notrace add_cpuinit_latent_entropy
75844 #define __cpuinitdata __section(.cpuinit.data)
75845 #define __cpuinitconst __constsection(.cpuinit.rodata)
75846 #define __cpuexit __section(.cpuexit.text) __exitused __cold notrace
75847 @@ -102,7 +129,7 @@
75848 #define __cpuexitconst __constsection(.cpuexit.rodata)
75849
75850 /* Used for MEMORY_HOTPLUG */
75851 -#define __meminit __section(.meminit.text) __cold notrace
75852 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
75853 #define __meminitdata __section(.meminit.data)
75854 #define __meminitconst __constsection(.meminit.rodata)
75855 #define __memexit __section(.memexit.text) __exitused __cold notrace
75856 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
75857 index 5cd0f09..c9f67cc 100644
75858 --- a/include/linux/init_task.h
75859 +++ b/include/linux/init_task.h
75860 @@ -154,6 +154,12 @@ extern struct task_group root_task_group;
75861
75862 #define INIT_TASK_COMM "swapper"
75863
75864 +#ifdef CONFIG_X86
75865 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
75866 +#else
75867 +#define INIT_TASK_THREAD_INFO
75868 +#endif
75869 +
75870 /*
75871 * INIT_TASK is used to set up the first task table, touch at
75872 * your own risk!. Base=0, limit=0x1fffff (=2MB)
75873 @@ -193,6 +199,7 @@ extern struct task_group root_task_group;
75874 RCU_POINTER_INITIALIZER(cred, &init_cred), \
75875 .comm = INIT_TASK_COMM, \
75876 .thread = INIT_THREAD, \
75877 + INIT_TASK_THREAD_INFO \
75878 .fs = &init_fs, \
75879 .files = &init_files, \
75880 .signal = &init_signals, \
75881 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
75882 index 5fa5afe..ac55b25 100644
75883 --- a/include/linux/interrupt.h
75884 +++ b/include/linux/interrupt.h
75885 @@ -430,7 +430,7 @@ enum
75886 /* map softirq index to softirq name. update 'softirq_to_name' in
75887 * kernel/softirq.c when adding a new softirq.
75888 */
75889 -extern char *softirq_to_name[NR_SOFTIRQS];
75890 +extern const char * const softirq_to_name[NR_SOFTIRQS];
75891
75892 /* softirq mask and active fields moved to irq_cpustat_t in
75893 * asm/hardirq.h to get better cache usage. KAO
75894 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
75895
75896 struct softirq_action
75897 {
75898 - void (*action)(struct softirq_action *);
75899 -};
75900 + void (*action)(void);
75901 +} __no_const;
75902
75903 asmlinkage void do_softirq(void);
75904 asmlinkage void __do_softirq(void);
75905 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
75906 +extern void open_softirq(int nr, void (*action)(void));
75907 extern void softirq_init(void);
75908 extern void __raise_softirq_irqoff(unsigned int nr);
75909
75910 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
75911 index 3aeb730..2177f39 100644
75912 --- a/include/linux/iommu.h
75913 +++ b/include/linux/iommu.h
75914 @@ -113,7 +113,7 @@ struct iommu_ops {
75915 u32 (*domain_get_windows)(struct iommu_domain *domain);
75916
75917 unsigned long pgsize_bitmap;
75918 -};
75919 +} __do_const;
75920
75921 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
75922 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
75923 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
75924 index 89b7c24..382af74 100644
75925 --- a/include/linux/ioport.h
75926 +++ b/include/linux/ioport.h
75927 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
75928 int adjust_resource(struct resource *res, resource_size_t start,
75929 resource_size_t size);
75930 resource_size_t resource_alignment(struct resource *res);
75931 -static inline resource_size_t resource_size(const struct resource *res)
75932 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
75933 {
75934 return res->end - res->start + 1;
75935 }
75936 diff --git a/include/linux/irq.h b/include/linux/irq.h
75937 index bc4e066..50468a9 100644
75938 --- a/include/linux/irq.h
75939 +++ b/include/linux/irq.h
75940 @@ -328,7 +328,8 @@ struct irq_chip {
75941 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
75942
75943 unsigned long flags;
75944 -};
75945 +} __do_const;
75946 +typedef struct irq_chip __no_const irq_chip_no_const;
75947
75948 /*
75949 * irq_chip specific flags
75950 diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
75951 index 3e203eb..3fe68d0 100644
75952 --- a/include/linux/irqchip/arm-gic.h
75953 +++ b/include/linux/irqchip/arm-gic.h
75954 @@ -59,9 +59,11 @@
75955
75956 #ifndef __ASSEMBLY__
75957
75958 +#include <linux/irq.h>
75959 +
75960 struct device_node;
75961
75962 -extern struct irq_chip gic_arch_extn;
75963 +extern irq_chip_no_const gic_arch_extn;
75964
75965 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
75966 u32 offset, struct device_node *);
75967 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
75968 index 6883e19..e854fcb 100644
75969 --- a/include/linux/kallsyms.h
75970 +++ b/include/linux/kallsyms.h
75971 @@ -15,7 +15,8 @@
75972
75973 struct module;
75974
75975 -#ifdef CONFIG_KALLSYMS
75976 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
75977 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
75978 /* Lookup the address for a symbol. Returns 0 if not found. */
75979 unsigned long kallsyms_lookup_name(const char *name);
75980
75981 @@ -106,6 +107,21 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
75982 /* Stupid that this does nothing, but I didn't create this mess. */
75983 #define __print_symbol(fmt, addr)
75984 #endif /*CONFIG_KALLSYMS*/
75985 +#else /* when included by kallsyms.c, vsnprintf.c, kprobes.c, or
75986 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
75987 +extern unsigned long kallsyms_lookup_name(const char *name);
75988 +extern void __print_symbol(const char *fmt, unsigned long address);
75989 +extern int sprint_backtrace(char *buffer, unsigned long address);
75990 +extern int sprint_symbol(char *buffer, unsigned long address);
75991 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
75992 +const char *kallsyms_lookup(unsigned long addr,
75993 + unsigned long *symbolsize,
75994 + unsigned long *offset,
75995 + char **modname, char *namebuf);
75996 +extern int kallsyms_lookup_size_offset(unsigned long addr,
75997 + unsigned long *symbolsize,
75998 + unsigned long *offset);
75999 +#endif
76000
76001 /* This macro allows us to keep printk typechecking */
76002 static __printf(1, 2)
76003 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
76004 index 518a53a..5e28358 100644
76005 --- a/include/linux/key-type.h
76006 +++ b/include/linux/key-type.h
76007 @@ -125,7 +125,7 @@ struct key_type {
76008 /* internal fields */
76009 struct list_head link; /* link in types list */
76010 struct lock_class_key lock_class; /* key->sem lock class */
76011 -};
76012 +} __do_const;
76013
76014 extern struct key_type key_type_keyring;
76015
76016 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
76017 index c6e091b..a940adf 100644
76018 --- a/include/linux/kgdb.h
76019 +++ b/include/linux/kgdb.h
76020 @@ -52,7 +52,7 @@ extern int kgdb_connected;
76021 extern int kgdb_io_module_registered;
76022
76023 extern atomic_t kgdb_setting_breakpoint;
76024 -extern atomic_t kgdb_cpu_doing_single_step;
76025 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
76026
76027 extern struct task_struct *kgdb_usethread;
76028 extern struct task_struct *kgdb_contthread;
76029 @@ -254,7 +254,7 @@ struct kgdb_arch {
76030 void (*correct_hw_break)(void);
76031
76032 void (*enable_nmi)(bool on);
76033 -};
76034 +} __do_const;
76035
76036 /**
76037 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
76038 @@ -279,7 +279,7 @@ struct kgdb_io {
76039 void (*pre_exception) (void);
76040 void (*post_exception) (void);
76041 int is_console;
76042 -};
76043 +} __do_const;
76044
76045 extern struct kgdb_arch arch_kgdb_ops;
76046
76047 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
76048 index 0555cc6..b16a7a4 100644
76049 --- a/include/linux/kmod.h
76050 +++ b/include/linux/kmod.h
76051 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
76052 * usually useless though. */
76053 extern __printf(2, 3)
76054 int __request_module(bool wait, const char *name, ...);
76055 +extern __printf(3, 4)
76056 +int ___request_module(bool wait, char *param_name, const char *name, ...);
76057 #define request_module(mod...) __request_module(true, mod)
76058 #define request_module_nowait(mod...) __request_module(false, mod)
76059 #define try_then_request_module(x, mod...) \
76060 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
76061 index 939b112..ed6ed51 100644
76062 --- a/include/linux/kobject.h
76063 +++ b/include/linux/kobject.h
76064 @@ -111,7 +111,7 @@ struct kobj_type {
76065 struct attribute **default_attrs;
76066 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
76067 const void *(*namespace)(struct kobject *kobj);
76068 -};
76069 +} __do_const;
76070
76071 struct kobj_uevent_env {
76072 char *envp[UEVENT_NUM_ENVP];
76073 @@ -134,6 +134,7 @@ struct kobj_attribute {
76074 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
76075 const char *buf, size_t count);
76076 };
76077 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
76078
76079 extern const struct sysfs_ops kobj_sysfs_ops;
76080
76081 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
76082 index f66b065..c2c29b4 100644
76083 --- a/include/linux/kobject_ns.h
76084 +++ b/include/linux/kobject_ns.h
76085 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
76086 const void *(*netlink_ns)(struct sock *sk);
76087 const void *(*initial_ns)(void);
76088 void (*drop_ns)(void *);
76089 -};
76090 +} __do_const;
76091
76092 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
76093 int kobj_ns_type_registered(enum kobj_ns_type type);
76094 diff --git a/include/linux/kref.h b/include/linux/kref.h
76095 index 484604d..0f6c5b6 100644
76096 --- a/include/linux/kref.h
76097 +++ b/include/linux/kref.h
76098 @@ -68,7 +68,7 @@ static inline void kref_get(struct kref *kref)
76099 static inline int kref_sub(struct kref *kref, unsigned int count,
76100 void (*release)(struct kref *kref))
76101 {
76102 - WARN_ON(release == NULL);
76103 + BUG_ON(release == NULL);
76104
76105 if (atomic_sub_and_test((int) count, &kref->refcount)) {
76106 release(kref);
76107 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
76108 index 8db53cf..c21121d 100644
76109 --- a/include/linux/kvm_host.h
76110 +++ b/include/linux/kvm_host.h
76111 @@ -444,7 +444,7 @@ static inline void kvm_irqfd_exit(void)
76112 {
76113 }
76114 #endif
76115 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
76116 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
76117 struct module *module);
76118 void kvm_exit(void);
76119
76120 @@ -616,7 +616,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
76121 struct kvm_guest_debug *dbg);
76122 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
76123
76124 -int kvm_arch_init(void *opaque);
76125 +int kvm_arch_init(const void *opaque);
76126 void kvm_arch_exit(void);
76127
76128 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
76129 diff --git a/include/linux/libata.h b/include/linux/libata.h
76130 index eae7a05..2cdd875 100644
76131 --- a/include/linux/libata.h
76132 +++ b/include/linux/libata.h
76133 @@ -919,7 +919,7 @@ struct ata_port_operations {
76134 * fields must be pointers.
76135 */
76136 const struct ata_port_operations *inherits;
76137 -};
76138 +} __do_const;
76139
76140 struct ata_port_info {
76141 unsigned long flags;
76142 diff --git a/include/linux/list.h b/include/linux/list.h
76143 index b83e565..baa6c1d 100644
76144 --- a/include/linux/list.h
76145 +++ b/include/linux/list.h
76146 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
76147 extern void list_del(struct list_head *entry);
76148 #endif
76149
76150 +extern void __pax_list_add(struct list_head *new,
76151 + struct list_head *prev,
76152 + struct list_head *next);
76153 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
76154 +{
76155 + __pax_list_add(new, head, head->next);
76156 +}
76157 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
76158 +{
76159 + __pax_list_add(new, head->prev, head);
76160 +}
76161 +extern void pax_list_del(struct list_head *entry);
76162 +
76163 /**
76164 * list_replace - replace old entry by new one
76165 * @old : the element to be replaced
76166 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
76167 INIT_LIST_HEAD(entry);
76168 }
76169
76170 +extern void pax_list_del_init(struct list_head *entry);
76171 +
76172 /**
76173 * list_move - delete from one list and add as another's head
76174 * @list: the entry to move
76175 diff --git a/include/linux/math64.h b/include/linux/math64.h
76176 index 2913b86..8dcbb1e 100644
76177 --- a/include/linux/math64.h
76178 +++ b/include/linux/math64.h
76179 @@ -15,7 +15,7 @@
76180 * This is commonly provided by 32bit archs to provide an optimized 64bit
76181 * divide.
76182 */
76183 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
76184 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
76185 {
76186 *remainder = dividend % divisor;
76187 return dividend / divisor;
76188 @@ -33,7 +33,7 @@ static inline s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
76189 /**
76190 * div64_u64 - unsigned 64bit divide with 64bit divisor
76191 */
76192 -static inline u64 div64_u64(u64 dividend, u64 divisor)
76193 +static inline u64 __intentional_overflow(0) div64_u64(u64 dividend, u64 divisor)
76194 {
76195 return dividend / divisor;
76196 }
76197 @@ -52,7 +52,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
76198 #define div64_ul(x, y) div_u64((x), (y))
76199
76200 #ifndef div_u64_rem
76201 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
76202 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
76203 {
76204 *remainder = do_div(dividend, divisor);
76205 return dividend;
76206 @@ -81,7 +81,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
76207 * divide.
76208 */
76209 #ifndef div_u64
76210 -static inline u64 div_u64(u64 dividend, u32 divisor)
76211 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
76212 {
76213 u32 remainder;
76214 return div_u64_rem(dividend, divisor, &remainder);
76215 diff --git a/include/linux/mm.h b/include/linux/mm.h
76216 index e0c8528..bcf0c29 100644
76217 --- a/include/linux/mm.h
76218 +++ b/include/linux/mm.h
76219 @@ -104,6 +104,11 @@ extern unsigned int kobjsize(const void *objp);
76220 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
76221 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
76222 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
76223 +
76224 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
76225 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
76226 +#endif
76227 +
76228 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
76229
76230 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
76231 @@ -205,8 +210,8 @@ struct vm_operations_struct {
76232 /* called by access_process_vm when get_user_pages() fails, typically
76233 * for use by special VMAs that can switch between memory and hardware
76234 */
76235 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
76236 - void *buf, int len, int write);
76237 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
76238 + void *buf, size_t len, int write);
76239 #ifdef CONFIG_NUMA
76240 /*
76241 * set_policy() op must add a reference to any non-NULL @new mempolicy
76242 @@ -236,6 +241,7 @@ struct vm_operations_struct {
76243 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
76244 unsigned long size, pgoff_t pgoff);
76245 };
76246 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
76247
76248 struct mmu_gather;
76249 struct inode;
76250 @@ -980,8 +986,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
76251 unsigned long *pfn);
76252 int follow_phys(struct vm_area_struct *vma, unsigned long address,
76253 unsigned int flags, unsigned long *prot, resource_size_t *phys);
76254 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
76255 - void *buf, int len, int write);
76256 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
76257 + void *buf, size_t len, int write);
76258
76259 static inline void unmap_shared_mapping_range(struct address_space *mapping,
76260 loff_t const holebegin, loff_t const holelen)
76261 @@ -1020,9 +1026,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
76262 }
76263 #endif
76264
76265 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
76266 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
76267 - void *buf, int len, int write);
76268 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
76269 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
76270 + void *buf, size_t len, int write);
76271
76272 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
76273 unsigned long start, unsigned long nr_pages,
76274 @@ -1053,34 +1059,6 @@ int set_page_dirty(struct page *page);
76275 int set_page_dirty_lock(struct page *page);
76276 int clear_page_dirty_for_io(struct page *page);
76277
76278 -/* Is the vma a continuation of the stack vma above it? */
76279 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
76280 -{
76281 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
76282 -}
76283 -
76284 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
76285 - unsigned long addr)
76286 -{
76287 - return (vma->vm_flags & VM_GROWSDOWN) &&
76288 - (vma->vm_start == addr) &&
76289 - !vma_growsdown(vma->vm_prev, addr);
76290 -}
76291 -
76292 -/* Is the vma a continuation of the stack vma below it? */
76293 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
76294 -{
76295 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
76296 -}
76297 -
76298 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
76299 - unsigned long addr)
76300 -{
76301 - return (vma->vm_flags & VM_GROWSUP) &&
76302 - (vma->vm_end == addr) &&
76303 - !vma_growsup(vma->vm_next, addr);
76304 -}
76305 -
76306 extern pid_t
76307 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
76308
76309 @@ -1180,6 +1158,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
76310 }
76311 #endif
76312
76313 +#ifdef CONFIG_MMU
76314 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
76315 +#else
76316 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
76317 +{
76318 + return __pgprot(0);
76319 +}
76320 +#endif
76321 +
76322 int vma_wants_writenotify(struct vm_area_struct *vma);
76323
76324 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
76325 @@ -1198,8 +1185,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
76326 {
76327 return 0;
76328 }
76329 +
76330 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
76331 + unsigned long address)
76332 +{
76333 + return 0;
76334 +}
76335 #else
76336 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
76337 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
76338 #endif
76339
76340 #ifdef __PAGETABLE_PMD_FOLDED
76341 @@ -1208,8 +1202,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
76342 {
76343 return 0;
76344 }
76345 +
76346 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
76347 + unsigned long address)
76348 +{
76349 + return 0;
76350 +}
76351 #else
76352 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
76353 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
76354 #endif
76355
76356 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
76357 @@ -1227,11 +1228,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
76358 NULL: pud_offset(pgd, address);
76359 }
76360
76361 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
76362 +{
76363 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
76364 + NULL: pud_offset(pgd, address);
76365 +}
76366 +
76367 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
76368 {
76369 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
76370 NULL: pmd_offset(pud, address);
76371 }
76372 +
76373 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
76374 +{
76375 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
76376 + NULL: pmd_offset(pud, address);
76377 +}
76378 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
76379
76380 #if USE_SPLIT_PTLOCKS
76381 @@ -1517,6 +1530,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
76382 unsigned long len, unsigned long prot, unsigned long flags,
76383 unsigned long pgoff, unsigned long *populate);
76384 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
76385 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
76386
76387 #ifdef CONFIG_MMU
76388 extern int __mm_populate(unsigned long addr, unsigned long len,
76389 @@ -1545,10 +1559,11 @@ struct vm_unmapped_area_info {
76390 unsigned long high_limit;
76391 unsigned long align_mask;
76392 unsigned long align_offset;
76393 + unsigned long threadstack_offset;
76394 };
76395
76396 -extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
76397 -extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
76398 +extern unsigned long unmapped_area(const struct vm_unmapped_area_info *info);
76399 +extern unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info);
76400
76401 /*
76402 * Search for an unmapped address range.
76403 @@ -1560,7 +1575,7 @@ extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
76404 * - satisfies (begin_addr & align_mask) == (align_offset & align_mask)
76405 */
76406 static inline unsigned long
76407 -vm_unmapped_area(struct vm_unmapped_area_info *info)
76408 +vm_unmapped_area(const struct vm_unmapped_area_info *info)
76409 {
76410 if (!(info->flags & VM_UNMAPPED_AREA_TOPDOWN))
76411 return unmapped_area(info);
76412 @@ -1623,6 +1638,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
76413 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
76414 struct vm_area_struct **pprev);
76415
76416 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
76417 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
76418 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
76419 +
76420 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
76421 NULL if none. Assume start_addr < end_addr. */
76422 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
76423 @@ -1651,15 +1670,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
76424 return vma;
76425 }
76426
76427 -#ifdef CONFIG_MMU
76428 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
76429 -#else
76430 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
76431 -{
76432 - return __pgprot(0);
76433 -}
76434 -#endif
76435 -
76436 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
76437 unsigned long change_prot_numa(struct vm_area_struct *vma,
76438 unsigned long start, unsigned long end);
76439 @@ -1711,6 +1721,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
76440 static inline void vm_stat_account(struct mm_struct *mm,
76441 unsigned long flags, struct file *file, long pages)
76442 {
76443 +
76444 +#ifdef CONFIG_PAX_RANDMMAP
76445 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
76446 +#endif
76447 +
76448 mm->total_vm += pages;
76449 }
76450 #endif /* CONFIG_PROC_FS */
76451 @@ -1791,7 +1806,7 @@ extern int unpoison_memory(unsigned long pfn);
76452 extern int sysctl_memory_failure_early_kill;
76453 extern int sysctl_memory_failure_recovery;
76454 extern void shake_page(struct page *p, int access);
76455 -extern atomic_long_t num_poisoned_pages;
76456 +extern atomic_long_unchecked_t num_poisoned_pages;
76457 extern int soft_offline_page(struct page *page, int flags);
76458
76459 extern void dump_page(struct page *page);
76460 @@ -1828,5 +1843,11 @@ void __init setup_nr_node_ids(void);
76461 static inline void setup_nr_node_ids(void) {}
76462 #endif
76463
76464 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
76465 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
76466 +#else
76467 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
76468 +#endif
76469 +
76470 #endif /* __KERNEL__ */
76471 #endif /* _LINUX_MM_H */
76472 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
76473 index 4a189ba..04101d6 100644
76474 --- a/include/linux/mm_types.h
76475 +++ b/include/linux/mm_types.h
76476 @@ -289,6 +289,8 @@ struct vm_area_struct {
76477 #ifdef CONFIG_NUMA
76478 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
76479 #endif
76480 +
76481 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
76482 };
76483
76484 struct core_thread {
76485 @@ -438,6 +440,24 @@ struct mm_struct {
76486 int first_nid;
76487 #endif
76488 struct uprobes_state uprobes_state;
76489 +
76490 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
76491 + unsigned long pax_flags;
76492 +#endif
76493 +
76494 +#ifdef CONFIG_PAX_DLRESOLVE
76495 + unsigned long call_dl_resolve;
76496 +#endif
76497 +
76498 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
76499 + unsigned long call_syscall;
76500 +#endif
76501 +
76502 +#ifdef CONFIG_PAX_ASLR
76503 + unsigned long delta_mmap; /* randomized offset */
76504 + unsigned long delta_stack; /* randomized offset */
76505 +#endif
76506 +
76507 };
76508
76509 /* first nid will either be a valid NID or one of these values */
76510 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
76511 index c5d5278..f0b68c8 100644
76512 --- a/include/linux/mmiotrace.h
76513 +++ b/include/linux/mmiotrace.h
76514 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
76515 /* Called from ioremap.c */
76516 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
76517 void __iomem *addr);
76518 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
76519 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
76520
76521 /* For anyone to insert markers. Remember trailing newline. */
76522 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
76523 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
76524 {
76525 }
76526
76527 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
76528 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
76529 {
76530 }
76531
76532 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
76533 index 5c76737..61f518e 100644
76534 --- a/include/linux/mmzone.h
76535 +++ b/include/linux/mmzone.h
76536 @@ -396,7 +396,7 @@ struct zone {
76537 unsigned long flags; /* zone flags, see below */
76538
76539 /* Zone statistics */
76540 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
76541 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
76542
76543 /*
76544 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
76545 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
76546 index b508016..237cfe5 100644
76547 --- a/include/linux/mod_devicetable.h
76548 +++ b/include/linux/mod_devicetable.h
76549 @@ -13,7 +13,7 @@
76550 typedef unsigned long kernel_ulong_t;
76551 #endif
76552
76553 -#define PCI_ANY_ID (~0)
76554 +#define PCI_ANY_ID ((__u16)~0)
76555
76556 struct pci_device_id {
76557 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
76558 @@ -139,7 +139,7 @@ struct usb_device_id {
76559 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
76560 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
76561
76562 -#define HID_ANY_ID (~0)
76563 +#define HID_ANY_ID (~0U)
76564 #define HID_BUS_ANY 0xffff
76565 #define HID_GROUP_ANY 0x0000
76566
76567 @@ -465,7 +465,7 @@ struct dmi_system_id {
76568 const char *ident;
76569 struct dmi_strmatch matches[4];
76570 void *driver_data;
76571 -};
76572 +} __do_const;
76573 /*
76574 * struct dmi_device_id appears during expansion of
76575 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
76576 diff --git a/include/linux/module.h b/include/linux/module.h
76577 index 46f1ea0..a34ca37 100644
76578 --- a/include/linux/module.h
76579 +++ b/include/linux/module.h
76580 @@ -17,9 +17,11 @@
76581 #include <linux/moduleparam.h>
76582 #include <linux/tracepoint.h>
76583 #include <linux/export.h>
76584 +#include <linux/fs.h>
76585
76586 #include <linux/percpu.h>
76587 #include <asm/module.h>
76588 +#include <asm/pgtable.h>
76589
76590 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
76591 #define MODULE_SIG_STRING "~Module signature appended~\n"
76592 @@ -54,12 +56,13 @@ struct module_attribute {
76593 int (*test)(struct module *);
76594 void (*free)(struct module *);
76595 };
76596 +typedef struct module_attribute __no_const module_attribute_no_const;
76597
76598 struct module_version_attribute {
76599 struct module_attribute mattr;
76600 const char *module_name;
76601 const char *version;
76602 -} __attribute__ ((__aligned__(sizeof(void *))));
76603 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
76604
76605 extern ssize_t __modver_version_show(struct module_attribute *,
76606 struct module_kobject *, char *);
76607 @@ -232,7 +235,7 @@ struct module
76608
76609 /* Sysfs stuff. */
76610 struct module_kobject mkobj;
76611 - struct module_attribute *modinfo_attrs;
76612 + module_attribute_no_const *modinfo_attrs;
76613 const char *version;
76614 const char *srcversion;
76615 struct kobject *holders_dir;
76616 @@ -281,19 +284,16 @@ struct module
76617 int (*init)(void);
76618
76619 /* If this is non-NULL, vfree after init() returns */
76620 - void *module_init;
76621 + void *module_init_rx, *module_init_rw;
76622
76623 /* Here is the actual code + data, vfree'd on unload. */
76624 - void *module_core;
76625 + void *module_core_rx, *module_core_rw;
76626
76627 /* Here are the sizes of the init and core sections */
76628 - unsigned int init_size, core_size;
76629 + unsigned int init_size_rw, core_size_rw;
76630
76631 /* The size of the executable code in each section. */
76632 - unsigned int init_text_size, core_text_size;
76633 -
76634 - /* Size of RO sections of the module (text+rodata) */
76635 - unsigned int init_ro_size, core_ro_size;
76636 + unsigned int init_size_rx, core_size_rx;
76637
76638 /* Arch-specific module values */
76639 struct mod_arch_specific arch;
76640 @@ -349,6 +349,10 @@ struct module
76641 #ifdef CONFIG_EVENT_TRACING
76642 struct ftrace_event_call **trace_events;
76643 unsigned int num_trace_events;
76644 + struct file_operations trace_id;
76645 + struct file_operations trace_enable;
76646 + struct file_operations trace_format;
76647 + struct file_operations trace_filter;
76648 #endif
76649 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
76650 unsigned int num_ftrace_callsites;
76651 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
76652 bool is_module_percpu_address(unsigned long addr);
76653 bool is_module_text_address(unsigned long addr);
76654
76655 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
76656 +{
76657 +
76658 +#ifdef CONFIG_PAX_KERNEXEC
76659 + if (ktla_ktva(addr) >= (unsigned long)start &&
76660 + ktla_ktva(addr) < (unsigned long)start + size)
76661 + return 1;
76662 +#endif
76663 +
76664 + return ((void *)addr >= start && (void *)addr < start + size);
76665 +}
76666 +
76667 +static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
76668 +{
76669 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
76670 +}
76671 +
76672 +static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
76673 +{
76674 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
76675 +}
76676 +
76677 +static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
76678 +{
76679 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
76680 +}
76681 +
76682 +static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
76683 +{
76684 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
76685 +}
76686 +
76687 static inline int within_module_core(unsigned long addr, const struct module *mod)
76688 {
76689 - return (unsigned long)mod->module_core <= addr &&
76690 - addr < (unsigned long)mod->module_core + mod->core_size;
76691 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
76692 }
76693
76694 static inline int within_module_init(unsigned long addr, const struct module *mod)
76695 {
76696 - return (unsigned long)mod->module_init <= addr &&
76697 - addr < (unsigned long)mod->module_init + mod->init_size;
76698 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
76699 }
76700
76701 /* Search for module by name: must hold module_mutex. */
76702 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
76703 index 560ca53..ef621ef 100644
76704 --- a/include/linux/moduleloader.h
76705 +++ b/include/linux/moduleloader.h
76706 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
76707 sections. Returns NULL on failure. */
76708 void *module_alloc(unsigned long size);
76709
76710 +#ifdef CONFIG_PAX_KERNEXEC
76711 +void *module_alloc_exec(unsigned long size);
76712 +#else
76713 +#define module_alloc_exec(x) module_alloc(x)
76714 +#endif
76715 +
76716 /* Free memory returned from module_alloc. */
76717 void module_free(struct module *mod, void *module_region);
76718
76719 +#ifdef CONFIG_PAX_KERNEXEC
76720 +void module_free_exec(struct module *mod, void *module_region);
76721 +#else
76722 +#define module_free_exec(x, y) module_free((x), (y))
76723 +#endif
76724 +
76725 /*
76726 * Apply the given relocation to the (simplified) ELF. Return -error
76727 * or 0.
76728 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
76729 unsigned int relsec,
76730 struct module *me)
76731 {
76732 +#ifdef CONFIG_MODULES
76733 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
76734 +#endif
76735 return -ENOEXEC;
76736 }
76737 #endif
76738 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
76739 unsigned int relsec,
76740 struct module *me)
76741 {
76742 +#ifdef CONFIG_MODULES
76743 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
76744 +#endif
76745 return -ENOEXEC;
76746 }
76747 #endif
76748 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
76749 index 137b419..fe663ec 100644
76750 --- a/include/linux/moduleparam.h
76751 +++ b/include/linux/moduleparam.h
76752 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
76753 * @len is usually just sizeof(string).
76754 */
76755 #define module_param_string(name, string, len, perm) \
76756 - static const struct kparam_string __param_string_##name \
76757 + static const struct kparam_string __param_string_##name __used \
76758 = { len, string }; \
76759 __module_param_call(MODULE_PARAM_PREFIX, name, \
76760 &param_ops_string, \
76761 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
76762 */
76763 #define module_param_array_named(name, array, type, nump, perm) \
76764 param_check_##type(name, &(array)[0]); \
76765 - static const struct kparam_array __param_arr_##name \
76766 + static const struct kparam_array __param_arr_##name __used \
76767 = { .max = ARRAY_SIZE(array), .num = nump, \
76768 .ops = &param_ops_##type, \
76769 .elemsize = sizeof(array[0]), .elem = array }; \
76770 diff --git a/include/linux/namei.h b/include/linux/namei.h
76771 index 5a5ff57..5ae5070 100644
76772 --- a/include/linux/namei.h
76773 +++ b/include/linux/namei.h
76774 @@ -19,7 +19,7 @@ struct nameidata {
76775 unsigned seq;
76776 int last_type;
76777 unsigned depth;
76778 - char *saved_names[MAX_NESTED_LINKS + 1];
76779 + const char *saved_names[MAX_NESTED_LINKS + 1];
76780 };
76781
76782 /*
76783 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
76784
76785 extern void nd_jump_link(struct nameidata *nd, struct path *path);
76786
76787 -static inline void nd_set_link(struct nameidata *nd, char *path)
76788 +static inline void nd_set_link(struct nameidata *nd, const char *path)
76789 {
76790 nd->saved_names[nd->depth] = path;
76791 }
76792
76793 -static inline char *nd_get_link(struct nameidata *nd)
76794 +static inline const char *nd_get_link(const struct nameidata *nd)
76795 {
76796 return nd->saved_names[nd->depth];
76797 }
76798 diff --git a/include/linux/net.h b/include/linux/net.h
76799 index 99c9f0c..e1cf296 100644
76800 --- a/include/linux/net.h
76801 +++ b/include/linux/net.h
76802 @@ -183,7 +183,7 @@ struct net_proto_family {
76803 int (*create)(struct net *net, struct socket *sock,
76804 int protocol, int kern);
76805 struct module *owner;
76806 -};
76807 +} __do_const;
76808
76809 struct iovec;
76810 struct kvec;
76811 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
76812 index 96e4c21..9cc8278 100644
76813 --- a/include/linux/netdevice.h
76814 +++ b/include/linux/netdevice.h
76815 @@ -1026,6 +1026,7 @@ struct net_device_ops {
76816 int (*ndo_change_carrier)(struct net_device *dev,
76817 bool new_carrier);
76818 };
76819 +typedef struct net_device_ops __no_const net_device_ops_no_const;
76820
76821 /*
76822 * The DEVICE structure.
76823 @@ -1094,7 +1095,7 @@ struct net_device {
76824 int iflink;
76825
76826 struct net_device_stats stats;
76827 - atomic_long_t rx_dropped; /* dropped packets by core network
76828 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
76829 * Do not use this in drivers.
76830 */
76831
76832 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
76833 index 0060fde..481c6ae 100644
76834 --- a/include/linux/netfilter.h
76835 +++ b/include/linux/netfilter.h
76836 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
76837 #endif
76838 /* Use the module struct to lock set/get code in place */
76839 struct module *owner;
76840 -};
76841 +} __do_const;
76842
76843 /* Function to register/unregister hook points. */
76844 int nf_register_hook(struct nf_hook_ops *reg);
76845 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
76846 index d80e275..c3510b8 100644
76847 --- a/include/linux/netfilter/ipset/ip_set.h
76848 +++ b/include/linux/netfilter/ipset/ip_set.h
76849 @@ -124,7 +124,7 @@ struct ip_set_type_variant {
76850 /* Return true if "b" set is the same as "a"
76851 * according to the create set parameters */
76852 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
76853 -};
76854 +} __do_const;
76855
76856 /* The core set type structure */
76857 struct ip_set_type {
76858 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
76859 index cadb740..d7c37c0 100644
76860 --- a/include/linux/netfilter/nfnetlink.h
76861 +++ b/include/linux/netfilter/nfnetlink.h
76862 @@ -16,7 +16,7 @@ struct nfnl_callback {
76863 const struct nlattr * const cda[]);
76864 const struct nla_policy *policy; /* netlink attribute policy */
76865 const u_int16_t attr_count; /* number of nlattr's */
76866 -};
76867 +} __do_const;
76868
76869 struct nfnetlink_subsystem {
76870 const char *name;
76871 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
76872 new file mode 100644
76873 index 0000000..33f4af8
76874 --- /dev/null
76875 +++ b/include/linux/netfilter/xt_gradm.h
76876 @@ -0,0 +1,9 @@
76877 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
76878 +#define _LINUX_NETFILTER_XT_GRADM_H 1
76879 +
76880 +struct xt_gradm_mtinfo {
76881 + __u16 flags;
76882 + __u16 invflags;
76883 +};
76884 +
76885 +#endif
76886 diff --git a/include/linux/nls.h b/include/linux/nls.h
76887 index 5dc635f..35f5e11 100644
76888 --- a/include/linux/nls.h
76889 +++ b/include/linux/nls.h
76890 @@ -31,7 +31,7 @@ struct nls_table {
76891 const unsigned char *charset2upper;
76892 struct module *owner;
76893 struct nls_table *next;
76894 -};
76895 +} __do_const;
76896
76897 /* this value hold the maximum octet of charset */
76898 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
76899 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
76900 index d14a4c3..a078786 100644
76901 --- a/include/linux/notifier.h
76902 +++ b/include/linux/notifier.h
76903 @@ -54,7 +54,8 @@ struct notifier_block {
76904 notifier_fn_t notifier_call;
76905 struct notifier_block __rcu *next;
76906 int priority;
76907 -};
76908 +} __do_const;
76909 +typedef struct notifier_block __no_const notifier_block_no_const;
76910
76911 struct atomic_notifier_head {
76912 spinlock_t lock;
76913 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
76914 index a4c5624..79d6d88 100644
76915 --- a/include/linux/oprofile.h
76916 +++ b/include/linux/oprofile.h
76917 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
76918 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
76919 char const * name, ulong * val);
76920
76921 -/** Create a file for read-only access to an atomic_t. */
76922 +/** Create a file for read-only access to an atomic_unchecked_t. */
76923 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
76924 - char const * name, atomic_t * val);
76925 + char const * name, atomic_unchecked_t * val);
76926
76927 /** create a directory */
76928 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
76929 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
76930 index 8db71dc..a76bf2c 100644
76931 --- a/include/linux/pci_hotplug.h
76932 +++ b/include/linux/pci_hotplug.h
76933 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
76934 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
76935 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
76936 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
76937 -};
76938 +} __do_const;
76939 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
76940
76941 /**
76942 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
76943 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
76944 index c5b6dbf..b124155 100644
76945 --- a/include/linux/perf_event.h
76946 +++ b/include/linux/perf_event.h
76947 @@ -318,8 +318,8 @@ struct perf_event {
76948
76949 enum perf_event_active_state state;
76950 unsigned int attach_state;
76951 - local64_t count;
76952 - atomic64_t child_count;
76953 + local64_t count; /* PaX: fix it one day */
76954 + atomic64_unchecked_t child_count;
76955
76956 /*
76957 * These are the total time in nanoseconds that the event
76958 @@ -370,8 +370,8 @@ struct perf_event {
76959 * These accumulate total time (in nanoseconds) that children
76960 * events have been enabled and running, respectively.
76961 */
76962 - atomic64_t child_total_time_enabled;
76963 - atomic64_t child_total_time_running;
76964 + atomic64_unchecked_t child_total_time_enabled;
76965 + atomic64_unchecked_t child_total_time_running;
76966
76967 /*
76968 * Protect attach/detach and child_list:
76969 @@ -692,7 +692,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
76970 entry->ip[entry->nr++] = ip;
76971 }
76972
76973 -extern int sysctl_perf_event_paranoid;
76974 +extern int sysctl_perf_event_legitimately_concerned;
76975 extern int sysctl_perf_event_mlock;
76976 extern int sysctl_perf_event_sample_rate;
76977
76978 @@ -700,19 +700,24 @@ extern int perf_proc_update_handler(struct ctl_table *table, int write,
76979 void __user *buffer, size_t *lenp,
76980 loff_t *ppos);
76981
76982 +static inline bool perf_paranoid_any(void)
76983 +{
76984 + return sysctl_perf_event_legitimately_concerned > 2;
76985 +}
76986 +
76987 static inline bool perf_paranoid_tracepoint_raw(void)
76988 {
76989 - return sysctl_perf_event_paranoid > -1;
76990 + return sysctl_perf_event_legitimately_concerned > -1;
76991 }
76992
76993 static inline bool perf_paranoid_cpu(void)
76994 {
76995 - return sysctl_perf_event_paranoid > 0;
76996 + return sysctl_perf_event_legitimately_concerned > 0;
76997 }
76998
76999 static inline bool perf_paranoid_kernel(void)
77000 {
77001 - return sysctl_perf_event_paranoid > 1;
77002 + return sysctl_perf_event_legitimately_concerned > 1;
77003 }
77004
77005 extern void perf_event_init(void);
77006 @@ -806,7 +811,7 @@ static inline void perf_restore_debug_store(void) { }
77007 */
77008 #define perf_cpu_notifier(fn) \
77009 do { \
77010 - static struct notifier_block fn##_nb __cpuinitdata = \
77011 + static struct notifier_block fn##_nb = \
77012 { .notifier_call = fn, .priority = CPU_PRI_PERF }; \
77013 unsigned long cpu = smp_processor_id(); \
77014 unsigned long flags; \
77015 @@ -826,7 +831,7 @@ struct perf_pmu_events_attr {
77016 struct device_attribute attr;
77017 u64 id;
77018 const char *event_str;
77019 -};
77020 +} __do_const;
77021
77022 #define PMU_EVENT_ATTR(_name, _var, _id, _show) \
77023 static struct perf_pmu_events_attr _var = { \
77024 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
77025 index b8809fe..ae4ccd0 100644
77026 --- a/include/linux/pipe_fs_i.h
77027 +++ b/include/linux/pipe_fs_i.h
77028 @@ -47,10 +47,10 @@ struct pipe_inode_info {
77029 struct mutex mutex;
77030 wait_queue_head_t wait;
77031 unsigned int nrbufs, curbuf, buffers;
77032 - unsigned int readers;
77033 - unsigned int writers;
77034 - unsigned int files;
77035 - unsigned int waiting_writers;
77036 + atomic_t readers;
77037 + atomic_t writers;
77038 + atomic_t files;
77039 + atomic_t waiting_writers;
77040 unsigned int r_counter;
77041 unsigned int w_counter;
77042 struct page *tmp_page;
77043 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
77044 index 5f28cae..3d23723 100644
77045 --- a/include/linux/platform_data/usb-ehci-s5p.h
77046 +++ b/include/linux/platform_data/usb-ehci-s5p.h
77047 @@ -14,7 +14,7 @@
77048 struct s5p_ehci_platdata {
77049 int (*phy_init)(struct platform_device *pdev, int type);
77050 int (*phy_exit)(struct platform_device *pdev, int type);
77051 -};
77052 +} __no_const;
77053
77054 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
77055
77056 diff --git a/include/linux/platform_data/usb-ohci-exynos.h b/include/linux/platform_data/usb-ohci-exynos.h
77057 index c256c59..8ea94c7 100644
77058 --- a/include/linux/platform_data/usb-ohci-exynos.h
77059 +++ b/include/linux/platform_data/usb-ohci-exynos.h
77060 @@ -14,7 +14,7 @@
77061 struct exynos4_ohci_platdata {
77062 int (*phy_init)(struct platform_device *pdev, int type);
77063 int (*phy_exit)(struct platform_device *pdev, int type);
77064 -};
77065 +} __no_const;
77066
77067 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
77068
77069 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
77070 index 7c1d252..c5c773e 100644
77071 --- a/include/linux/pm_domain.h
77072 +++ b/include/linux/pm_domain.h
77073 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
77074
77075 struct gpd_cpu_data {
77076 unsigned int saved_exit_latency;
77077 - struct cpuidle_state *idle_state;
77078 + cpuidle_state_no_const *idle_state;
77079 };
77080
77081 struct generic_pm_domain {
77082 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
77083 index 7d7e09e..8671ef8 100644
77084 --- a/include/linux/pm_runtime.h
77085 +++ b/include/linux/pm_runtime.h
77086 @@ -104,7 +104,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
77087
77088 static inline void pm_runtime_mark_last_busy(struct device *dev)
77089 {
77090 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
77091 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
77092 }
77093
77094 #else /* !CONFIG_PM_RUNTIME */
77095 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
77096 index 195aafc..49a7bc2 100644
77097 --- a/include/linux/pnp.h
77098 +++ b/include/linux/pnp.h
77099 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
77100 struct pnp_fixup {
77101 char id[7];
77102 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
77103 -};
77104 +} __do_const;
77105
77106 /* config parameters */
77107 #define PNP_CONFIG_NORMAL 0x0001
77108 diff --git a/include/linux/poison.h b/include/linux/poison.h
77109 index 2110a81..13a11bb 100644
77110 --- a/include/linux/poison.h
77111 +++ b/include/linux/poison.h
77112 @@ -19,8 +19,8 @@
77113 * under normal circumstances, used to verify that nobody uses
77114 * non-initialized list entries.
77115 */
77116 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
77117 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
77118 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
77119 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
77120
77121 /********** include/linux/timer.h **********/
77122 /*
77123 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
77124 index c0f44c2..1572583 100644
77125 --- a/include/linux/power/smartreflex.h
77126 +++ b/include/linux/power/smartreflex.h
77127 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
77128 int (*notify)(struct omap_sr *sr, u32 status);
77129 u8 notify_flags;
77130 u8 class_type;
77131 -};
77132 +} __do_const;
77133
77134 /**
77135 * struct omap_sr_nvalue_table - Smartreflex n-target value info
77136 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
77137 index 4ea1d37..80f4b33 100644
77138 --- a/include/linux/ppp-comp.h
77139 +++ b/include/linux/ppp-comp.h
77140 @@ -84,7 +84,7 @@ struct compressor {
77141 struct module *owner;
77142 /* Extra skb space needed by the compressor algorithm */
77143 unsigned int comp_extra;
77144 -};
77145 +} __do_const;
77146
77147 /*
77148 * The return value from decompress routine is the length of the
77149 diff --git a/include/linux/preempt.h b/include/linux/preempt.h
77150 index f5d4723..a6ea2fa 100644
77151 --- a/include/linux/preempt.h
77152 +++ b/include/linux/preempt.h
77153 @@ -18,8 +18,13 @@
77154 # define sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
77155 #endif
77156
77157 +#define raw_add_preempt_count(val) do { preempt_count() += (val); } while (0)
77158 +#define raw_sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
77159 +
77160 #define inc_preempt_count() add_preempt_count(1)
77161 +#define raw_inc_preempt_count() raw_add_preempt_count(1)
77162 #define dec_preempt_count() sub_preempt_count(1)
77163 +#define raw_dec_preempt_count() raw_sub_preempt_count(1)
77164
77165 #define preempt_count() (current_thread_info()->preempt_count)
77166
77167 @@ -64,6 +69,12 @@ do { \
77168 barrier(); \
77169 } while (0)
77170
77171 +#define raw_preempt_disable() \
77172 +do { \
77173 + raw_inc_preempt_count(); \
77174 + barrier(); \
77175 +} while (0)
77176 +
77177 #define sched_preempt_enable_no_resched() \
77178 do { \
77179 barrier(); \
77180 @@ -72,6 +83,12 @@ do { \
77181
77182 #define preempt_enable_no_resched() sched_preempt_enable_no_resched()
77183
77184 +#define raw_preempt_enable_no_resched() \
77185 +do { \
77186 + barrier(); \
77187 + raw_dec_preempt_count(); \
77188 +} while (0)
77189 +
77190 #define preempt_enable() \
77191 do { \
77192 preempt_enable_no_resched(); \
77193 @@ -116,8 +133,10 @@ do { \
77194 * region.
77195 */
77196 #define preempt_disable() barrier()
77197 +#define raw_preempt_disable() barrier()
77198 #define sched_preempt_enable_no_resched() barrier()
77199 #define preempt_enable_no_resched() barrier()
77200 +#define raw_preempt_enable_no_resched() barrier()
77201 #define preempt_enable() barrier()
77202
77203 #define preempt_disable_notrace() barrier()
77204 diff --git a/include/linux/printk.h b/include/linux/printk.h
77205 index 22c7052..ad3fa0a 100644
77206 --- a/include/linux/printk.h
77207 +++ b/include/linux/printk.h
77208 @@ -106,6 +106,8 @@ static inline __printf(1, 2) __cold
77209 void early_printk(const char *s, ...) { }
77210 #endif
77211
77212 +extern int kptr_restrict;
77213 +
77214 #ifdef CONFIG_PRINTK
77215 asmlinkage __printf(5, 0)
77216 int vprintk_emit(int facility, int level,
77217 @@ -140,7 +142,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
77218
77219 extern int printk_delay_msec;
77220 extern int dmesg_restrict;
77221 -extern int kptr_restrict;
77222
77223 extern void wake_up_klogd(void);
77224
77225 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
77226 index 608e60a..c26f864 100644
77227 --- a/include/linux/proc_fs.h
77228 +++ b/include/linux/proc_fs.h
77229 @@ -34,6 +34,19 @@ static inline struct proc_dir_entry *proc_create(
77230 return proc_create_data(name, mode, parent, proc_fops, NULL);
77231 }
77232
77233 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
77234 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
77235 +{
77236 +#ifdef CONFIG_GRKERNSEC_PROC_USER
77237 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
77238 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
77239 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
77240 +#else
77241 + return proc_create_data(name, mode, parent, proc_fops, NULL);
77242 +#endif
77243 +}
77244 +
77245 +
77246 extern void proc_set_size(struct proc_dir_entry *, loff_t);
77247 extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
77248 extern void *PDE_DATA(const struct inode *);
77249 diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
77250 index 34a1e10..03a6d03 100644
77251 --- a/include/linux/proc_ns.h
77252 +++ b/include/linux/proc_ns.h
77253 @@ -14,7 +14,7 @@ struct proc_ns_operations {
77254 void (*put)(void *ns);
77255 int (*install)(struct nsproxy *nsproxy, void *ns);
77256 unsigned int (*inum)(void *ns);
77257 -};
77258 +} __do_const;
77259
77260 struct proc_ns {
77261 void *ns;
77262 diff --git a/include/linux/random.h b/include/linux/random.h
77263 index 3b9377d..61b506a 100644
77264 --- a/include/linux/random.h
77265 +++ b/include/linux/random.h
77266 @@ -32,6 +32,11 @@ void prandom_seed(u32 seed);
77267 u32 prandom_u32_state(struct rnd_state *);
77268 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
77269
77270 +static inline unsigned long pax_get_random_long(void)
77271 +{
77272 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
77273 +}
77274 +
77275 /*
77276 * Handle minimum values for seeds
77277 */
77278 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
77279 index f4b1001..8ddb2b6 100644
77280 --- a/include/linux/rculist.h
77281 +++ b/include/linux/rculist.h
77282 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
77283 struct list_head *prev, struct list_head *next);
77284 #endif
77285
77286 +extern void __pax_list_add_rcu(struct list_head *new,
77287 + struct list_head *prev, struct list_head *next);
77288 +
77289 /**
77290 * list_add_rcu - add a new entry to rcu-protected list
77291 * @new: new entry to be added
77292 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
77293 __list_add_rcu(new, head, head->next);
77294 }
77295
77296 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
77297 +{
77298 + __pax_list_add_rcu(new, head, head->next);
77299 +}
77300 +
77301 /**
77302 * list_add_tail_rcu - add a new entry to rcu-protected list
77303 * @new: new entry to be added
77304 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
77305 __list_add_rcu(new, head->prev, head);
77306 }
77307
77308 +static inline void pax_list_add_tail_rcu(struct list_head *new,
77309 + struct list_head *head)
77310 +{
77311 + __pax_list_add_rcu(new, head->prev, head);
77312 +}
77313 +
77314 /**
77315 * list_del_rcu - deletes entry from list without re-initialization
77316 * @entry: the element to delete from the list.
77317 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
77318 entry->prev = LIST_POISON2;
77319 }
77320
77321 +extern void pax_list_del_rcu(struct list_head *entry);
77322 +
77323 /**
77324 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
77325 * @n: the element to delete from the hash list.
77326 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
77327 index 23b3630..e1bc12b 100644
77328 --- a/include/linux/reboot.h
77329 +++ b/include/linux/reboot.h
77330 @@ -18,9 +18,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
77331 * Architecture-specific implementations of sys_reboot commands.
77332 */
77333
77334 -extern void machine_restart(char *cmd);
77335 -extern void machine_halt(void);
77336 -extern void machine_power_off(void);
77337 +extern void machine_restart(char *cmd) __noreturn;
77338 +extern void machine_halt(void) __noreturn;
77339 +extern void machine_power_off(void) __noreturn;
77340
77341 extern void machine_shutdown(void);
77342 struct pt_regs;
77343 @@ -31,9 +31,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
77344 */
77345
77346 extern void kernel_restart_prepare(char *cmd);
77347 -extern void kernel_restart(char *cmd);
77348 -extern void kernel_halt(void);
77349 -extern void kernel_power_off(void);
77350 +extern void kernel_restart(char *cmd) __noreturn;
77351 +extern void kernel_halt(void) __noreturn;
77352 +extern void kernel_power_off(void) __noreturn;
77353
77354 extern int C_A_D; /* for sysctl */
77355 void ctrl_alt_del(void);
77356 @@ -47,7 +47,7 @@ extern int orderly_poweroff(bool force);
77357 * Emergency restart, callable from an interrupt handler.
77358 */
77359
77360 -extern void emergency_restart(void);
77361 +extern void emergency_restart(void) __noreturn;
77362 #include <asm/emergency-restart.h>
77363
77364 #endif /* _LINUX_REBOOT_H */
77365 diff --git a/include/linux/regset.h b/include/linux/regset.h
77366 index 8e0c9fe..ac4d221 100644
77367 --- a/include/linux/regset.h
77368 +++ b/include/linux/regset.h
77369 @@ -161,7 +161,8 @@ struct user_regset {
77370 unsigned int align;
77371 unsigned int bias;
77372 unsigned int core_note_type;
77373 -};
77374 +} __do_const;
77375 +typedef struct user_regset __no_const user_regset_no_const;
77376
77377 /**
77378 * struct user_regset_view - available regsets
77379 diff --git a/include/linux/relay.h b/include/linux/relay.h
77380 index d7c8359..818daf5 100644
77381 --- a/include/linux/relay.h
77382 +++ b/include/linux/relay.h
77383 @@ -157,7 +157,7 @@ struct rchan_callbacks
77384 * The callback should return 0 if successful, negative if not.
77385 */
77386 int (*remove_buf_file)(struct dentry *dentry);
77387 -};
77388 +} __no_const;
77389
77390 /*
77391 * CONFIG_RELAY kernel API, kernel/relay.c
77392 diff --git a/include/linux/rio.h b/include/linux/rio.h
77393 index 18e0993..8ab5b21 100644
77394 --- a/include/linux/rio.h
77395 +++ b/include/linux/rio.h
77396 @@ -345,7 +345,7 @@ struct rio_ops {
77397 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
77398 u64 rstart, u32 size, u32 flags);
77399 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
77400 -};
77401 +} __no_const;
77402
77403 #define RIO_RESOURCE_MEM 0x00000100
77404 #define RIO_RESOURCE_DOORBELL 0x00000200
77405 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
77406 index 6dacb93..6174423 100644
77407 --- a/include/linux/rmap.h
77408 +++ b/include/linux/rmap.h
77409 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
77410 void anon_vma_init(void); /* create anon_vma_cachep */
77411 int anon_vma_prepare(struct vm_area_struct *);
77412 void unlink_anon_vmas(struct vm_area_struct *);
77413 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
77414 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
77415 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
77416 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
77417
77418 static inline void anon_vma_merge(struct vm_area_struct *vma,
77419 struct vm_area_struct *next)
77420 diff --git a/include/linux/sched.h b/include/linux/sched.h
77421 index 178a8d9..918ea01 100644
77422 --- a/include/linux/sched.h
77423 +++ b/include/linux/sched.h
77424 @@ -62,6 +62,7 @@ struct bio_list;
77425 struct fs_struct;
77426 struct perf_event_context;
77427 struct blk_plug;
77428 +struct linux_binprm;
77429
77430 /*
77431 * List of flags we want to share for kernel threads,
77432 @@ -303,7 +304,7 @@ extern char __sched_text_start[], __sched_text_end[];
77433 extern int in_sched_functions(unsigned long addr);
77434
77435 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
77436 -extern signed long schedule_timeout(signed long timeout);
77437 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
77438 extern signed long schedule_timeout_interruptible(signed long timeout);
77439 extern signed long schedule_timeout_killable(signed long timeout);
77440 extern signed long schedule_timeout_uninterruptible(signed long timeout);
77441 @@ -314,6 +315,18 @@ struct nsproxy;
77442 struct user_namespace;
77443
77444 #ifdef CONFIG_MMU
77445 +
77446 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
77447 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
77448 +#else
77449 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
77450 +{
77451 + return 0;
77452 +}
77453 +#endif
77454 +
77455 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
77456 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
77457 extern void arch_pick_mmap_layout(struct mm_struct *mm);
77458 extern unsigned long
77459 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
77460 @@ -591,6 +604,17 @@ struct signal_struct {
77461 #ifdef CONFIG_TASKSTATS
77462 struct taskstats *stats;
77463 #endif
77464 +
77465 +#ifdef CONFIG_GRKERNSEC
77466 + u32 curr_ip;
77467 + u32 saved_ip;
77468 + u32 gr_saddr;
77469 + u32 gr_daddr;
77470 + u16 gr_sport;
77471 + u16 gr_dport;
77472 + u8 used_accept:1;
77473 +#endif
77474 +
77475 #ifdef CONFIG_AUDIT
77476 unsigned audit_tty;
77477 unsigned audit_tty_log_passwd;
77478 @@ -671,6 +695,14 @@ struct user_struct {
77479 struct key *session_keyring; /* UID's default session keyring */
77480 #endif
77481
77482 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
77483 + unsigned char kernel_banned;
77484 +#endif
77485 +#ifdef CONFIG_GRKERNSEC_BRUTE
77486 + unsigned char suid_banned;
77487 + unsigned long suid_ban_expires;
77488 +#endif
77489 +
77490 /* Hash table maintenance information */
77491 struct hlist_node uidhash_node;
77492 kuid_t uid;
77493 @@ -1158,8 +1190,8 @@ struct task_struct {
77494 struct list_head thread_group;
77495
77496 struct completion *vfork_done; /* for vfork() */
77497 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
77498 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
77499 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
77500 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
77501
77502 cputime_t utime, stime, utimescaled, stimescaled;
77503 cputime_t gtime;
77504 @@ -1184,11 +1216,6 @@ struct task_struct {
77505 struct task_cputime cputime_expires;
77506 struct list_head cpu_timers[3];
77507
77508 -/* process credentials */
77509 - const struct cred __rcu *real_cred; /* objective and real subjective task
77510 - * credentials (COW) */
77511 - const struct cred __rcu *cred; /* effective (overridable) subjective task
77512 - * credentials (COW) */
77513 char comm[TASK_COMM_LEN]; /* executable name excluding path
77514 - access with [gs]et_task_comm (which lock
77515 it with task_lock())
77516 @@ -1205,6 +1232,10 @@ struct task_struct {
77517 #endif
77518 /* CPU-specific state of this task */
77519 struct thread_struct thread;
77520 +/* thread_info moved to task_struct */
77521 +#ifdef CONFIG_X86
77522 + struct thread_info tinfo;
77523 +#endif
77524 /* filesystem information */
77525 struct fs_struct *fs;
77526 /* open file information */
77527 @@ -1278,6 +1309,10 @@ struct task_struct {
77528 gfp_t lockdep_reclaim_gfp;
77529 #endif
77530
77531 +/* process credentials */
77532 + const struct cred __rcu *real_cred; /* objective and real subjective task
77533 + * credentials (COW) */
77534 +
77535 /* journalling filesystem info */
77536 void *journal_info;
77537
77538 @@ -1316,6 +1351,10 @@ struct task_struct {
77539 /* cg_list protected by css_set_lock and tsk->alloc_lock */
77540 struct list_head cg_list;
77541 #endif
77542 +
77543 + const struct cred __rcu *cred; /* effective (overridable) subjective task
77544 + * credentials (COW) */
77545 +
77546 #ifdef CONFIG_FUTEX
77547 struct robust_list_head __user *robust_list;
77548 #ifdef CONFIG_COMPAT
77549 @@ -1416,8 +1455,76 @@ struct task_struct {
77550 unsigned int sequential_io;
77551 unsigned int sequential_io_avg;
77552 #endif
77553 +
77554 +#ifdef CONFIG_GRKERNSEC
77555 + /* grsecurity */
77556 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
77557 + u64 exec_id;
77558 +#endif
77559 +#ifdef CONFIG_GRKERNSEC_SETXID
77560 + const struct cred *delayed_cred;
77561 +#endif
77562 + struct dentry *gr_chroot_dentry;
77563 + struct acl_subject_label *acl;
77564 + struct acl_role_label *role;
77565 + struct file *exec_file;
77566 + unsigned long brute_expires;
77567 + u16 acl_role_id;
77568 + /* is this the task that authenticated to the special role */
77569 + u8 acl_sp_role;
77570 + u8 is_writable;
77571 + u8 brute;
77572 + u8 gr_is_chrooted;
77573 +#endif
77574 +
77575 };
77576
77577 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
77578 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
77579 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
77580 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
77581 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
77582 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
77583 +
77584 +#ifdef CONFIG_PAX_SOFTMODE
77585 +extern int pax_softmode;
77586 +#endif
77587 +
77588 +extern int pax_check_flags(unsigned long *);
77589 +
77590 +/* if tsk != current then task_lock must be held on it */
77591 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
77592 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
77593 +{
77594 + if (likely(tsk->mm))
77595 + return tsk->mm->pax_flags;
77596 + else
77597 + return 0UL;
77598 +}
77599 +
77600 +/* if tsk != current then task_lock must be held on it */
77601 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
77602 +{
77603 + if (likely(tsk->mm)) {
77604 + tsk->mm->pax_flags = flags;
77605 + return 0;
77606 + }
77607 + return -EINVAL;
77608 +}
77609 +#endif
77610 +
77611 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
77612 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
77613 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
77614 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
77615 +#endif
77616 +
77617 +struct path;
77618 +extern char *pax_get_path(const struct path *path, char *buf, int buflen);
77619 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
77620 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
77621 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
77622 +
77623 /* Future-safe accessor for struct task_struct's cpus_allowed. */
77624 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
77625
77626 @@ -1476,7 +1583,7 @@ struct pid_namespace;
77627 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
77628 struct pid_namespace *ns);
77629
77630 -static inline pid_t task_pid_nr(struct task_struct *tsk)
77631 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
77632 {
77633 return tsk->pid;
77634 }
77635 @@ -1919,7 +2026,9 @@ void yield(void);
77636 extern struct exec_domain default_exec_domain;
77637
77638 union thread_union {
77639 +#ifndef CONFIG_X86
77640 struct thread_info thread_info;
77641 +#endif
77642 unsigned long stack[THREAD_SIZE/sizeof(long)];
77643 };
77644
77645 @@ -1952,6 +2061,7 @@ extern struct pid_namespace init_pid_ns;
77646 */
77647
77648 extern struct task_struct *find_task_by_vpid(pid_t nr);
77649 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
77650 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
77651 struct pid_namespace *ns);
77652
77653 @@ -2118,7 +2228,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
77654 extern void exit_itimers(struct signal_struct *);
77655 extern void flush_itimer_signals(void);
77656
77657 -extern void do_group_exit(int);
77658 +extern __noreturn void do_group_exit(int);
77659
77660 extern int allow_signal(int);
77661 extern int disallow_signal(int);
77662 @@ -2309,9 +2419,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
77663
77664 #endif
77665
77666 -static inline int object_is_on_stack(void *obj)
77667 +static inline int object_starts_on_stack(void *obj)
77668 {
77669 - void *stack = task_stack_page(current);
77670 + const void *stack = task_stack_page(current);
77671
77672 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
77673 }
77674 diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
77675 index bf8086b..962b035 100644
77676 --- a/include/linux/sched/sysctl.h
77677 +++ b/include/linux/sched/sysctl.h
77678 @@ -30,6 +30,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
77679 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
77680
77681 extern int sysctl_max_map_count;
77682 +extern unsigned long sysctl_heap_stack_gap;
77683
77684 extern unsigned int sysctl_sched_latency;
77685 extern unsigned int sysctl_sched_min_granularity;
77686 diff --git a/include/linux/security.h b/include/linux/security.h
77687 index 4686491..2bd210e 100644
77688 --- a/include/linux/security.h
77689 +++ b/include/linux/security.h
77690 @@ -26,6 +26,7 @@
77691 #include <linux/capability.h>
77692 #include <linux/slab.h>
77693 #include <linux/err.h>
77694 +#include <linux/grsecurity.h>
77695
77696 struct linux_binprm;
77697 struct cred;
77698 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
77699 index 2da29ac..aac448ec 100644
77700 --- a/include/linux/seq_file.h
77701 +++ b/include/linux/seq_file.h
77702 @@ -26,6 +26,9 @@ struct seq_file {
77703 struct mutex lock;
77704 const struct seq_operations *op;
77705 int poll_event;
77706 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
77707 + u64 exec_id;
77708 +#endif
77709 #ifdef CONFIG_USER_NS
77710 struct user_namespace *user_ns;
77711 #endif
77712 @@ -38,6 +41,7 @@ struct seq_operations {
77713 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
77714 int (*show) (struct seq_file *m, void *v);
77715 };
77716 +typedef struct seq_operations __no_const seq_operations_no_const;
77717
77718 #define SEQ_SKIP 1
77719
77720 diff --git a/include/linux/shm.h b/include/linux/shm.h
77721 index 429c199..4d42e38 100644
77722 --- a/include/linux/shm.h
77723 +++ b/include/linux/shm.h
77724 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
77725
77726 /* The task created the shm object. NULL if the task is dead. */
77727 struct task_struct *shm_creator;
77728 +#ifdef CONFIG_GRKERNSEC
77729 + time_t shm_createtime;
77730 + pid_t shm_lapid;
77731 +#endif
77732 };
77733
77734 /* shm_mode upper byte flags */
77735 diff --git a/include/linux/signal.h b/include/linux/signal.h
77736 index d897484..323ba98 100644
77737 --- a/include/linux/signal.h
77738 +++ b/include/linux/signal.h
77739 @@ -433,6 +433,7 @@ void signals_init(void);
77740
77741 int restore_altstack(const stack_t __user *);
77742 int __save_altstack(stack_t __user *, unsigned long);
77743 +void __save_altstack_ex(stack_t __user *, unsigned long);
77744
77745 #ifdef CONFIG_PROC_FS
77746 struct seq_file;
77747 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
77748 index dec1748..112c1f9 100644
77749 --- a/include/linux/skbuff.h
77750 +++ b/include/linux/skbuff.h
77751 @@ -640,7 +640,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
77752 extern struct sk_buff *__alloc_skb(unsigned int size,
77753 gfp_t priority, int flags, int node);
77754 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
77755 -static inline struct sk_buff *alloc_skb(unsigned int size,
77756 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
77757 gfp_t priority)
77758 {
77759 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
77760 @@ -756,7 +756,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
77761 */
77762 static inline int skb_queue_empty(const struct sk_buff_head *list)
77763 {
77764 - return list->next == (struct sk_buff *)list;
77765 + return list->next == (const struct sk_buff *)list;
77766 }
77767
77768 /**
77769 @@ -769,7 +769,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
77770 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
77771 const struct sk_buff *skb)
77772 {
77773 - return skb->next == (struct sk_buff *)list;
77774 + return skb->next == (const struct sk_buff *)list;
77775 }
77776
77777 /**
77778 @@ -782,7 +782,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
77779 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
77780 const struct sk_buff *skb)
77781 {
77782 - return skb->prev == (struct sk_buff *)list;
77783 + return skb->prev == (const struct sk_buff *)list;
77784 }
77785
77786 /**
77787 @@ -1848,7 +1848,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
77788 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
77789 */
77790 #ifndef NET_SKB_PAD
77791 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
77792 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
77793 #endif
77794
77795 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
77796 @@ -2443,7 +2443,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
77797 int noblock, int *err);
77798 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
77799 struct poll_table_struct *wait);
77800 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
77801 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
77802 int offset, struct iovec *to,
77803 int size);
77804 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
77805 @@ -2733,6 +2733,9 @@ static inline void nf_reset(struct sk_buff *skb)
77806 nf_bridge_put(skb->nf_bridge);
77807 skb->nf_bridge = NULL;
77808 #endif
77809 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
77810 + skb->nf_trace = 0;
77811 +#endif
77812 }
77813
77814 static inline void nf_reset_trace(struct sk_buff *skb)
77815 diff --git a/include/linux/slab.h b/include/linux/slab.h
77816 index 0c62175..f016ac1 100644
77817 --- a/include/linux/slab.h
77818 +++ b/include/linux/slab.h
77819 @@ -12,15 +12,29 @@
77820 #include <linux/gfp.h>
77821 #include <linux/types.h>
77822 #include <linux/workqueue.h>
77823 -
77824 +#include <linux/err.h>
77825
77826 /*
77827 * Flags to pass to kmem_cache_create().
77828 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
77829 */
77830 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
77831 +
77832 +#ifdef CONFIG_PAX_USERCOPY_SLABS
77833 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
77834 +#else
77835 +#define SLAB_USERCOPY 0x00000000UL
77836 +#endif
77837 +
77838 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
77839 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
77840 +
77841 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
77842 +#define SLAB_NO_SANITIZE 0x00001000UL /* PaX: Do not sanitize objs on free */
77843 +#else
77844 +#define SLAB_NO_SANITIZE 0x00000000UL
77845 +#endif
77846 +
77847 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
77848 #define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */
77849 #define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */
77850 @@ -89,10 +103,13 @@
77851 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
77852 * Both make kfree a no-op.
77853 */
77854 -#define ZERO_SIZE_PTR ((void *)16)
77855 +#define ZERO_SIZE_PTR \
77856 +({ \
77857 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
77858 + (void *)(-MAX_ERRNO-1L); \
77859 +})
77860
77861 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
77862 - (unsigned long)ZERO_SIZE_PTR)
77863 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
77864
77865
77866 struct mem_cgroup;
77867 @@ -132,6 +149,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
77868 void kfree(const void *);
77869 void kzfree(const void *);
77870 size_t ksize(const void *);
77871 +const char *check_heap_object(const void *ptr, unsigned long n);
77872 +bool is_usercopy_object(const void *ptr);
77873
77874 /*
77875 * Some archs want to perform DMA into kmalloc caches and need a guaranteed
77876 @@ -164,7 +183,7 @@ struct kmem_cache {
77877 unsigned int align; /* Alignment as calculated */
77878 unsigned long flags; /* Active flags on the slab */
77879 const char *name; /* Slab name for sysfs */
77880 - int refcount; /* Use counter */
77881 + atomic_t refcount; /* Use counter */
77882 void (*ctor)(void *); /* Called on object slot creation */
77883 struct list_head list; /* List of all slab caches on the system */
77884 };
77885 @@ -226,6 +245,10 @@ extern struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
77886 extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
77887 #endif
77888
77889 +#ifdef CONFIG_PAX_USERCOPY_SLABS
77890 +extern struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
77891 +#endif
77892 +
77893 /*
77894 * Figure out which kmalloc slab an allocation of a certain size
77895 * belongs to.
77896 @@ -234,7 +257,7 @@ extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
77897 * 2 = 120 .. 192 bytes
77898 * n = 2^(n-1) .. 2^n -1
77899 */
77900 -static __always_inline int kmalloc_index(size_t size)
77901 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
77902 {
77903 if (!size)
77904 return 0;
77905 @@ -406,6 +429,7 @@ void print_slabinfo_header(struct seq_file *m);
77906 * for general use, and so are not documented here. For a full list of
77907 * potential flags, always refer to linux/gfp.h.
77908 */
77909 +
77910 static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
77911 {
77912 if (size != 0 && n > SIZE_MAX / size)
77913 @@ -465,7 +489,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
77914 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
77915 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
77916 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
77917 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
77918 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
77919 #define kmalloc_track_caller(size, flags) \
77920 __kmalloc_track_caller(size, flags, _RET_IP_)
77921 #else
77922 @@ -485,7 +509,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
77923 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
77924 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
77925 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
77926 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
77927 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
77928 #define kmalloc_node_track_caller(size, flags, node) \
77929 __kmalloc_node_track_caller(size, flags, node, \
77930 _RET_IP_)
77931 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
77932 index cd40158..4e2f7af 100644
77933 --- a/include/linux/slab_def.h
77934 +++ b/include/linux/slab_def.h
77935 @@ -50,7 +50,7 @@ struct kmem_cache {
77936 /* 4) cache creation/removal */
77937 const char *name;
77938 struct list_head list;
77939 - int refcount;
77940 + atomic_t refcount;
77941 int object_size;
77942 int align;
77943
77944 @@ -66,10 +66,14 @@ struct kmem_cache {
77945 unsigned long node_allocs;
77946 unsigned long node_frees;
77947 unsigned long node_overflow;
77948 - atomic_t allochit;
77949 - atomic_t allocmiss;
77950 - atomic_t freehit;
77951 - atomic_t freemiss;
77952 + atomic_unchecked_t allochit;
77953 + atomic_unchecked_t allocmiss;
77954 + atomic_unchecked_t freehit;
77955 + atomic_unchecked_t freemiss;
77956 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
77957 + atomic_unchecked_t sanitized;
77958 + atomic_unchecked_t not_sanitized;
77959 +#endif
77960
77961 /*
77962 * If debugging is enabled, then the allocator can add additional
77963 @@ -103,7 +107,7 @@ struct kmem_cache {
77964 };
77965
77966 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
77967 -void *__kmalloc(size_t size, gfp_t flags);
77968 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
77969
77970 #ifdef CONFIG_TRACING
77971 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
77972 @@ -136,6 +140,13 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
77973 cachep = kmalloc_dma_caches[i];
77974 else
77975 #endif
77976 +
77977 +#ifdef CONFIG_PAX_USERCOPY_SLABS
77978 + if (flags & GFP_USERCOPY)
77979 + cachep = kmalloc_usercopy_caches[i];
77980 + else
77981 +#endif
77982 +
77983 cachep = kmalloc_caches[i];
77984
77985 ret = kmem_cache_alloc_trace(cachep, flags, size);
77986 @@ -146,7 +157,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
77987 }
77988
77989 #ifdef CONFIG_NUMA
77990 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
77991 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
77992 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
77993
77994 #ifdef CONFIG_TRACING
77995 @@ -185,6 +196,13 @@ static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
77996 cachep = kmalloc_dma_caches[i];
77997 else
77998 #endif
77999 +
78000 +#ifdef CONFIG_PAX_USERCOPY_SLABS
78001 + if (flags & GFP_USERCOPY)
78002 + cachep = kmalloc_usercopy_caches[i];
78003 + else
78004 +#endif
78005 +
78006 cachep = kmalloc_caches[i];
78007
78008 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
78009 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
78010 index f28e14a..7831211 100644
78011 --- a/include/linux/slob_def.h
78012 +++ b/include/linux/slob_def.h
78013 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
78014 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
78015 }
78016
78017 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
78018 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
78019
78020 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
78021 {
78022 @@ -31,7 +31,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
78023 return __kmalloc_node(size, flags, NUMA_NO_NODE);
78024 }
78025
78026 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
78027 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
78028 {
78029 return kmalloc(size, flags);
78030 }
78031 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
78032 index 027276f..092bfe8 100644
78033 --- a/include/linux/slub_def.h
78034 +++ b/include/linux/slub_def.h
78035 @@ -80,7 +80,7 @@ struct kmem_cache {
78036 struct kmem_cache_order_objects max;
78037 struct kmem_cache_order_objects min;
78038 gfp_t allocflags; /* gfp flags to use on each alloc */
78039 - int refcount; /* Refcount for slab cache destroy */
78040 + atomic_t refcount; /* Refcount for slab cache destroy */
78041 void (*ctor)(void *);
78042 int inuse; /* Offset to metadata */
78043 int align; /* Alignment */
78044 @@ -105,7 +105,7 @@ struct kmem_cache {
78045 };
78046
78047 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
78048 -void *__kmalloc(size_t size, gfp_t flags);
78049 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
78050
78051 static __always_inline void *
78052 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
78053 @@ -149,7 +149,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
78054 }
78055 #endif
78056
78057 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
78058 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
78059 {
78060 unsigned int order = get_order(size);
78061 return kmalloc_order_trace(size, flags, order);
78062 @@ -175,7 +175,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
78063 }
78064
78065 #ifdef CONFIG_NUMA
78066 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
78067 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
78068 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
78069
78070 #ifdef CONFIG_TRACING
78071 diff --git a/include/linux/smp.h b/include/linux/smp.h
78072 index c848876..11e8a84 100644
78073 --- a/include/linux/smp.h
78074 +++ b/include/linux/smp.h
78075 @@ -221,7 +221,9 @@ static inline void kick_all_cpus_sync(void) { }
78076 #endif
78077
78078 #define get_cpu() ({ preempt_disable(); smp_processor_id(); })
78079 +#define raw_get_cpu() ({ raw_preempt_disable(); raw_smp_processor_id(); })
78080 #define put_cpu() preempt_enable()
78081 +#define raw_put_cpu_no_resched() raw_preempt_enable_no_resched()
78082
78083 /*
78084 * Callback to arch code if there's nosmp or maxcpus=0 on the
78085 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
78086 index 54f91d3..be2c379 100644
78087 --- a/include/linux/sock_diag.h
78088 +++ b/include/linux/sock_diag.h
78089 @@ -11,7 +11,7 @@ struct sock;
78090 struct sock_diag_handler {
78091 __u8 family;
78092 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
78093 -};
78094 +} __do_const;
78095
78096 int sock_diag_register(const struct sock_diag_handler *h);
78097 void sock_diag_unregister(const struct sock_diag_handler *h);
78098 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
78099 index 680f9a3..f13aeb0 100644
78100 --- a/include/linux/sonet.h
78101 +++ b/include/linux/sonet.h
78102 @@ -7,7 +7,7 @@
78103 #include <uapi/linux/sonet.h>
78104
78105 struct k_sonet_stats {
78106 -#define __HANDLE_ITEM(i) atomic_t i
78107 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
78108 __SONET_ITEMS
78109 #undef __HANDLE_ITEM
78110 };
78111 diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
78112 index 07d8e53..dc934c9 100644
78113 --- a/include/linux/sunrpc/addr.h
78114 +++ b/include/linux/sunrpc/addr.h
78115 @@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
78116 {
78117 switch (sap->sa_family) {
78118 case AF_INET:
78119 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
78120 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
78121 case AF_INET6:
78122 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
78123 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
78124 }
78125 return 0;
78126 }
78127 @@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
78128 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
78129 const struct sockaddr *src)
78130 {
78131 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
78132 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
78133 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
78134
78135 dsin->sin_family = ssin->sin_family;
78136 @@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
78137 if (sa->sa_family != AF_INET6)
78138 return 0;
78139
78140 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
78141 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
78142 }
78143
78144 #endif /* _LINUX_SUNRPC_ADDR_H */
78145 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
78146 index bfe11be..12bc8c4 100644
78147 --- a/include/linux/sunrpc/clnt.h
78148 +++ b/include/linux/sunrpc/clnt.h
78149 @@ -96,7 +96,7 @@ struct rpc_procinfo {
78150 unsigned int p_timer; /* Which RTT timer to use */
78151 u32 p_statidx; /* Which procedure to account */
78152 const char * p_name; /* name of procedure */
78153 -};
78154 +} __do_const;
78155
78156 #ifdef __KERNEL__
78157
78158 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
78159 index 1f0216b..6a4fa50 100644
78160 --- a/include/linux/sunrpc/svc.h
78161 +++ b/include/linux/sunrpc/svc.h
78162 @@ -411,7 +411,7 @@ struct svc_procedure {
78163 unsigned int pc_count; /* call count */
78164 unsigned int pc_cachetype; /* cache info (NFS) */
78165 unsigned int pc_xdrressize; /* maximum size of XDR reply */
78166 -};
78167 +} __do_const;
78168
78169 /*
78170 * Function prototypes.
78171 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
78172 index 0b8e3e6..33e0a01 100644
78173 --- a/include/linux/sunrpc/svc_rdma.h
78174 +++ b/include/linux/sunrpc/svc_rdma.h
78175 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
78176 extern unsigned int svcrdma_max_requests;
78177 extern unsigned int svcrdma_max_req_size;
78178
78179 -extern atomic_t rdma_stat_recv;
78180 -extern atomic_t rdma_stat_read;
78181 -extern atomic_t rdma_stat_write;
78182 -extern atomic_t rdma_stat_sq_starve;
78183 -extern atomic_t rdma_stat_rq_starve;
78184 -extern atomic_t rdma_stat_rq_poll;
78185 -extern atomic_t rdma_stat_rq_prod;
78186 -extern atomic_t rdma_stat_sq_poll;
78187 -extern atomic_t rdma_stat_sq_prod;
78188 +extern atomic_unchecked_t rdma_stat_recv;
78189 +extern atomic_unchecked_t rdma_stat_read;
78190 +extern atomic_unchecked_t rdma_stat_write;
78191 +extern atomic_unchecked_t rdma_stat_sq_starve;
78192 +extern atomic_unchecked_t rdma_stat_rq_starve;
78193 +extern atomic_unchecked_t rdma_stat_rq_poll;
78194 +extern atomic_unchecked_t rdma_stat_rq_prod;
78195 +extern atomic_unchecked_t rdma_stat_sq_poll;
78196 +extern atomic_unchecked_t rdma_stat_sq_prod;
78197
78198 #define RPCRDMA_VERSION 1
78199
78200 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
78201 index ff374ab..7fd2ecb 100644
78202 --- a/include/linux/sunrpc/svcauth.h
78203 +++ b/include/linux/sunrpc/svcauth.h
78204 @@ -109,7 +109,7 @@ struct auth_ops {
78205 int (*release)(struct svc_rqst *rq);
78206 void (*domain_release)(struct auth_domain *);
78207 int (*set_client)(struct svc_rqst *rq);
78208 -};
78209 +} __do_const;
78210
78211 #define SVC_GARBAGE 1
78212 #define SVC_SYSERR 2
78213 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
78214 index a5ffd32..0935dea 100644
78215 --- a/include/linux/swiotlb.h
78216 +++ b/include/linux/swiotlb.h
78217 @@ -60,7 +60,8 @@ extern void
78218
78219 extern void
78220 swiotlb_free_coherent(struct device *hwdev, size_t size,
78221 - void *vaddr, dma_addr_t dma_handle);
78222 + void *vaddr, dma_addr_t dma_handle,
78223 + struct dma_attrs *attrs);
78224
78225 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
78226 unsigned long offset, size_t size,
78227 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
78228 index 84662ec..d8f8adb 100644
78229 --- a/include/linux/syscalls.h
78230 +++ b/include/linux/syscalls.h
78231 @@ -97,8 +97,12 @@ struct sigaltstack;
78232 #define __MAP(n,...) __MAP##n(__VA_ARGS__)
78233
78234 #define __SC_DECL(t, a) t a
78235 -#define __TYPE_IS_LL(t) (__same_type((t)0, 0LL) || __same_type((t)0, 0ULL))
78236 -#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a
78237 +#define __TYPE_IS_SL(t) (__same_type((t)0, 0L))
78238 +#define __TYPE_IS_UL(t) (__same_type((t)0, 0UL))
78239 +#define __TYPE_IS_SLL(t) (__same_type((t)0, 0LL))
78240 +#define __TYPE_IS_ULL(t) (__same_type((t)0, 0ULL))
78241 +#define __TYPE_IS_LL(t) (__TYPE_IS_SLL(t) || __TYPE_IS_ULL(t))
78242 +#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), __builtin_choose_expr(__TYPE_IS_ULL(t), 0ULL, 0LL), __builtin_choose_expr(__TYPE_IS_UL(t), 0UL, 0L))) a
78243 #define __SC_CAST(t, a) (t) a
78244 #define __SC_ARGS(t, a) a
78245 #define __SC_TEST(t, a) (void)BUILD_BUG_ON_ZERO(!__TYPE_IS_LL(t) && sizeof(t) > sizeof(long))
78246 @@ -362,11 +366,11 @@ asmlinkage long sys_sync(void);
78247 asmlinkage long sys_fsync(unsigned int fd);
78248 asmlinkage long sys_fdatasync(unsigned int fd);
78249 asmlinkage long sys_bdflush(int func, long data);
78250 -asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
78251 - char __user *type, unsigned long flags,
78252 +asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
78253 + const char __user *type, unsigned long flags,
78254 void __user *data);
78255 -asmlinkage long sys_umount(char __user *name, int flags);
78256 -asmlinkage long sys_oldumount(char __user *name);
78257 +asmlinkage long sys_umount(const char __user *name, int flags);
78258 +asmlinkage long sys_oldumount(const char __user *name);
78259 asmlinkage long sys_truncate(const char __user *path, long length);
78260 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
78261 asmlinkage long sys_stat(const char __user *filename,
78262 @@ -578,7 +582,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
78263 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
78264 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
78265 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
78266 - struct sockaddr __user *, int);
78267 + struct sockaddr __user *, int) __intentional_overflow(0);
78268 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
78269 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
78270 unsigned int vlen, unsigned flags);
78271 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
78272 index 27b3b0b..e093dd9 100644
78273 --- a/include/linux/syscore_ops.h
78274 +++ b/include/linux/syscore_ops.h
78275 @@ -16,7 +16,7 @@ struct syscore_ops {
78276 int (*suspend)(void);
78277 void (*resume)(void);
78278 void (*shutdown)(void);
78279 -};
78280 +} __do_const;
78281
78282 extern void register_syscore_ops(struct syscore_ops *ops);
78283 extern void unregister_syscore_ops(struct syscore_ops *ops);
78284 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
78285 index 14a8ff2..af52bad 100644
78286 --- a/include/linux/sysctl.h
78287 +++ b/include/linux/sysctl.h
78288 @@ -34,13 +34,13 @@ struct ctl_table_root;
78289 struct ctl_table_header;
78290 struct ctl_dir;
78291
78292 -typedef struct ctl_table ctl_table;
78293 -
78294 typedef int proc_handler (struct ctl_table *ctl, int write,
78295 void __user *buffer, size_t *lenp, loff_t *ppos);
78296
78297 extern int proc_dostring(struct ctl_table *, int,
78298 void __user *, size_t *, loff_t *);
78299 +extern int proc_dostring_modpriv(struct ctl_table *, int,
78300 + void __user *, size_t *, loff_t *);
78301 extern int proc_dointvec(struct ctl_table *, int,
78302 void __user *, size_t *, loff_t *);
78303 extern int proc_dointvec_minmax(struct ctl_table *, int,
78304 @@ -115,7 +115,9 @@ struct ctl_table
78305 struct ctl_table_poll *poll;
78306 void *extra1;
78307 void *extra2;
78308 -};
78309 +} __do_const;
78310 +typedef struct ctl_table __no_const ctl_table_no_const;
78311 +typedef struct ctl_table ctl_table;
78312
78313 struct ctl_node {
78314 struct rb_node node;
78315 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
78316 index e2cee22..3ddb921 100644
78317 --- a/include/linux/sysfs.h
78318 +++ b/include/linux/sysfs.h
78319 @@ -31,7 +31,8 @@ struct attribute {
78320 struct lock_class_key *key;
78321 struct lock_class_key skey;
78322 #endif
78323 -};
78324 +} __do_const;
78325 +typedef struct attribute __no_const attribute_no_const;
78326
78327 /**
78328 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
78329 @@ -59,8 +60,8 @@ struct attribute_group {
78330 umode_t (*is_visible)(struct kobject *,
78331 struct attribute *, int);
78332 struct attribute **attrs;
78333 -};
78334 -
78335 +} __do_const;
78336 +typedef struct attribute_group __no_const attribute_group_no_const;
78337
78338
78339 /**
78340 @@ -107,7 +108,8 @@ struct bin_attribute {
78341 char *, loff_t, size_t);
78342 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
78343 struct vm_area_struct *vma);
78344 -};
78345 +} __do_const;
78346 +typedef struct bin_attribute __no_const bin_attribute_no_const;
78347
78348 /**
78349 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
78350 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
78351 index 7faf933..9b85a0c 100644
78352 --- a/include/linux/sysrq.h
78353 +++ b/include/linux/sysrq.h
78354 @@ -16,6 +16,7 @@
78355
78356 #include <linux/errno.h>
78357 #include <linux/types.h>
78358 +#include <linux/compiler.h>
78359
78360 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
78361 #define SYSRQ_DEFAULT_ENABLE 1
78362 @@ -36,7 +37,7 @@ struct sysrq_key_op {
78363 char *help_msg;
78364 char *action_msg;
78365 int enable_mask;
78366 -};
78367 +} __do_const;
78368
78369 #ifdef CONFIG_MAGIC_SYSRQ
78370
78371 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
78372 index e7e0473..7989295 100644
78373 --- a/include/linux/thread_info.h
78374 +++ b/include/linux/thread_info.h
78375 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
78376 #error "no set_restore_sigmask() provided and default one won't work"
78377 #endif
78378
78379 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
78380 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
78381 +{
78382 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
78383 + if (!__builtin_constant_p(n))
78384 +#endif
78385 + __check_object_size(ptr, n, to_user);
78386 +}
78387 +
78388 #endif /* __KERNEL__ */
78389
78390 #endif /* _LINUX_THREAD_INFO_H */
78391 diff --git a/include/linux/tty.h b/include/linux/tty.h
78392 index 8780bd2..d1ae08b 100644
78393 --- a/include/linux/tty.h
78394 +++ b/include/linux/tty.h
78395 @@ -194,7 +194,7 @@ struct tty_port {
78396 const struct tty_port_operations *ops; /* Port operations */
78397 spinlock_t lock; /* Lock protecting tty field */
78398 int blocked_open; /* Waiting to open */
78399 - int count; /* Usage count */
78400 + atomic_t count; /* Usage count */
78401 wait_queue_head_t open_wait; /* Open waiters */
78402 wait_queue_head_t close_wait; /* Close waiters */
78403 wait_queue_head_t delta_msr_wait; /* Modem status change */
78404 @@ -550,7 +550,7 @@ extern int tty_port_open(struct tty_port *port,
78405 struct tty_struct *tty, struct file *filp);
78406 static inline int tty_port_users(struct tty_port *port)
78407 {
78408 - return port->count + port->blocked_open;
78409 + return atomic_read(&port->count) + port->blocked_open;
78410 }
78411
78412 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
78413 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
78414 index 756a609..b302dd6 100644
78415 --- a/include/linux/tty_driver.h
78416 +++ b/include/linux/tty_driver.h
78417 @@ -285,7 +285,7 @@ struct tty_operations {
78418 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
78419 #endif
78420 const struct file_operations *proc_fops;
78421 -};
78422 +} __do_const;
78423
78424 struct tty_driver {
78425 int magic; /* magic number for this structure */
78426 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
78427 index 58390c7..95e214c 100644
78428 --- a/include/linux/tty_ldisc.h
78429 +++ b/include/linux/tty_ldisc.h
78430 @@ -146,7 +146,7 @@ struct tty_ldisc_ops {
78431
78432 struct module *owner;
78433
78434 - int refcount;
78435 + atomic_t refcount;
78436 };
78437
78438 struct tty_ldisc {
78439 diff --git a/include/linux/types.h b/include/linux/types.h
78440 index 4d118ba..c3ee9bf 100644
78441 --- a/include/linux/types.h
78442 +++ b/include/linux/types.h
78443 @@ -176,10 +176,26 @@ typedef struct {
78444 int counter;
78445 } atomic_t;
78446
78447 +#ifdef CONFIG_PAX_REFCOUNT
78448 +typedef struct {
78449 + int counter;
78450 +} atomic_unchecked_t;
78451 +#else
78452 +typedef atomic_t atomic_unchecked_t;
78453 +#endif
78454 +
78455 #ifdef CONFIG_64BIT
78456 typedef struct {
78457 long counter;
78458 } atomic64_t;
78459 +
78460 +#ifdef CONFIG_PAX_REFCOUNT
78461 +typedef struct {
78462 + long counter;
78463 +} atomic64_unchecked_t;
78464 +#else
78465 +typedef atomic64_t atomic64_unchecked_t;
78466 +#endif
78467 #endif
78468
78469 struct list_head {
78470 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
78471 index 5ca0951..ab496a5 100644
78472 --- a/include/linux/uaccess.h
78473 +++ b/include/linux/uaccess.h
78474 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
78475 long ret; \
78476 mm_segment_t old_fs = get_fs(); \
78477 \
78478 - set_fs(KERNEL_DS); \
78479 pagefault_disable(); \
78480 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
78481 - pagefault_enable(); \
78482 + set_fs(KERNEL_DS); \
78483 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
78484 set_fs(old_fs); \
78485 + pagefault_enable(); \
78486 ret; \
78487 })
78488
78489 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
78490 index 8e522cbc..aa8572d 100644
78491 --- a/include/linux/uidgid.h
78492 +++ b/include/linux/uidgid.h
78493 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
78494
78495 #endif /* CONFIG_USER_NS */
78496
78497 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
78498 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
78499 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
78500 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
78501 +
78502 #endif /* _LINUX_UIDGID_H */
78503 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
78504 index 99c1b4d..562e6f3 100644
78505 --- a/include/linux/unaligned/access_ok.h
78506 +++ b/include/linux/unaligned/access_ok.h
78507 @@ -4,34 +4,34 @@
78508 #include <linux/kernel.h>
78509 #include <asm/byteorder.h>
78510
78511 -static inline u16 get_unaligned_le16(const void *p)
78512 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
78513 {
78514 - return le16_to_cpup((__le16 *)p);
78515 + return le16_to_cpup((const __le16 *)p);
78516 }
78517
78518 -static inline u32 get_unaligned_le32(const void *p)
78519 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
78520 {
78521 - return le32_to_cpup((__le32 *)p);
78522 + return le32_to_cpup((const __le32 *)p);
78523 }
78524
78525 -static inline u64 get_unaligned_le64(const void *p)
78526 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
78527 {
78528 - return le64_to_cpup((__le64 *)p);
78529 + return le64_to_cpup((const __le64 *)p);
78530 }
78531
78532 -static inline u16 get_unaligned_be16(const void *p)
78533 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
78534 {
78535 - return be16_to_cpup((__be16 *)p);
78536 + return be16_to_cpup((const __be16 *)p);
78537 }
78538
78539 -static inline u32 get_unaligned_be32(const void *p)
78540 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
78541 {
78542 - return be32_to_cpup((__be32 *)p);
78543 + return be32_to_cpup((const __be32 *)p);
78544 }
78545
78546 -static inline u64 get_unaligned_be64(const void *p)
78547 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
78548 {
78549 - return be64_to_cpup((__be64 *)p);
78550 + return be64_to_cpup((const __be64 *)p);
78551 }
78552
78553 static inline void put_unaligned_le16(u16 val, void *p)
78554 diff --git a/include/linux/usb.h b/include/linux/usb.h
78555 index a0bee5a..5533a52 100644
78556 --- a/include/linux/usb.h
78557 +++ b/include/linux/usb.h
78558 @@ -552,7 +552,7 @@ struct usb_device {
78559 int maxchild;
78560
78561 u32 quirks;
78562 - atomic_t urbnum;
78563 + atomic_unchecked_t urbnum;
78564
78565 unsigned long active_duration;
78566
78567 @@ -1607,7 +1607,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
78568
78569 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
78570 __u8 request, __u8 requesttype, __u16 value, __u16 index,
78571 - void *data, __u16 size, int timeout);
78572 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
78573 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
78574 void *data, int len, int *actual_length, int timeout);
78575 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
78576 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
78577 index e452ba6..78f8e80 100644
78578 --- a/include/linux/usb/renesas_usbhs.h
78579 +++ b/include/linux/usb/renesas_usbhs.h
78580 @@ -39,7 +39,7 @@ enum {
78581 */
78582 struct renesas_usbhs_driver_callback {
78583 int (*notify_hotplug)(struct platform_device *pdev);
78584 -};
78585 +} __no_const;
78586
78587 /*
78588 * callback functions for platform
78589 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
78590 index 6f8fbcf..8259001 100644
78591 --- a/include/linux/vermagic.h
78592 +++ b/include/linux/vermagic.h
78593 @@ -25,9 +25,35 @@
78594 #define MODULE_ARCH_VERMAGIC ""
78595 #endif
78596
78597 +#ifdef CONFIG_PAX_REFCOUNT
78598 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
78599 +#else
78600 +#define MODULE_PAX_REFCOUNT ""
78601 +#endif
78602 +
78603 +#ifdef CONSTIFY_PLUGIN
78604 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
78605 +#else
78606 +#define MODULE_CONSTIFY_PLUGIN ""
78607 +#endif
78608 +
78609 +#ifdef STACKLEAK_PLUGIN
78610 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
78611 +#else
78612 +#define MODULE_STACKLEAK_PLUGIN ""
78613 +#endif
78614 +
78615 +#ifdef CONFIG_GRKERNSEC
78616 +#define MODULE_GRSEC "GRSEC "
78617 +#else
78618 +#define MODULE_GRSEC ""
78619 +#endif
78620 +
78621 #define VERMAGIC_STRING \
78622 UTS_RELEASE " " \
78623 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
78624 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
78625 - MODULE_ARCH_VERMAGIC
78626 + MODULE_ARCH_VERMAGIC \
78627 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
78628 + MODULE_GRSEC
78629
78630 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
78631 index 7d5773a..541c01c 100644
78632 --- a/include/linux/vmalloc.h
78633 +++ b/include/linux/vmalloc.h
78634 @@ -16,6 +16,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
78635 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
78636 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
78637 #define VM_UNLIST 0x00000020 /* vm_struct is not listed in vmlist */
78638 +
78639 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
78640 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
78641 +#endif
78642 +
78643 /* bits [20..32] reserved for arch specific ioremap internals */
78644
78645 /*
78646 @@ -75,7 +80,7 @@ extern void *vmalloc_32_user(unsigned long size);
78647 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
78648 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
78649 unsigned long start, unsigned long end, gfp_t gfp_mask,
78650 - pgprot_t prot, int node, const void *caller);
78651 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
78652 extern void vfree(const void *addr);
78653
78654 extern void *vmap(struct page **pages, unsigned int count,
78655 @@ -137,8 +142,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
78656 extern void free_vm_area(struct vm_struct *area);
78657
78658 /* for /dev/kmem */
78659 -extern long vread(char *buf, char *addr, unsigned long count);
78660 -extern long vwrite(char *buf, char *addr, unsigned long count);
78661 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
78662 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
78663
78664 /*
78665 * Internals. Dont't use..
78666 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
78667 index c586679..f06b389 100644
78668 --- a/include/linux/vmstat.h
78669 +++ b/include/linux/vmstat.h
78670 @@ -90,18 +90,18 @@ static inline void vm_events_fold_cpu(int cpu)
78671 /*
78672 * Zone based page accounting with per cpu differentials.
78673 */
78674 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
78675 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
78676
78677 static inline void zone_page_state_add(long x, struct zone *zone,
78678 enum zone_stat_item item)
78679 {
78680 - atomic_long_add(x, &zone->vm_stat[item]);
78681 - atomic_long_add(x, &vm_stat[item]);
78682 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
78683 + atomic_long_add_unchecked(x, &vm_stat[item]);
78684 }
78685
78686 static inline unsigned long global_page_state(enum zone_stat_item item)
78687 {
78688 - long x = atomic_long_read(&vm_stat[item]);
78689 + long x = atomic_long_read_unchecked(&vm_stat[item]);
78690 #ifdef CONFIG_SMP
78691 if (x < 0)
78692 x = 0;
78693 @@ -112,7 +112,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
78694 static inline unsigned long zone_page_state(struct zone *zone,
78695 enum zone_stat_item item)
78696 {
78697 - long x = atomic_long_read(&zone->vm_stat[item]);
78698 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
78699 #ifdef CONFIG_SMP
78700 if (x < 0)
78701 x = 0;
78702 @@ -129,7 +129,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
78703 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
78704 enum zone_stat_item item)
78705 {
78706 - long x = atomic_long_read(&zone->vm_stat[item]);
78707 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
78708
78709 #ifdef CONFIG_SMP
78710 int cpu;
78711 @@ -221,8 +221,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
78712
78713 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
78714 {
78715 - atomic_long_inc(&zone->vm_stat[item]);
78716 - atomic_long_inc(&vm_stat[item]);
78717 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
78718 + atomic_long_inc_unchecked(&vm_stat[item]);
78719 }
78720
78721 static inline void __inc_zone_page_state(struct page *page,
78722 @@ -233,8 +233,8 @@ static inline void __inc_zone_page_state(struct page *page,
78723
78724 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
78725 {
78726 - atomic_long_dec(&zone->vm_stat[item]);
78727 - atomic_long_dec(&vm_stat[item]);
78728 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
78729 + atomic_long_dec_unchecked(&vm_stat[item]);
78730 }
78731
78732 static inline void __dec_zone_page_state(struct page *page,
78733 diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
78734 index 623488f..44b5742 100644
78735 --- a/include/linux/workqueue.h
78736 +++ b/include/linux/workqueue.h
78737 @@ -410,11 +410,11 @@ __alloc_workqueue_key(const char *fmt, unsigned int flags, int max_active,
78738 alloc_workqueue(fmt, WQ_UNBOUND | __WQ_ORDERED | (flags), 1, ##args)
78739
78740 #define create_workqueue(name) \
78741 - alloc_workqueue((name), WQ_MEM_RECLAIM, 1)
78742 + alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, (name))
78743 #define create_freezable_workqueue(name) \
78744 - alloc_workqueue((name), WQ_FREEZABLE | WQ_UNBOUND | WQ_MEM_RECLAIM, 1)
78745 + alloc_workqueue("%s", WQ_FREEZABLE | WQ_UNBOUND | WQ_MEM_RECLAIM, 1, (name))
78746 #define create_singlethread_workqueue(name) \
78747 - alloc_workqueue((name), WQ_UNBOUND | WQ_MEM_RECLAIM, 1)
78748 + alloc_workqueue("%s", WQ_UNBOUND | WQ_MEM_RECLAIM, 1, (name))
78749
78750 extern void destroy_workqueue(struct workqueue_struct *wq);
78751
78752 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
78753 index fdbafc6..49dfe4f 100644
78754 --- a/include/linux/xattr.h
78755 +++ b/include/linux/xattr.h
78756 @@ -28,7 +28,7 @@ struct xattr_handler {
78757 size_t size, int handler_flags);
78758 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
78759 size_t size, int flags, int handler_flags);
78760 -};
78761 +} __do_const;
78762
78763 struct xattr {
78764 char *name;
78765 @@ -37,6 +37,9 @@ struct xattr {
78766 };
78767
78768 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
78769 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
78770 +ssize_t pax_getxattr(struct dentry *, void *, size_t);
78771 +#endif
78772 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
78773 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
78774 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
78775 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
78776 index 9c5a6b4..09c9438 100644
78777 --- a/include/linux/zlib.h
78778 +++ b/include/linux/zlib.h
78779 @@ -31,6 +31,7 @@
78780 #define _ZLIB_H
78781
78782 #include <linux/zconf.h>
78783 +#include <linux/compiler.h>
78784
78785 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
78786 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
78787 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
78788
78789 /* basic functions */
78790
78791 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
78792 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
78793 /*
78794 Returns the number of bytes that needs to be allocated for a per-
78795 stream workspace with the specified parameters. A pointer to this
78796 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
78797 index 95d1c91..6798cca 100644
78798 --- a/include/media/v4l2-dev.h
78799 +++ b/include/media/v4l2-dev.h
78800 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
78801 int (*mmap) (struct file *, struct vm_area_struct *);
78802 int (*open) (struct file *);
78803 int (*release) (struct file *);
78804 -};
78805 +} __do_const;
78806
78807 /*
78808 * Newer version of video_device, handled by videodev2.c
78809 diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
78810 index c9b1593..a572459 100644
78811 --- a/include/media/v4l2-device.h
78812 +++ b/include/media/v4l2-device.h
78813 @@ -95,7 +95,7 @@ int __must_check v4l2_device_register(struct device *dev, struct v4l2_device *v4
78814 this function returns 0. If the name ends with a digit (e.g. cx18),
78815 then the name will be set to cx18-0 since cx180 looks really odd. */
78816 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
78817 - atomic_t *instance);
78818 + atomic_unchecked_t *instance);
78819
78820 /* Set v4l2_dev->dev to NULL. Call when the USB parent disconnects.
78821 Since the parent disappears this ensures that v4l2_dev doesn't have an
78822 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
78823 index adcbb20..62c2559 100644
78824 --- a/include/net/9p/transport.h
78825 +++ b/include/net/9p/transport.h
78826 @@ -57,7 +57,7 @@ struct p9_trans_module {
78827 int (*cancel) (struct p9_client *, struct p9_req_t *req);
78828 int (*zc_request)(struct p9_client *, struct p9_req_t *,
78829 char *, char *, int , int, int, int);
78830 -};
78831 +} __do_const;
78832
78833 void v9fs_register_trans(struct p9_trans_module *m);
78834 void v9fs_unregister_trans(struct p9_trans_module *m);
78835 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
78836 index fb94cf1..7c0c987 100644
78837 --- a/include/net/bluetooth/l2cap.h
78838 +++ b/include/net/bluetooth/l2cap.h
78839 @@ -551,7 +551,7 @@ struct l2cap_ops {
78840 void (*defer) (struct l2cap_chan *chan);
78841 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
78842 unsigned long len, int nb);
78843 -};
78844 +} __do_const;
78845
78846 struct l2cap_conn {
78847 struct hci_conn *hcon;
78848 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
78849 index f2ae33d..c457cf0 100644
78850 --- a/include/net/caif/cfctrl.h
78851 +++ b/include/net/caif/cfctrl.h
78852 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
78853 void (*radioset_rsp)(void);
78854 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
78855 struct cflayer *client_layer);
78856 -};
78857 +} __no_const;
78858
78859 /* Link Setup Parameters for CAIF-Links. */
78860 struct cfctrl_link_param {
78861 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
78862 struct cfctrl {
78863 struct cfsrvl serv;
78864 struct cfctrl_rsp res;
78865 - atomic_t req_seq_no;
78866 - atomic_t rsp_seq_no;
78867 + atomic_unchecked_t req_seq_no;
78868 + atomic_unchecked_t rsp_seq_no;
78869 struct list_head list;
78870 /* Protects from simultaneous access to first_req list */
78871 spinlock_t info_list_lock;
78872 diff --git a/include/net/flow.h b/include/net/flow.h
78873 index 628e11b..4c475df 100644
78874 --- a/include/net/flow.h
78875 +++ b/include/net/flow.h
78876 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
78877
78878 extern void flow_cache_flush(void);
78879 extern void flow_cache_flush_deferred(void);
78880 -extern atomic_t flow_cache_genid;
78881 +extern atomic_unchecked_t flow_cache_genid;
78882
78883 #endif
78884 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
78885 index 93024a4..eeb6b6e 100644
78886 --- a/include/net/genetlink.h
78887 +++ b/include/net/genetlink.h
78888 @@ -119,7 +119,7 @@ struct genl_ops {
78889 struct netlink_callback *cb);
78890 int (*done)(struct netlink_callback *cb);
78891 struct list_head ops_list;
78892 -};
78893 +} __do_const;
78894
78895 extern int genl_register_family(struct genl_family *family);
78896 extern int genl_register_family_with_ops(struct genl_family *family,
78897 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
78898 index 734d9b5..48a9a4b 100644
78899 --- a/include/net/gro_cells.h
78900 +++ b/include/net/gro_cells.h
78901 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
78902 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
78903
78904 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
78905 - atomic_long_inc(&dev->rx_dropped);
78906 + atomic_long_inc_unchecked(&dev->rx_dropped);
78907 kfree_skb(skb);
78908 return;
78909 }
78910 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
78911 index de2c785..0588a6b 100644
78912 --- a/include/net/inet_connection_sock.h
78913 +++ b/include/net/inet_connection_sock.h
78914 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
78915 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
78916 int (*bind_conflict)(const struct sock *sk,
78917 const struct inet_bind_bucket *tb, bool relax);
78918 -};
78919 +} __do_const;
78920
78921 /** inet_connection_sock - INET connection oriented sock
78922 *
78923 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
78924 index 53f464d..0bd0b49 100644
78925 --- a/include/net/inetpeer.h
78926 +++ b/include/net/inetpeer.h
78927 @@ -47,8 +47,8 @@ struct inet_peer {
78928 */
78929 union {
78930 struct {
78931 - atomic_t rid; /* Frag reception counter */
78932 - atomic_t ip_id_count; /* IP ID for the next packet */
78933 + atomic_unchecked_t rid; /* Frag reception counter */
78934 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
78935 };
78936 struct rcu_head rcu;
78937 struct inet_peer *gc_next;
78938 @@ -178,16 +178,13 @@ static inline void inet_peer_refcheck(const struct inet_peer *p)
78939 /* can be called with or without local BH being disabled */
78940 static inline int inet_getid(struct inet_peer *p, int more)
78941 {
78942 - int old, new;
78943 + int id;
78944 more++;
78945 inet_peer_refcheck(p);
78946 - do {
78947 - old = atomic_read(&p->ip_id_count);
78948 - new = old + more;
78949 - if (!new)
78950 - new = 1;
78951 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
78952 - return new;
78953 + id = atomic_add_return_unchecked(more, &p->ip_id_count);
78954 + if (!id)
78955 + id = atomic_inc_return_unchecked(&p->ip_id_count);
78956 + return id;
78957 }
78958
78959 #endif /* _NET_INETPEER_H */
78960 diff --git a/include/net/ip.h b/include/net/ip.h
78961 index a68f838..74518ab 100644
78962 --- a/include/net/ip.h
78963 +++ b/include/net/ip.h
78964 @@ -202,7 +202,7 @@ extern struct local_ports {
78965 } sysctl_local_ports;
78966 extern void inet_get_local_port_range(int *low, int *high);
78967
78968 -extern unsigned long *sysctl_local_reserved_ports;
78969 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
78970 static inline int inet_is_reserved_local_port(int port)
78971 {
78972 return test_bit(port, sysctl_local_reserved_ports);
78973 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
78974 index e49db91..76a81de 100644
78975 --- a/include/net/ip_fib.h
78976 +++ b/include/net/ip_fib.h
78977 @@ -167,7 +167,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
78978
78979 #define FIB_RES_SADDR(net, res) \
78980 ((FIB_RES_NH(res).nh_saddr_genid == \
78981 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
78982 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
78983 FIB_RES_NH(res).nh_saddr : \
78984 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
78985 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
78986 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
78987 index 4c062cc..3562c31 100644
78988 --- a/include/net/ip_vs.h
78989 +++ b/include/net/ip_vs.h
78990 @@ -612,7 +612,7 @@ struct ip_vs_conn {
78991 struct ip_vs_conn *control; /* Master control connection */
78992 atomic_t n_control; /* Number of controlled ones */
78993 struct ip_vs_dest *dest; /* real server */
78994 - atomic_t in_pkts; /* incoming packet counter */
78995 + atomic_unchecked_t in_pkts; /* incoming packet counter */
78996
78997 /* packet transmitter for different forwarding methods. If it
78998 mangles the packet, it must return NF_DROP or better NF_STOLEN,
78999 @@ -761,7 +761,7 @@ struct ip_vs_dest {
79000 __be16 port; /* port number of the server */
79001 union nf_inet_addr addr; /* IP address of the server */
79002 volatile unsigned int flags; /* dest status flags */
79003 - atomic_t conn_flags; /* flags to copy to conn */
79004 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
79005 atomic_t weight; /* server weight */
79006
79007 atomic_t refcnt; /* reference counter */
79008 @@ -1013,11 +1013,11 @@ struct netns_ipvs {
79009 /* ip_vs_lblc */
79010 int sysctl_lblc_expiration;
79011 struct ctl_table_header *lblc_ctl_header;
79012 - struct ctl_table *lblc_ctl_table;
79013 + ctl_table_no_const *lblc_ctl_table;
79014 /* ip_vs_lblcr */
79015 int sysctl_lblcr_expiration;
79016 struct ctl_table_header *lblcr_ctl_header;
79017 - struct ctl_table *lblcr_ctl_table;
79018 + ctl_table_no_const *lblcr_ctl_table;
79019 /* ip_vs_est */
79020 struct list_head est_list; /* estimator list */
79021 spinlock_t est_lock;
79022 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
79023 index 80ffde3..968b0f4 100644
79024 --- a/include/net/irda/ircomm_tty.h
79025 +++ b/include/net/irda/ircomm_tty.h
79026 @@ -35,6 +35,7 @@
79027 #include <linux/termios.h>
79028 #include <linux/timer.h>
79029 #include <linux/tty.h> /* struct tty_struct */
79030 +#include <asm/local.h>
79031
79032 #include <net/irda/irias_object.h>
79033 #include <net/irda/ircomm_core.h>
79034 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
79035 index 714cc9a..ea05f3e 100644
79036 --- a/include/net/iucv/af_iucv.h
79037 +++ b/include/net/iucv/af_iucv.h
79038 @@ -149,7 +149,7 @@ struct iucv_skb_cb {
79039 struct iucv_sock_list {
79040 struct hlist_head head;
79041 rwlock_t lock;
79042 - atomic_t autobind_name;
79043 + atomic_unchecked_t autobind_name;
79044 };
79045
79046 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
79047 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
79048 index df83f69..9b640b8 100644
79049 --- a/include/net/llc_c_ac.h
79050 +++ b/include/net/llc_c_ac.h
79051 @@ -87,7 +87,7 @@
79052 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
79053 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
79054
79055 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
79056 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
79057
79058 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
79059 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
79060 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
79061 index 6ca3113..f8026dd 100644
79062 --- a/include/net/llc_c_ev.h
79063 +++ b/include/net/llc_c_ev.h
79064 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
79065 return (struct llc_conn_state_ev *)skb->cb;
79066 }
79067
79068 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
79069 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
79070 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
79071 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
79072
79073 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
79074 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
79075 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
79076 index 0e79cfb..f46db31 100644
79077 --- a/include/net/llc_c_st.h
79078 +++ b/include/net/llc_c_st.h
79079 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
79080 u8 next_state;
79081 llc_conn_ev_qfyr_t *ev_qualifiers;
79082 llc_conn_action_t *ev_actions;
79083 -};
79084 +} __do_const;
79085
79086 struct llc_conn_state {
79087 u8 current_state;
79088 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
79089 index 37a3bbd..55a4241 100644
79090 --- a/include/net/llc_s_ac.h
79091 +++ b/include/net/llc_s_ac.h
79092 @@ -23,7 +23,7 @@
79093 #define SAP_ACT_TEST_IND 9
79094
79095 /* All action functions must look like this */
79096 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
79097 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
79098
79099 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
79100 struct sk_buff *skb);
79101 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
79102 index 567c681..cd73ac0 100644
79103 --- a/include/net/llc_s_st.h
79104 +++ b/include/net/llc_s_st.h
79105 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
79106 llc_sap_ev_t ev;
79107 u8 next_state;
79108 llc_sap_action_t *ev_actions;
79109 -};
79110 +} __do_const;
79111
79112 struct llc_sap_state {
79113 u8 curr_state;
79114 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
79115 index 885898a..cdace34 100644
79116 --- a/include/net/mac80211.h
79117 +++ b/include/net/mac80211.h
79118 @@ -4205,7 +4205,7 @@ struct rate_control_ops {
79119 void (*add_sta_debugfs)(void *priv, void *priv_sta,
79120 struct dentry *dir);
79121 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
79122 -};
79123 +} __do_const;
79124
79125 static inline int rate_supported(struct ieee80211_sta *sta,
79126 enum ieee80211_band band,
79127 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
79128 index 7e748ad..5c6229b 100644
79129 --- a/include/net/neighbour.h
79130 +++ b/include/net/neighbour.h
79131 @@ -123,7 +123,7 @@ struct neigh_ops {
79132 void (*error_report)(struct neighbour *, struct sk_buff *);
79133 int (*output)(struct neighbour *, struct sk_buff *);
79134 int (*connected_output)(struct neighbour *, struct sk_buff *);
79135 -};
79136 +} __do_const;
79137
79138 struct pneigh_entry {
79139 struct pneigh_entry *next;
79140 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
79141 index b176978..ea169f4 100644
79142 --- a/include/net/net_namespace.h
79143 +++ b/include/net/net_namespace.h
79144 @@ -117,7 +117,7 @@ struct net {
79145 #endif
79146 struct netns_ipvs *ipvs;
79147 struct sock *diag_nlsk;
79148 - atomic_t rt_genid;
79149 + atomic_unchecked_t rt_genid;
79150 };
79151
79152 /*
79153 @@ -274,7 +274,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
79154 #define __net_init __init
79155 #define __net_exit __exit_refok
79156 #define __net_initdata __initdata
79157 +#ifdef CONSTIFY_PLUGIN
79158 #define __net_initconst __initconst
79159 +#else
79160 +#define __net_initconst __initdata
79161 +#endif
79162 #endif
79163
79164 struct pernet_operations {
79165 @@ -284,7 +288,7 @@ struct pernet_operations {
79166 void (*exit_batch)(struct list_head *net_exit_list);
79167 int *id;
79168 size_t size;
79169 -};
79170 +} __do_const;
79171
79172 /*
79173 * Use these carefully. If you implement a network device and it
79174 @@ -332,12 +336,12 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
79175
79176 static inline int rt_genid(struct net *net)
79177 {
79178 - return atomic_read(&net->rt_genid);
79179 + return atomic_read_unchecked(&net->rt_genid);
79180 }
79181
79182 static inline void rt_genid_bump(struct net *net)
79183 {
79184 - atomic_inc(&net->rt_genid);
79185 + atomic_inc_unchecked(&net->rt_genid);
79186 }
79187
79188 #endif /* __NET_NET_NAMESPACE_H */
79189 diff --git a/include/net/netdma.h b/include/net/netdma.h
79190 index 8ba8ce2..99b7fff 100644
79191 --- a/include/net/netdma.h
79192 +++ b/include/net/netdma.h
79193 @@ -24,7 +24,7 @@
79194 #include <linux/dmaengine.h>
79195 #include <linux/skbuff.h>
79196
79197 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
79198 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
79199 struct sk_buff *skb, int offset, struct iovec *to,
79200 size_t len, struct dma_pinned_list *pinned_list);
79201
79202 diff --git a/include/net/netlink.h b/include/net/netlink.h
79203 index 9690b0f..87aded7 100644
79204 --- a/include/net/netlink.h
79205 +++ b/include/net/netlink.h
79206 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
79207 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
79208 {
79209 if (mark)
79210 - skb_trim(skb, (unsigned char *) mark - skb->data);
79211 + skb_trim(skb, (const unsigned char *) mark - skb->data);
79212 }
79213
79214 /**
79215 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
79216 index c9c0c53..53f24c3 100644
79217 --- a/include/net/netns/conntrack.h
79218 +++ b/include/net/netns/conntrack.h
79219 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
79220 struct nf_proto_net {
79221 #ifdef CONFIG_SYSCTL
79222 struct ctl_table_header *ctl_table_header;
79223 - struct ctl_table *ctl_table;
79224 + ctl_table_no_const *ctl_table;
79225 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
79226 struct ctl_table_header *ctl_compat_header;
79227 - struct ctl_table *ctl_compat_table;
79228 + ctl_table_no_const *ctl_compat_table;
79229 #endif
79230 #endif
79231 unsigned int users;
79232 @@ -58,7 +58,7 @@ struct nf_ip_net {
79233 struct nf_icmp_net icmpv6;
79234 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
79235 struct ctl_table_header *ctl_table_header;
79236 - struct ctl_table *ctl_table;
79237 + ctl_table_no_const *ctl_table;
79238 #endif
79239 };
79240
79241 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
79242 index 2ba9de8..47bd6c7 100644
79243 --- a/include/net/netns/ipv4.h
79244 +++ b/include/net/netns/ipv4.h
79245 @@ -67,7 +67,7 @@ struct netns_ipv4 {
79246 kgid_t sysctl_ping_group_range[2];
79247 long sysctl_tcp_mem[3];
79248
79249 - atomic_t dev_addr_genid;
79250 + atomic_unchecked_t dev_addr_genid;
79251
79252 #ifdef CONFIG_IP_MROUTE
79253 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
79254 diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
79255 index 005e2c2..023d340 100644
79256 --- a/include/net/netns/ipv6.h
79257 +++ b/include/net/netns/ipv6.h
79258 @@ -71,7 +71,7 @@ struct netns_ipv6 {
79259 struct fib_rules_ops *mr6_rules_ops;
79260 #endif
79261 #endif
79262 - atomic_t dev_addr_genid;
79263 + atomic_unchecked_t dev_addr_genid;
79264 };
79265
79266 #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
79267 diff --git a/include/net/protocol.h b/include/net/protocol.h
79268 index 047c047..b9dad15 100644
79269 --- a/include/net/protocol.h
79270 +++ b/include/net/protocol.h
79271 @@ -44,7 +44,7 @@ struct net_protocol {
79272 void (*err_handler)(struct sk_buff *skb, u32 info);
79273 unsigned int no_policy:1,
79274 netns_ok:1;
79275 -};
79276 +} __do_const;
79277
79278 #if IS_ENABLED(CONFIG_IPV6)
79279 struct inet6_protocol {
79280 @@ -57,7 +57,7 @@ struct inet6_protocol {
79281 u8 type, u8 code, int offset,
79282 __be32 info);
79283 unsigned int flags; /* INET6_PROTO_xxx */
79284 -};
79285 +} __do_const;
79286
79287 #define INET6_PROTO_NOPOLICY 0x1
79288 #define INET6_PROTO_FINAL 0x2
79289 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
79290 index 7026648..584cc8c 100644
79291 --- a/include/net/rtnetlink.h
79292 +++ b/include/net/rtnetlink.h
79293 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
79294 const struct net_device *dev);
79295 unsigned int (*get_num_tx_queues)(void);
79296 unsigned int (*get_num_rx_queues)(void);
79297 -};
79298 +} __do_const;
79299
79300 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
79301 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
79302 diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
79303 index cd89510..d67810f 100644
79304 --- a/include/net/sctp/sctp.h
79305 +++ b/include/net/sctp/sctp.h
79306 @@ -330,9 +330,9 @@ do { \
79307
79308 #else /* SCTP_DEBUG */
79309
79310 -#define SCTP_DEBUG_PRINTK(whatever...)
79311 -#define SCTP_DEBUG_PRINTK_CONT(fmt, args...)
79312 -#define SCTP_DEBUG_PRINTK_IPADDR(whatever...)
79313 +#define SCTP_DEBUG_PRINTK(whatever...) do {} while (0)
79314 +#define SCTP_DEBUG_PRINTK_CONT(fmt, args...) do {} while (0)
79315 +#define SCTP_DEBUG_PRINTK_IPADDR(whatever...) do {} while (0)
79316 #define SCTP_ENABLE_DEBUG
79317 #define SCTP_DISABLE_DEBUG
79318 #define SCTP_ASSERT(expr, str, func)
79319 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
79320 index 2a82d13..62a31c2 100644
79321 --- a/include/net/sctp/sm.h
79322 +++ b/include/net/sctp/sm.h
79323 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
79324 typedef struct {
79325 sctp_state_fn_t *fn;
79326 const char *name;
79327 -} sctp_sm_table_entry_t;
79328 +} __do_const sctp_sm_table_entry_t;
79329
79330 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
79331 * currently in use.
79332 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
79333 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
79334
79335 /* Extern declarations for major data structures. */
79336 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
79337 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
79338
79339
79340 /* Get the size of a DATA chunk payload. */
79341 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
79342 index 1bd4c41..9250b5b 100644
79343 --- a/include/net/sctp/structs.h
79344 +++ b/include/net/sctp/structs.h
79345 @@ -516,7 +516,7 @@ struct sctp_pf {
79346 struct sctp_association *asoc);
79347 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
79348 struct sctp_af *af;
79349 -};
79350 +} __do_const;
79351
79352
79353 /* Structure to track chunk fragments that have been acked, but peer
79354 diff --git a/include/net/sock.h b/include/net/sock.h
79355 index 66772cf..25bc45b 100644
79356 --- a/include/net/sock.h
79357 +++ b/include/net/sock.h
79358 @@ -325,7 +325,7 @@ struct sock {
79359 #ifdef CONFIG_RPS
79360 __u32 sk_rxhash;
79361 #endif
79362 - atomic_t sk_drops;
79363 + atomic_unchecked_t sk_drops;
79364 int sk_rcvbuf;
79365
79366 struct sk_filter __rcu *sk_filter;
79367 @@ -1797,7 +1797,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
79368 }
79369
79370 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
79371 - char __user *from, char *to,
79372 + char __user *from, unsigned char *to,
79373 int copy, int offset)
79374 {
79375 if (skb->ip_summed == CHECKSUM_NONE) {
79376 @@ -2056,7 +2056,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
79377 }
79378 }
79379
79380 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
79381 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
79382
79383 /**
79384 * sk_page_frag - return an appropriate page_frag
79385 diff --git a/include/net/tcp.h b/include/net/tcp.h
79386 index 5bba80f..8520a82 100644
79387 --- a/include/net/tcp.h
79388 +++ b/include/net/tcp.h
79389 @@ -524,7 +524,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
79390 extern void tcp_xmit_retransmit_queue(struct sock *);
79391 extern void tcp_simple_retransmit(struct sock *);
79392 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
79393 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
79394 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
79395
79396 extern void tcp_send_probe0(struct sock *);
79397 extern void tcp_send_partial(struct sock *);
79398 @@ -697,8 +697,8 @@ struct tcp_skb_cb {
79399 struct inet6_skb_parm h6;
79400 #endif
79401 } header; /* For incoming frames */
79402 - __u32 seq; /* Starting sequence number */
79403 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
79404 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
79405 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
79406 __u32 when; /* used to compute rtt's */
79407 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
79408
79409 @@ -712,7 +712,7 @@ struct tcp_skb_cb {
79410
79411 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
79412 /* 1 byte hole */
79413 - __u32 ack_seq; /* Sequence number ACK'd */
79414 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
79415 };
79416
79417 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
79418 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
79419 index 94ce082..62b278d 100644
79420 --- a/include/net/xfrm.h
79421 +++ b/include/net/xfrm.h
79422 @@ -305,7 +305,7 @@ struct xfrm_policy_afinfo {
79423 struct net_device *dev,
79424 const struct flowi *fl);
79425 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
79426 -};
79427 +} __do_const;
79428
79429 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
79430 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
79431 @@ -341,7 +341,7 @@ struct xfrm_state_afinfo {
79432 struct sk_buff *skb);
79433 int (*transport_finish)(struct sk_buff *skb,
79434 int async);
79435 -};
79436 +} __do_const;
79437
79438 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
79439 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
79440 @@ -424,7 +424,7 @@ struct xfrm_mode {
79441 struct module *owner;
79442 unsigned int encap;
79443 int flags;
79444 -};
79445 +} __do_const;
79446
79447 /* Flags for xfrm_mode. */
79448 enum {
79449 @@ -521,7 +521,7 @@ struct xfrm_policy {
79450 struct timer_list timer;
79451
79452 struct flow_cache_object flo;
79453 - atomic_t genid;
79454 + atomic_unchecked_t genid;
79455 u32 priority;
79456 u32 index;
79457 struct xfrm_mark mark;
79458 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
79459 index 1a046b1..ee0bef0 100644
79460 --- a/include/rdma/iw_cm.h
79461 +++ b/include/rdma/iw_cm.h
79462 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
79463 int backlog);
79464
79465 int (*destroy_listen)(struct iw_cm_id *cm_id);
79466 -};
79467 +} __no_const;
79468
79469 /**
79470 * iw_create_cm_id - Create an IW CM identifier.
79471 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
79472 index e1379b4..67eafbe 100644
79473 --- a/include/scsi/libfc.h
79474 +++ b/include/scsi/libfc.h
79475 @@ -762,6 +762,7 @@ struct libfc_function_template {
79476 */
79477 void (*disc_stop_final) (struct fc_lport *);
79478 };
79479 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
79480
79481 /**
79482 * struct fc_disc - Discovery context
79483 @@ -866,7 +867,7 @@ struct fc_lport {
79484 struct fc_vport *vport;
79485
79486 /* Operational Information */
79487 - struct libfc_function_template tt;
79488 + libfc_function_template_no_const tt;
79489 u8 link_up;
79490 u8 qfull;
79491 enum fc_lport_state state;
79492 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
79493 index cc64587..608f523 100644
79494 --- a/include/scsi/scsi_device.h
79495 +++ b/include/scsi/scsi_device.h
79496 @@ -171,9 +171,9 @@ struct scsi_device {
79497 unsigned int max_device_blocked; /* what device_blocked counts down from */
79498 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
79499
79500 - atomic_t iorequest_cnt;
79501 - atomic_t iodone_cnt;
79502 - atomic_t ioerr_cnt;
79503 + atomic_unchecked_t iorequest_cnt;
79504 + atomic_unchecked_t iodone_cnt;
79505 + atomic_unchecked_t ioerr_cnt;
79506
79507 struct device sdev_gendev,
79508 sdev_dev;
79509 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
79510 index b797e8f..8e2c3aa 100644
79511 --- a/include/scsi/scsi_transport_fc.h
79512 +++ b/include/scsi/scsi_transport_fc.h
79513 @@ -751,7 +751,8 @@ struct fc_function_template {
79514 unsigned long show_host_system_hostname:1;
79515
79516 unsigned long disable_target_scan:1;
79517 -};
79518 +} __do_const;
79519 +typedef struct fc_function_template __no_const fc_function_template_no_const;
79520
79521
79522 /**
79523 diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
79524 index 9031a26..750d592 100644
79525 --- a/include/sound/compress_driver.h
79526 +++ b/include/sound/compress_driver.h
79527 @@ -128,7 +128,7 @@ struct snd_compr_ops {
79528 struct snd_compr_caps *caps);
79529 int (*get_codec_caps) (struct snd_compr_stream *stream,
79530 struct snd_compr_codec_caps *codec);
79531 -};
79532 +} __no_const;
79533
79534 /**
79535 * struct snd_compr: Compressed device
79536 diff --git a/include/sound/soc.h b/include/sound/soc.h
79537 index 85c1522..f44bad1 100644
79538 --- a/include/sound/soc.h
79539 +++ b/include/sound/soc.h
79540 @@ -781,7 +781,7 @@ struct snd_soc_codec_driver {
79541 /* probe ordering - for components with runtime dependencies */
79542 int probe_order;
79543 int remove_order;
79544 -};
79545 +} __do_const;
79546
79547 /* SoC platform interface */
79548 struct snd_soc_platform_driver {
79549 @@ -827,7 +827,7 @@ struct snd_soc_platform_driver {
79550 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
79551 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
79552 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
79553 -};
79554 +} __do_const;
79555
79556 struct snd_soc_platform {
79557 const char *name;
79558 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
79559 index 4ea4f98..a63629b 100644
79560 --- a/include/target/target_core_base.h
79561 +++ b/include/target/target_core_base.h
79562 @@ -653,7 +653,7 @@ struct se_device {
79563 spinlock_t stats_lock;
79564 /* Active commands on this virtual SE device */
79565 atomic_t simple_cmds;
79566 - atomic_t dev_ordered_id;
79567 + atomic_unchecked_t dev_ordered_id;
79568 atomic_t dev_ordered_sync;
79569 atomic_t dev_qf_count;
79570 int export_count;
79571 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
79572 new file mode 100644
79573 index 0000000..fb634b7
79574 --- /dev/null
79575 +++ b/include/trace/events/fs.h
79576 @@ -0,0 +1,53 @@
79577 +#undef TRACE_SYSTEM
79578 +#define TRACE_SYSTEM fs
79579 +
79580 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
79581 +#define _TRACE_FS_H
79582 +
79583 +#include <linux/fs.h>
79584 +#include <linux/tracepoint.h>
79585 +
79586 +TRACE_EVENT(do_sys_open,
79587 +
79588 + TP_PROTO(const char *filename, int flags, int mode),
79589 +
79590 + TP_ARGS(filename, flags, mode),
79591 +
79592 + TP_STRUCT__entry(
79593 + __string( filename, filename )
79594 + __field( int, flags )
79595 + __field( int, mode )
79596 + ),
79597 +
79598 + TP_fast_assign(
79599 + __assign_str(filename, filename);
79600 + __entry->flags = flags;
79601 + __entry->mode = mode;
79602 + ),
79603 +
79604 + TP_printk("\"%s\" %x %o",
79605 + __get_str(filename), __entry->flags, __entry->mode)
79606 +);
79607 +
79608 +TRACE_EVENT(open_exec,
79609 +
79610 + TP_PROTO(const char *filename),
79611 +
79612 + TP_ARGS(filename),
79613 +
79614 + TP_STRUCT__entry(
79615 + __string( filename, filename )
79616 + ),
79617 +
79618 + TP_fast_assign(
79619 + __assign_str(filename, filename);
79620 + ),
79621 +
79622 + TP_printk("\"%s\"",
79623 + __get_str(filename))
79624 +);
79625 +
79626 +#endif /* _TRACE_FS_H */
79627 +
79628 +/* This part must be outside protection */
79629 +#include <trace/define_trace.h>
79630 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
79631 index 1c09820..7f5ec79 100644
79632 --- a/include/trace/events/irq.h
79633 +++ b/include/trace/events/irq.h
79634 @@ -36,7 +36,7 @@ struct softirq_action;
79635 */
79636 TRACE_EVENT(irq_handler_entry,
79637
79638 - TP_PROTO(int irq, struct irqaction *action),
79639 + TP_PROTO(int irq, const struct irqaction *action),
79640
79641 TP_ARGS(irq, action),
79642
79643 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
79644 */
79645 TRACE_EVENT(irq_handler_exit,
79646
79647 - TP_PROTO(int irq, struct irqaction *action, int ret),
79648 + TP_PROTO(int irq, const struct irqaction *action, int ret),
79649
79650 TP_ARGS(irq, action, ret),
79651
79652 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
79653 index 7caf44c..23c6f27 100644
79654 --- a/include/uapi/linux/a.out.h
79655 +++ b/include/uapi/linux/a.out.h
79656 @@ -39,6 +39,14 @@ enum machine_type {
79657 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
79658 };
79659
79660 +/* Constants for the N_FLAGS field */
79661 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
79662 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
79663 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
79664 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
79665 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
79666 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
79667 +
79668 #if !defined (N_MAGIC)
79669 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
79670 #endif
79671 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
79672 index d876736..ccce5c0 100644
79673 --- a/include/uapi/linux/byteorder/little_endian.h
79674 +++ b/include/uapi/linux/byteorder/little_endian.h
79675 @@ -42,51 +42,51 @@
79676
79677 static inline __le64 __cpu_to_le64p(const __u64 *p)
79678 {
79679 - return (__force __le64)*p;
79680 + return (__force const __le64)*p;
79681 }
79682 -static inline __u64 __le64_to_cpup(const __le64 *p)
79683 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
79684 {
79685 - return (__force __u64)*p;
79686 + return (__force const __u64)*p;
79687 }
79688 static inline __le32 __cpu_to_le32p(const __u32 *p)
79689 {
79690 - return (__force __le32)*p;
79691 + return (__force const __le32)*p;
79692 }
79693 static inline __u32 __le32_to_cpup(const __le32 *p)
79694 {
79695 - return (__force __u32)*p;
79696 + return (__force const __u32)*p;
79697 }
79698 static inline __le16 __cpu_to_le16p(const __u16 *p)
79699 {
79700 - return (__force __le16)*p;
79701 + return (__force const __le16)*p;
79702 }
79703 static inline __u16 __le16_to_cpup(const __le16 *p)
79704 {
79705 - return (__force __u16)*p;
79706 + return (__force const __u16)*p;
79707 }
79708 static inline __be64 __cpu_to_be64p(const __u64 *p)
79709 {
79710 - return (__force __be64)__swab64p(p);
79711 + return (__force const __be64)__swab64p(p);
79712 }
79713 static inline __u64 __be64_to_cpup(const __be64 *p)
79714 {
79715 - return __swab64p((__u64 *)p);
79716 + return __swab64p((const __u64 *)p);
79717 }
79718 static inline __be32 __cpu_to_be32p(const __u32 *p)
79719 {
79720 - return (__force __be32)__swab32p(p);
79721 + return (__force const __be32)__swab32p(p);
79722 }
79723 -static inline __u32 __be32_to_cpup(const __be32 *p)
79724 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
79725 {
79726 - return __swab32p((__u32 *)p);
79727 + return __swab32p((const __u32 *)p);
79728 }
79729 static inline __be16 __cpu_to_be16p(const __u16 *p)
79730 {
79731 - return (__force __be16)__swab16p(p);
79732 + return (__force const __be16)__swab16p(p);
79733 }
79734 static inline __u16 __be16_to_cpup(const __be16 *p)
79735 {
79736 - return __swab16p((__u16 *)p);
79737 + return __swab16p((const __u16 *)p);
79738 }
79739 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
79740 #define __le64_to_cpus(x) do { (void)(x); } while (0)
79741 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
79742 index ef6103b..d4e65dd 100644
79743 --- a/include/uapi/linux/elf.h
79744 +++ b/include/uapi/linux/elf.h
79745 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
79746 #define PT_GNU_EH_FRAME 0x6474e550
79747
79748 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
79749 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
79750 +
79751 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
79752 +
79753 +/* Constants for the e_flags field */
79754 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
79755 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
79756 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
79757 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
79758 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
79759 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
79760
79761 /*
79762 * Extended Numbering
79763 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
79764 #define DT_DEBUG 21
79765 #define DT_TEXTREL 22
79766 #define DT_JMPREL 23
79767 +#define DT_FLAGS 30
79768 + #define DF_TEXTREL 0x00000004
79769 #define DT_ENCODING 32
79770 #define OLD_DT_LOOS 0x60000000
79771 #define DT_LOOS 0x6000000d
79772 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
79773 #define PF_W 0x2
79774 #define PF_X 0x1
79775
79776 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
79777 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
79778 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
79779 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
79780 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
79781 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
79782 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
79783 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
79784 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
79785 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
79786 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
79787 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
79788 +
79789 typedef struct elf32_phdr{
79790 Elf32_Word p_type;
79791 Elf32_Off p_offset;
79792 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
79793 #define EI_OSABI 7
79794 #define EI_PAD 8
79795
79796 +#define EI_PAX 14
79797 +
79798 #define ELFMAG0 0x7f /* EI_MAG */
79799 #define ELFMAG1 'E'
79800 #define ELFMAG2 'L'
79801 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
79802 index aa169c4..6a2771d 100644
79803 --- a/include/uapi/linux/personality.h
79804 +++ b/include/uapi/linux/personality.h
79805 @@ -30,6 +30,7 @@ enum {
79806 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
79807 ADDR_NO_RANDOMIZE | \
79808 ADDR_COMPAT_LAYOUT | \
79809 + ADDR_LIMIT_3GB | \
79810 MMAP_PAGE_ZERO)
79811
79812 /*
79813 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
79814 index 7530e74..e714828 100644
79815 --- a/include/uapi/linux/screen_info.h
79816 +++ b/include/uapi/linux/screen_info.h
79817 @@ -43,7 +43,8 @@ struct screen_info {
79818 __u16 pages; /* 0x32 */
79819 __u16 vesa_attributes; /* 0x34 */
79820 __u32 capabilities; /* 0x36 */
79821 - __u8 _reserved[6]; /* 0x3a */
79822 + __u16 vesapm_size; /* 0x3a */
79823 + __u8 _reserved[4]; /* 0x3c */
79824 } __attribute__((packed));
79825
79826 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
79827 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
79828 index 0e011eb..82681b1 100644
79829 --- a/include/uapi/linux/swab.h
79830 +++ b/include/uapi/linux/swab.h
79831 @@ -43,7 +43,7 @@
79832 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
79833 */
79834
79835 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
79836 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
79837 {
79838 #ifdef __HAVE_BUILTIN_BSWAP16__
79839 return __builtin_bswap16(val);
79840 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
79841 #endif
79842 }
79843
79844 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
79845 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
79846 {
79847 #ifdef __HAVE_BUILTIN_BSWAP32__
79848 return __builtin_bswap32(val);
79849 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
79850 #endif
79851 }
79852
79853 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
79854 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
79855 {
79856 #ifdef __HAVE_BUILTIN_BSWAP64__
79857 return __builtin_bswap64(val);
79858 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
79859 index 6d67213..8dab561 100644
79860 --- a/include/uapi/linux/sysctl.h
79861 +++ b/include/uapi/linux/sysctl.h
79862 @@ -155,7 +155,11 @@ enum
79863 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
79864 };
79865
79866 -
79867 +#ifdef CONFIG_PAX_SOFTMODE
79868 +enum {
79869 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
79870 +};
79871 +#endif
79872
79873 /* CTL_VM names: */
79874 enum
79875 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
79876 index e4629b9..6958086 100644
79877 --- a/include/uapi/linux/xattr.h
79878 +++ b/include/uapi/linux/xattr.h
79879 @@ -63,5 +63,9 @@
79880 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
79881 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
79882
79883 +/* User namespace */
79884 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
79885 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
79886 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
79887
79888 #endif /* _UAPI_LINUX_XATTR_H */
79889 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
79890 index f9466fa..f4e2b81 100644
79891 --- a/include/video/udlfb.h
79892 +++ b/include/video/udlfb.h
79893 @@ -53,10 +53,10 @@ struct dlfb_data {
79894 u32 pseudo_palette[256];
79895 int blank_mode; /*one of FB_BLANK_ */
79896 /* blit-only rendering path metrics, exposed through sysfs */
79897 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
79898 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
79899 - atomic_t bytes_sent; /* to usb, after compression including overhead */
79900 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
79901 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
79902 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
79903 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
79904 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
79905 };
79906
79907 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
79908 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
79909 index 1a91850..28573f8 100644
79910 --- a/include/video/uvesafb.h
79911 +++ b/include/video/uvesafb.h
79912 @@ -122,6 +122,7 @@ struct uvesafb_par {
79913 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
79914 u8 pmi_setpal; /* PMI for palette changes */
79915 u16 *pmi_base; /* protected mode interface location */
79916 + u8 *pmi_code; /* protected mode code location */
79917 void *pmi_start;
79918 void *pmi_pal;
79919 u8 *vbe_state_orig; /*
79920 diff --git a/init/Kconfig b/init/Kconfig
79921 index 2d9b831..ae4c8ac 100644
79922 --- a/init/Kconfig
79923 +++ b/init/Kconfig
79924 @@ -1029,6 +1029,7 @@ endif # CGROUPS
79925
79926 config CHECKPOINT_RESTORE
79927 bool "Checkpoint/restore support" if EXPERT
79928 + depends on !GRKERNSEC
79929 default n
79930 help
79931 Enables additional kernel features in a sake of checkpoint/restore.
79932 @@ -1516,7 +1517,7 @@ config SLUB_DEBUG
79933
79934 config COMPAT_BRK
79935 bool "Disable heap randomization"
79936 - default y
79937 + default n
79938 help
79939 Randomizing heap placement makes heap exploits harder, but it
79940 also breaks ancient binaries (including anything libc5 based).
79941 @@ -1779,7 +1780,7 @@ config INIT_ALL_POSSIBLE
79942 config STOP_MACHINE
79943 bool
79944 default y
79945 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
79946 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
79947 help
79948 Need stop_machine() primitive.
79949
79950 diff --git a/init/Makefile b/init/Makefile
79951 index 7bc47ee..6da2dc7 100644
79952 --- a/init/Makefile
79953 +++ b/init/Makefile
79954 @@ -2,6 +2,9 @@
79955 # Makefile for the linux kernel.
79956 #
79957
79958 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
79959 +asflags-y := $(GCC_PLUGINS_AFLAGS)
79960 +
79961 obj-y := main.o version.o mounts.o
79962 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
79963 obj-y += noinitramfs.o
79964 diff --git a/init/do_mounts.c b/init/do_mounts.c
79965 index a2b49f2..03a0e17c 100644
79966 --- a/init/do_mounts.c
79967 +++ b/init/do_mounts.c
79968 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
79969 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
79970 {
79971 struct super_block *s;
79972 - int err = sys_mount(name, "/root", fs, flags, data);
79973 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
79974 if (err)
79975 return err;
79976
79977 - sys_chdir("/root");
79978 + sys_chdir((const char __force_user *)"/root");
79979 s = current->fs->pwd.dentry->d_sb;
79980 ROOT_DEV = s->s_dev;
79981 printk(KERN_INFO
79982 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
79983 va_start(args, fmt);
79984 vsprintf(buf, fmt, args);
79985 va_end(args);
79986 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
79987 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
79988 if (fd >= 0) {
79989 sys_ioctl(fd, FDEJECT, 0);
79990 sys_close(fd);
79991 }
79992 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
79993 - fd = sys_open("/dev/console", O_RDWR, 0);
79994 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
79995 if (fd >= 0) {
79996 sys_ioctl(fd, TCGETS, (long)&termios);
79997 termios.c_lflag &= ~ICANON;
79998 sys_ioctl(fd, TCSETSF, (long)&termios);
79999 - sys_read(fd, &c, 1);
80000 + sys_read(fd, (char __user *)&c, 1);
80001 termios.c_lflag |= ICANON;
80002 sys_ioctl(fd, TCSETSF, (long)&termios);
80003 sys_close(fd);
80004 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
80005 mount_root();
80006 out:
80007 devtmpfs_mount("dev");
80008 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
80009 - sys_chroot(".");
80010 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
80011 + sys_chroot((const char __force_user *)".");
80012 }
80013 diff --git a/init/do_mounts.h b/init/do_mounts.h
80014 index f5b978a..69dbfe8 100644
80015 --- a/init/do_mounts.h
80016 +++ b/init/do_mounts.h
80017 @@ -15,15 +15,15 @@ extern int root_mountflags;
80018
80019 static inline int create_dev(char *name, dev_t dev)
80020 {
80021 - sys_unlink(name);
80022 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
80023 + sys_unlink((char __force_user *)name);
80024 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
80025 }
80026
80027 #if BITS_PER_LONG == 32
80028 static inline u32 bstat(char *name)
80029 {
80030 struct stat64 stat;
80031 - if (sys_stat64(name, &stat) != 0)
80032 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
80033 return 0;
80034 if (!S_ISBLK(stat.st_mode))
80035 return 0;
80036 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
80037 static inline u32 bstat(char *name)
80038 {
80039 struct stat stat;
80040 - if (sys_newstat(name, &stat) != 0)
80041 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
80042 return 0;
80043 if (!S_ISBLK(stat.st_mode))
80044 return 0;
80045 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
80046 index 3e0878e..8a9d7a0 100644
80047 --- a/init/do_mounts_initrd.c
80048 +++ b/init/do_mounts_initrd.c
80049 @@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
80050 {
80051 sys_unshare(CLONE_FS | CLONE_FILES);
80052 /* stdin/stdout/stderr for /linuxrc */
80053 - sys_open("/dev/console", O_RDWR, 0);
80054 + sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
80055 sys_dup(0);
80056 sys_dup(0);
80057 /* move initrd over / and chdir/chroot in initrd root */
80058 - sys_chdir("/root");
80059 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
80060 - sys_chroot(".");
80061 + sys_chdir((const char __force_user *)"/root");
80062 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
80063 + sys_chroot((const char __force_user *)".");
80064 sys_setsid();
80065 return 0;
80066 }
80067 @@ -59,8 +59,8 @@ static void __init handle_initrd(void)
80068 create_dev("/dev/root.old", Root_RAM0);
80069 /* mount initrd on rootfs' /root */
80070 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
80071 - sys_mkdir("/old", 0700);
80072 - sys_chdir("/old");
80073 + sys_mkdir((const char __force_user *)"/old", 0700);
80074 + sys_chdir((const char __force_user *)"/old");
80075
80076 /* try loading default modules from initrd */
80077 load_default_modules();
80078 @@ -80,31 +80,31 @@ static void __init handle_initrd(void)
80079 current->flags &= ~PF_FREEZER_SKIP;
80080
80081 /* move initrd to rootfs' /old */
80082 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
80083 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
80084 /* switch root and cwd back to / of rootfs */
80085 - sys_chroot("..");
80086 + sys_chroot((const char __force_user *)"..");
80087
80088 if (new_decode_dev(real_root_dev) == Root_RAM0) {
80089 - sys_chdir("/old");
80090 + sys_chdir((const char __force_user *)"/old");
80091 return;
80092 }
80093
80094 - sys_chdir("/");
80095 + sys_chdir((const char __force_user *)"/");
80096 ROOT_DEV = new_decode_dev(real_root_dev);
80097 mount_root();
80098
80099 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
80100 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
80101 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
80102 if (!error)
80103 printk("okay\n");
80104 else {
80105 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
80106 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
80107 if (error == -ENOENT)
80108 printk("/initrd does not exist. Ignored.\n");
80109 else
80110 printk("failed\n");
80111 printk(KERN_NOTICE "Unmounting old root\n");
80112 - sys_umount("/old", MNT_DETACH);
80113 + sys_umount((char __force_user *)"/old", MNT_DETACH);
80114 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
80115 if (fd < 0) {
80116 error = fd;
80117 @@ -127,11 +127,11 @@ int __init initrd_load(void)
80118 * mounted in the normal path.
80119 */
80120 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
80121 - sys_unlink("/initrd.image");
80122 + sys_unlink((const char __force_user *)"/initrd.image");
80123 handle_initrd();
80124 return 1;
80125 }
80126 }
80127 - sys_unlink("/initrd.image");
80128 + sys_unlink((const char __force_user *)"/initrd.image");
80129 return 0;
80130 }
80131 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
80132 index 8cb6db5..d729f50 100644
80133 --- a/init/do_mounts_md.c
80134 +++ b/init/do_mounts_md.c
80135 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
80136 partitioned ? "_d" : "", minor,
80137 md_setup_args[ent].device_names);
80138
80139 - fd = sys_open(name, 0, 0);
80140 + fd = sys_open((char __force_user *)name, 0, 0);
80141 if (fd < 0) {
80142 printk(KERN_ERR "md: open failed - cannot start "
80143 "array %s\n", name);
80144 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
80145 * array without it
80146 */
80147 sys_close(fd);
80148 - fd = sys_open(name, 0, 0);
80149 + fd = sys_open((char __force_user *)name, 0, 0);
80150 sys_ioctl(fd, BLKRRPART, 0);
80151 }
80152 sys_close(fd);
80153 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
80154
80155 wait_for_device_probe();
80156
80157 - fd = sys_open("/dev/md0", 0, 0);
80158 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
80159 if (fd >= 0) {
80160 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
80161 sys_close(fd);
80162 diff --git a/init/init_task.c b/init/init_task.c
80163 index ba0a7f36..2bcf1d5 100644
80164 --- a/init/init_task.c
80165 +++ b/init/init_task.c
80166 @@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
80167 * Initial thread structure. Alignment of this is handled by a special
80168 * linker map entry.
80169 */
80170 +#ifdef CONFIG_X86
80171 +union thread_union init_thread_union __init_task_data;
80172 +#else
80173 union thread_union init_thread_union __init_task_data =
80174 { INIT_THREAD_INFO(init_task) };
80175 +#endif
80176 diff --git a/init/initramfs.c b/init/initramfs.c
80177 index a67ef9d..2d17ed9 100644
80178 --- a/init/initramfs.c
80179 +++ b/init/initramfs.c
80180 @@ -84,7 +84,7 @@ static void __init free_hash(void)
80181 }
80182 }
80183
80184 -static long __init do_utime(char *filename, time_t mtime)
80185 +static long __init do_utime(char __force_user *filename, time_t mtime)
80186 {
80187 struct timespec t[2];
80188
80189 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
80190 struct dir_entry *de, *tmp;
80191 list_for_each_entry_safe(de, tmp, &dir_list, list) {
80192 list_del(&de->list);
80193 - do_utime(de->name, de->mtime);
80194 + do_utime((char __force_user *)de->name, de->mtime);
80195 kfree(de->name);
80196 kfree(de);
80197 }
80198 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
80199 if (nlink >= 2) {
80200 char *old = find_link(major, minor, ino, mode, collected);
80201 if (old)
80202 - return (sys_link(old, collected) < 0) ? -1 : 1;
80203 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
80204 }
80205 return 0;
80206 }
80207 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
80208 {
80209 struct stat st;
80210
80211 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
80212 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
80213 if (S_ISDIR(st.st_mode))
80214 - sys_rmdir(path);
80215 + sys_rmdir((char __force_user *)path);
80216 else
80217 - sys_unlink(path);
80218 + sys_unlink((char __force_user *)path);
80219 }
80220 }
80221
80222 @@ -315,7 +315,7 @@ static int __init do_name(void)
80223 int openflags = O_WRONLY|O_CREAT;
80224 if (ml != 1)
80225 openflags |= O_TRUNC;
80226 - wfd = sys_open(collected, openflags, mode);
80227 + wfd = sys_open((char __force_user *)collected, openflags, mode);
80228
80229 if (wfd >= 0) {
80230 sys_fchown(wfd, uid, gid);
80231 @@ -327,17 +327,17 @@ static int __init do_name(void)
80232 }
80233 }
80234 } else if (S_ISDIR(mode)) {
80235 - sys_mkdir(collected, mode);
80236 - sys_chown(collected, uid, gid);
80237 - sys_chmod(collected, mode);
80238 + sys_mkdir((char __force_user *)collected, mode);
80239 + sys_chown((char __force_user *)collected, uid, gid);
80240 + sys_chmod((char __force_user *)collected, mode);
80241 dir_add(collected, mtime);
80242 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
80243 S_ISFIFO(mode) || S_ISSOCK(mode)) {
80244 if (maybe_link() == 0) {
80245 - sys_mknod(collected, mode, rdev);
80246 - sys_chown(collected, uid, gid);
80247 - sys_chmod(collected, mode);
80248 - do_utime(collected, mtime);
80249 + sys_mknod((char __force_user *)collected, mode, rdev);
80250 + sys_chown((char __force_user *)collected, uid, gid);
80251 + sys_chmod((char __force_user *)collected, mode);
80252 + do_utime((char __force_user *)collected, mtime);
80253 }
80254 }
80255 return 0;
80256 @@ -346,15 +346,15 @@ static int __init do_name(void)
80257 static int __init do_copy(void)
80258 {
80259 if (count >= body_len) {
80260 - sys_write(wfd, victim, body_len);
80261 + sys_write(wfd, (char __force_user *)victim, body_len);
80262 sys_close(wfd);
80263 - do_utime(vcollected, mtime);
80264 + do_utime((char __force_user *)vcollected, mtime);
80265 kfree(vcollected);
80266 eat(body_len);
80267 state = SkipIt;
80268 return 0;
80269 } else {
80270 - sys_write(wfd, victim, count);
80271 + sys_write(wfd, (char __force_user *)victim, count);
80272 body_len -= count;
80273 eat(count);
80274 return 1;
80275 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
80276 {
80277 collected[N_ALIGN(name_len) + body_len] = '\0';
80278 clean_path(collected, 0);
80279 - sys_symlink(collected + N_ALIGN(name_len), collected);
80280 - sys_lchown(collected, uid, gid);
80281 - do_utime(collected, mtime);
80282 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
80283 + sys_lchown((char __force_user *)collected, uid, gid);
80284 + do_utime((char __force_user *)collected, mtime);
80285 state = SkipIt;
80286 next_state = Reset;
80287 return 0;
80288 @@ -583,7 +583,7 @@ static int __init populate_rootfs(void)
80289 {
80290 char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
80291 if (err)
80292 - panic(err); /* Failed to decompress INTERNAL initramfs */
80293 + panic("%s", err); /* Failed to decompress INTERNAL initramfs */
80294 if (initrd_start) {
80295 #ifdef CONFIG_BLK_DEV_RAM
80296 int fd;
80297 diff --git a/init/main.c b/init/main.c
80298 index 9484f4b..0eac7c3 100644
80299 --- a/init/main.c
80300 +++ b/init/main.c
80301 @@ -100,6 +100,8 @@ static inline void mark_rodata_ro(void) { }
80302 extern void tc_init(void);
80303 #endif
80304
80305 +extern void grsecurity_init(void);
80306 +
80307 /*
80308 * Debug helper: via this flag we know that we are in 'early bootup code'
80309 * where only the boot processor is running with IRQ disabled. This means
80310 @@ -153,6 +155,74 @@ static int __init set_reset_devices(char *str)
80311
80312 __setup("reset_devices", set_reset_devices);
80313
80314 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
80315 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
80316 +static int __init setup_grsec_proc_gid(char *str)
80317 +{
80318 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
80319 + return 1;
80320 +}
80321 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
80322 +#endif
80323 +
80324 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
80325 +unsigned long pax_user_shadow_base __read_only;
80326 +EXPORT_SYMBOL(pax_user_shadow_base);
80327 +extern char pax_enter_kernel_user[];
80328 +extern char pax_exit_kernel_user[];
80329 +#endif
80330 +
80331 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
80332 +static int __init setup_pax_nouderef(char *str)
80333 +{
80334 +#ifdef CONFIG_X86_32
80335 + unsigned int cpu;
80336 + struct desc_struct *gdt;
80337 +
80338 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
80339 + gdt = get_cpu_gdt_table(cpu);
80340 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
80341 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
80342 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
80343 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
80344 + }
80345 + loadsegment(ds, __KERNEL_DS);
80346 + loadsegment(es, __KERNEL_DS);
80347 + loadsegment(ss, __KERNEL_DS);
80348 +#else
80349 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
80350 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
80351 + clone_pgd_mask = ~(pgdval_t)0UL;
80352 + pax_user_shadow_base = 0UL;
80353 + setup_clear_cpu_cap(X86_FEATURE_PCID);
80354 +#endif
80355 +
80356 + return 0;
80357 +}
80358 +early_param("pax_nouderef", setup_pax_nouderef);
80359 +
80360 +#ifdef CONFIG_X86_64
80361 +static int __init setup_pax_weakuderef(char *str)
80362 +{
80363 + if (clone_pgd_mask != ~(pgdval_t)0UL)
80364 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
80365 + return 1;
80366 +}
80367 +__setup("pax_weakuderef", setup_pax_weakuderef);
80368 +#endif
80369 +#endif
80370 +
80371 +#ifdef CONFIG_PAX_SOFTMODE
80372 +int pax_softmode;
80373 +
80374 +static int __init setup_pax_softmode(char *str)
80375 +{
80376 + get_option(&str, &pax_softmode);
80377 + return 1;
80378 +}
80379 +__setup("pax_softmode=", setup_pax_softmode);
80380 +#endif
80381 +
80382 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
80383 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
80384 static const char *panic_later, *panic_param;
80385 @@ -655,8 +725,6 @@ static void __init do_ctors(void)
80386 bool initcall_debug;
80387 core_param(initcall_debug, initcall_debug, bool, 0644);
80388
80389 -static char msgbuf[64];
80390 -
80391 static int __init_or_module do_one_initcall_debug(initcall_t fn)
80392 {
80393 ktime_t calltime, delta, rettime;
80394 @@ -679,23 +747,22 @@ int __init_or_module do_one_initcall(initcall_t fn)
80395 {
80396 int count = preempt_count();
80397 int ret;
80398 + const char *msg1 = "", *msg2 = "";
80399
80400 if (initcall_debug)
80401 ret = do_one_initcall_debug(fn);
80402 else
80403 ret = fn();
80404
80405 - msgbuf[0] = 0;
80406 -
80407 if (preempt_count() != count) {
80408 - sprintf(msgbuf, "preemption imbalance ");
80409 + msg1 = " preemption imbalance";
80410 preempt_count() = count;
80411 }
80412 if (irqs_disabled()) {
80413 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
80414 + msg2 = " disabled interrupts";
80415 local_irq_enable();
80416 }
80417 - WARN(msgbuf[0], "initcall %pF returned with %s\n", fn, msgbuf);
80418 + WARN(*msg1 || *msg2, "initcall %pF returned with%s%s\n", fn, msg1, msg2);
80419
80420 return ret;
80421 }
80422 @@ -748,8 +815,14 @@ static void __init do_initcall_level(int level)
80423 level, level,
80424 &repair_env_string);
80425
80426 - for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
80427 + for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) {
80428 do_one_initcall(*fn);
80429 +
80430 +#ifdef LATENT_ENTROPY_PLUGIN
80431 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
80432 +#endif
80433 +
80434 + }
80435 }
80436
80437 static void __init do_initcalls(void)
80438 @@ -783,8 +856,14 @@ static void __init do_pre_smp_initcalls(void)
80439 {
80440 initcall_t *fn;
80441
80442 - for (fn = __initcall_start; fn < __initcall0_start; fn++)
80443 + for (fn = __initcall_start; fn < __initcall0_start; fn++) {
80444 do_one_initcall(*fn);
80445 +
80446 +#ifdef LATENT_ENTROPY_PLUGIN
80447 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
80448 +#endif
80449 +
80450 + }
80451 }
80452
80453 /*
80454 @@ -802,8 +881,8 @@ static int run_init_process(const char *init_filename)
80455 {
80456 argv_init[0] = init_filename;
80457 return do_execve(init_filename,
80458 - (const char __user *const __user *)argv_init,
80459 - (const char __user *const __user *)envp_init);
80460 + (const char __user *const __force_user *)argv_init,
80461 + (const char __user *const __force_user *)envp_init);
80462 }
80463
80464 static noinline void __init kernel_init_freeable(void);
80465 @@ -880,7 +959,7 @@ static noinline void __init kernel_init_freeable(void)
80466 do_basic_setup();
80467
80468 /* Open the /dev/console on the rootfs, this should never fail */
80469 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
80470 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
80471 pr_err("Warning: unable to open an initial console.\n");
80472
80473 (void) sys_dup(0);
80474 @@ -893,11 +972,13 @@ static noinline void __init kernel_init_freeable(void)
80475 if (!ramdisk_execute_command)
80476 ramdisk_execute_command = "/init";
80477
80478 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
80479 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
80480 ramdisk_execute_command = NULL;
80481 prepare_namespace();
80482 }
80483
80484 + grsecurity_init();
80485 +
80486 /*
80487 * Ok, we have completed the initial bootup, and
80488 * we're essentially up and running. Get rid of the
80489 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
80490 index 130dfec..cc88451 100644
80491 --- a/ipc/ipc_sysctl.c
80492 +++ b/ipc/ipc_sysctl.c
80493 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
80494 static int proc_ipc_dointvec(ctl_table *table, int write,
80495 void __user *buffer, size_t *lenp, loff_t *ppos)
80496 {
80497 - struct ctl_table ipc_table;
80498 + ctl_table_no_const ipc_table;
80499
80500 memcpy(&ipc_table, table, sizeof(ipc_table));
80501 ipc_table.data = get_ipc(table);
80502 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
80503 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
80504 void __user *buffer, size_t *lenp, loff_t *ppos)
80505 {
80506 - struct ctl_table ipc_table;
80507 + ctl_table_no_const ipc_table;
80508
80509 memcpy(&ipc_table, table, sizeof(ipc_table));
80510 ipc_table.data = get_ipc(table);
80511 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
80512 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
80513 void __user *buffer, size_t *lenp, loff_t *ppos)
80514 {
80515 - struct ctl_table ipc_table;
80516 + ctl_table_no_const ipc_table;
80517 size_t lenp_bef = *lenp;
80518 int rc;
80519
80520 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
80521 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
80522 void __user *buffer, size_t *lenp, loff_t *ppos)
80523 {
80524 - struct ctl_table ipc_table;
80525 + ctl_table_no_const ipc_table;
80526 memcpy(&ipc_table, table, sizeof(ipc_table));
80527 ipc_table.data = get_ipc(table);
80528
80529 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
80530 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
80531 void __user *buffer, size_t *lenp, loff_t *ppos)
80532 {
80533 - struct ctl_table ipc_table;
80534 + ctl_table_no_const ipc_table;
80535 size_t lenp_bef = *lenp;
80536 int oldval;
80537 int rc;
80538 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
80539 index 383d638..943fdbb 100644
80540 --- a/ipc/mq_sysctl.c
80541 +++ b/ipc/mq_sysctl.c
80542 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
80543 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
80544 void __user *buffer, size_t *lenp, loff_t *ppos)
80545 {
80546 - struct ctl_table mq_table;
80547 + ctl_table_no_const mq_table;
80548 memcpy(&mq_table, table, sizeof(mq_table));
80549 mq_table.data = get_mq(table);
80550
80551 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
80552 index e4e47f6..a85e0ad 100644
80553 --- a/ipc/mqueue.c
80554 +++ b/ipc/mqueue.c
80555 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
80556 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
80557 info->attr.mq_msgsize);
80558
80559 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
80560 spin_lock(&mq_lock);
80561 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
80562 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
80563 diff --git a/ipc/msg.c b/ipc/msg.c
80564 index d0c6d96..69a893c 100644
80565 --- a/ipc/msg.c
80566 +++ b/ipc/msg.c
80567 @@ -296,18 +296,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
80568 return security_msg_queue_associate(msq, msgflg);
80569 }
80570
80571 +static struct ipc_ops msg_ops = {
80572 + .getnew = newque,
80573 + .associate = msg_security,
80574 + .more_checks = NULL
80575 +};
80576 +
80577 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
80578 {
80579 struct ipc_namespace *ns;
80580 - struct ipc_ops msg_ops;
80581 struct ipc_params msg_params;
80582
80583 ns = current->nsproxy->ipc_ns;
80584
80585 - msg_ops.getnew = newque;
80586 - msg_ops.associate = msg_security;
80587 - msg_ops.more_checks = NULL;
80588 -
80589 msg_params.key = key;
80590 msg_params.flg = msgflg;
80591
80592 diff --git a/ipc/sem.c b/ipc/sem.c
80593 index 70480a3..f4e8262 100644
80594 --- a/ipc/sem.c
80595 +++ b/ipc/sem.c
80596 @@ -460,10 +460,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
80597 return 0;
80598 }
80599
80600 +static struct ipc_ops sem_ops = {
80601 + .getnew = newary,
80602 + .associate = sem_security,
80603 + .more_checks = sem_more_checks
80604 +};
80605 +
80606 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
80607 {
80608 struct ipc_namespace *ns;
80609 - struct ipc_ops sem_ops;
80610 struct ipc_params sem_params;
80611
80612 ns = current->nsproxy->ipc_ns;
80613 @@ -471,10 +476,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
80614 if (nsems < 0 || nsems > ns->sc_semmsl)
80615 return -EINVAL;
80616
80617 - sem_ops.getnew = newary;
80618 - sem_ops.associate = sem_security;
80619 - sem_ops.more_checks = sem_more_checks;
80620 -
80621 sem_params.key = key;
80622 sem_params.flg = semflg;
80623 sem_params.u.nsems = nsems;
80624 diff --git a/ipc/shm.c b/ipc/shm.c
80625 index 7e199fa..180a1ca 100644
80626 --- a/ipc/shm.c
80627 +++ b/ipc/shm.c
80628 @@ -69,6 +69,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
80629 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
80630 #endif
80631
80632 +#ifdef CONFIG_GRKERNSEC
80633 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
80634 + const time_t shm_createtime, const kuid_t cuid,
80635 + const int shmid);
80636 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
80637 + const time_t shm_createtime);
80638 +#endif
80639 +
80640 void shm_init_ns(struct ipc_namespace *ns)
80641 {
80642 ns->shm_ctlmax = SHMMAX;
80643 @@ -531,6 +539,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
80644 shp->shm_lprid = 0;
80645 shp->shm_atim = shp->shm_dtim = 0;
80646 shp->shm_ctim = get_seconds();
80647 +#ifdef CONFIG_GRKERNSEC
80648 + {
80649 + struct timespec timeval;
80650 + do_posix_clock_monotonic_gettime(&timeval);
80651 +
80652 + shp->shm_createtime = timeval.tv_sec;
80653 + }
80654 +#endif
80655 shp->shm_segsz = size;
80656 shp->shm_nattch = 0;
80657 shp->shm_file = file;
80658 @@ -582,18 +598,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
80659 return 0;
80660 }
80661
80662 +static struct ipc_ops shm_ops = {
80663 + .getnew = newseg,
80664 + .associate = shm_security,
80665 + .more_checks = shm_more_checks
80666 +};
80667 +
80668 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
80669 {
80670 struct ipc_namespace *ns;
80671 - struct ipc_ops shm_ops;
80672 struct ipc_params shm_params;
80673
80674 ns = current->nsproxy->ipc_ns;
80675
80676 - shm_ops.getnew = newseg;
80677 - shm_ops.associate = shm_security;
80678 - shm_ops.more_checks = shm_more_checks;
80679 -
80680 shm_params.key = key;
80681 shm_params.flg = shmflg;
80682 shm_params.u.size = size;
80683 @@ -1014,6 +1031,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
80684 f_mode = FMODE_READ | FMODE_WRITE;
80685 }
80686 if (shmflg & SHM_EXEC) {
80687 +
80688 +#ifdef CONFIG_PAX_MPROTECT
80689 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
80690 + goto out;
80691 +#endif
80692 +
80693 prot |= PROT_EXEC;
80694 acc_mode |= S_IXUGO;
80695 }
80696 @@ -1037,9 +1060,21 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
80697 if (err)
80698 goto out_unlock;
80699
80700 +#ifdef CONFIG_GRKERNSEC
80701 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
80702 + shp->shm_perm.cuid, shmid) ||
80703 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
80704 + err = -EACCES;
80705 + goto out_unlock;
80706 + }
80707 +#endif
80708 +
80709 path = shp->shm_file->f_path;
80710 path_get(&path);
80711 shp->shm_nattch++;
80712 +#ifdef CONFIG_GRKERNSEC
80713 + shp->shm_lapid = current->pid;
80714 +#endif
80715 size = i_size_read(path.dentry->d_inode);
80716 shm_unlock(shp);
80717
80718 diff --git a/kernel/acct.c b/kernel/acct.c
80719 index 8d6e145..33e0b1e 100644
80720 --- a/kernel/acct.c
80721 +++ b/kernel/acct.c
80722 @@ -556,7 +556,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
80723 */
80724 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
80725 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
80726 - file->f_op->write(file, (char *)&ac,
80727 + file->f_op->write(file, (char __force_user *)&ac,
80728 sizeof(acct_t), &file->f_pos);
80729 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
80730 set_fs(fs);
80731 diff --git a/kernel/audit.c b/kernel/audit.c
80732 index 91e53d0..d9e3ec4 100644
80733 --- a/kernel/audit.c
80734 +++ b/kernel/audit.c
80735 @@ -118,7 +118,7 @@ u32 audit_sig_sid = 0;
80736 3) suppressed due to audit_rate_limit
80737 4) suppressed due to audit_backlog_limit
80738 */
80739 -static atomic_t audit_lost = ATOMIC_INIT(0);
80740 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
80741
80742 /* The netlink socket. */
80743 static struct sock *audit_sock;
80744 @@ -240,7 +240,7 @@ void audit_log_lost(const char *message)
80745 unsigned long now;
80746 int print;
80747
80748 - atomic_inc(&audit_lost);
80749 + atomic_inc_unchecked(&audit_lost);
80750
80751 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
80752
80753 @@ -259,7 +259,7 @@ void audit_log_lost(const char *message)
80754 printk(KERN_WARNING
80755 "audit: audit_lost=%d audit_rate_limit=%d "
80756 "audit_backlog_limit=%d\n",
80757 - atomic_read(&audit_lost),
80758 + atomic_read_unchecked(&audit_lost),
80759 audit_rate_limit,
80760 audit_backlog_limit);
80761 audit_panic(message);
80762 @@ -664,7 +664,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
80763 status_set.pid = audit_pid;
80764 status_set.rate_limit = audit_rate_limit;
80765 status_set.backlog_limit = audit_backlog_limit;
80766 - status_set.lost = atomic_read(&audit_lost);
80767 + status_set.lost = atomic_read_unchecked(&audit_lost);
80768 status_set.backlog = skb_queue_len(&audit_skb_queue);
80769 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
80770 &status_set, sizeof(status_set));
80771 diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
80772 index 6bd4a90..0ee9eff 100644
80773 --- a/kernel/auditfilter.c
80774 +++ b/kernel/auditfilter.c
80775 @@ -423,7 +423,7 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data,
80776 f->lsm_rule = NULL;
80777
80778 /* Support legacy tests for a valid loginuid */
80779 - if ((f->type == AUDIT_LOGINUID) && (f->val == 4294967295)) {
80780 + if ((f->type == AUDIT_LOGINUID) && (f->val == 4294967295U)) {
80781 f->type = AUDIT_LOGINUID_SET;
80782 f->val = 0;
80783 }
80784 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
80785 index 3c8a601..3a416f6 100644
80786 --- a/kernel/auditsc.c
80787 +++ b/kernel/auditsc.c
80788 @@ -1956,7 +1956,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
80789 }
80790
80791 /* global counter which is incremented every time something logs in */
80792 -static atomic_t session_id = ATOMIC_INIT(0);
80793 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
80794
80795 /**
80796 * audit_set_loginuid - set current task's audit_context loginuid
80797 @@ -1980,7 +1980,7 @@ int audit_set_loginuid(kuid_t loginuid)
80798 return -EPERM;
80799 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
80800
80801 - sessionid = atomic_inc_return(&session_id);
80802 + sessionid = atomic_inc_return_unchecked(&session_id);
80803 if (context && context->in_syscall) {
80804 struct audit_buffer *ab;
80805
80806 diff --git a/kernel/capability.c b/kernel/capability.c
80807 index f6c2ce5..982c0f9 100644
80808 --- a/kernel/capability.c
80809 +++ b/kernel/capability.c
80810 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
80811 * before modification is attempted and the application
80812 * fails.
80813 */
80814 + if (tocopy > ARRAY_SIZE(kdata))
80815 + return -EFAULT;
80816 +
80817 if (copy_to_user(dataptr, kdata, tocopy
80818 * sizeof(struct __user_cap_data_struct))) {
80819 return -EFAULT;
80820 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
80821 int ret;
80822
80823 rcu_read_lock();
80824 - ret = security_capable(__task_cred(t), ns, cap);
80825 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
80826 + gr_task_is_capable(t, __task_cred(t), cap);
80827 rcu_read_unlock();
80828
80829 - return (ret == 0);
80830 + return ret;
80831 }
80832
80833 /**
80834 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
80835 int ret;
80836
80837 rcu_read_lock();
80838 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
80839 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
80840 rcu_read_unlock();
80841
80842 - return (ret == 0);
80843 + return ret;
80844 }
80845
80846 /**
80847 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
80848 BUG();
80849 }
80850
80851 - if (security_capable(current_cred(), ns, cap) == 0) {
80852 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
80853 current->flags |= PF_SUPERPRIV;
80854 return true;
80855 }
80856 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
80857 }
80858 EXPORT_SYMBOL(ns_capable);
80859
80860 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
80861 +{
80862 + if (unlikely(!cap_valid(cap))) {
80863 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
80864 + BUG();
80865 + }
80866 +
80867 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
80868 + current->flags |= PF_SUPERPRIV;
80869 + return true;
80870 + }
80871 + return false;
80872 +}
80873 +EXPORT_SYMBOL(ns_capable_nolog);
80874 +
80875 /**
80876 * file_ns_capable - Determine if the file's opener had a capability in effect
80877 * @file: The file we want to check
80878 @@ -432,6 +451,12 @@ bool capable(int cap)
80879 }
80880 EXPORT_SYMBOL(capable);
80881
80882 +bool capable_nolog(int cap)
80883 +{
80884 + return ns_capable_nolog(&init_user_ns, cap);
80885 +}
80886 +EXPORT_SYMBOL(capable_nolog);
80887 +
80888 /**
80889 * nsown_capable - Check superior capability to one's own user_ns
80890 * @cap: The capability in question
80891 @@ -464,3 +489,10 @@ bool inode_capable(const struct inode *inode, int cap)
80892
80893 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
80894 }
80895 +
80896 +bool inode_capable_nolog(const struct inode *inode, int cap)
80897 +{
80898 + struct user_namespace *ns = current_user_ns();
80899 +
80900 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
80901 +}
80902 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
80903 index 2e9b387..61817b1 100644
80904 --- a/kernel/cgroup.c
80905 +++ b/kernel/cgroup.c
80906 @@ -5398,7 +5398,7 @@ static int cgroup_css_links_read(struct cgroup *cont,
80907 struct css_set *cg = link->cg;
80908 struct task_struct *task;
80909 int count = 0;
80910 - seq_printf(seq, "css_set %p\n", cg);
80911 + seq_printf(seq, "css_set %pK\n", cg);
80912 list_for_each_entry(task, &cg->tasks, cg_list) {
80913 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
80914 seq_puts(seq, " ...\n");
80915 diff --git a/kernel/compat.c b/kernel/compat.c
80916 index 0a09e48..f44f3f0 100644
80917 --- a/kernel/compat.c
80918 +++ b/kernel/compat.c
80919 @@ -13,6 +13,7 @@
80920
80921 #include <linux/linkage.h>
80922 #include <linux/compat.h>
80923 +#include <linux/module.h>
80924 #include <linux/errno.h>
80925 #include <linux/time.h>
80926 #include <linux/signal.h>
80927 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
80928 mm_segment_t oldfs;
80929 long ret;
80930
80931 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
80932 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
80933 oldfs = get_fs();
80934 set_fs(KERNEL_DS);
80935 ret = hrtimer_nanosleep_restart(restart);
80936 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
80937 oldfs = get_fs();
80938 set_fs(KERNEL_DS);
80939 ret = hrtimer_nanosleep(&tu,
80940 - rmtp ? (struct timespec __user *)&rmt : NULL,
80941 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
80942 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
80943 set_fs(oldfs);
80944
80945 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
80946 mm_segment_t old_fs = get_fs();
80947
80948 set_fs(KERNEL_DS);
80949 - ret = sys_sigpending((old_sigset_t __user *) &s);
80950 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
80951 set_fs(old_fs);
80952 if (ret == 0)
80953 ret = put_user(s, set);
80954 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
80955 mm_segment_t old_fs = get_fs();
80956
80957 set_fs(KERNEL_DS);
80958 - ret = sys_old_getrlimit(resource, &r);
80959 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
80960 set_fs(old_fs);
80961
80962 if (!ret) {
80963 @@ -533,8 +534,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
80964 set_fs (KERNEL_DS);
80965 ret = sys_wait4(pid,
80966 (stat_addr ?
80967 - (unsigned int __user *) &status : NULL),
80968 - options, (struct rusage __user *) &r);
80969 + (unsigned int __force_user *) &status : NULL),
80970 + options, (struct rusage __force_user *) &r);
80971 set_fs (old_fs);
80972
80973 if (ret > 0) {
80974 @@ -560,8 +561,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
80975 memset(&info, 0, sizeof(info));
80976
80977 set_fs(KERNEL_DS);
80978 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
80979 - uru ? (struct rusage __user *)&ru : NULL);
80980 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
80981 + uru ? (struct rusage __force_user *)&ru : NULL);
80982 set_fs(old_fs);
80983
80984 if ((ret < 0) || (info.si_signo == 0))
80985 @@ -695,8 +696,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
80986 oldfs = get_fs();
80987 set_fs(KERNEL_DS);
80988 err = sys_timer_settime(timer_id, flags,
80989 - (struct itimerspec __user *) &newts,
80990 - (struct itimerspec __user *) &oldts);
80991 + (struct itimerspec __force_user *) &newts,
80992 + (struct itimerspec __force_user *) &oldts);
80993 set_fs(oldfs);
80994 if (!err && old && put_compat_itimerspec(old, &oldts))
80995 return -EFAULT;
80996 @@ -713,7 +714,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
80997 oldfs = get_fs();
80998 set_fs(KERNEL_DS);
80999 err = sys_timer_gettime(timer_id,
81000 - (struct itimerspec __user *) &ts);
81001 + (struct itimerspec __force_user *) &ts);
81002 set_fs(oldfs);
81003 if (!err && put_compat_itimerspec(setting, &ts))
81004 return -EFAULT;
81005 @@ -732,7 +733,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
81006 oldfs = get_fs();
81007 set_fs(KERNEL_DS);
81008 err = sys_clock_settime(which_clock,
81009 - (struct timespec __user *) &ts);
81010 + (struct timespec __force_user *) &ts);
81011 set_fs(oldfs);
81012 return err;
81013 }
81014 @@ -747,7 +748,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
81015 oldfs = get_fs();
81016 set_fs(KERNEL_DS);
81017 err = sys_clock_gettime(which_clock,
81018 - (struct timespec __user *) &ts);
81019 + (struct timespec __force_user *) &ts);
81020 set_fs(oldfs);
81021 if (!err && put_compat_timespec(&ts, tp))
81022 return -EFAULT;
81023 @@ -767,7 +768,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
81024
81025 oldfs = get_fs();
81026 set_fs(KERNEL_DS);
81027 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
81028 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
81029 set_fs(oldfs);
81030
81031 err = compat_put_timex(utp, &txc);
81032 @@ -787,7 +788,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
81033 oldfs = get_fs();
81034 set_fs(KERNEL_DS);
81035 err = sys_clock_getres(which_clock,
81036 - (struct timespec __user *) &ts);
81037 + (struct timespec __force_user *) &ts);
81038 set_fs(oldfs);
81039 if (!err && tp && put_compat_timespec(&ts, tp))
81040 return -EFAULT;
81041 @@ -799,9 +800,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
81042 long err;
81043 mm_segment_t oldfs;
81044 struct timespec tu;
81045 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
81046 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
81047
81048 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
81049 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
81050 oldfs = get_fs();
81051 set_fs(KERNEL_DS);
81052 err = clock_nanosleep_restart(restart);
81053 @@ -833,8 +834,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
81054 oldfs = get_fs();
81055 set_fs(KERNEL_DS);
81056 err = sys_clock_nanosleep(which_clock, flags,
81057 - (struct timespec __user *) &in,
81058 - (struct timespec __user *) &out);
81059 + (struct timespec __force_user *) &in,
81060 + (struct timespec __force_user *) &out);
81061 set_fs(oldfs);
81062
81063 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
81064 diff --git a/kernel/configs.c b/kernel/configs.c
81065 index c18b1f1..b9a0132 100644
81066 --- a/kernel/configs.c
81067 +++ b/kernel/configs.c
81068 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
81069 struct proc_dir_entry *entry;
81070
81071 /* create the current config file */
81072 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
81073 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
81074 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
81075 + &ikconfig_file_ops);
81076 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
81077 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
81078 + &ikconfig_file_ops);
81079 +#endif
81080 +#else
81081 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
81082 &ikconfig_file_ops);
81083 +#endif
81084 +
81085 if (!entry)
81086 return -ENOMEM;
81087
81088 diff --git a/kernel/cred.c b/kernel/cred.c
81089 index e0573a4..3874e41 100644
81090 --- a/kernel/cred.c
81091 +++ b/kernel/cred.c
81092 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
81093 validate_creds(cred);
81094 alter_cred_subscribers(cred, -1);
81095 put_cred(cred);
81096 +
81097 +#ifdef CONFIG_GRKERNSEC_SETXID
81098 + cred = (struct cred *) tsk->delayed_cred;
81099 + if (cred != NULL) {
81100 + tsk->delayed_cred = NULL;
81101 + validate_creds(cred);
81102 + alter_cred_subscribers(cred, -1);
81103 + put_cred(cred);
81104 + }
81105 +#endif
81106 }
81107
81108 /**
81109 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
81110 * Always returns 0 thus allowing this function to be tail-called at the end
81111 * of, say, sys_setgid().
81112 */
81113 -int commit_creds(struct cred *new)
81114 +static int __commit_creds(struct cred *new)
81115 {
81116 struct task_struct *task = current;
81117 const struct cred *old = task->real_cred;
81118 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
81119
81120 get_cred(new); /* we will require a ref for the subj creds too */
81121
81122 + gr_set_role_label(task, new->uid, new->gid);
81123 +
81124 /* dumpability changes */
81125 if (!uid_eq(old->euid, new->euid) ||
81126 !gid_eq(old->egid, new->egid) ||
81127 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
81128 put_cred(old);
81129 return 0;
81130 }
81131 +#ifdef CONFIG_GRKERNSEC_SETXID
81132 +extern int set_user(struct cred *new);
81133 +
81134 +void gr_delayed_cred_worker(void)
81135 +{
81136 + const struct cred *new = current->delayed_cred;
81137 + struct cred *ncred;
81138 +
81139 + current->delayed_cred = NULL;
81140 +
81141 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
81142 + // from doing get_cred on it when queueing this
81143 + put_cred(new);
81144 + return;
81145 + } else if (new == NULL)
81146 + return;
81147 +
81148 + ncred = prepare_creds();
81149 + if (!ncred)
81150 + goto die;
81151 + // uids
81152 + ncred->uid = new->uid;
81153 + ncred->euid = new->euid;
81154 + ncred->suid = new->suid;
81155 + ncred->fsuid = new->fsuid;
81156 + // gids
81157 + ncred->gid = new->gid;
81158 + ncred->egid = new->egid;
81159 + ncred->sgid = new->sgid;
81160 + ncred->fsgid = new->fsgid;
81161 + // groups
81162 + if (set_groups(ncred, new->group_info) < 0) {
81163 + abort_creds(ncred);
81164 + goto die;
81165 + }
81166 + // caps
81167 + ncred->securebits = new->securebits;
81168 + ncred->cap_inheritable = new->cap_inheritable;
81169 + ncred->cap_permitted = new->cap_permitted;
81170 + ncred->cap_effective = new->cap_effective;
81171 + ncred->cap_bset = new->cap_bset;
81172 +
81173 + if (set_user(ncred)) {
81174 + abort_creds(ncred);
81175 + goto die;
81176 + }
81177 +
81178 + // from doing get_cred on it when queueing this
81179 + put_cred(new);
81180 +
81181 + __commit_creds(ncred);
81182 + return;
81183 +die:
81184 + // from doing get_cred on it when queueing this
81185 + put_cred(new);
81186 + do_group_exit(SIGKILL);
81187 +}
81188 +#endif
81189 +
81190 +int commit_creds(struct cred *new)
81191 +{
81192 +#ifdef CONFIG_GRKERNSEC_SETXID
81193 + int ret;
81194 + int schedule_it = 0;
81195 + struct task_struct *t;
81196 +
81197 + /* we won't get called with tasklist_lock held for writing
81198 + and interrupts disabled as the cred struct in that case is
81199 + init_cred
81200 + */
81201 + if (grsec_enable_setxid && !current_is_single_threaded() &&
81202 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
81203 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
81204 + schedule_it = 1;
81205 + }
81206 + ret = __commit_creds(new);
81207 + if (schedule_it) {
81208 + rcu_read_lock();
81209 + read_lock(&tasklist_lock);
81210 + for (t = next_thread(current); t != current;
81211 + t = next_thread(t)) {
81212 + if (t->delayed_cred == NULL) {
81213 + t->delayed_cred = get_cred(new);
81214 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
81215 + set_tsk_need_resched(t);
81216 + }
81217 + }
81218 + read_unlock(&tasklist_lock);
81219 + rcu_read_unlock();
81220 + }
81221 + return ret;
81222 +#else
81223 + return __commit_creds(new);
81224 +#endif
81225 +}
81226 +
81227 EXPORT_SYMBOL(commit_creds);
81228
81229 /**
81230 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
81231 index 0506d44..2c20034 100644
81232 --- a/kernel/debug/debug_core.c
81233 +++ b/kernel/debug/debug_core.c
81234 @@ -123,7 +123,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
81235 */
81236 static atomic_t masters_in_kgdb;
81237 static atomic_t slaves_in_kgdb;
81238 -static atomic_t kgdb_break_tasklet_var;
81239 +static atomic_unchecked_t kgdb_break_tasklet_var;
81240 atomic_t kgdb_setting_breakpoint;
81241
81242 struct task_struct *kgdb_usethread;
81243 @@ -133,7 +133,7 @@ int kgdb_single_step;
81244 static pid_t kgdb_sstep_pid;
81245
81246 /* to keep track of the CPU which is doing the single stepping*/
81247 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
81248 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
81249
81250 /*
81251 * If you are debugging a problem where roundup (the collection of
81252 @@ -541,7 +541,7 @@ return_normal:
81253 * kernel will only try for the value of sstep_tries before
81254 * giving up and continuing on.
81255 */
81256 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
81257 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
81258 (kgdb_info[cpu].task &&
81259 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
81260 atomic_set(&kgdb_active, -1);
81261 @@ -635,8 +635,8 @@ cpu_master_loop:
81262 }
81263
81264 kgdb_restore:
81265 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
81266 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
81267 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
81268 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
81269 if (kgdb_info[sstep_cpu].task)
81270 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
81271 else
81272 @@ -888,18 +888,18 @@ static void kgdb_unregister_callbacks(void)
81273 static void kgdb_tasklet_bpt(unsigned long ing)
81274 {
81275 kgdb_breakpoint();
81276 - atomic_set(&kgdb_break_tasklet_var, 0);
81277 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
81278 }
81279
81280 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
81281
81282 void kgdb_schedule_breakpoint(void)
81283 {
81284 - if (atomic_read(&kgdb_break_tasklet_var) ||
81285 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
81286 atomic_read(&kgdb_active) != -1 ||
81287 atomic_read(&kgdb_setting_breakpoint))
81288 return;
81289 - atomic_inc(&kgdb_break_tasklet_var);
81290 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
81291 tasklet_schedule(&kgdb_tasklet_breakpoint);
81292 }
81293 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
81294 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
81295 index 00eb8f7..d7e3244 100644
81296 --- a/kernel/debug/kdb/kdb_main.c
81297 +++ b/kernel/debug/kdb/kdb_main.c
81298 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
81299 continue;
81300
81301 kdb_printf("%-20s%8u 0x%p ", mod->name,
81302 - mod->core_size, (void *)mod);
81303 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
81304 #ifdef CONFIG_MODULE_UNLOAD
81305 kdb_printf("%4ld ", module_refcount(mod));
81306 #endif
81307 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
81308 kdb_printf(" (Loading)");
81309 else
81310 kdb_printf(" (Live)");
81311 - kdb_printf(" 0x%p", mod->module_core);
81312 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
81313
81314 #ifdef CONFIG_MODULE_UNLOAD
81315 {
81316 diff --git a/kernel/events/core.c b/kernel/events/core.c
81317 index e76e495..cbfe63a 100644
81318 --- a/kernel/events/core.c
81319 +++ b/kernel/events/core.c
81320 @@ -156,8 +156,15 @@ static struct srcu_struct pmus_srcu;
81321 * 0 - disallow raw tracepoint access for unpriv
81322 * 1 - disallow cpu events for unpriv
81323 * 2 - disallow kernel profiling for unpriv
81324 + * 3 - disallow all unpriv perf event use
81325 */
81326 -int sysctl_perf_event_paranoid __read_mostly = 1;
81327 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
81328 +int sysctl_perf_event_legitimately_concerned __read_mostly = 3;
81329 +#elif defined(CONFIG_GRKERNSEC_HIDESYM)
81330 +int sysctl_perf_event_legitimately_concerned __read_mostly = 2;
81331 +#else
81332 +int sysctl_perf_event_legitimately_concerned __read_mostly = 1;
81333 +#endif
81334
81335 /* Minimum for 512 kiB + 1 user control page */
81336 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
81337 @@ -184,7 +191,7 @@ int perf_proc_update_handler(struct ctl_table *table, int write,
81338 return 0;
81339 }
81340
81341 -static atomic64_t perf_event_id;
81342 +static atomic64_unchecked_t perf_event_id;
81343
81344 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
81345 enum event_type_t event_type);
81346 @@ -2747,7 +2754,7 @@ static void __perf_event_read(void *info)
81347
81348 static inline u64 perf_event_count(struct perf_event *event)
81349 {
81350 - return local64_read(&event->count) + atomic64_read(&event->child_count);
81351 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
81352 }
81353
81354 static u64 perf_event_read(struct perf_event *event)
81355 @@ -3093,9 +3100,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
81356 mutex_lock(&event->child_mutex);
81357 total += perf_event_read(event);
81358 *enabled += event->total_time_enabled +
81359 - atomic64_read(&event->child_total_time_enabled);
81360 + atomic64_read_unchecked(&event->child_total_time_enabled);
81361 *running += event->total_time_running +
81362 - atomic64_read(&event->child_total_time_running);
81363 + atomic64_read_unchecked(&event->child_total_time_running);
81364
81365 list_for_each_entry(child, &event->child_list, child_list) {
81366 total += perf_event_read(child);
81367 @@ -3481,10 +3488,10 @@ void perf_event_update_userpage(struct perf_event *event)
81368 userpg->offset -= local64_read(&event->hw.prev_count);
81369
81370 userpg->time_enabled = enabled +
81371 - atomic64_read(&event->child_total_time_enabled);
81372 + atomic64_read_unchecked(&event->child_total_time_enabled);
81373
81374 userpg->time_running = running +
81375 - atomic64_read(&event->child_total_time_running);
81376 + atomic64_read_unchecked(&event->child_total_time_running);
81377
81378 arch_perf_update_userpage(userpg, now);
81379
81380 @@ -4034,7 +4041,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
81381
81382 /* Data. */
81383 sp = perf_user_stack_pointer(regs);
81384 - rem = __output_copy_user(handle, (void *) sp, dump_size);
81385 + rem = __output_copy_user(handle, (void __user *) sp, dump_size);
81386 dyn_size = dump_size - rem;
81387
81388 perf_output_skip(handle, rem);
81389 @@ -4122,11 +4129,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
81390 values[n++] = perf_event_count(event);
81391 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
81392 values[n++] = enabled +
81393 - atomic64_read(&event->child_total_time_enabled);
81394 + atomic64_read_unchecked(&event->child_total_time_enabled);
81395 }
81396 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
81397 values[n++] = running +
81398 - atomic64_read(&event->child_total_time_running);
81399 + atomic64_read_unchecked(&event->child_total_time_running);
81400 }
81401 if (read_format & PERF_FORMAT_ID)
81402 values[n++] = primary_event_id(event);
81403 @@ -4835,12 +4842,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
81404 * need to add enough zero bytes after the string to handle
81405 * the 64bit alignment we do later.
81406 */
81407 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
81408 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
81409 if (!buf) {
81410 name = strncpy(tmp, "//enomem", sizeof(tmp));
81411 goto got_name;
81412 }
81413 - name = d_path(&file->f_path, buf, PATH_MAX);
81414 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
81415 if (IS_ERR(name)) {
81416 name = strncpy(tmp, "//toolong", sizeof(tmp));
81417 goto got_name;
81418 @@ -6262,7 +6269,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
81419 event->parent = parent_event;
81420
81421 event->ns = get_pid_ns(task_active_pid_ns(current));
81422 - event->id = atomic64_inc_return(&perf_event_id);
81423 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
81424
81425 event->state = PERF_EVENT_STATE_INACTIVE;
81426
81427 @@ -6572,6 +6579,11 @@ SYSCALL_DEFINE5(perf_event_open,
81428 if (flags & ~PERF_FLAG_ALL)
81429 return -EINVAL;
81430
81431 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
81432 + if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN))
81433 + return -EACCES;
81434 +#endif
81435 +
81436 err = perf_copy_attr(attr_uptr, &attr);
81437 if (err)
81438 return err;
81439 @@ -6904,10 +6916,10 @@ static void sync_child_event(struct perf_event *child_event,
81440 /*
81441 * Add back the child's count to the parent's count:
81442 */
81443 - atomic64_add(child_val, &parent_event->child_count);
81444 - atomic64_add(child_event->total_time_enabled,
81445 + atomic64_add_unchecked(child_val, &parent_event->child_count);
81446 + atomic64_add_unchecked(child_event->total_time_enabled,
81447 &parent_event->child_total_time_enabled);
81448 - atomic64_add(child_event->total_time_running,
81449 + atomic64_add_unchecked(child_event->total_time_running,
81450 &parent_event->child_total_time_running);
81451
81452 /*
81453 diff --git a/kernel/events/internal.h b/kernel/events/internal.h
81454 index ca65997..60df03d 100644
81455 --- a/kernel/events/internal.h
81456 +++ b/kernel/events/internal.h
81457 @@ -81,10 +81,10 @@ static inline unsigned long perf_data_size(struct ring_buffer *rb)
81458 return rb->nr_pages << (PAGE_SHIFT + page_order(rb));
81459 }
81460
81461 -#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
81462 -static inline unsigned int \
81463 +#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
81464 +static inline unsigned long \
81465 func_name(struct perf_output_handle *handle, \
81466 - const void *buf, unsigned int len) \
81467 + const void user *buf, unsigned long len) \
81468 { \
81469 unsigned long size, written; \
81470 \
81471 @@ -116,17 +116,17 @@ static inline int memcpy_common(void *dst, const void *src, size_t n)
81472 return n;
81473 }
81474
81475 -DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
81476 +DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
81477
81478 #define MEMCPY_SKIP(dst, src, n) (n)
81479
81480 -DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP)
81481 +DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP, )
81482
81483 #ifndef arch_perf_out_copy_user
81484 #define arch_perf_out_copy_user __copy_from_user_inatomic
81485 #endif
81486
81487 -DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
81488 +DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
81489
81490 /* Callchain handling */
81491 extern struct perf_callchain_entry *
81492 diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
81493 index f356974..cb8c570 100644
81494 --- a/kernel/events/uprobes.c
81495 +++ b/kernel/events/uprobes.c
81496 @@ -1556,7 +1556,7 @@ static int is_trap_at_addr(struct mm_struct *mm, unsigned long vaddr)
81497 {
81498 struct page *page;
81499 uprobe_opcode_t opcode;
81500 - int result;
81501 + long result;
81502
81503 pagefault_disable();
81504 result = __copy_from_user_inatomic(&opcode, (void __user*)vaddr,
81505 diff --git a/kernel/exit.c b/kernel/exit.c
81506 index 7bb73f9..d7978ed 100644
81507 --- a/kernel/exit.c
81508 +++ b/kernel/exit.c
81509 @@ -172,6 +172,10 @@ void release_task(struct task_struct * p)
81510 struct task_struct *leader;
81511 int zap_leader;
81512 repeat:
81513 +#ifdef CONFIG_NET
81514 + gr_del_task_from_ip_table(p);
81515 +#endif
81516 +
81517 /* don't need to get the RCU readlock here - the process is dead and
81518 * can't be modifying its own credentials. But shut RCU-lockdep up */
81519 rcu_read_lock();
81520 @@ -340,7 +344,7 @@ int allow_signal(int sig)
81521 * know it'll be handled, so that they don't get converted to
81522 * SIGKILL or just silently dropped.
81523 */
81524 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
81525 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
81526 recalc_sigpending();
81527 spin_unlock_irq(&current->sighand->siglock);
81528 return 0;
81529 @@ -709,6 +713,8 @@ void do_exit(long code)
81530 struct task_struct *tsk = current;
81531 int group_dead;
81532
81533 + set_fs(USER_DS);
81534 +
81535 profile_task_exit(tsk);
81536
81537 WARN_ON(blk_needs_flush_plug(tsk));
81538 @@ -725,7 +731,6 @@ void do_exit(long code)
81539 * mm_release()->clear_child_tid() from writing to a user-controlled
81540 * kernel address.
81541 */
81542 - set_fs(USER_DS);
81543
81544 ptrace_event(PTRACE_EVENT_EXIT, code);
81545
81546 @@ -784,6 +789,9 @@ void do_exit(long code)
81547 tsk->exit_code = code;
81548 taskstats_exit(tsk, group_dead);
81549
81550 + gr_acl_handle_psacct(tsk, code);
81551 + gr_acl_handle_exit();
81552 +
81553 exit_mm(tsk);
81554
81555 if (group_dead)
81556 @@ -905,7 +913,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
81557 * Take down every thread in the group. This is called by fatal signals
81558 * as well as by sys_exit_group (below).
81559 */
81560 -void
81561 +__noreturn void
81562 do_group_exit(int exit_code)
81563 {
81564 struct signal_struct *sig = current->signal;
81565 diff --git a/kernel/fork.c b/kernel/fork.c
81566 index ffbc090..08ceeee 100644
81567 --- a/kernel/fork.c
81568 +++ b/kernel/fork.c
81569 @@ -319,7 +319,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
81570 *stackend = STACK_END_MAGIC; /* for overflow detection */
81571
81572 #ifdef CONFIG_CC_STACKPROTECTOR
81573 - tsk->stack_canary = get_random_int();
81574 + tsk->stack_canary = pax_get_random_long();
81575 #endif
81576
81577 /*
81578 @@ -345,13 +345,81 @@ free_tsk:
81579 }
81580
81581 #ifdef CONFIG_MMU
81582 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
81583 +{
81584 + struct vm_area_struct *tmp;
81585 + unsigned long charge;
81586 + struct mempolicy *pol;
81587 + struct file *file;
81588 +
81589 + charge = 0;
81590 + if (mpnt->vm_flags & VM_ACCOUNT) {
81591 + unsigned long len = vma_pages(mpnt);
81592 +
81593 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
81594 + goto fail_nomem;
81595 + charge = len;
81596 + }
81597 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
81598 + if (!tmp)
81599 + goto fail_nomem;
81600 + *tmp = *mpnt;
81601 + tmp->vm_mm = mm;
81602 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
81603 + pol = mpol_dup(vma_policy(mpnt));
81604 + if (IS_ERR(pol))
81605 + goto fail_nomem_policy;
81606 + vma_set_policy(tmp, pol);
81607 + if (anon_vma_fork(tmp, mpnt))
81608 + goto fail_nomem_anon_vma_fork;
81609 + tmp->vm_flags &= ~VM_LOCKED;
81610 + tmp->vm_next = tmp->vm_prev = NULL;
81611 + tmp->vm_mirror = NULL;
81612 + file = tmp->vm_file;
81613 + if (file) {
81614 + struct inode *inode = file_inode(file);
81615 + struct address_space *mapping = file->f_mapping;
81616 +
81617 + get_file(file);
81618 + if (tmp->vm_flags & VM_DENYWRITE)
81619 + atomic_dec(&inode->i_writecount);
81620 + mutex_lock(&mapping->i_mmap_mutex);
81621 + if (tmp->vm_flags & VM_SHARED)
81622 + mapping->i_mmap_writable++;
81623 + flush_dcache_mmap_lock(mapping);
81624 + /* insert tmp into the share list, just after mpnt */
81625 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
81626 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
81627 + else
81628 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
81629 + flush_dcache_mmap_unlock(mapping);
81630 + mutex_unlock(&mapping->i_mmap_mutex);
81631 + }
81632 +
81633 + /*
81634 + * Clear hugetlb-related page reserves for children. This only
81635 + * affects MAP_PRIVATE mappings. Faults generated by the child
81636 + * are not guaranteed to succeed, even if read-only
81637 + */
81638 + if (is_vm_hugetlb_page(tmp))
81639 + reset_vma_resv_huge_pages(tmp);
81640 +
81641 + return tmp;
81642 +
81643 +fail_nomem_anon_vma_fork:
81644 + mpol_put(pol);
81645 +fail_nomem_policy:
81646 + kmem_cache_free(vm_area_cachep, tmp);
81647 +fail_nomem:
81648 + vm_unacct_memory(charge);
81649 + return NULL;
81650 +}
81651 +
81652 static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
81653 {
81654 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
81655 struct rb_node **rb_link, *rb_parent;
81656 int retval;
81657 - unsigned long charge;
81658 - struct mempolicy *pol;
81659
81660 uprobe_start_dup_mmap();
81661 down_write(&oldmm->mmap_sem);
81662 @@ -365,8 +433,8 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
81663 mm->locked_vm = 0;
81664 mm->mmap = NULL;
81665 mm->mmap_cache = NULL;
81666 - mm->free_area_cache = oldmm->mmap_base;
81667 - mm->cached_hole_size = ~0UL;
81668 + mm->free_area_cache = oldmm->free_area_cache;
81669 + mm->cached_hole_size = oldmm->cached_hole_size;
81670 mm->map_count = 0;
81671 cpumask_clear(mm_cpumask(mm));
81672 mm->mm_rb = RB_ROOT;
81673 @@ -382,57 +450,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
81674
81675 prev = NULL;
81676 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
81677 - struct file *file;
81678 -
81679 if (mpnt->vm_flags & VM_DONTCOPY) {
81680 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
81681 -vma_pages(mpnt));
81682 continue;
81683 }
81684 - charge = 0;
81685 - if (mpnt->vm_flags & VM_ACCOUNT) {
81686 - unsigned long len = vma_pages(mpnt);
81687 -
81688 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
81689 - goto fail_nomem;
81690 - charge = len;
81691 - }
81692 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
81693 - if (!tmp)
81694 - goto fail_nomem;
81695 - *tmp = *mpnt;
81696 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
81697 - pol = mpol_dup(vma_policy(mpnt));
81698 - retval = PTR_ERR(pol);
81699 - if (IS_ERR(pol))
81700 - goto fail_nomem_policy;
81701 - vma_set_policy(tmp, pol);
81702 - tmp->vm_mm = mm;
81703 - if (anon_vma_fork(tmp, mpnt))
81704 - goto fail_nomem_anon_vma_fork;
81705 - tmp->vm_flags &= ~VM_LOCKED;
81706 - tmp->vm_next = tmp->vm_prev = NULL;
81707 - file = tmp->vm_file;
81708 - if (file) {
81709 - struct inode *inode = file_inode(file);
81710 - struct address_space *mapping = file->f_mapping;
81711 -
81712 - get_file(file);
81713 - if (tmp->vm_flags & VM_DENYWRITE)
81714 - atomic_dec(&inode->i_writecount);
81715 - mutex_lock(&mapping->i_mmap_mutex);
81716 - if (tmp->vm_flags & VM_SHARED)
81717 - mapping->i_mmap_writable++;
81718 - flush_dcache_mmap_lock(mapping);
81719 - /* insert tmp into the share list, just after mpnt */
81720 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
81721 - vma_nonlinear_insert(tmp,
81722 - &mapping->i_mmap_nonlinear);
81723 - else
81724 - vma_interval_tree_insert_after(tmp, mpnt,
81725 - &mapping->i_mmap);
81726 - flush_dcache_mmap_unlock(mapping);
81727 - mutex_unlock(&mapping->i_mmap_mutex);
81728 + tmp = dup_vma(mm, oldmm, mpnt);
81729 + if (!tmp) {
81730 + retval = -ENOMEM;
81731 + goto out;
81732 }
81733
81734 /*
81735 @@ -464,6 +490,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
81736 if (retval)
81737 goto out;
81738 }
81739 +
81740 +#ifdef CONFIG_PAX_SEGMEXEC
81741 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
81742 + struct vm_area_struct *mpnt_m;
81743 +
81744 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
81745 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
81746 +
81747 + if (!mpnt->vm_mirror)
81748 + continue;
81749 +
81750 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
81751 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
81752 + mpnt->vm_mirror = mpnt_m;
81753 + } else {
81754 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
81755 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
81756 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
81757 + mpnt->vm_mirror->vm_mirror = mpnt;
81758 + }
81759 + }
81760 + BUG_ON(mpnt_m);
81761 + }
81762 +#endif
81763 +
81764 /* a new mm has just been created */
81765 arch_dup_mmap(oldmm, mm);
81766 retval = 0;
81767 @@ -473,14 +524,6 @@ out:
81768 up_write(&oldmm->mmap_sem);
81769 uprobe_end_dup_mmap();
81770 return retval;
81771 -fail_nomem_anon_vma_fork:
81772 - mpol_put(pol);
81773 -fail_nomem_policy:
81774 - kmem_cache_free(vm_area_cachep, tmp);
81775 -fail_nomem:
81776 - retval = -ENOMEM;
81777 - vm_unacct_memory(charge);
81778 - goto out;
81779 }
81780
81781 static inline int mm_alloc_pgd(struct mm_struct *mm)
81782 @@ -695,8 +738,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
81783 return ERR_PTR(err);
81784
81785 mm = get_task_mm(task);
81786 - if (mm && mm != current->mm &&
81787 - !ptrace_may_access(task, mode)) {
81788 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
81789 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
81790 mmput(mm);
81791 mm = ERR_PTR(-EACCES);
81792 }
81793 @@ -918,13 +961,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
81794 spin_unlock(&fs->lock);
81795 return -EAGAIN;
81796 }
81797 - fs->users++;
81798 + atomic_inc(&fs->users);
81799 spin_unlock(&fs->lock);
81800 return 0;
81801 }
81802 tsk->fs = copy_fs_struct(fs);
81803 if (!tsk->fs)
81804 return -ENOMEM;
81805 + /* Carry through gr_chroot_dentry and is_chrooted instead
81806 + of recomputing it here. Already copied when the task struct
81807 + is duplicated. This allows pivot_root to not be treated as
81808 + a chroot
81809 + */
81810 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
81811 +
81812 return 0;
81813 }
81814
81815 @@ -1197,10 +1247,13 @@ static struct task_struct *copy_process(unsigned long clone_flags,
81816 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
81817 #endif
81818 retval = -EAGAIN;
81819 +
81820 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
81821 +
81822 if (atomic_read(&p->real_cred->user->processes) >=
81823 task_rlimit(p, RLIMIT_NPROC)) {
81824 - if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
81825 - p->real_cred->user != INIT_USER)
81826 + if (p->real_cred->user != INIT_USER &&
81827 + !capable(CAP_SYS_RESOURCE) && !capable(CAP_SYS_ADMIN))
81828 goto bad_fork_free;
81829 }
81830 current->flags &= ~PF_NPROC_EXCEEDED;
81831 @@ -1446,6 +1499,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
81832 goto bad_fork_free_pid;
81833 }
81834
81835 + /* synchronizes with gr_set_acls()
81836 + we need to call this past the point of no return for fork()
81837 + */
81838 + gr_copy_label(p);
81839 +
81840 if (clone_flags & CLONE_THREAD) {
81841 current->signal->nr_threads++;
81842 atomic_inc(&current->signal->live);
81843 @@ -1529,6 +1587,8 @@ bad_fork_cleanup_count:
81844 bad_fork_free:
81845 free_task(p);
81846 fork_out:
81847 + gr_log_forkfail(retval);
81848 +
81849 return ERR_PTR(retval);
81850 }
81851
81852 @@ -1613,6 +1673,8 @@ long do_fork(unsigned long clone_flags,
81853 if (clone_flags & CLONE_PARENT_SETTID)
81854 put_user(nr, parent_tidptr);
81855
81856 + gr_handle_brute_check();
81857 +
81858 if (clone_flags & CLONE_VFORK) {
81859 p->vfork_done = &vfork;
81860 init_completion(&vfork);
81861 @@ -1729,7 +1791,7 @@ void __init proc_caches_init(void)
81862 mm_cachep = kmem_cache_create("mm_struct",
81863 sizeof(struct mm_struct), ARCH_MIN_MMSTRUCT_ALIGN,
81864 SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_NOTRACK, NULL);
81865 - vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC);
81866 + vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC | SLAB_NO_SANITIZE);
81867 mmap_init();
81868 nsproxy_cache_init();
81869 }
81870 @@ -1769,7 +1831,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
81871 return 0;
81872
81873 /* don't need lock here; in the worst case we'll do useless copy */
81874 - if (fs->users == 1)
81875 + if (atomic_read(&fs->users) == 1)
81876 return 0;
81877
81878 *new_fsp = copy_fs_struct(fs);
81879 @@ -1881,7 +1943,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
81880 fs = current->fs;
81881 spin_lock(&fs->lock);
81882 current->fs = new_fs;
81883 - if (--fs->users)
81884 + gr_set_chroot_entries(current, &current->fs->root);
81885 + if (atomic_dec_return(&fs->users))
81886 new_fs = NULL;
81887 else
81888 new_fs = fs;
81889 diff --git a/kernel/futex.c b/kernel/futex.c
81890 index 49dacfb..2ac4526 100644
81891 --- a/kernel/futex.c
81892 +++ b/kernel/futex.c
81893 @@ -54,6 +54,7 @@
81894 #include <linux/mount.h>
81895 #include <linux/pagemap.h>
81896 #include <linux/syscalls.h>
81897 +#include <linux/ptrace.h>
81898 #include <linux/signal.h>
81899 #include <linux/export.h>
81900 #include <linux/magic.h>
81901 @@ -242,6 +243,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
81902 struct page *page, *page_head;
81903 int err, ro = 0;
81904
81905 +#ifdef CONFIG_PAX_SEGMEXEC
81906 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
81907 + return -EFAULT;
81908 +#endif
81909 +
81910 /*
81911 * The futex address must be "naturally" aligned.
81912 */
81913 @@ -440,7 +446,7 @@ static int cmpxchg_futex_value_locked(u32 *curval, u32 __user *uaddr,
81914
81915 static int get_futex_value_locked(u32 *dest, u32 __user *from)
81916 {
81917 - int ret;
81918 + unsigned long ret;
81919
81920 pagefault_disable();
81921 ret = __copy_from_user_inatomic(dest, from, sizeof(u32));
81922 @@ -2733,6 +2739,7 @@ static int __init futex_init(void)
81923 {
81924 u32 curval;
81925 int i;
81926 + mm_segment_t oldfs;
81927
81928 /*
81929 * This will fail and we want it. Some arch implementations do
81930 @@ -2744,8 +2751,11 @@ static int __init futex_init(void)
81931 * implementation, the non-functional ones will return
81932 * -ENOSYS.
81933 */
81934 + oldfs = get_fs();
81935 + set_fs(USER_DS);
81936 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
81937 futex_cmpxchg_enabled = 1;
81938 + set_fs(oldfs);
81939
81940 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
81941 plist_head_init(&futex_queues[i].chain);
81942 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
81943 index f9f44fd..29885e4 100644
81944 --- a/kernel/futex_compat.c
81945 +++ b/kernel/futex_compat.c
81946 @@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
81947 return 0;
81948 }
81949
81950 -static void __user *futex_uaddr(struct robust_list __user *entry,
81951 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
81952 compat_long_t futex_offset)
81953 {
81954 compat_uptr_t base = ptr_to_compat(entry);
81955 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
81956 index 9b22d03..6295b62 100644
81957 --- a/kernel/gcov/base.c
81958 +++ b/kernel/gcov/base.c
81959 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
81960 }
81961
81962 #ifdef CONFIG_MODULES
81963 -static inline int within(void *addr, void *start, unsigned long size)
81964 -{
81965 - return ((addr >= start) && (addr < start + size));
81966 -}
81967 -
81968 /* Update list and generate events when modules are unloaded. */
81969 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
81970 void *data)
81971 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
81972 prev = NULL;
81973 /* Remove entries located in module from linked list. */
81974 for (info = gcov_info_head; info; info = info->next) {
81975 - if (within(info, mod->module_core, mod->core_size)) {
81976 + if (within_module_core_rw((unsigned long)info, mod)) {
81977 if (prev)
81978 prev->next = info->next;
81979 else
81980 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
81981 index 2288fbd..0f3941f 100644
81982 --- a/kernel/hrtimer.c
81983 +++ b/kernel/hrtimer.c
81984 @@ -1435,7 +1435,7 @@ void hrtimer_peek_ahead_timers(void)
81985 local_irq_restore(flags);
81986 }
81987
81988 -static void run_hrtimer_softirq(struct softirq_action *h)
81989 +static void run_hrtimer_softirq(void)
81990 {
81991 hrtimer_peek_ahead_timers();
81992 }
81993 @@ -1770,7 +1770,7 @@ static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self,
81994 return NOTIFY_OK;
81995 }
81996
81997 -static struct notifier_block __cpuinitdata hrtimers_nb = {
81998 +static struct notifier_block hrtimers_nb = {
81999 .notifier_call = hrtimer_cpu_notify,
82000 };
82001
82002 diff --git a/kernel/irq_work.c b/kernel/irq_work.c
82003 index 55fcce6..0e4cf34 100644
82004 --- a/kernel/irq_work.c
82005 +++ b/kernel/irq_work.c
82006 @@ -189,12 +189,13 @@ static int irq_work_cpu_notify(struct notifier_block *self,
82007 return NOTIFY_OK;
82008 }
82009
82010 -static struct notifier_block cpu_notify;
82011 +static struct notifier_block cpu_notify = {
82012 + .notifier_call = irq_work_cpu_notify,
82013 + .priority = 0,
82014 +};
82015
82016 static __init int irq_work_init_cpu_notifier(void)
82017 {
82018 - cpu_notify.notifier_call = irq_work_cpu_notify;
82019 - cpu_notify.priority = 0;
82020 register_cpu_notifier(&cpu_notify);
82021 return 0;
82022 }
82023 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
82024 index 60f48fa..7f3a770 100644
82025 --- a/kernel/jump_label.c
82026 +++ b/kernel/jump_label.c
82027 @@ -13,6 +13,7 @@
82028 #include <linux/sort.h>
82029 #include <linux/err.h>
82030 #include <linux/static_key.h>
82031 +#include <linux/mm.h>
82032
82033 #ifdef HAVE_JUMP_LABEL
82034
82035 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
82036
82037 size = (((unsigned long)stop - (unsigned long)start)
82038 / sizeof(struct jump_entry));
82039 + pax_open_kernel();
82040 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
82041 + pax_close_kernel();
82042 }
82043
82044 static void jump_label_update(struct static_key *key, int enable);
82045 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
82046 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
82047 struct jump_entry *iter;
82048
82049 + pax_open_kernel();
82050 for (iter = iter_start; iter < iter_stop; iter++) {
82051 if (within_module_init(iter->code, mod))
82052 iter->code = 0;
82053 }
82054 + pax_close_kernel();
82055 }
82056
82057 static int
82058 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
82059 index 3127ad5..159d880 100644
82060 --- a/kernel/kallsyms.c
82061 +++ b/kernel/kallsyms.c
82062 @@ -11,6 +11,9 @@
82063 * Changed the compression method from stem compression to "table lookup"
82064 * compression (see scripts/kallsyms.c for a more complete description)
82065 */
82066 +#ifdef CONFIG_GRKERNSEC_HIDESYM
82067 +#define __INCLUDED_BY_HIDESYM 1
82068 +#endif
82069 #include <linux/kallsyms.h>
82070 #include <linux/module.h>
82071 #include <linux/init.h>
82072 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
82073
82074 static inline int is_kernel_inittext(unsigned long addr)
82075 {
82076 + if (system_state != SYSTEM_BOOTING)
82077 + return 0;
82078 +
82079 if (addr >= (unsigned long)_sinittext
82080 && addr <= (unsigned long)_einittext)
82081 return 1;
82082 return 0;
82083 }
82084
82085 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
82086 +#ifdef CONFIG_MODULES
82087 +static inline int is_module_text(unsigned long addr)
82088 +{
82089 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
82090 + return 1;
82091 +
82092 + addr = ktla_ktva(addr);
82093 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
82094 +}
82095 +#else
82096 +static inline int is_module_text(unsigned long addr)
82097 +{
82098 + return 0;
82099 +}
82100 +#endif
82101 +#endif
82102 +
82103 static inline int is_kernel_text(unsigned long addr)
82104 {
82105 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
82106 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
82107
82108 static inline int is_kernel(unsigned long addr)
82109 {
82110 +
82111 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
82112 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
82113 + return 1;
82114 +
82115 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
82116 +#else
82117 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
82118 +#endif
82119 +
82120 return 1;
82121 return in_gate_area_no_mm(addr);
82122 }
82123
82124 static int is_ksym_addr(unsigned long addr)
82125 {
82126 +
82127 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
82128 + if (is_module_text(addr))
82129 + return 0;
82130 +#endif
82131 +
82132 if (all_var)
82133 return is_kernel(addr);
82134
82135 @@ -480,7 +519,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
82136
82137 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
82138 {
82139 - iter->name[0] = '\0';
82140 iter->nameoff = get_symbol_offset(new_pos);
82141 iter->pos = new_pos;
82142 }
82143 @@ -528,6 +566,11 @@ static int s_show(struct seq_file *m, void *p)
82144 {
82145 struct kallsym_iter *iter = m->private;
82146
82147 +#ifdef CONFIG_GRKERNSEC_HIDESYM
82148 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
82149 + return 0;
82150 +#endif
82151 +
82152 /* Some debugging symbols have no name. Ignore them. */
82153 if (!iter->name[0])
82154 return 0;
82155 @@ -541,6 +584,7 @@ static int s_show(struct seq_file *m, void *p)
82156 */
82157 type = iter->exported ? toupper(iter->type) :
82158 tolower(iter->type);
82159 +
82160 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
82161 type, iter->name, iter->module_name);
82162 } else
82163 @@ -566,7 +610,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
82164 struct kallsym_iter *iter;
82165 int ret;
82166
82167 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
82168 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
82169 if (!iter)
82170 return -ENOMEM;
82171 reset_iter(iter, 0);
82172 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
82173 index e30ac0f..3528cac 100644
82174 --- a/kernel/kcmp.c
82175 +++ b/kernel/kcmp.c
82176 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
82177 struct task_struct *task1, *task2;
82178 int ret;
82179
82180 +#ifdef CONFIG_GRKERNSEC
82181 + return -ENOSYS;
82182 +#endif
82183 +
82184 rcu_read_lock();
82185
82186 /*
82187 diff --git a/kernel/kexec.c b/kernel/kexec.c
82188 index 59f7b55..4022f65 100644
82189 --- a/kernel/kexec.c
82190 +++ b/kernel/kexec.c
82191 @@ -1041,7 +1041,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
82192 unsigned long flags)
82193 {
82194 struct compat_kexec_segment in;
82195 - struct kexec_segment out, __user *ksegments;
82196 + struct kexec_segment out;
82197 + struct kexec_segment __user *ksegments;
82198 unsigned long i, result;
82199
82200 /* Don't allow clients that don't understand the native
82201 diff --git a/kernel/kmod.c b/kernel/kmod.c
82202 index 8241906..d625f2c 100644
82203 --- a/kernel/kmod.c
82204 +++ b/kernel/kmod.c
82205 @@ -75,7 +75,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
82206 kfree(info->argv);
82207 }
82208
82209 -static int call_modprobe(char *module_name, int wait)
82210 +static int call_modprobe(char *module_name, char *module_param, int wait)
82211 {
82212 struct subprocess_info *info;
82213 static char *envp[] = {
82214 @@ -85,7 +85,7 @@ static int call_modprobe(char *module_name, int wait)
82215 NULL
82216 };
82217
82218 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
82219 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
82220 if (!argv)
82221 goto out;
82222
82223 @@ -97,7 +97,8 @@ static int call_modprobe(char *module_name, int wait)
82224 argv[1] = "-q";
82225 argv[2] = "--";
82226 argv[3] = module_name; /* check free_modprobe_argv() */
82227 - argv[4] = NULL;
82228 + argv[4] = module_param;
82229 + argv[5] = NULL;
82230
82231 info = call_usermodehelper_setup(modprobe_path, argv, envp, GFP_KERNEL,
82232 NULL, free_modprobe_argv, NULL);
82233 @@ -129,9 +130,8 @@ out:
82234 * If module auto-loading support is disabled then this function
82235 * becomes a no-operation.
82236 */
82237 -int __request_module(bool wait, const char *fmt, ...)
82238 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
82239 {
82240 - va_list args;
82241 char module_name[MODULE_NAME_LEN];
82242 unsigned int max_modprobes;
82243 int ret;
82244 @@ -147,9 +147,7 @@ int __request_module(bool wait, const char *fmt, ...)
82245 */
82246 WARN_ON_ONCE(wait && current_is_async());
82247
82248 - va_start(args, fmt);
82249 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
82250 - va_end(args);
82251 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
82252 if (ret >= MODULE_NAME_LEN)
82253 return -ENAMETOOLONG;
82254
82255 @@ -157,6 +155,20 @@ int __request_module(bool wait, const char *fmt, ...)
82256 if (ret)
82257 return ret;
82258
82259 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82260 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
82261 + /* hack to workaround consolekit/udisks stupidity */
82262 + read_lock(&tasklist_lock);
82263 + if (!strcmp(current->comm, "mount") &&
82264 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
82265 + read_unlock(&tasklist_lock);
82266 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
82267 + return -EPERM;
82268 + }
82269 + read_unlock(&tasklist_lock);
82270 + }
82271 +#endif
82272 +
82273 /* If modprobe needs a service that is in a module, we get a recursive
82274 * loop. Limit the number of running kmod threads to max_threads/2 or
82275 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
82276 @@ -185,11 +197,52 @@ int __request_module(bool wait, const char *fmt, ...)
82277
82278 trace_module_request(module_name, wait, _RET_IP_);
82279
82280 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
82281 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
82282
82283 atomic_dec(&kmod_concurrent);
82284 return ret;
82285 }
82286 +
82287 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
82288 +{
82289 + va_list args;
82290 + int ret;
82291 +
82292 + va_start(args, fmt);
82293 + ret = ____request_module(wait, module_param, fmt, args);
82294 + va_end(args);
82295 +
82296 + return ret;
82297 +}
82298 +
82299 +int __request_module(bool wait, const char *fmt, ...)
82300 +{
82301 + va_list args;
82302 + int ret;
82303 +
82304 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82305 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
82306 + char module_param[MODULE_NAME_LEN];
82307 +
82308 + memset(module_param, 0, sizeof(module_param));
82309 +
82310 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
82311 +
82312 + va_start(args, fmt);
82313 + ret = ____request_module(wait, module_param, fmt, args);
82314 + va_end(args);
82315 +
82316 + return ret;
82317 + }
82318 +#endif
82319 +
82320 + va_start(args, fmt);
82321 + ret = ____request_module(wait, NULL, fmt, args);
82322 + va_end(args);
82323 +
82324 + return ret;
82325 +}
82326 +
82327 EXPORT_SYMBOL(__request_module);
82328 #endif /* CONFIG_MODULES */
82329
82330 @@ -300,7 +353,7 @@ static int wait_for_helper(void *data)
82331 *
82332 * Thus the __user pointer cast is valid here.
82333 */
82334 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
82335 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
82336
82337 /*
82338 * If ret is 0, either ____call_usermodehelper failed and the
82339 @@ -651,7 +704,7 @@ EXPORT_SYMBOL(call_usermodehelper);
82340 static int proc_cap_handler(struct ctl_table *table, int write,
82341 void __user *buffer, size_t *lenp, loff_t *ppos)
82342 {
82343 - struct ctl_table t;
82344 + ctl_table_no_const t;
82345 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
82346 kernel_cap_t new_cap;
82347 int err, i;
82348 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
82349 index bddf3b2..233bf40 100644
82350 --- a/kernel/kprobes.c
82351 +++ b/kernel/kprobes.c
82352 @@ -31,6 +31,9 @@
82353 * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi
82354 * <prasanna@in.ibm.com> added function-return probes.
82355 */
82356 +#ifdef CONFIG_GRKERNSEC_HIDESYM
82357 +#define __INCLUDED_BY_HIDESYM 1
82358 +#endif
82359 #include <linux/kprobes.h>
82360 #include <linux/hash.h>
82361 #include <linux/init.h>
82362 @@ -185,7 +188,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
82363 * kernel image and loaded module images reside. This is required
82364 * so x86_64 can correctly handle the %rip-relative fixups.
82365 */
82366 - kip->insns = module_alloc(PAGE_SIZE);
82367 + kip->insns = module_alloc_exec(PAGE_SIZE);
82368 if (!kip->insns) {
82369 kfree(kip);
82370 return NULL;
82371 @@ -225,7 +228,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
82372 */
82373 if (!list_is_singular(&kip->list)) {
82374 list_del(&kip->list);
82375 - module_free(NULL, kip->insns);
82376 + module_free_exec(NULL, kip->insns);
82377 kfree(kip);
82378 }
82379 return 1;
82380 @@ -2083,7 +2086,7 @@ static int __init init_kprobes(void)
82381 {
82382 int i, err = 0;
82383 unsigned long offset = 0, size = 0;
82384 - char *modname, namebuf[128];
82385 + char *modname, namebuf[KSYM_NAME_LEN];
82386 const char *symbol_name;
82387 void *addr;
82388 struct kprobe_blackpoint *kb;
82389 @@ -2168,11 +2171,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
82390 kprobe_type = "k";
82391
82392 if (sym)
82393 - seq_printf(pi, "%p %s %s+0x%x %s ",
82394 + seq_printf(pi, "%pK %s %s+0x%x %s ",
82395 p->addr, kprobe_type, sym, offset,
82396 (modname ? modname : " "));
82397 else
82398 - seq_printf(pi, "%p %s %p ",
82399 + seq_printf(pi, "%pK %s %pK ",
82400 p->addr, kprobe_type, p->addr);
82401
82402 if (!pp)
82403 @@ -2209,7 +2212,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
82404 const char *sym = NULL;
82405 unsigned int i = *(loff_t *) v;
82406 unsigned long offset = 0;
82407 - char *modname, namebuf[128];
82408 + char *modname, namebuf[KSYM_NAME_LEN];
82409
82410 head = &kprobe_table[i];
82411 preempt_disable();
82412 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
82413 index 6ada93c..dce7d5d 100644
82414 --- a/kernel/ksysfs.c
82415 +++ b/kernel/ksysfs.c
82416 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
82417 {
82418 if (count+1 > UEVENT_HELPER_PATH_LEN)
82419 return -ENOENT;
82420 + if (!capable(CAP_SYS_ADMIN))
82421 + return -EPERM;
82422 memcpy(uevent_helper, buf, count);
82423 uevent_helper[count] = '\0';
82424 if (count && uevent_helper[count-1] == '\n')
82425 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
82426 return count;
82427 }
82428
82429 -static struct bin_attribute notes_attr = {
82430 +static bin_attribute_no_const notes_attr __read_only = {
82431 .attr = {
82432 .name = "notes",
82433 .mode = S_IRUGO,
82434 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
82435 index 1f3186b..bb7dbc6 100644
82436 --- a/kernel/lockdep.c
82437 +++ b/kernel/lockdep.c
82438 @@ -596,6 +596,10 @@ static int static_obj(void *obj)
82439 end = (unsigned long) &_end,
82440 addr = (unsigned long) obj;
82441
82442 +#ifdef CONFIG_PAX_KERNEXEC
82443 + start = ktla_ktva(start);
82444 +#endif
82445 +
82446 /*
82447 * static variable?
82448 */
82449 @@ -736,6 +740,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
82450 if (!static_obj(lock->key)) {
82451 debug_locks_off();
82452 printk("INFO: trying to register non-static key.\n");
82453 + printk("lock:%pS key:%pS.\n", lock, lock->key);
82454 printk("the code is fine but needs lockdep annotation.\n");
82455 printk("turning off the locking correctness validator.\n");
82456 dump_stack();
82457 @@ -3080,7 +3085,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
82458 if (!class)
82459 return 0;
82460 }
82461 - atomic_inc((atomic_t *)&class->ops);
82462 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
82463 if (very_verbose(class)) {
82464 printk("\nacquire class [%p] %s", class->key, class->name);
82465 if (class->name_version > 1)
82466 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
82467 index b2c71c5..7b88d63 100644
82468 --- a/kernel/lockdep_proc.c
82469 +++ b/kernel/lockdep_proc.c
82470 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
82471 return 0;
82472 }
82473
82474 - seq_printf(m, "%p", class->key);
82475 + seq_printf(m, "%pK", class->key);
82476 #ifdef CONFIG_DEBUG_LOCKDEP
82477 seq_printf(m, " OPS:%8ld", class->ops);
82478 #endif
82479 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
82480
82481 list_for_each_entry(entry, &class->locks_after, entry) {
82482 if (entry->distance == 1) {
82483 - seq_printf(m, " -> [%p] ", entry->class->key);
82484 + seq_printf(m, " -> [%pK] ", entry->class->key);
82485 print_name(m, entry->class);
82486 seq_puts(m, "\n");
82487 }
82488 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
82489 if (!class->key)
82490 continue;
82491
82492 - seq_printf(m, "[%p] ", class->key);
82493 + seq_printf(m, "[%pK] ", class->key);
82494 print_name(m, class);
82495 seq_puts(m, "\n");
82496 }
82497 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
82498 if (!i)
82499 seq_line(m, '-', 40-namelen, namelen);
82500
82501 - snprintf(ip, sizeof(ip), "[<%p>]",
82502 + snprintf(ip, sizeof(ip), "[<%pK>]",
82503 (void *)class->contention_point[i]);
82504 seq_printf(m, "%40s %14lu %29s %pS\n",
82505 name, stats->contention_point[i],
82506 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
82507 if (!i)
82508 seq_line(m, '-', 40-namelen, namelen);
82509
82510 - snprintf(ip, sizeof(ip), "[<%p>]",
82511 + snprintf(ip, sizeof(ip), "[<%pK>]",
82512 (void *)class->contending_point[i]);
82513 seq_printf(m, "%40s %14lu %29s %pS\n",
82514 name, stats->contending_point[i],
82515 diff --git a/kernel/module.c b/kernel/module.c
82516 index fa53db8..6f17200 100644
82517 --- a/kernel/module.c
82518 +++ b/kernel/module.c
82519 @@ -61,6 +61,7 @@
82520 #include <linux/pfn.h>
82521 #include <linux/bsearch.h>
82522 #include <linux/fips.h>
82523 +#include <linux/grsecurity.h>
82524 #include <uapi/linux/module.h>
82525 #include "module-internal.h"
82526
82527 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
82528
82529 /* Bounds of module allocation, for speeding __module_address.
82530 * Protected by module_mutex. */
82531 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
82532 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
82533 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
82534
82535 int register_module_notifier(struct notifier_block * nb)
82536 {
82537 @@ -323,7 +325,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
82538 return true;
82539
82540 list_for_each_entry_rcu(mod, &modules, list) {
82541 - struct symsearch arr[] = {
82542 + struct symsearch modarr[] = {
82543 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
82544 NOT_GPL_ONLY, false },
82545 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
82546 @@ -348,7 +350,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
82547 if (mod->state == MODULE_STATE_UNFORMED)
82548 continue;
82549
82550 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
82551 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
82552 return true;
82553 }
82554 return false;
82555 @@ -485,7 +487,7 @@ static inline void __percpu *mod_percpu(struct module *mod)
82556 static int percpu_modalloc(struct module *mod,
82557 unsigned long size, unsigned long align)
82558 {
82559 - if (align > PAGE_SIZE) {
82560 + if (align-1 >= PAGE_SIZE) {
82561 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
82562 mod->name, align, PAGE_SIZE);
82563 align = PAGE_SIZE;
82564 @@ -1089,7 +1091,7 @@ struct module_attribute module_uevent =
82565 static ssize_t show_coresize(struct module_attribute *mattr,
82566 struct module_kobject *mk, char *buffer)
82567 {
82568 - return sprintf(buffer, "%u\n", mk->mod->core_size);
82569 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
82570 }
82571
82572 static struct module_attribute modinfo_coresize =
82573 @@ -1098,7 +1100,7 @@ static struct module_attribute modinfo_coresize =
82574 static ssize_t show_initsize(struct module_attribute *mattr,
82575 struct module_kobject *mk, char *buffer)
82576 {
82577 - return sprintf(buffer, "%u\n", mk->mod->init_size);
82578 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
82579 }
82580
82581 static struct module_attribute modinfo_initsize =
82582 @@ -1313,7 +1315,7 @@ resolve_symbol_wait(struct module *mod,
82583 */
82584 #ifdef CONFIG_SYSFS
82585
82586 -#ifdef CONFIG_KALLSYMS
82587 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
82588 static inline bool sect_empty(const Elf_Shdr *sect)
82589 {
82590 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
82591 @@ -1453,7 +1455,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
82592 {
82593 unsigned int notes, loaded, i;
82594 struct module_notes_attrs *notes_attrs;
82595 - struct bin_attribute *nattr;
82596 + bin_attribute_no_const *nattr;
82597
82598 /* failed to create section attributes, so can't create notes */
82599 if (!mod->sect_attrs)
82600 @@ -1565,7 +1567,7 @@ static void del_usage_links(struct module *mod)
82601 static int module_add_modinfo_attrs(struct module *mod)
82602 {
82603 struct module_attribute *attr;
82604 - struct module_attribute *temp_attr;
82605 + module_attribute_no_const *temp_attr;
82606 int error = 0;
82607 int i;
82608
82609 @@ -1779,21 +1781,21 @@ static void set_section_ro_nx(void *base,
82610
82611 static void unset_module_core_ro_nx(struct module *mod)
82612 {
82613 - set_page_attributes(mod->module_core + mod->core_text_size,
82614 - mod->module_core + mod->core_size,
82615 + set_page_attributes(mod->module_core_rw,
82616 + mod->module_core_rw + mod->core_size_rw,
82617 set_memory_x);
82618 - set_page_attributes(mod->module_core,
82619 - mod->module_core + mod->core_ro_size,
82620 + set_page_attributes(mod->module_core_rx,
82621 + mod->module_core_rx + mod->core_size_rx,
82622 set_memory_rw);
82623 }
82624
82625 static void unset_module_init_ro_nx(struct module *mod)
82626 {
82627 - set_page_attributes(mod->module_init + mod->init_text_size,
82628 - mod->module_init + mod->init_size,
82629 + set_page_attributes(mod->module_init_rw,
82630 + mod->module_init_rw + mod->init_size_rw,
82631 set_memory_x);
82632 - set_page_attributes(mod->module_init,
82633 - mod->module_init + mod->init_ro_size,
82634 + set_page_attributes(mod->module_init_rx,
82635 + mod->module_init_rx + mod->init_size_rx,
82636 set_memory_rw);
82637 }
82638
82639 @@ -1806,14 +1808,14 @@ void set_all_modules_text_rw(void)
82640 list_for_each_entry_rcu(mod, &modules, list) {
82641 if (mod->state == MODULE_STATE_UNFORMED)
82642 continue;
82643 - if ((mod->module_core) && (mod->core_text_size)) {
82644 - set_page_attributes(mod->module_core,
82645 - mod->module_core + mod->core_text_size,
82646 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
82647 + set_page_attributes(mod->module_core_rx,
82648 + mod->module_core_rx + mod->core_size_rx,
82649 set_memory_rw);
82650 }
82651 - if ((mod->module_init) && (mod->init_text_size)) {
82652 - set_page_attributes(mod->module_init,
82653 - mod->module_init + mod->init_text_size,
82654 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
82655 + set_page_attributes(mod->module_init_rx,
82656 + mod->module_init_rx + mod->init_size_rx,
82657 set_memory_rw);
82658 }
82659 }
82660 @@ -1829,14 +1831,14 @@ void set_all_modules_text_ro(void)
82661 list_for_each_entry_rcu(mod, &modules, list) {
82662 if (mod->state == MODULE_STATE_UNFORMED)
82663 continue;
82664 - if ((mod->module_core) && (mod->core_text_size)) {
82665 - set_page_attributes(mod->module_core,
82666 - mod->module_core + mod->core_text_size,
82667 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
82668 + set_page_attributes(mod->module_core_rx,
82669 + mod->module_core_rx + mod->core_size_rx,
82670 set_memory_ro);
82671 }
82672 - if ((mod->module_init) && (mod->init_text_size)) {
82673 - set_page_attributes(mod->module_init,
82674 - mod->module_init + mod->init_text_size,
82675 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
82676 + set_page_attributes(mod->module_init_rx,
82677 + mod->module_init_rx + mod->init_size_rx,
82678 set_memory_ro);
82679 }
82680 }
82681 @@ -1887,16 +1889,19 @@ static void free_module(struct module *mod)
82682
82683 /* This may be NULL, but that's OK */
82684 unset_module_init_ro_nx(mod);
82685 - module_free(mod, mod->module_init);
82686 + module_free(mod, mod->module_init_rw);
82687 + module_free_exec(mod, mod->module_init_rx);
82688 kfree(mod->args);
82689 percpu_modfree(mod);
82690
82691 /* Free lock-classes: */
82692 - lockdep_free_key_range(mod->module_core, mod->core_size);
82693 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
82694 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
82695
82696 /* Finally, free the core (containing the module structure) */
82697 unset_module_core_ro_nx(mod);
82698 - module_free(mod, mod->module_core);
82699 + module_free_exec(mod, mod->module_core_rx);
82700 + module_free(mod, mod->module_core_rw);
82701
82702 #ifdef CONFIG_MPU
82703 update_protections(current->mm);
82704 @@ -1966,9 +1971,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
82705 int ret = 0;
82706 const struct kernel_symbol *ksym;
82707
82708 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82709 + int is_fs_load = 0;
82710 + int register_filesystem_found = 0;
82711 + char *p;
82712 +
82713 + p = strstr(mod->args, "grsec_modharden_fs");
82714 + if (p) {
82715 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
82716 + /* copy \0 as well */
82717 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
82718 + is_fs_load = 1;
82719 + }
82720 +#endif
82721 +
82722 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
82723 const char *name = info->strtab + sym[i].st_name;
82724
82725 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82726 + /* it's a real shame this will never get ripped and copied
82727 + upstream! ;(
82728 + */
82729 + if (is_fs_load && !strcmp(name, "register_filesystem"))
82730 + register_filesystem_found = 1;
82731 +#endif
82732 +
82733 switch (sym[i].st_shndx) {
82734 case SHN_COMMON:
82735 /* We compiled with -fno-common. These are not
82736 @@ -1989,7 +2016,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
82737 ksym = resolve_symbol_wait(mod, info, name);
82738 /* Ok if resolved. */
82739 if (ksym && !IS_ERR(ksym)) {
82740 + pax_open_kernel();
82741 sym[i].st_value = ksym->value;
82742 + pax_close_kernel();
82743 break;
82744 }
82745
82746 @@ -2008,11 +2037,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
82747 secbase = (unsigned long)mod_percpu(mod);
82748 else
82749 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
82750 + pax_open_kernel();
82751 sym[i].st_value += secbase;
82752 + pax_close_kernel();
82753 break;
82754 }
82755 }
82756
82757 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82758 + if (is_fs_load && !register_filesystem_found) {
82759 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
82760 + ret = -EPERM;
82761 + }
82762 +#endif
82763 +
82764 return ret;
82765 }
82766
82767 @@ -2096,22 +2134,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
82768 || s->sh_entsize != ~0UL
82769 || strstarts(sname, ".init"))
82770 continue;
82771 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
82772 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
82773 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
82774 + else
82775 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
82776 pr_debug("\t%s\n", sname);
82777 }
82778 - switch (m) {
82779 - case 0: /* executable */
82780 - mod->core_size = debug_align(mod->core_size);
82781 - mod->core_text_size = mod->core_size;
82782 - break;
82783 - case 1: /* RO: text and ro-data */
82784 - mod->core_size = debug_align(mod->core_size);
82785 - mod->core_ro_size = mod->core_size;
82786 - break;
82787 - case 3: /* whole core */
82788 - mod->core_size = debug_align(mod->core_size);
82789 - break;
82790 - }
82791 }
82792
82793 pr_debug("Init section allocation order:\n");
82794 @@ -2125,23 +2153,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
82795 || s->sh_entsize != ~0UL
82796 || !strstarts(sname, ".init"))
82797 continue;
82798 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
82799 - | INIT_OFFSET_MASK);
82800 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
82801 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
82802 + else
82803 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
82804 + s->sh_entsize |= INIT_OFFSET_MASK;
82805 pr_debug("\t%s\n", sname);
82806 }
82807 - switch (m) {
82808 - case 0: /* executable */
82809 - mod->init_size = debug_align(mod->init_size);
82810 - mod->init_text_size = mod->init_size;
82811 - break;
82812 - case 1: /* RO: text and ro-data */
82813 - mod->init_size = debug_align(mod->init_size);
82814 - mod->init_ro_size = mod->init_size;
82815 - break;
82816 - case 3: /* whole init */
82817 - mod->init_size = debug_align(mod->init_size);
82818 - break;
82819 - }
82820 }
82821 }
82822
82823 @@ -2314,7 +2332,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
82824
82825 /* Put symbol section at end of init part of module. */
82826 symsect->sh_flags |= SHF_ALLOC;
82827 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
82828 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
82829 info->index.sym) | INIT_OFFSET_MASK;
82830 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
82831
82832 @@ -2331,13 +2349,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
82833 }
82834
82835 /* Append room for core symbols at end of core part. */
82836 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
82837 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
82838 - mod->core_size += strtab_size;
82839 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
82840 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
82841 + mod->core_size_rx += strtab_size;
82842
82843 /* Put string table section at end of init part of module. */
82844 strsect->sh_flags |= SHF_ALLOC;
82845 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
82846 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
82847 info->index.str) | INIT_OFFSET_MASK;
82848 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
82849 }
82850 @@ -2355,12 +2373,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
82851 /* Make sure we get permanent strtab: don't use info->strtab. */
82852 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
82853
82854 + pax_open_kernel();
82855 +
82856 /* Set types up while we still have access to sections. */
82857 for (i = 0; i < mod->num_symtab; i++)
82858 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
82859
82860 - mod->core_symtab = dst = mod->module_core + info->symoffs;
82861 - mod->core_strtab = s = mod->module_core + info->stroffs;
82862 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
82863 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
82864 src = mod->symtab;
82865 for (ndst = i = 0; i < mod->num_symtab; i++) {
82866 if (i == 0 ||
82867 @@ -2372,6 +2392,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
82868 }
82869 }
82870 mod->core_num_syms = ndst;
82871 +
82872 + pax_close_kernel();
82873 }
82874 #else
82875 static inline void layout_symtab(struct module *mod, struct load_info *info)
82876 @@ -2405,17 +2427,33 @@ void * __weak module_alloc(unsigned long size)
82877 return vmalloc_exec(size);
82878 }
82879
82880 -static void *module_alloc_update_bounds(unsigned long size)
82881 +static void *module_alloc_update_bounds_rw(unsigned long size)
82882 {
82883 void *ret = module_alloc(size);
82884
82885 if (ret) {
82886 mutex_lock(&module_mutex);
82887 /* Update module bounds. */
82888 - if ((unsigned long)ret < module_addr_min)
82889 - module_addr_min = (unsigned long)ret;
82890 - if ((unsigned long)ret + size > module_addr_max)
82891 - module_addr_max = (unsigned long)ret + size;
82892 + if ((unsigned long)ret < module_addr_min_rw)
82893 + module_addr_min_rw = (unsigned long)ret;
82894 + if ((unsigned long)ret + size > module_addr_max_rw)
82895 + module_addr_max_rw = (unsigned long)ret + size;
82896 + mutex_unlock(&module_mutex);
82897 + }
82898 + return ret;
82899 +}
82900 +
82901 +static void *module_alloc_update_bounds_rx(unsigned long size)
82902 +{
82903 + void *ret = module_alloc_exec(size);
82904 +
82905 + if (ret) {
82906 + mutex_lock(&module_mutex);
82907 + /* Update module bounds. */
82908 + if ((unsigned long)ret < module_addr_min_rx)
82909 + module_addr_min_rx = (unsigned long)ret;
82910 + if ((unsigned long)ret + size > module_addr_max_rx)
82911 + module_addr_max_rx = (unsigned long)ret + size;
82912 mutex_unlock(&module_mutex);
82913 }
82914 return ret;
82915 @@ -2691,8 +2729,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
82916 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
82917 {
82918 const char *modmagic = get_modinfo(info, "vermagic");
82919 + const char *license = get_modinfo(info, "license");
82920 int err;
82921
82922 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
82923 + if (!license || !license_is_gpl_compatible(license))
82924 + return -ENOEXEC;
82925 +#endif
82926 +
82927 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
82928 modmagic = NULL;
82929
82930 @@ -2718,7 +2762,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
82931 }
82932
82933 /* Set up license info based on the info section */
82934 - set_license(mod, get_modinfo(info, "license"));
82935 + set_license(mod, license);
82936
82937 return 0;
82938 }
82939 @@ -2799,7 +2843,7 @@ static int move_module(struct module *mod, struct load_info *info)
82940 void *ptr;
82941
82942 /* Do the allocs. */
82943 - ptr = module_alloc_update_bounds(mod->core_size);
82944 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
82945 /*
82946 * The pointer to this block is stored in the module structure
82947 * which is inside the block. Just mark it as not being a
82948 @@ -2809,11 +2853,11 @@ static int move_module(struct module *mod, struct load_info *info)
82949 if (!ptr)
82950 return -ENOMEM;
82951
82952 - memset(ptr, 0, mod->core_size);
82953 - mod->module_core = ptr;
82954 + memset(ptr, 0, mod->core_size_rw);
82955 + mod->module_core_rw = ptr;
82956
82957 - if (mod->init_size) {
82958 - ptr = module_alloc_update_bounds(mod->init_size);
82959 + if (mod->init_size_rw) {
82960 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
82961 /*
82962 * The pointer to this block is stored in the module structure
82963 * which is inside the block. This block doesn't need to be
82964 @@ -2822,13 +2866,45 @@ static int move_module(struct module *mod, struct load_info *info)
82965 */
82966 kmemleak_ignore(ptr);
82967 if (!ptr) {
82968 - module_free(mod, mod->module_core);
82969 + module_free(mod, mod->module_core_rw);
82970 return -ENOMEM;
82971 }
82972 - memset(ptr, 0, mod->init_size);
82973 - mod->module_init = ptr;
82974 + memset(ptr, 0, mod->init_size_rw);
82975 + mod->module_init_rw = ptr;
82976 } else
82977 - mod->module_init = NULL;
82978 + mod->module_init_rw = NULL;
82979 +
82980 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
82981 + kmemleak_not_leak(ptr);
82982 + if (!ptr) {
82983 + if (mod->module_init_rw)
82984 + module_free(mod, mod->module_init_rw);
82985 + module_free(mod, mod->module_core_rw);
82986 + return -ENOMEM;
82987 + }
82988 +
82989 + pax_open_kernel();
82990 + memset(ptr, 0, mod->core_size_rx);
82991 + pax_close_kernel();
82992 + mod->module_core_rx = ptr;
82993 +
82994 + if (mod->init_size_rx) {
82995 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
82996 + kmemleak_ignore(ptr);
82997 + if (!ptr && mod->init_size_rx) {
82998 + module_free_exec(mod, mod->module_core_rx);
82999 + if (mod->module_init_rw)
83000 + module_free(mod, mod->module_init_rw);
83001 + module_free(mod, mod->module_core_rw);
83002 + return -ENOMEM;
83003 + }
83004 +
83005 + pax_open_kernel();
83006 + memset(ptr, 0, mod->init_size_rx);
83007 + pax_close_kernel();
83008 + mod->module_init_rx = ptr;
83009 + } else
83010 + mod->module_init_rx = NULL;
83011
83012 /* Transfer each section which specifies SHF_ALLOC */
83013 pr_debug("final section addresses:\n");
83014 @@ -2839,16 +2915,45 @@ static int move_module(struct module *mod, struct load_info *info)
83015 if (!(shdr->sh_flags & SHF_ALLOC))
83016 continue;
83017
83018 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
83019 - dest = mod->module_init
83020 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
83021 - else
83022 - dest = mod->module_core + shdr->sh_entsize;
83023 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
83024 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
83025 + dest = mod->module_init_rw
83026 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
83027 + else
83028 + dest = mod->module_init_rx
83029 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
83030 + } else {
83031 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
83032 + dest = mod->module_core_rw + shdr->sh_entsize;
83033 + else
83034 + dest = mod->module_core_rx + shdr->sh_entsize;
83035 + }
83036 +
83037 + if (shdr->sh_type != SHT_NOBITS) {
83038 +
83039 +#ifdef CONFIG_PAX_KERNEXEC
83040 +#ifdef CONFIG_X86_64
83041 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
83042 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
83043 +#endif
83044 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
83045 + pax_open_kernel();
83046 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
83047 + pax_close_kernel();
83048 + } else
83049 +#endif
83050
83051 - if (shdr->sh_type != SHT_NOBITS)
83052 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
83053 + }
83054 /* Update sh_addr to point to copy in image. */
83055 - shdr->sh_addr = (unsigned long)dest;
83056 +
83057 +#ifdef CONFIG_PAX_KERNEXEC
83058 + if (shdr->sh_flags & SHF_EXECINSTR)
83059 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
83060 + else
83061 +#endif
83062 +
83063 + shdr->sh_addr = (unsigned long)dest;
83064 pr_debug("\t0x%lx %s\n",
83065 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
83066 }
83067 @@ -2905,12 +3010,12 @@ static void flush_module_icache(const struct module *mod)
83068 * Do it before processing of module parameters, so the module
83069 * can provide parameter accessor functions of its own.
83070 */
83071 - if (mod->module_init)
83072 - flush_icache_range((unsigned long)mod->module_init,
83073 - (unsigned long)mod->module_init
83074 - + mod->init_size);
83075 - flush_icache_range((unsigned long)mod->module_core,
83076 - (unsigned long)mod->module_core + mod->core_size);
83077 + if (mod->module_init_rx)
83078 + flush_icache_range((unsigned long)mod->module_init_rx,
83079 + (unsigned long)mod->module_init_rx
83080 + + mod->init_size_rx);
83081 + flush_icache_range((unsigned long)mod->module_core_rx,
83082 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
83083
83084 set_fs(old_fs);
83085 }
83086 @@ -2977,8 +3082,10 @@ static int alloc_module_percpu(struct module *mod, struct load_info *info)
83087 static void module_deallocate(struct module *mod, struct load_info *info)
83088 {
83089 percpu_modfree(mod);
83090 - module_free(mod, mod->module_init);
83091 - module_free(mod, mod->module_core);
83092 + module_free_exec(mod, mod->module_init_rx);
83093 + module_free_exec(mod, mod->module_core_rx);
83094 + module_free(mod, mod->module_init_rw);
83095 + module_free(mod, mod->module_core_rw);
83096 }
83097
83098 int __weak module_finalize(const Elf_Ehdr *hdr,
83099 @@ -2991,7 +3098,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
83100 static int post_relocation(struct module *mod, const struct load_info *info)
83101 {
83102 /* Sort exception table now relocations are done. */
83103 + pax_open_kernel();
83104 sort_extable(mod->extable, mod->extable + mod->num_exentries);
83105 + pax_close_kernel();
83106
83107 /* Copy relocated percpu area over. */
83108 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
83109 @@ -3045,16 +3154,16 @@ static int do_init_module(struct module *mod)
83110 MODULE_STATE_COMING, mod);
83111
83112 /* Set RO and NX regions for core */
83113 - set_section_ro_nx(mod->module_core,
83114 - mod->core_text_size,
83115 - mod->core_ro_size,
83116 - mod->core_size);
83117 + set_section_ro_nx(mod->module_core_rx,
83118 + mod->core_size_rx,
83119 + mod->core_size_rx,
83120 + mod->core_size_rx);
83121
83122 /* Set RO and NX regions for init */
83123 - set_section_ro_nx(mod->module_init,
83124 - mod->init_text_size,
83125 - mod->init_ro_size,
83126 - mod->init_size);
83127 + set_section_ro_nx(mod->module_init_rx,
83128 + mod->init_size_rx,
83129 + mod->init_size_rx,
83130 + mod->init_size_rx);
83131
83132 do_mod_ctors(mod);
83133 /* Start the module */
83134 @@ -3116,11 +3225,12 @@ static int do_init_module(struct module *mod)
83135 mod->strtab = mod->core_strtab;
83136 #endif
83137 unset_module_init_ro_nx(mod);
83138 - module_free(mod, mod->module_init);
83139 - mod->module_init = NULL;
83140 - mod->init_size = 0;
83141 - mod->init_ro_size = 0;
83142 - mod->init_text_size = 0;
83143 + module_free(mod, mod->module_init_rw);
83144 + module_free_exec(mod, mod->module_init_rx);
83145 + mod->module_init_rw = NULL;
83146 + mod->module_init_rx = NULL;
83147 + mod->init_size_rw = 0;
83148 + mod->init_size_rx = 0;
83149 mutex_unlock(&module_mutex);
83150 wake_up_all(&module_wq);
83151
83152 @@ -3252,9 +3362,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
83153 if (err)
83154 goto free_unload;
83155
83156 + /* Now copy in args */
83157 + mod->args = strndup_user(uargs, ~0UL >> 1);
83158 + if (IS_ERR(mod->args)) {
83159 + err = PTR_ERR(mod->args);
83160 + goto free_unload;
83161 + }
83162 +
83163 /* Set up MODINFO_ATTR fields */
83164 setup_modinfo(mod, info);
83165
83166 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
83167 + {
83168 + char *p, *p2;
83169 +
83170 + if (strstr(mod->args, "grsec_modharden_netdev")) {
83171 + 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);
83172 + err = -EPERM;
83173 + goto free_modinfo;
83174 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
83175 + p += sizeof("grsec_modharden_normal") - 1;
83176 + p2 = strstr(p, "_");
83177 + if (p2) {
83178 + *p2 = '\0';
83179 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
83180 + *p2 = '_';
83181 + }
83182 + err = -EPERM;
83183 + goto free_modinfo;
83184 + }
83185 + }
83186 +#endif
83187 +
83188 /* Fix up syms, so that st_value is a pointer to location. */
83189 err = simplify_symbols(mod, info);
83190 if (err < 0)
83191 @@ -3270,13 +3409,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
83192
83193 flush_module_icache(mod);
83194
83195 - /* Now copy in args */
83196 - mod->args = strndup_user(uargs, ~0UL >> 1);
83197 - if (IS_ERR(mod->args)) {
83198 - err = PTR_ERR(mod->args);
83199 - goto free_arch_cleanup;
83200 - }
83201 -
83202 dynamic_debug_setup(info->debug, info->num_debug);
83203
83204 /* Finally it's fully formed, ready to start executing. */
83205 @@ -3311,11 +3443,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
83206 ddebug_cleanup:
83207 dynamic_debug_remove(info->debug);
83208 synchronize_sched();
83209 - kfree(mod->args);
83210 - free_arch_cleanup:
83211 module_arch_cleanup(mod);
83212 free_modinfo:
83213 free_modinfo(mod);
83214 + kfree(mod->args);
83215 free_unload:
83216 module_unload_free(mod);
83217 unlink_mod:
83218 @@ -3398,10 +3529,16 @@ static const char *get_ksymbol(struct module *mod,
83219 unsigned long nextval;
83220
83221 /* At worse, next value is at end of module */
83222 - if (within_module_init(addr, mod))
83223 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
83224 + if (within_module_init_rx(addr, mod))
83225 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
83226 + else if (within_module_init_rw(addr, mod))
83227 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
83228 + else if (within_module_core_rx(addr, mod))
83229 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
83230 + else if (within_module_core_rw(addr, mod))
83231 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
83232 else
83233 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
83234 + return NULL;
83235
83236 /* Scan for closest preceding symbol, and next symbol. (ELF
83237 starts real symbols at 1). */
83238 @@ -3654,7 +3791,7 @@ static int m_show(struct seq_file *m, void *p)
83239 return 0;
83240
83241 seq_printf(m, "%s %u",
83242 - mod->name, mod->init_size + mod->core_size);
83243 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
83244 print_unload_info(m, mod);
83245
83246 /* Informative for users. */
83247 @@ -3663,7 +3800,7 @@ static int m_show(struct seq_file *m, void *p)
83248 mod->state == MODULE_STATE_COMING ? "Loading":
83249 "Live");
83250 /* Used by oprofile and other similar tools. */
83251 - seq_printf(m, " 0x%pK", mod->module_core);
83252 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
83253
83254 /* Taints info */
83255 if (mod->taints)
83256 @@ -3699,7 +3836,17 @@ static const struct file_operations proc_modules_operations = {
83257
83258 static int __init proc_modules_init(void)
83259 {
83260 +#ifndef CONFIG_GRKERNSEC_HIDESYM
83261 +#ifdef CONFIG_GRKERNSEC_PROC_USER
83262 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
83263 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
83264 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
83265 +#else
83266 proc_create("modules", 0, NULL, &proc_modules_operations);
83267 +#endif
83268 +#else
83269 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
83270 +#endif
83271 return 0;
83272 }
83273 module_init(proc_modules_init);
83274 @@ -3760,14 +3907,14 @@ struct module *__module_address(unsigned long addr)
83275 {
83276 struct module *mod;
83277
83278 - if (addr < module_addr_min || addr > module_addr_max)
83279 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
83280 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
83281 return NULL;
83282
83283 list_for_each_entry_rcu(mod, &modules, list) {
83284 if (mod->state == MODULE_STATE_UNFORMED)
83285 continue;
83286 - if (within_module_core(addr, mod)
83287 - || within_module_init(addr, mod))
83288 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
83289 return mod;
83290 }
83291 return NULL;
83292 @@ -3802,11 +3949,20 @@ bool is_module_text_address(unsigned long addr)
83293 */
83294 struct module *__module_text_address(unsigned long addr)
83295 {
83296 - struct module *mod = __module_address(addr);
83297 + struct module *mod;
83298 +
83299 +#ifdef CONFIG_X86_32
83300 + addr = ktla_ktva(addr);
83301 +#endif
83302 +
83303 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
83304 + return NULL;
83305 +
83306 + mod = __module_address(addr);
83307 +
83308 if (mod) {
83309 /* Make sure it's within the text section. */
83310 - if (!within(addr, mod->module_init, mod->init_text_size)
83311 - && !within(addr, mod->module_core, mod->core_text_size))
83312 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
83313 mod = NULL;
83314 }
83315 return mod;
83316 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
83317 index 7e3443f..b2a1e6b 100644
83318 --- a/kernel/mutex-debug.c
83319 +++ b/kernel/mutex-debug.c
83320 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
83321 }
83322
83323 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
83324 - struct thread_info *ti)
83325 + struct task_struct *task)
83326 {
83327 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
83328
83329 /* Mark the current thread as blocked on the lock: */
83330 - ti->task->blocked_on = waiter;
83331 + task->blocked_on = waiter;
83332 }
83333
83334 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
83335 - struct thread_info *ti)
83336 + struct task_struct *task)
83337 {
83338 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
83339 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
83340 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
83341 - ti->task->blocked_on = NULL;
83342 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
83343 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
83344 + task->blocked_on = NULL;
83345
83346 list_del_init(&waiter->list);
83347 waiter->task = NULL;
83348 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
83349 index 0799fd3..d06ae3b 100644
83350 --- a/kernel/mutex-debug.h
83351 +++ b/kernel/mutex-debug.h
83352 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
83353 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
83354 extern void debug_mutex_add_waiter(struct mutex *lock,
83355 struct mutex_waiter *waiter,
83356 - struct thread_info *ti);
83357 + struct task_struct *task);
83358 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
83359 - struct thread_info *ti);
83360 + struct task_struct *task);
83361 extern void debug_mutex_unlock(struct mutex *lock);
83362 extern void debug_mutex_init(struct mutex *lock, const char *name,
83363 struct lock_class_key *key);
83364 diff --git a/kernel/mutex.c b/kernel/mutex.c
83365 index ad53a66..f1bf8bc 100644
83366 --- a/kernel/mutex.c
83367 +++ b/kernel/mutex.c
83368 @@ -134,7 +134,7 @@ void mspin_lock(struct mspin_node **lock, struct mspin_node *node)
83369 node->locked = 1;
83370 return;
83371 }
83372 - ACCESS_ONCE(prev->next) = node;
83373 + ACCESS_ONCE_RW(prev->next) = node;
83374 smp_wmb();
83375 /* Wait until the lock holder passes the lock down */
83376 while (!ACCESS_ONCE(node->locked))
83377 @@ -155,7 +155,7 @@ static void mspin_unlock(struct mspin_node **lock, struct mspin_node *node)
83378 while (!(next = ACCESS_ONCE(node->next)))
83379 arch_mutex_cpu_relax();
83380 }
83381 - ACCESS_ONCE(next->locked) = 1;
83382 + ACCESS_ONCE_RW(next->locked) = 1;
83383 smp_wmb();
83384 }
83385
83386 @@ -341,7 +341,7 @@ slowpath:
83387 spin_lock_mutex(&lock->wait_lock, flags);
83388
83389 debug_mutex_lock_common(lock, &waiter);
83390 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
83391 + debug_mutex_add_waiter(lock, &waiter, task);
83392
83393 /* add waiting tasks to the end of the waitqueue (FIFO): */
83394 list_add_tail(&waiter.list, &lock->wait_list);
83395 @@ -371,8 +371,7 @@ slowpath:
83396 * TASK_UNINTERRUPTIBLE case.)
83397 */
83398 if (unlikely(signal_pending_state(state, task))) {
83399 - mutex_remove_waiter(lock, &waiter,
83400 - task_thread_info(task));
83401 + mutex_remove_waiter(lock, &waiter, task);
83402 mutex_release(&lock->dep_map, 1, ip);
83403 spin_unlock_mutex(&lock->wait_lock, flags);
83404
83405 @@ -391,7 +390,7 @@ slowpath:
83406 done:
83407 lock_acquired(&lock->dep_map, ip);
83408 /* got the lock - rejoice! */
83409 - mutex_remove_waiter(lock, &waiter, current_thread_info());
83410 + mutex_remove_waiter(lock, &waiter, task);
83411 mutex_set_owner(lock);
83412
83413 /* set it to 0 if there are no waiters left: */
83414 diff --git a/kernel/notifier.c b/kernel/notifier.c
83415 index 2d5cc4c..d9ea600 100644
83416 --- a/kernel/notifier.c
83417 +++ b/kernel/notifier.c
83418 @@ -5,6 +5,7 @@
83419 #include <linux/rcupdate.h>
83420 #include <linux/vmalloc.h>
83421 #include <linux/reboot.h>
83422 +#include <linux/mm.h>
83423
83424 /*
83425 * Notifier list for kernel code which wants to be called
83426 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
83427 while ((*nl) != NULL) {
83428 if (n->priority > (*nl)->priority)
83429 break;
83430 - nl = &((*nl)->next);
83431 + nl = (struct notifier_block **)&((*nl)->next);
83432 }
83433 - n->next = *nl;
83434 + pax_open_kernel();
83435 + *(const void **)&n->next = *nl;
83436 rcu_assign_pointer(*nl, n);
83437 + pax_close_kernel();
83438 return 0;
83439 }
83440
83441 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
83442 return 0;
83443 if (n->priority > (*nl)->priority)
83444 break;
83445 - nl = &((*nl)->next);
83446 + nl = (struct notifier_block **)&((*nl)->next);
83447 }
83448 - n->next = *nl;
83449 + pax_open_kernel();
83450 + *(const void **)&n->next = *nl;
83451 rcu_assign_pointer(*nl, n);
83452 + pax_close_kernel();
83453 return 0;
83454 }
83455
83456 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
83457 {
83458 while ((*nl) != NULL) {
83459 if ((*nl) == n) {
83460 + pax_open_kernel();
83461 rcu_assign_pointer(*nl, n->next);
83462 + pax_close_kernel();
83463 return 0;
83464 }
83465 - nl = &((*nl)->next);
83466 + nl = (struct notifier_block **)&((*nl)->next);
83467 }
83468 return -ENOENT;
83469 }
83470 diff --git a/kernel/panic.c b/kernel/panic.c
83471 index 167ec09..0dda5f9 100644
83472 --- a/kernel/panic.c
83473 +++ b/kernel/panic.c
83474 @@ -400,7 +400,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
83475 unsigned taint, struct slowpath_args *args)
83476 {
83477 printk(KERN_WARNING "------------[ cut here ]------------\n");
83478 - printk(KERN_WARNING "WARNING: at %s:%d %pS()\n", file, line, caller);
83479 + printk(KERN_WARNING "WARNING: at %s:%d %pA()\n", file, line, caller);
83480
83481 if (args)
83482 vprintk(args->fmt, args->args);
83483 @@ -453,7 +453,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
83484 */
83485 void __stack_chk_fail(void)
83486 {
83487 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
83488 + dump_stack();
83489 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
83490 __builtin_return_address(0));
83491 }
83492 EXPORT_SYMBOL(__stack_chk_fail);
83493 diff --git a/kernel/pid.c b/kernel/pid.c
83494 index 0db3e79..95b9dc2 100644
83495 --- a/kernel/pid.c
83496 +++ b/kernel/pid.c
83497 @@ -33,6 +33,7 @@
83498 #include <linux/rculist.h>
83499 #include <linux/bootmem.h>
83500 #include <linux/hash.h>
83501 +#include <linux/security.h>
83502 #include <linux/pid_namespace.h>
83503 #include <linux/init_task.h>
83504 #include <linux/syscalls.h>
83505 @@ -47,7 +48,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
83506
83507 int pid_max = PID_MAX_DEFAULT;
83508
83509 -#define RESERVED_PIDS 300
83510 +#define RESERVED_PIDS 500
83511
83512 int pid_max_min = RESERVED_PIDS + 1;
83513 int pid_max_max = PID_MAX_LIMIT;
83514 @@ -442,10 +443,18 @@ EXPORT_SYMBOL(pid_task);
83515 */
83516 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
83517 {
83518 + struct task_struct *task;
83519 +
83520 rcu_lockdep_assert(rcu_read_lock_held(),
83521 "find_task_by_pid_ns() needs rcu_read_lock()"
83522 " protection");
83523 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
83524 +
83525 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
83526 +
83527 + if (gr_pid_is_chrooted(task))
83528 + return NULL;
83529 +
83530 + return task;
83531 }
83532
83533 struct task_struct *find_task_by_vpid(pid_t vnr)
83534 @@ -453,6 +462,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
83535 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
83536 }
83537
83538 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
83539 +{
83540 + rcu_lockdep_assert(rcu_read_lock_held(),
83541 + "find_task_by_pid_ns() needs rcu_read_lock()"
83542 + " protection");
83543 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
83544 +}
83545 +
83546 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
83547 {
83548 struct pid *pid;
83549 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
83550 index 6917e8e..9909aeb 100644
83551 --- a/kernel/pid_namespace.c
83552 +++ b/kernel/pid_namespace.c
83553 @@ -247,7 +247,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
83554 void __user *buffer, size_t *lenp, loff_t *ppos)
83555 {
83556 struct pid_namespace *pid_ns = task_active_pid_ns(current);
83557 - struct ctl_table tmp = *table;
83558 + ctl_table_no_const tmp = *table;
83559
83560 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
83561 return -EPERM;
83562 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
83563 index 42670e9..8719c2f 100644
83564 --- a/kernel/posix-cpu-timers.c
83565 +++ b/kernel/posix-cpu-timers.c
83566 @@ -1636,14 +1636,14 @@ struct k_clock clock_posix_cpu = {
83567
83568 static __init int init_posix_cpu_timers(void)
83569 {
83570 - struct k_clock process = {
83571 + static struct k_clock process = {
83572 .clock_getres = process_cpu_clock_getres,
83573 .clock_get = process_cpu_clock_get,
83574 .timer_create = process_cpu_timer_create,
83575 .nsleep = process_cpu_nsleep,
83576 .nsleep_restart = process_cpu_nsleep_restart,
83577 };
83578 - struct k_clock thread = {
83579 + static struct k_clock thread = {
83580 .clock_getres = thread_cpu_clock_getres,
83581 .clock_get = thread_cpu_clock_get,
83582 .timer_create = thread_cpu_timer_create,
83583 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
83584 index 424c2d4..679242f 100644
83585 --- a/kernel/posix-timers.c
83586 +++ b/kernel/posix-timers.c
83587 @@ -43,6 +43,7 @@
83588 #include <linux/hash.h>
83589 #include <linux/posix-clock.h>
83590 #include <linux/posix-timers.h>
83591 +#include <linux/grsecurity.h>
83592 #include <linux/syscalls.h>
83593 #include <linux/wait.h>
83594 #include <linux/workqueue.h>
83595 @@ -122,7 +123,7 @@ static DEFINE_SPINLOCK(hash_lock);
83596 * which we beg off on and pass to do_sys_settimeofday().
83597 */
83598
83599 -static struct k_clock posix_clocks[MAX_CLOCKS];
83600 +static struct k_clock *posix_clocks[MAX_CLOCKS];
83601
83602 /*
83603 * These ones are defined below.
83604 @@ -275,7 +276,7 @@ static int posix_get_tai(clockid_t which_clock, struct timespec *tp)
83605 */
83606 static __init int init_posix_timers(void)
83607 {
83608 - struct k_clock clock_realtime = {
83609 + static struct k_clock clock_realtime = {
83610 .clock_getres = hrtimer_get_res,
83611 .clock_get = posix_clock_realtime_get,
83612 .clock_set = posix_clock_realtime_set,
83613 @@ -287,7 +288,7 @@ static __init int init_posix_timers(void)
83614 .timer_get = common_timer_get,
83615 .timer_del = common_timer_del,
83616 };
83617 - struct k_clock clock_monotonic = {
83618 + static struct k_clock clock_monotonic = {
83619 .clock_getres = hrtimer_get_res,
83620 .clock_get = posix_ktime_get_ts,
83621 .nsleep = common_nsleep,
83622 @@ -297,19 +298,19 @@ static __init int init_posix_timers(void)
83623 .timer_get = common_timer_get,
83624 .timer_del = common_timer_del,
83625 };
83626 - struct k_clock clock_monotonic_raw = {
83627 + static struct k_clock clock_monotonic_raw = {
83628 .clock_getres = hrtimer_get_res,
83629 .clock_get = posix_get_monotonic_raw,
83630 };
83631 - struct k_clock clock_realtime_coarse = {
83632 + static struct k_clock clock_realtime_coarse = {
83633 .clock_getres = posix_get_coarse_res,
83634 .clock_get = posix_get_realtime_coarse,
83635 };
83636 - struct k_clock clock_monotonic_coarse = {
83637 + static struct k_clock clock_monotonic_coarse = {
83638 .clock_getres = posix_get_coarse_res,
83639 .clock_get = posix_get_monotonic_coarse,
83640 };
83641 - struct k_clock clock_tai = {
83642 + static struct k_clock clock_tai = {
83643 .clock_getres = hrtimer_get_res,
83644 .clock_get = posix_get_tai,
83645 .nsleep = common_nsleep,
83646 @@ -319,7 +320,7 @@ static __init int init_posix_timers(void)
83647 .timer_get = common_timer_get,
83648 .timer_del = common_timer_del,
83649 };
83650 - struct k_clock clock_boottime = {
83651 + static struct k_clock clock_boottime = {
83652 .clock_getres = hrtimer_get_res,
83653 .clock_get = posix_get_boottime,
83654 .nsleep = common_nsleep,
83655 @@ -531,7 +532,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
83656 return;
83657 }
83658
83659 - posix_clocks[clock_id] = *new_clock;
83660 + posix_clocks[clock_id] = new_clock;
83661 }
83662 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
83663
83664 @@ -577,9 +578,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
83665 return (id & CLOCKFD_MASK) == CLOCKFD ?
83666 &clock_posix_dynamic : &clock_posix_cpu;
83667
83668 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
83669 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
83670 return NULL;
83671 - return &posix_clocks[id];
83672 + return posix_clocks[id];
83673 }
83674
83675 static int common_timer_create(struct k_itimer *new_timer)
83676 @@ -597,7 +598,7 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
83677 struct k_clock *kc = clockid_to_kclock(which_clock);
83678 struct k_itimer *new_timer;
83679 int error, new_timer_id;
83680 - sigevent_t event;
83681 + sigevent_t event = { };
83682 int it_id_set = IT_ID_NOT_SET;
83683
83684 if (!kc)
83685 @@ -1011,6 +1012,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
83686 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
83687 return -EFAULT;
83688
83689 + /* only the CLOCK_REALTIME clock can be set, all other clocks
83690 + have their clock_set fptr set to a nosettime dummy function
83691 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
83692 + call common_clock_set, which calls do_sys_settimeofday, which
83693 + we hook
83694 + */
83695 +
83696 return kc->clock_set(which_clock, &new_tp);
83697 }
83698
83699 diff --git a/kernel/power/process.c b/kernel/power/process.c
83700 index 98088e0..aaf95c0 100644
83701 --- a/kernel/power/process.c
83702 +++ b/kernel/power/process.c
83703 @@ -33,6 +33,7 @@ static int try_to_freeze_tasks(bool user_only)
83704 u64 elapsed_csecs64;
83705 unsigned int elapsed_csecs;
83706 bool wakeup = false;
83707 + bool timedout = false;
83708
83709 do_gettimeofday(&start);
83710
83711 @@ -43,13 +44,20 @@ static int try_to_freeze_tasks(bool user_only)
83712
83713 while (true) {
83714 todo = 0;
83715 + if (time_after(jiffies, end_time))
83716 + timedout = true;
83717 read_lock(&tasklist_lock);
83718 do_each_thread(g, p) {
83719 if (p == current || !freeze_task(p))
83720 continue;
83721
83722 - if (!freezer_should_skip(p))
83723 + if (!freezer_should_skip(p)) {
83724 todo++;
83725 + if (timedout) {
83726 + printk(KERN_ERR "Task refusing to freeze:\n");
83727 + sched_show_task(p);
83728 + }
83729 + }
83730 } while_each_thread(g, p);
83731 read_unlock(&tasklist_lock);
83732
83733 @@ -58,7 +66,7 @@ static int try_to_freeze_tasks(bool user_only)
83734 todo += wq_busy;
83735 }
83736
83737 - if (!todo || time_after(jiffies, end_time))
83738 + if (!todo || timedout)
83739 break;
83740
83741 if (pm_wakeup_pending()) {
83742 diff --git a/kernel/printk.c b/kernel/printk.c
83743 index d37d45c..ab918b3 100644
83744 --- a/kernel/printk.c
83745 +++ b/kernel/printk.c
83746 @@ -390,6 +390,11 @@ static int check_syslog_permissions(int type, bool from_file)
83747 if (from_file && type != SYSLOG_ACTION_OPEN)
83748 return 0;
83749
83750 +#ifdef CONFIG_GRKERNSEC_DMESG
83751 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
83752 + return -EPERM;
83753 +#endif
83754 +
83755 if (syslog_action_restricted(type)) {
83756 if (capable(CAP_SYSLOG))
83757 return 0;
83758 diff --git a/kernel/profile.c b/kernel/profile.c
83759 index 0bf4007..6234708 100644
83760 --- a/kernel/profile.c
83761 +++ b/kernel/profile.c
83762 @@ -37,7 +37,7 @@ struct profile_hit {
83763 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
83764 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
83765
83766 -static atomic_t *prof_buffer;
83767 +static atomic_unchecked_t *prof_buffer;
83768 static unsigned long prof_len, prof_shift;
83769
83770 int prof_on __read_mostly;
83771 @@ -260,7 +260,7 @@ static void profile_flip_buffers(void)
83772 hits[i].pc = 0;
83773 continue;
83774 }
83775 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
83776 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
83777 hits[i].hits = hits[i].pc = 0;
83778 }
83779 }
83780 @@ -321,9 +321,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
83781 * Add the current hit(s) and flush the write-queue out
83782 * to the global buffer:
83783 */
83784 - atomic_add(nr_hits, &prof_buffer[pc]);
83785 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
83786 for (i = 0; i < NR_PROFILE_HIT; ++i) {
83787 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
83788 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
83789 hits[i].pc = hits[i].hits = 0;
83790 }
83791 out:
83792 @@ -398,7 +398,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
83793 {
83794 unsigned long pc;
83795 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
83796 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
83797 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
83798 }
83799 #endif /* !CONFIG_SMP */
83800
83801 @@ -494,7 +494,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
83802 return -EFAULT;
83803 buf++; p++; count--; read++;
83804 }
83805 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
83806 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
83807 if (copy_to_user(buf, (void *)pnt, count))
83808 return -EFAULT;
83809 read += count;
83810 @@ -525,7 +525,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
83811 }
83812 #endif
83813 profile_discard_flip_buffers();
83814 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
83815 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
83816 return count;
83817 }
83818
83819 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
83820 index 335a7ae..3bbbceb 100644
83821 --- a/kernel/ptrace.c
83822 +++ b/kernel/ptrace.c
83823 @@ -326,7 +326,7 @@ static int ptrace_attach(struct task_struct *task, long request,
83824 if (seize)
83825 flags |= PT_SEIZED;
83826 rcu_read_lock();
83827 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
83828 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
83829 flags |= PT_PTRACE_CAP;
83830 rcu_read_unlock();
83831 task->ptrace = flags;
83832 @@ -537,7 +537,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
83833 break;
83834 return -EIO;
83835 }
83836 - if (copy_to_user(dst, buf, retval))
83837 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
83838 return -EFAULT;
83839 copied += retval;
83840 src += retval;
83841 @@ -805,7 +805,7 @@ int ptrace_request(struct task_struct *child, long request,
83842 bool seized = child->ptrace & PT_SEIZED;
83843 int ret = -EIO;
83844 siginfo_t siginfo, *si;
83845 - void __user *datavp = (void __user *) data;
83846 + void __user *datavp = (__force void __user *) data;
83847 unsigned long __user *datalp = datavp;
83848 unsigned long flags;
83849
83850 @@ -1011,14 +1011,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
83851 goto out;
83852 }
83853
83854 + if (gr_handle_ptrace(child, request)) {
83855 + ret = -EPERM;
83856 + goto out_put_task_struct;
83857 + }
83858 +
83859 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
83860 ret = ptrace_attach(child, request, addr, data);
83861 /*
83862 * Some architectures need to do book-keeping after
83863 * a ptrace attach.
83864 */
83865 - if (!ret)
83866 + if (!ret) {
83867 arch_ptrace_attach(child);
83868 + gr_audit_ptrace(child);
83869 + }
83870 goto out_put_task_struct;
83871 }
83872
83873 @@ -1046,7 +1053,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
83874 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
83875 if (copied != sizeof(tmp))
83876 return -EIO;
83877 - return put_user(tmp, (unsigned long __user *)data);
83878 + return put_user(tmp, (__force unsigned long __user *)data);
83879 }
83880
83881 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
83882 @@ -1140,7 +1147,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
83883 }
83884
83885 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
83886 - compat_long_t addr, compat_long_t data)
83887 + compat_ulong_t addr, compat_ulong_t data)
83888 {
83889 struct task_struct *child;
83890 long ret;
83891 @@ -1156,14 +1163,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
83892 goto out;
83893 }
83894
83895 + if (gr_handle_ptrace(child, request)) {
83896 + ret = -EPERM;
83897 + goto out_put_task_struct;
83898 + }
83899 +
83900 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
83901 ret = ptrace_attach(child, request, addr, data);
83902 /*
83903 * Some architectures need to do book-keeping after
83904 * a ptrace attach.
83905 */
83906 - if (!ret)
83907 + if (!ret) {
83908 arch_ptrace_attach(child);
83909 + gr_audit_ptrace(child);
83910 + }
83911 goto out_put_task_struct;
83912 }
83913
83914 diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
83915 index 48ab703..07561d4 100644
83916 --- a/kernel/rcupdate.c
83917 +++ b/kernel/rcupdate.c
83918 @@ -439,10 +439,10 @@ int rcu_jiffies_till_stall_check(void)
83919 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
83920 */
83921 if (till_stall_check < 3) {
83922 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
83923 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
83924 till_stall_check = 3;
83925 } else if (till_stall_check > 300) {
83926 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
83927 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
83928 till_stall_check = 300;
83929 }
83930 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
83931 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
83932 index a0714a5..2ab5e34 100644
83933 --- a/kernel/rcutiny.c
83934 +++ b/kernel/rcutiny.c
83935 @@ -46,7 +46,7 @@
83936 struct rcu_ctrlblk;
83937 static void invoke_rcu_callbacks(void);
83938 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
83939 -static void rcu_process_callbacks(struct softirq_action *unused);
83940 +static void rcu_process_callbacks(void);
83941 static void __call_rcu(struct rcu_head *head,
83942 void (*func)(struct rcu_head *rcu),
83943 struct rcu_ctrlblk *rcp);
83944 @@ -312,7 +312,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
83945 rcu_is_callbacks_kthread()));
83946 }
83947
83948 -static void rcu_process_callbacks(struct softirq_action *unused)
83949 +static void rcu_process_callbacks(void)
83950 {
83951 __rcu_process_callbacks(&rcu_sched_ctrlblk);
83952 __rcu_process_callbacks(&rcu_bh_ctrlblk);
83953 diff --git a/kernel/rcutiny_plugin.h b/kernel/rcutiny_plugin.h
83954 index 8a23300..4255818 100644
83955 --- a/kernel/rcutiny_plugin.h
83956 +++ b/kernel/rcutiny_plugin.h
83957 @@ -945,7 +945,7 @@ static int rcu_kthread(void *arg)
83958 have_rcu_kthread_work = morework;
83959 local_irq_restore(flags);
83960 if (work)
83961 - rcu_process_callbacks(NULL);
83962 + rcu_process_callbacks();
83963 schedule_timeout_interruptible(1); /* Leave CPU for others. */
83964 }
83965
83966 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
83967 index e1f3a8c..42c94a2 100644
83968 --- a/kernel/rcutorture.c
83969 +++ b/kernel/rcutorture.c
83970 @@ -164,12 +164,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
83971 { 0 };
83972 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
83973 { 0 };
83974 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
83975 -static atomic_t n_rcu_torture_alloc;
83976 -static atomic_t n_rcu_torture_alloc_fail;
83977 -static atomic_t n_rcu_torture_free;
83978 -static atomic_t n_rcu_torture_mberror;
83979 -static atomic_t n_rcu_torture_error;
83980 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
83981 +static atomic_unchecked_t n_rcu_torture_alloc;
83982 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
83983 +static atomic_unchecked_t n_rcu_torture_free;
83984 +static atomic_unchecked_t n_rcu_torture_mberror;
83985 +static atomic_unchecked_t n_rcu_torture_error;
83986 static long n_rcu_torture_barrier_error;
83987 static long n_rcu_torture_boost_ktrerror;
83988 static long n_rcu_torture_boost_rterror;
83989 @@ -287,11 +287,11 @@ rcu_torture_alloc(void)
83990
83991 spin_lock_bh(&rcu_torture_lock);
83992 if (list_empty(&rcu_torture_freelist)) {
83993 - atomic_inc(&n_rcu_torture_alloc_fail);
83994 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
83995 spin_unlock_bh(&rcu_torture_lock);
83996 return NULL;
83997 }
83998 - atomic_inc(&n_rcu_torture_alloc);
83999 + atomic_inc_unchecked(&n_rcu_torture_alloc);
84000 p = rcu_torture_freelist.next;
84001 list_del_init(p);
84002 spin_unlock_bh(&rcu_torture_lock);
84003 @@ -304,7 +304,7 @@ rcu_torture_alloc(void)
84004 static void
84005 rcu_torture_free(struct rcu_torture *p)
84006 {
84007 - atomic_inc(&n_rcu_torture_free);
84008 + atomic_inc_unchecked(&n_rcu_torture_free);
84009 spin_lock_bh(&rcu_torture_lock);
84010 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
84011 spin_unlock_bh(&rcu_torture_lock);
84012 @@ -424,7 +424,7 @@ rcu_torture_cb(struct rcu_head *p)
84013 i = rp->rtort_pipe_count;
84014 if (i > RCU_TORTURE_PIPE_LEN)
84015 i = RCU_TORTURE_PIPE_LEN;
84016 - atomic_inc(&rcu_torture_wcount[i]);
84017 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
84018 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
84019 rp->rtort_mbtest = 0;
84020 rcu_torture_free(rp);
84021 @@ -472,7 +472,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
84022 i = rp->rtort_pipe_count;
84023 if (i > RCU_TORTURE_PIPE_LEN)
84024 i = RCU_TORTURE_PIPE_LEN;
84025 - atomic_inc(&rcu_torture_wcount[i]);
84026 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
84027 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
84028 rp->rtort_mbtest = 0;
84029 list_del(&rp->rtort_free);
84030 @@ -990,7 +990,7 @@ rcu_torture_writer(void *arg)
84031 i = old_rp->rtort_pipe_count;
84032 if (i > RCU_TORTURE_PIPE_LEN)
84033 i = RCU_TORTURE_PIPE_LEN;
84034 - atomic_inc(&rcu_torture_wcount[i]);
84035 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
84036 old_rp->rtort_pipe_count++;
84037 cur_ops->deferred_free(old_rp);
84038 }
84039 @@ -1076,7 +1076,7 @@ static void rcu_torture_timer(unsigned long unused)
84040 return;
84041 }
84042 if (p->rtort_mbtest == 0)
84043 - atomic_inc(&n_rcu_torture_mberror);
84044 + atomic_inc_unchecked(&n_rcu_torture_mberror);
84045 spin_lock(&rand_lock);
84046 cur_ops->read_delay(&rand);
84047 n_rcu_torture_timers++;
84048 @@ -1146,7 +1146,7 @@ rcu_torture_reader(void *arg)
84049 continue;
84050 }
84051 if (p->rtort_mbtest == 0)
84052 - atomic_inc(&n_rcu_torture_mberror);
84053 + atomic_inc_unchecked(&n_rcu_torture_mberror);
84054 cur_ops->read_delay(&rand);
84055 preempt_disable();
84056 pipe_count = p->rtort_pipe_count;
84057 @@ -1209,11 +1209,11 @@ rcu_torture_printk(char *page)
84058 rcu_torture_current,
84059 rcu_torture_current_version,
84060 list_empty(&rcu_torture_freelist),
84061 - atomic_read(&n_rcu_torture_alloc),
84062 - atomic_read(&n_rcu_torture_alloc_fail),
84063 - atomic_read(&n_rcu_torture_free));
84064 + atomic_read_unchecked(&n_rcu_torture_alloc),
84065 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
84066 + atomic_read_unchecked(&n_rcu_torture_free));
84067 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
84068 - atomic_read(&n_rcu_torture_mberror),
84069 + atomic_read_unchecked(&n_rcu_torture_mberror),
84070 n_rcu_torture_boost_ktrerror,
84071 n_rcu_torture_boost_rterror);
84072 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
84073 @@ -1232,14 +1232,14 @@ rcu_torture_printk(char *page)
84074 n_barrier_attempts,
84075 n_rcu_torture_barrier_error);
84076 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
84077 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
84078 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
84079 n_rcu_torture_barrier_error != 0 ||
84080 n_rcu_torture_boost_ktrerror != 0 ||
84081 n_rcu_torture_boost_rterror != 0 ||
84082 n_rcu_torture_boost_failure != 0 ||
84083 i > 1) {
84084 cnt += sprintf(&page[cnt], "!!! ");
84085 - atomic_inc(&n_rcu_torture_error);
84086 + atomic_inc_unchecked(&n_rcu_torture_error);
84087 WARN_ON_ONCE(1);
84088 }
84089 cnt += sprintf(&page[cnt], "Reader Pipe: ");
84090 @@ -1253,7 +1253,7 @@ rcu_torture_printk(char *page)
84091 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
84092 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
84093 cnt += sprintf(&page[cnt], " %d",
84094 - atomic_read(&rcu_torture_wcount[i]));
84095 + atomic_read_unchecked(&rcu_torture_wcount[i]));
84096 }
84097 cnt += sprintf(&page[cnt], "\n");
84098 if (cur_ops->stats)
84099 @@ -1962,7 +1962,7 @@ rcu_torture_cleanup(void)
84100
84101 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
84102
84103 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
84104 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
84105 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
84106 else if (n_online_successes != n_online_attempts ||
84107 n_offline_successes != n_offline_attempts)
84108 @@ -2031,18 +2031,18 @@ rcu_torture_init(void)
84109
84110 rcu_torture_current = NULL;
84111 rcu_torture_current_version = 0;
84112 - atomic_set(&n_rcu_torture_alloc, 0);
84113 - atomic_set(&n_rcu_torture_alloc_fail, 0);
84114 - atomic_set(&n_rcu_torture_free, 0);
84115 - atomic_set(&n_rcu_torture_mberror, 0);
84116 - atomic_set(&n_rcu_torture_error, 0);
84117 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
84118 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
84119 + atomic_set_unchecked(&n_rcu_torture_free, 0);
84120 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
84121 + atomic_set_unchecked(&n_rcu_torture_error, 0);
84122 n_rcu_torture_barrier_error = 0;
84123 n_rcu_torture_boost_ktrerror = 0;
84124 n_rcu_torture_boost_rterror = 0;
84125 n_rcu_torture_boost_failure = 0;
84126 n_rcu_torture_boosts = 0;
84127 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
84128 - atomic_set(&rcu_torture_wcount[i], 0);
84129 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
84130 for_each_possible_cpu(cpu) {
84131 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
84132 per_cpu(rcu_torture_count, cpu)[i] = 0;
84133 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
84134 index 3538001..e379e0b 100644
84135 --- a/kernel/rcutree.c
84136 +++ b/kernel/rcutree.c
84137 @@ -358,9 +358,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
84138 rcu_prepare_for_idle(smp_processor_id());
84139 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
84140 smp_mb__before_atomic_inc(); /* See above. */
84141 - atomic_inc(&rdtp->dynticks);
84142 + atomic_inc_unchecked(&rdtp->dynticks);
84143 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
84144 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
84145 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
84146
84147 /*
84148 * It is illegal to enter an extended quiescent state while
84149 @@ -496,10 +496,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
84150 int user)
84151 {
84152 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
84153 - atomic_inc(&rdtp->dynticks);
84154 + atomic_inc_unchecked(&rdtp->dynticks);
84155 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
84156 smp_mb__after_atomic_inc(); /* See above. */
84157 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
84158 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
84159 rcu_cleanup_after_idle(smp_processor_id());
84160 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
84161 if (!user && !is_idle_task(current)) {
84162 @@ -638,14 +638,14 @@ void rcu_nmi_enter(void)
84163 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
84164
84165 if (rdtp->dynticks_nmi_nesting == 0 &&
84166 - (atomic_read(&rdtp->dynticks) & 0x1))
84167 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
84168 return;
84169 rdtp->dynticks_nmi_nesting++;
84170 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
84171 - atomic_inc(&rdtp->dynticks);
84172 + atomic_inc_unchecked(&rdtp->dynticks);
84173 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
84174 smp_mb__after_atomic_inc(); /* See above. */
84175 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
84176 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
84177 }
84178
84179 /**
84180 @@ -664,9 +664,9 @@ void rcu_nmi_exit(void)
84181 return;
84182 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
84183 smp_mb__before_atomic_inc(); /* See above. */
84184 - atomic_inc(&rdtp->dynticks);
84185 + atomic_inc_unchecked(&rdtp->dynticks);
84186 smp_mb__after_atomic_inc(); /* Force delay to next write. */
84187 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
84188 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
84189 }
84190
84191 /**
84192 @@ -680,7 +680,7 @@ int rcu_is_cpu_idle(void)
84193 int ret;
84194
84195 preempt_disable();
84196 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
84197 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
84198 preempt_enable();
84199 return ret;
84200 }
84201 @@ -748,7 +748,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
84202 */
84203 static int dyntick_save_progress_counter(struct rcu_data *rdp)
84204 {
84205 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
84206 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
84207 return (rdp->dynticks_snap & 0x1) == 0;
84208 }
84209
84210 @@ -763,7 +763,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
84211 unsigned int curr;
84212 unsigned int snap;
84213
84214 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
84215 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
84216 snap = (unsigned int)rdp->dynticks_snap;
84217
84218 /*
84219 @@ -1440,9 +1440,9 @@ static int rcu_gp_init(struct rcu_state *rsp)
84220 rdp = this_cpu_ptr(rsp->rda);
84221 rcu_preempt_check_blocked_tasks(rnp);
84222 rnp->qsmask = rnp->qsmaskinit;
84223 - ACCESS_ONCE(rnp->gpnum) = rsp->gpnum;
84224 + ACCESS_ONCE_RW(rnp->gpnum) = rsp->gpnum;
84225 WARN_ON_ONCE(rnp->completed != rsp->completed);
84226 - ACCESS_ONCE(rnp->completed) = rsp->completed;
84227 + ACCESS_ONCE_RW(rnp->completed) = rsp->completed;
84228 if (rnp == rdp->mynode)
84229 rcu_start_gp_per_cpu(rsp, rnp, rdp);
84230 rcu_preempt_boost_start_gp(rnp);
84231 @@ -1524,7 +1524,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
84232 */
84233 rcu_for_each_node_breadth_first(rsp, rnp) {
84234 raw_spin_lock_irq(&rnp->lock);
84235 - ACCESS_ONCE(rnp->completed) = rsp->gpnum;
84236 + ACCESS_ONCE_RW(rnp->completed) = rsp->gpnum;
84237 rdp = this_cpu_ptr(rsp->rda);
84238 if (rnp == rdp->mynode)
84239 __rcu_process_gp_end(rsp, rnp, rdp);
84240 @@ -1855,7 +1855,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
84241 rsp->qlen += rdp->qlen;
84242 rdp->n_cbs_orphaned += rdp->qlen;
84243 rdp->qlen_lazy = 0;
84244 - ACCESS_ONCE(rdp->qlen) = 0;
84245 + ACCESS_ONCE_RW(rdp->qlen) = 0;
84246 }
84247
84248 /*
84249 @@ -2101,7 +2101,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
84250 }
84251 smp_mb(); /* List handling before counting for rcu_barrier(). */
84252 rdp->qlen_lazy -= count_lazy;
84253 - ACCESS_ONCE(rdp->qlen) -= count;
84254 + ACCESS_ONCE_RW(rdp->qlen) -= count;
84255 rdp->n_cbs_invoked += count;
84256
84257 /* Reinstate batch limit if we have worked down the excess. */
84258 @@ -2295,7 +2295,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
84259 /*
84260 * Do RCU core processing for the current CPU.
84261 */
84262 -static void rcu_process_callbacks(struct softirq_action *unused)
84263 +static void rcu_process_callbacks(void)
84264 {
84265 struct rcu_state *rsp;
84266
84267 @@ -2419,7 +2419,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
84268 local_irq_restore(flags);
84269 return;
84270 }
84271 - ACCESS_ONCE(rdp->qlen)++;
84272 + ACCESS_ONCE_RW(rdp->qlen)++;
84273 if (lazy)
84274 rdp->qlen_lazy++;
84275 else
84276 @@ -2628,11 +2628,11 @@ void synchronize_sched_expedited(void)
84277 * counter wrap on a 32-bit system. Quite a few more CPUs would of
84278 * course be required on a 64-bit system.
84279 */
84280 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
84281 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
84282 (ulong)atomic_long_read(&rsp->expedited_done) +
84283 ULONG_MAX / 8)) {
84284 synchronize_sched();
84285 - atomic_long_inc(&rsp->expedited_wrap);
84286 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
84287 return;
84288 }
84289
84290 @@ -2640,7 +2640,7 @@ void synchronize_sched_expedited(void)
84291 * Take a ticket. Note that atomic_inc_return() implies a
84292 * full memory barrier.
84293 */
84294 - snap = atomic_long_inc_return(&rsp->expedited_start);
84295 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
84296 firstsnap = snap;
84297 get_online_cpus();
84298 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
84299 @@ -2653,14 +2653,14 @@ void synchronize_sched_expedited(void)
84300 synchronize_sched_expedited_cpu_stop,
84301 NULL) == -EAGAIN) {
84302 put_online_cpus();
84303 - atomic_long_inc(&rsp->expedited_tryfail);
84304 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
84305
84306 /* Check to see if someone else did our work for us. */
84307 s = atomic_long_read(&rsp->expedited_done);
84308 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
84309 /* ensure test happens before caller kfree */
84310 smp_mb__before_atomic_inc(); /* ^^^ */
84311 - atomic_long_inc(&rsp->expedited_workdone1);
84312 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
84313 return;
84314 }
84315
84316 @@ -2669,7 +2669,7 @@ void synchronize_sched_expedited(void)
84317 udelay(trycount * num_online_cpus());
84318 } else {
84319 wait_rcu_gp(call_rcu_sched);
84320 - atomic_long_inc(&rsp->expedited_normal);
84321 + atomic_long_inc_unchecked(&rsp->expedited_normal);
84322 return;
84323 }
84324
84325 @@ -2678,7 +2678,7 @@ void synchronize_sched_expedited(void)
84326 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
84327 /* ensure test happens before caller kfree */
84328 smp_mb__before_atomic_inc(); /* ^^^ */
84329 - atomic_long_inc(&rsp->expedited_workdone2);
84330 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
84331 return;
84332 }
84333
84334 @@ -2690,10 +2690,10 @@ void synchronize_sched_expedited(void)
84335 * period works for us.
84336 */
84337 get_online_cpus();
84338 - snap = atomic_long_read(&rsp->expedited_start);
84339 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
84340 smp_mb(); /* ensure read is before try_stop_cpus(). */
84341 }
84342 - atomic_long_inc(&rsp->expedited_stoppedcpus);
84343 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
84344
84345 /*
84346 * Everyone up to our most recent fetch is covered by our grace
84347 @@ -2702,16 +2702,16 @@ void synchronize_sched_expedited(void)
84348 * than we did already did their update.
84349 */
84350 do {
84351 - atomic_long_inc(&rsp->expedited_done_tries);
84352 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
84353 s = atomic_long_read(&rsp->expedited_done);
84354 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
84355 /* ensure test happens before caller kfree */
84356 smp_mb__before_atomic_inc(); /* ^^^ */
84357 - atomic_long_inc(&rsp->expedited_done_lost);
84358 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
84359 break;
84360 }
84361 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
84362 - atomic_long_inc(&rsp->expedited_done_exit);
84363 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
84364
84365 put_online_cpus();
84366 }
84367 @@ -2893,7 +2893,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
84368 * ACCESS_ONCE() to prevent the compiler from speculating
84369 * the increment to precede the early-exit check.
84370 */
84371 - ACCESS_ONCE(rsp->n_barrier_done)++;
84372 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
84373 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
84374 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
84375 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
84376 @@ -2943,7 +2943,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
84377
84378 /* Increment ->n_barrier_done to prevent duplicate work. */
84379 smp_mb(); /* Keep increment after above mechanism. */
84380 - ACCESS_ONCE(rsp->n_barrier_done)++;
84381 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
84382 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
84383 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
84384 smp_mb(); /* Keep increment before caller's subsequent code. */
84385 @@ -2988,10 +2988,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
84386 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
84387 init_callback_list(rdp);
84388 rdp->qlen_lazy = 0;
84389 - ACCESS_ONCE(rdp->qlen) = 0;
84390 + ACCESS_ONCE_RW(rdp->qlen) = 0;
84391 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
84392 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
84393 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
84394 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
84395 rdp->cpu = cpu;
84396 rdp->rsp = rsp;
84397 rcu_boot_init_nocb_percpu_data(rdp);
84398 @@ -3024,8 +3024,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
84399 rdp->blimit = blimit;
84400 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
84401 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
84402 - atomic_set(&rdp->dynticks->dynticks,
84403 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
84404 + atomic_set_unchecked(&rdp->dynticks->dynticks,
84405 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
84406 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
84407
84408 /* Add CPU to rcu_node bitmasks. */
84409 @@ -3120,7 +3120,7 @@ static int __init rcu_spawn_gp_kthread(void)
84410 struct task_struct *t;
84411
84412 for_each_rcu_flavor(rsp) {
84413 - t = kthread_run(rcu_gp_kthread, rsp, rsp->name);
84414 + t = kthread_run(rcu_gp_kthread, rsp, "%s", rsp->name);
84415 BUG_ON(IS_ERR(t));
84416 rnp = rcu_get_root(rsp);
84417 raw_spin_lock_irqsave(&rnp->lock, flags);
84418 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
84419 index 4df5034..5ee93f2 100644
84420 --- a/kernel/rcutree.h
84421 +++ b/kernel/rcutree.h
84422 @@ -87,7 +87,7 @@ struct rcu_dynticks {
84423 long long dynticks_nesting; /* Track irq/process nesting level. */
84424 /* Process level is worth LLONG_MAX/2. */
84425 int dynticks_nmi_nesting; /* Track NMI nesting level. */
84426 - atomic_t dynticks; /* Even value for idle, else odd. */
84427 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
84428 #ifdef CONFIG_RCU_FAST_NO_HZ
84429 bool all_lazy; /* Are all CPU's CBs lazy? */
84430 unsigned long nonlazy_posted;
84431 @@ -414,17 +414,17 @@ struct rcu_state {
84432 /* _rcu_barrier(). */
84433 /* End of fields guarded by barrier_mutex. */
84434
84435 - atomic_long_t expedited_start; /* Starting ticket. */
84436 - atomic_long_t expedited_done; /* Done ticket. */
84437 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
84438 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
84439 - atomic_long_t expedited_workdone1; /* # done by others #1. */
84440 - atomic_long_t expedited_workdone2; /* # done by others #2. */
84441 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
84442 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
84443 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
84444 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
84445 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
84446 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
84447 + atomic_long_t expedited_done; /* Done ticket. */
84448 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
84449 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
84450 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
84451 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
84452 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
84453 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
84454 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
84455 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
84456 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
84457
84458 unsigned long jiffies_force_qs; /* Time at which to invoke */
84459 /* force_quiescent_state(). */
84460 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
84461 index 3db5a37..b395fb35 100644
84462 --- a/kernel/rcutree_plugin.h
84463 +++ b/kernel/rcutree_plugin.h
84464 @@ -903,7 +903,7 @@ void synchronize_rcu_expedited(void)
84465
84466 /* Clean up and exit. */
84467 smp_mb(); /* ensure expedited GP seen before counter increment. */
84468 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
84469 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
84470 unlock_mb_ret:
84471 mutex_unlock(&sync_rcu_preempt_exp_mutex);
84472 mb_ret:
84473 @@ -1451,7 +1451,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
84474 free_cpumask_var(cm);
84475 }
84476
84477 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
84478 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
84479 .store = &rcu_cpu_kthread_task,
84480 .thread_should_run = rcu_cpu_kthread_should_run,
84481 .thread_fn = rcu_cpu_kthread,
84482 @@ -1916,7 +1916,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
84483 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
84484 printk(KERN_ERR "\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u %s\n",
84485 cpu, ticks_value, ticks_title,
84486 - atomic_read(&rdtp->dynticks) & 0xfff,
84487 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
84488 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
84489 rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
84490 fast_no_hz);
84491 @@ -2079,7 +2079,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
84492
84493 /* Enqueue the callback on the nocb list and update counts. */
84494 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
84495 - ACCESS_ONCE(*old_rhpp) = rhp;
84496 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
84497 atomic_long_add(rhcount, &rdp->nocb_q_count);
84498 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
84499
84500 @@ -2219,12 +2219,12 @@ static int rcu_nocb_kthread(void *arg)
84501 * Extract queued callbacks, update counts, and wait
84502 * for a grace period to elapse.
84503 */
84504 - ACCESS_ONCE(rdp->nocb_head) = NULL;
84505 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
84506 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
84507 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
84508 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
84509 - ACCESS_ONCE(rdp->nocb_p_count) += c;
84510 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
84511 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
84512 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
84513 rcu_nocb_wait_gp(rdp);
84514
84515 /* Each pass through the following loop invokes a callback. */
84516 @@ -2246,8 +2246,8 @@ static int rcu_nocb_kthread(void *arg)
84517 list = next;
84518 }
84519 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
84520 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
84521 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
84522 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
84523 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
84524 rdp->n_nocbs_invoked += c;
84525 }
84526 return 0;
84527 @@ -2274,7 +2274,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
84528 t = kthread_run(rcu_nocb_kthread, rdp,
84529 "rcuo%c/%d", rsp->abbr, cpu);
84530 BUG_ON(IS_ERR(t));
84531 - ACCESS_ONCE(rdp->nocb_kthread) = t;
84532 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
84533 }
84534 }
84535
84536 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
84537 index cf6c174..a8f4b50 100644
84538 --- a/kernel/rcutree_trace.c
84539 +++ b/kernel/rcutree_trace.c
84540 @@ -121,7 +121,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
84541 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
84542 rdp->passed_quiesce, rdp->qs_pending);
84543 seq_printf(m, " dt=%d/%llx/%d df=%lu",
84544 - atomic_read(&rdp->dynticks->dynticks),
84545 + atomic_read_unchecked(&rdp->dynticks->dynticks),
84546 rdp->dynticks->dynticks_nesting,
84547 rdp->dynticks->dynticks_nmi_nesting,
84548 rdp->dynticks_fqs);
84549 @@ -182,17 +182,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
84550 struct rcu_state *rsp = (struct rcu_state *)m->private;
84551
84552 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",
84553 - atomic_long_read(&rsp->expedited_start),
84554 + atomic_long_read_unchecked(&rsp->expedited_start),
84555 atomic_long_read(&rsp->expedited_done),
84556 - atomic_long_read(&rsp->expedited_wrap),
84557 - atomic_long_read(&rsp->expedited_tryfail),
84558 - atomic_long_read(&rsp->expedited_workdone1),
84559 - atomic_long_read(&rsp->expedited_workdone2),
84560 - atomic_long_read(&rsp->expedited_normal),
84561 - atomic_long_read(&rsp->expedited_stoppedcpus),
84562 - atomic_long_read(&rsp->expedited_done_tries),
84563 - atomic_long_read(&rsp->expedited_done_lost),
84564 - atomic_long_read(&rsp->expedited_done_exit));
84565 + atomic_long_read_unchecked(&rsp->expedited_wrap),
84566 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
84567 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
84568 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
84569 + atomic_long_read_unchecked(&rsp->expedited_normal),
84570 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
84571 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
84572 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
84573 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
84574 return 0;
84575 }
84576
84577 diff --git a/kernel/resource.c b/kernel/resource.c
84578 index d738698..5f8e60a 100644
84579 --- a/kernel/resource.c
84580 +++ b/kernel/resource.c
84581 @@ -152,8 +152,18 @@ static const struct file_operations proc_iomem_operations = {
84582
84583 static int __init ioresources_init(void)
84584 {
84585 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
84586 +#ifdef CONFIG_GRKERNSEC_PROC_USER
84587 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
84588 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
84589 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
84590 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
84591 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
84592 +#endif
84593 +#else
84594 proc_create("ioports", 0, NULL, &proc_ioports_operations);
84595 proc_create("iomem", 0, NULL, &proc_iomem_operations);
84596 +#endif
84597 return 0;
84598 }
84599 __initcall(ioresources_init);
84600 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
84601 index 1d96dd0..994ff19 100644
84602 --- a/kernel/rtmutex-tester.c
84603 +++ b/kernel/rtmutex-tester.c
84604 @@ -22,7 +22,7 @@
84605 #define MAX_RT_TEST_MUTEXES 8
84606
84607 static spinlock_t rttest_lock;
84608 -static atomic_t rttest_event;
84609 +static atomic_unchecked_t rttest_event;
84610
84611 struct test_thread_data {
84612 int opcode;
84613 @@ -63,7 +63,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
84614
84615 case RTTEST_LOCKCONT:
84616 td->mutexes[td->opdata] = 1;
84617 - td->event = atomic_add_return(1, &rttest_event);
84618 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84619 return 0;
84620
84621 case RTTEST_RESET:
84622 @@ -76,7 +76,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
84623 return 0;
84624
84625 case RTTEST_RESETEVENT:
84626 - atomic_set(&rttest_event, 0);
84627 + atomic_set_unchecked(&rttest_event, 0);
84628 return 0;
84629
84630 default:
84631 @@ -93,9 +93,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
84632 return ret;
84633
84634 td->mutexes[id] = 1;
84635 - td->event = atomic_add_return(1, &rttest_event);
84636 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84637 rt_mutex_lock(&mutexes[id]);
84638 - td->event = atomic_add_return(1, &rttest_event);
84639 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84640 td->mutexes[id] = 4;
84641 return 0;
84642
84643 @@ -106,9 +106,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
84644 return ret;
84645
84646 td->mutexes[id] = 1;
84647 - td->event = atomic_add_return(1, &rttest_event);
84648 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84649 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
84650 - td->event = atomic_add_return(1, &rttest_event);
84651 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84652 td->mutexes[id] = ret ? 0 : 4;
84653 return ret ? -EINTR : 0;
84654
84655 @@ -117,9 +117,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
84656 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
84657 return ret;
84658
84659 - td->event = atomic_add_return(1, &rttest_event);
84660 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84661 rt_mutex_unlock(&mutexes[id]);
84662 - td->event = atomic_add_return(1, &rttest_event);
84663 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84664 td->mutexes[id] = 0;
84665 return 0;
84666
84667 @@ -166,7 +166,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
84668 break;
84669
84670 td->mutexes[dat] = 2;
84671 - td->event = atomic_add_return(1, &rttest_event);
84672 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84673 break;
84674
84675 default:
84676 @@ -186,7 +186,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
84677 return;
84678
84679 td->mutexes[dat] = 3;
84680 - td->event = atomic_add_return(1, &rttest_event);
84681 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84682 break;
84683
84684 case RTTEST_LOCKNOWAIT:
84685 @@ -198,7 +198,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
84686 return;
84687
84688 td->mutexes[dat] = 1;
84689 - td->event = atomic_add_return(1, &rttest_event);
84690 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84691 return;
84692
84693 default:
84694 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
84695 index 64de5f8..7735e12 100644
84696 --- a/kernel/sched/auto_group.c
84697 +++ b/kernel/sched/auto_group.c
84698 @@ -11,7 +11,7 @@
84699
84700 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
84701 static struct autogroup autogroup_default;
84702 -static atomic_t autogroup_seq_nr;
84703 +static atomic_unchecked_t autogroup_seq_nr;
84704
84705 void __init autogroup_init(struct task_struct *init_task)
84706 {
84707 @@ -81,7 +81,7 @@ static inline struct autogroup *autogroup_create(void)
84708
84709 kref_init(&ag->kref);
84710 init_rwsem(&ag->lock);
84711 - ag->id = atomic_inc_return(&autogroup_seq_nr);
84712 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
84713 ag->tg = tg;
84714 #ifdef CONFIG_RT_GROUP_SCHED
84715 /*
84716 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
84717 index e8b3350..d83d44e 100644
84718 --- a/kernel/sched/core.c
84719 +++ b/kernel/sched/core.c
84720 @@ -3440,7 +3440,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
84721 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
84722 * positive (at least 1, or number of jiffies left till timeout) if completed.
84723 */
84724 -long __sched
84725 +long __sched __intentional_overflow(-1)
84726 wait_for_completion_interruptible_timeout(struct completion *x,
84727 unsigned long timeout)
84728 {
84729 @@ -3457,7 +3457,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
84730 *
84731 * The return value is -ERESTARTSYS if interrupted, 0 if completed.
84732 */
84733 -int __sched wait_for_completion_killable(struct completion *x)
84734 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
84735 {
84736 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
84737 if (t == -ERESTARTSYS)
84738 @@ -3478,7 +3478,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
84739 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
84740 * positive (at least 1, or number of jiffies left till timeout) if completed.
84741 */
84742 -long __sched
84743 +long __sched __intentional_overflow(-1)
84744 wait_for_completion_killable_timeout(struct completion *x,
84745 unsigned long timeout)
84746 {
84747 @@ -3704,6 +3704,8 @@ int can_nice(const struct task_struct *p, const int nice)
84748 /* convert nice value [19,-20] to rlimit style value [1,40] */
84749 int nice_rlim = 20 - nice;
84750
84751 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
84752 +
84753 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
84754 capable(CAP_SYS_NICE));
84755 }
84756 @@ -3737,7 +3739,8 @@ SYSCALL_DEFINE1(nice, int, increment)
84757 if (nice > 19)
84758 nice = 19;
84759
84760 - if (increment < 0 && !can_nice(current, nice))
84761 + if (increment < 0 && (!can_nice(current, nice) ||
84762 + gr_handle_chroot_nice()))
84763 return -EPERM;
84764
84765 retval = security_task_setnice(current, nice);
84766 @@ -3891,6 +3894,7 @@ recheck:
84767 unsigned long rlim_rtprio =
84768 task_rlimit(p, RLIMIT_RTPRIO);
84769
84770 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
84771 /* can't set/change the rt policy */
84772 if (policy != p->policy && !rlim_rtprio)
84773 return -EPERM;
84774 @@ -4988,7 +4992,7 @@ static void migrate_tasks(unsigned int dead_cpu)
84775
84776 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
84777
84778 -static struct ctl_table sd_ctl_dir[] = {
84779 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
84780 {
84781 .procname = "sched_domain",
84782 .mode = 0555,
84783 @@ -5005,17 +5009,17 @@ static struct ctl_table sd_ctl_root[] = {
84784 {}
84785 };
84786
84787 -static struct ctl_table *sd_alloc_ctl_entry(int n)
84788 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
84789 {
84790 - struct ctl_table *entry =
84791 + ctl_table_no_const *entry =
84792 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
84793
84794 return entry;
84795 }
84796
84797 -static void sd_free_ctl_entry(struct ctl_table **tablep)
84798 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
84799 {
84800 - struct ctl_table *entry;
84801 + ctl_table_no_const *entry;
84802
84803 /*
84804 * In the intermediate directories, both the child directory and
84805 @@ -5023,22 +5027,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
84806 * will always be set. In the lowest directory the names are
84807 * static strings and all have proc handlers.
84808 */
84809 - for (entry = *tablep; entry->mode; entry++) {
84810 - if (entry->child)
84811 - sd_free_ctl_entry(&entry->child);
84812 + for (entry = tablep; entry->mode; entry++) {
84813 + if (entry->child) {
84814 + sd_free_ctl_entry(entry->child);
84815 + pax_open_kernel();
84816 + entry->child = NULL;
84817 + pax_close_kernel();
84818 + }
84819 if (entry->proc_handler == NULL)
84820 kfree(entry->procname);
84821 }
84822
84823 - kfree(*tablep);
84824 - *tablep = NULL;
84825 + kfree(tablep);
84826 }
84827
84828 static int min_load_idx = 0;
84829 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
84830
84831 static void
84832 -set_table_entry(struct ctl_table *entry,
84833 +set_table_entry(ctl_table_no_const *entry,
84834 const char *procname, void *data, int maxlen,
84835 umode_t mode, proc_handler *proc_handler,
84836 bool load_idx)
84837 @@ -5058,7 +5065,7 @@ set_table_entry(struct ctl_table *entry,
84838 static struct ctl_table *
84839 sd_alloc_ctl_domain_table(struct sched_domain *sd)
84840 {
84841 - struct ctl_table *table = sd_alloc_ctl_entry(13);
84842 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
84843
84844 if (table == NULL)
84845 return NULL;
84846 @@ -5093,9 +5100,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
84847 return table;
84848 }
84849
84850 -static ctl_table *sd_alloc_ctl_cpu_table(int cpu)
84851 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
84852 {
84853 - struct ctl_table *entry, *table;
84854 + ctl_table_no_const *entry, *table;
84855 struct sched_domain *sd;
84856 int domain_num = 0, i;
84857 char buf[32];
84858 @@ -5122,11 +5129,13 @@ static struct ctl_table_header *sd_sysctl_header;
84859 static void register_sched_domain_sysctl(void)
84860 {
84861 int i, cpu_num = num_possible_cpus();
84862 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
84863 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
84864 char buf[32];
84865
84866 WARN_ON(sd_ctl_dir[0].child);
84867 + pax_open_kernel();
84868 sd_ctl_dir[0].child = entry;
84869 + pax_close_kernel();
84870
84871 if (entry == NULL)
84872 return;
84873 @@ -5149,8 +5158,12 @@ static void unregister_sched_domain_sysctl(void)
84874 if (sd_sysctl_header)
84875 unregister_sysctl_table(sd_sysctl_header);
84876 sd_sysctl_header = NULL;
84877 - if (sd_ctl_dir[0].child)
84878 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
84879 + if (sd_ctl_dir[0].child) {
84880 + sd_free_ctl_entry(sd_ctl_dir[0].child);
84881 + pax_open_kernel();
84882 + sd_ctl_dir[0].child = NULL;
84883 + pax_close_kernel();
84884 + }
84885 }
84886 #else
84887 static void register_sched_domain_sysctl(void)
84888 @@ -5249,7 +5262,7 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
84889 * happens before everything else. This has to be lower priority than
84890 * the notifier in the perf_event subsystem, though.
84891 */
84892 -static struct notifier_block __cpuinitdata migration_notifier = {
84893 +static struct notifier_block migration_notifier = {
84894 .notifier_call = migration_call,
84895 .priority = CPU_PRI_MIGRATION,
84896 };
84897 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
84898 index 03b73be..9422b9f 100644
84899 --- a/kernel/sched/fair.c
84900 +++ b/kernel/sched/fair.c
84901 @@ -831,7 +831,7 @@ void task_numa_fault(int node, int pages, bool migrated)
84902
84903 static void reset_ptenuma_scan(struct task_struct *p)
84904 {
84905 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
84906 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
84907 p->mm->numa_scan_offset = 0;
84908 }
84909
84910 @@ -5687,7 +5687,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
84911 * run_rebalance_domains is triggered when needed from the scheduler tick.
84912 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
84913 */
84914 -static void run_rebalance_domains(struct softirq_action *h)
84915 +static void run_rebalance_domains(void)
84916 {
84917 int this_cpu = smp_processor_id();
84918 struct rq *this_rq = cpu_rq(this_cpu);
84919 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
84920 index ce39224d..0e09343 100644
84921 --- a/kernel/sched/sched.h
84922 +++ b/kernel/sched/sched.h
84923 @@ -1009,7 +1009,7 @@ struct sched_class {
84924 #ifdef CONFIG_FAIR_GROUP_SCHED
84925 void (*task_move_group) (struct task_struct *p, int on_rq);
84926 #endif
84927 -};
84928 +} __do_const;
84929
84930 #define sched_class_highest (&stop_sched_class)
84931 #define for_each_class(class) \
84932 diff --git a/kernel/signal.c b/kernel/signal.c
84933 index 113411b..20d0a99 100644
84934 --- a/kernel/signal.c
84935 +++ b/kernel/signal.c
84936 @@ -51,12 +51,12 @@ static struct kmem_cache *sigqueue_cachep;
84937
84938 int print_fatal_signals __read_mostly;
84939
84940 -static void __user *sig_handler(struct task_struct *t, int sig)
84941 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
84942 {
84943 return t->sighand->action[sig - 1].sa.sa_handler;
84944 }
84945
84946 -static int sig_handler_ignored(void __user *handler, int sig)
84947 +static int sig_handler_ignored(__sighandler_t handler, int sig)
84948 {
84949 /* Is it explicitly or implicitly ignored? */
84950 return handler == SIG_IGN ||
84951 @@ -65,7 +65,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
84952
84953 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
84954 {
84955 - void __user *handler;
84956 + __sighandler_t handler;
84957
84958 handler = sig_handler(t, sig);
84959
84960 @@ -369,6 +369,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
84961 atomic_inc(&user->sigpending);
84962 rcu_read_unlock();
84963
84964 + if (!override_rlimit)
84965 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
84966 +
84967 if (override_rlimit ||
84968 atomic_read(&user->sigpending) <=
84969 task_rlimit(t, RLIMIT_SIGPENDING)) {
84970 @@ -496,7 +499,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
84971
84972 int unhandled_signal(struct task_struct *tsk, int sig)
84973 {
84974 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
84975 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
84976 if (is_global_init(tsk))
84977 return 1;
84978 if (handler != SIG_IGN && handler != SIG_DFL)
84979 @@ -816,6 +819,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
84980 }
84981 }
84982
84983 + /* allow glibc communication via tgkill to other threads in our
84984 + thread group */
84985 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
84986 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
84987 + && gr_handle_signal(t, sig))
84988 + return -EPERM;
84989 +
84990 return security_task_kill(t, info, sig, 0);
84991 }
84992
84993 @@ -1199,7 +1209,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
84994 return send_signal(sig, info, p, 1);
84995 }
84996
84997 -static int
84998 +int
84999 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
85000 {
85001 return send_signal(sig, info, t, 0);
85002 @@ -1236,6 +1246,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
85003 unsigned long int flags;
85004 int ret, blocked, ignored;
85005 struct k_sigaction *action;
85006 + int is_unhandled = 0;
85007
85008 spin_lock_irqsave(&t->sighand->siglock, flags);
85009 action = &t->sighand->action[sig-1];
85010 @@ -1250,9 +1261,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
85011 }
85012 if (action->sa.sa_handler == SIG_DFL)
85013 t->signal->flags &= ~SIGNAL_UNKILLABLE;
85014 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
85015 + is_unhandled = 1;
85016 ret = specific_send_sig_info(sig, info, t);
85017 spin_unlock_irqrestore(&t->sighand->siglock, flags);
85018
85019 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
85020 + normal operation */
85021 + if (is_unhandled) {
85022 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
85023 + gr_handle_crash(t, sig);
85024 + }
85025 +
85026 return ret;
85027 }
85028
85029 @@ -1319,8 +1339,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
85030 ret = check_kill_permission(sig, info, p);
85031 rcu_read_unlock();
85032
85033 - if (!ret && sig)
85034 + if (!ret && sig) {
85035 ret = do_send_sig_info(sig, info, p, true);
85036 + if (!ret)
85037 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
85038 + }
85039
85040 return ret;
85041 }
85042 @@ -2926,7 +2949,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
85043 int error = -ESRCH;
85044
85045 rcu_read_lock();
85046 - p = find_task_by_vpid(pid);
85047 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
85048 + /* allow glibc communication via tgkill to other threads in our
85049 + thread group */
85050 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
85051 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
85052 + p = find_task_by_vpid_unrestricted(pid);
85053 + else
85054 +#endif
85055 + p = find_task_by_vpid(pid);
85056 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
85057 error = check_kill_permission(sig, info, p);
85058 /*
85059 @@ -3219,6 +3250,16 @@ int __save_altstack(stack_t __user *uss, unsigned long sp)
85060 __put_user(t->sas_ss_size, &uss->ss_size);
85061 }
85062
85063 +#ifdef CONFIG_X86
85064 +void __save_altstack_ex(stack_t __user *uss, unsigned long sp)
85065 +{
85066 + struct task_struct *t = current;
85067 + put_user_ex((void __user *)t->sas_ss_sp, &uss->ss_sp);
85068 + put_user_ex(sas_ss_flags(sp), &uss->ss_flags);
85069 + put_user_ex(t->sas_ss_size, &uss->ss_size);
85070 +}
85071 +#endif
85072 +
85073 #ifdef CONFIG_COMPAT
85074 COMPAT_SYSCALL_DEFINE2(sigaltstack,
85075 const compat_stack_t __user *, uss_ptr,
85076 @@ -3240,8 +3281,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
85077 }
85078 seg = get_fs();
85079 set_fs(KERNEL_DS);
85080 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
85081 - (stack_t __force __user *) &uoss,
85082 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
85083 + (stack_t __force_user *) &uoss,
85084 compat_user_stack_pointer());
85085 set_fs(seg);
85086 if (ret >= 0 && uoss_ptr) {
85087 @@ -3268,6 +3309,16 @@ int __compat_save_altstack(compat_stack_t __user *uss, unsigned long sp)
85088 __put_user(sas_ss_flags(sp), &uss->ss_flags) |
85089 __put_user(t->sas_ss_size, &uss->ss_size);
85090 }
85091 +
85092 +#ifdef CONFIG_X86
85093 +void __compat_save_altstack_ex(compat_stack_t __user *uss, unsigned long sp)
85094 +{
85095 + struct task_struct *t = current;
85096 + put_user_ex(ptr_to_compat((void __user *)t->sas_ss_sp), &uss->ss_sp);
85097 + put_user_ex(sas_ss_flags(sp), &uss->ss_flags);
85098 + put_user_ex(t->sas_ss_size, &uss->ss_size);
85099 +}
85100 +#endif
85101 #endif
85102
85103 #ifdef __ARCH_WANT_SYS_SIGPENDING
85104 diff --git a/kernel/smp.c b/kernel/smp.c
85105 index 4dba0f7..fe9f773 100644
85106 --- a/kernel/smp.c
85107 +++ b/kernel/smp.c
85108 @@ -73,7 +73,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
85109 return NOTIFY_OK;
85110 }
85111
85112 -static struct notifier_block __cpuinitdata hotplug_cfd_notifier = {
85113 +static struct notifier_block hotplug_cfd_notifier = {
85114 .notifier_call = hotplug_cfd,
85115 };
85116
85117 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
85118 index 02fc5c9..e54c335 100644
85119 --- a/kernel/smpboot.c
85120 +++ b/kernel/smpboot.c
85121 @@ -288,7 +288,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
85122 }
85123 smpboot_unpark_thread(plug_thread, cpu);
85124 }
85125 - list_add(&plug_thread->list, &hotplug_threads);
85126 + pax_list_add(&plug_thread->list, &hotplug_threads);
85127 out:
85128 mutex_unlock(&smpboot_threads_lock);
85129 return ret;
85130 @@ -305,7 +305,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
85131 {
85132 get_online_cpus();
85133 mutex_lock(&smpboot_threads_lock);
85134 - list_del(&plug_thread->list);
85135 + pax_list_del(&plug_thread->list);
85136 smpboot_destroy_threads(plug_thread);
85137 mutex_unlock(&smpboot_threads_lock);
85138 put_online_cpus();
85139 diff --git a/kernel/softirq.c b/kernel/softirq.c
85140 index 3d6833f..da6d93d 100644
85141 --- a/kernel/softirq.c
85142 +++ b/kernel/softirq.c
85143 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
85144 EXPORT_SYMBOL(irq_stat);
85145 #endif
85146
85147 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
85148 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
85149
85150 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
85151
85152 -char *softirq_to_name[NR_SOFTIRQS] = {
85153 +const char * const softirq_to_name[NR_SOFTIRQS] = {
85154 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
85155 "TASKLET", "SCHED", "HRTIMER", "RCU"
85156 };
85157 @@ -250,7 +250,7 @@ restart:
85158 kstat_incr_softirqs_this_cpu(vec_nr);
85159
85160 trace_softirq_entry(vec_nr);
85161 - h->action(h);
85162 + h->action();
85163 trace_softirq_exit(vec_nr);
85164 if (unlikely(prev_count != preempt_count())) {
85165 printk(KERN_ERR "huh, entered softirq %u %s %p"
85166 @@ -405,7 +405,7 @@ void __raise_softirq_irqoff(unsigned int nr)
85167 or_softirq_pending(1UL << nr);
85168 }
85169
85170 -void open_softirq(int nr, void (*action)(struct softirq_action *))
85171 +void __init open_softirq(int nr, void (*action)(void))
85172 {
85173 softirq_vec[nr].action = action;
85174 }
85175 @@ -461,7 +461,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
85176
85177 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
85178
85179 -static void tasklet_action(struct softirq_action *a)
85180 +static void tasklet_action(void)
85181 {
85182 struct tasklet_struct *list;
85183
85184 @@ -496,7 +496,7 @@ static void tasklet_action(struct softirq_action *a)
85185 }
85186 }
85187
85188 -static void tasklet_hi_action(struct softirq_action *a)
85189 +static void tasklet_hi_action(void)
85190 {
85191 struct tasklet_struct *list;
85192
85193 @@ -730,7 +730,7 @@ static int __cpuinit remote_softirq_cpu_notify(struct notifier_block *self,
85194 return NOTIFY_OK;
85195 }
85196
85197 -static struct notifier_block __cpuinitdata remote_softirq_cpu_notifier = {
85198 +static struct notifier_block remote_softirq_cpu_notifier = {
85199 .notifier_call = remote_softirq_cpu_notify,
85200 };
85201
85202 @@ -847,11 +847,11 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
85203 return NOTIFY_OK;
85204 }
85205
85206 -static struct notifier_block __cpuinitdata cpu_nfb = {
85207 +static struct notifier_block cpu_nfb = {
85208 .notifier_call = cpu_callback
85209 };
85210
85211 -static struct smp_hotplug_thread softirq_threads = {
85212 +static struct smp_hotplug_thread softirq_threads __read_only = {
85213 .store = &ksoftirqd,
85214 .thread_should_run = ksoftirqd_should_run,
85215 .thread_fn = run_ksoftirqd,
85216 diff --git a/kernel/srcu.c b/kernel/srcu.c
85217 index 01d5ccb..cdcbee6 100644
85218 --- a/kernel/srcu.c
85219 +++ b/kernel/srcu.c
85220 @@ -300,9 +300,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
85221
85222 idx = ACCESS_ONCE(sp->completed) & 0x1;
85223 preempt_disable();
85224 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
85225 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
85226 smp_mb(); /* B */ /* Avoid leaking the critical section. */
85227 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
85228 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
85229 preempt_enable();
85230 return idx;
85231 }
85232 diff --git a/kernel/sys.c b/kernel/sys.c
85233 index 2bbd9a7..0875671 100644
85234 --- a/kernel/sys.c
85235 +++ b/kernel/sys.c
85236 @@ -163,6 +163,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
85237 error = -EACCES;
85238 goto out;
85239 }
85240 +
85241 + if (gr_handle_chroot_setpriority(p, niceval)) {
85242 + error = -EACCES;
85243 + goto out;
85244 + }
85245 +
85246 no_nice = security_task_setnice(p, niceval);
85247 if (no_nice) {
85248 error = no_nice;
85249 @@ -626,6 +632,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
85250 goto error;
85251 }
85252
85253 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
85254 + goto error;
85255 +
85256 if (rgid != (gid_t) -1 ||
85257 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
85258 new->sgid = new->egid;
85259 @@ -661,6 +670,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
85260 old = current_cred();
85261
85262 retval = -EPERM;
85263 +
85264 + if (gr_check_group_change(kgid, kgid, kgid))
85265 + goto error;
85266 +
85267 if (nsown_capable(CAP_SETGID))
85268 new->gid = new->egid = new->sgid = new->fsgid = kgid;
85269 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
85270 @@ -678,7 +691,7 @@ error:
85271 /*
85272 * change the user struct in a credentials set to match the new UID
85273 */
85274 -static int set_user(struct cred *new)
85275 +int set_user(struct cred *new)
85276 {
85277 struct user_struct *new_user;
85278
85279 @@ -758,6 +771,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
85280 goto error;
85281 }
85282
85283 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
85284 + goto error;
85285 +
85286 if (!uid_eq(new->uid, old->uid)) {
85287 retval = set_user(new);
85288 if (retval < 0)
85289 @@ -808,6 +824,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
85290 old = current_cred();
85291
85292 retval = -EPERM;
85293 +
85294 + if (gr_check_crash_uid(kuid))
85295 + goto error;
85296 + if (gr_check_user_change(kuid, kuid, kuid))
85297 + goto error;
85298 +
85299 if (nsown_capable(CAP_SETUID)) {
85300 new->suid = new->uid = kuid;
85301 if (!uid_eq(kuid, old->uid)) {
85302 @@ -877,6 +899,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
85303 goto error;
85304 }
85305
85306 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
85307 + goto error;
85308 +
85309 if (ruid != (uid_t) -1) {
85310 new->uid = kruid;
85311 if (!uid_eq(kruid, old->uid)) {
85312 @@ -959,6 +984,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
85313 goto error;
85314 }
85315
85316 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
85317 + goto error;
85318 +
85319 if (rgid != (gid_t) -1)
85320 new->gid = krgid;
85321 if (egid != (gid_t) -1)
85322 @@ -1020,12 +1048,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
85323 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
85324 nsown_capable(CAP_SETUID)) {
85325 if (!uid_eq(kuid, old->fsuid)) {
85326 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
85327 + goto error;
85328 +
85329 new->fsuid = kuid;
85330 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
85331 goto change_okay;
85332 }
85333 }
85334
85335 +error:
85336 abort_creds(new);
85337 return old_fsuid;
85338
85339 @@ -1058,12 +1090,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
85340 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
85341 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
85342 nsown_capable(CAP_SETGID)) {
85343 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
85344 + goto error;
85345 +
85346 if (!gid_eq(kgid, old->fsgid)) {
85347 new->fsgid = kgid;
85348 goto change_okay;
85349 }
85350 }
85351
85352 +error:
85353 abort_creds(new);
85354 return old_fsgid;
85355
85356 @@ -1432,19 +1468,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
85357 return -EFAULT;
85358
85359 down_read(&uts_sem);
85360 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
85361 + error = __copy_to_user(name->sysname, &utsname()->sysname,
85362 __OLD_UTS_LEN);
85363 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
85364 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
85365 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
85366 __OLD_UTS_LEN);
85367 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
85368 - error |= __copy_to_user(&name->release, &utsname()->release,
85369 + error |= __copy_to_user(name->release, &utsname()->release,
85370 __OLD_UTS_LEN);
85371 error |= __put_user(0, name->release + __OLD_UTS_LEN);
85372 - error |= __copy_to_user(&name->version, &utsname()->version,
85373 + error |= __copy_to_user(name->version, &utsname()->version,
85374 __OLD_UTS_LEN);
85375 error |= __put_user(0, name->version + __OLD_UTS_LEN);
85376 - error |= __copy_to_user(&name->machine, &utsname()->machine,
85377 + error |= __copy_to_user(name->machine, &utsname()->machine,
85378 __OLD_UTS_LEN);
85379 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
85380 up_read(&uts_sem);
85381 @@ -1646,6 +1682,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
85382 */
85383 new_rlim->rlim_cur = 1;
85384 }
85385 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
85386 + is changed to a lower value. Since tasks can be created by the same
85387 + user in between this limit change and an execve by this task, force
85388 + a recheck only for this task by setting PF_NPROC_EXCEEDED
85389 + */
85390 + if (resource == RLIMIT_NPROC && tsk->real_cred->user != INIT_USER)
85391 + tsk->flags |= PF_NPROC_EXCEEDED;
85392 }
85393 if (!retval) {
85394 if (old_rlim)
85395 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
85396 index 9edcf45..713c960 100644
85397 --- a/kernel/sysctl.c
85398 +++ b/kernel/sysctl.c
85399 @@ -93,7 +93,6 @@
85400
85401
85402 #if defined(CONFIG_SYSCTL)
85403 -
85404 /* External variables not in a header file. */
85405 extern int sysctl_overcommit_memory;
85406 extern int sysctl_overcommit_ratio;
85407 @@ -119,18 +118,18 @@ extern int blk_iopoll_enabled;
85408
85409 /* Constants used for minimum and maximum */
85410 #ifdef CONFIG_LOCKUP_DETECTOR
85411 -static int sixty = 60;
85412 -static int neg_one = -1;
85413 +static int sixty __read_only = 60;
85414 #endif
85415
85416 -static int zero;
85417 -static int __maybe_unused one = 1;
85418 -static int __maybe_unused two = 2;
85419 -static int __maybe_unused three = 3;
85420 -static unsigned long one_ul = 1;
85421 -static int one_hundred = 100;
85422 +static int neg_one __read_only = -1;
85423 +static int zero __read_only = 0;
85424 +static int __maybe_unused one __read_only = 1;
85425 +static int __maybe_unused two __read_only = 2;
85426 +static int __maybe_unused three __read_only = 3;
85427 +static unsigned long one_ul __read_only = 1;
85428 +static int one_hundred __read_only = 100;
85429 #ifdef CONFIG_PRINTK
85430 -static int ten_thousand = 10000;
85431 +static int ten_thousand __read_only = 10000;
85432 #endif
85433
85434 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
85435 @@ -177,10 +176,8 @@ static int proc_taint(struct ctl_table *table, int write,
85436 void __user *buffer, size_t *lenp, loff_t *ppos);
85437 #endif
85438
85439 -#ifdef CONFIG_PRINTK
85440 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
85441 void __user *buffer, size_t *lenp, loff_t *ppos);
85442 -#endif
85443
85444 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
85445 void __user *buffer, size_t *lenp, loff_t *ppos);
85446 @@ -211,6 +208,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
85447
85448 #endif
85449
85450 +extern struct ctl_table grsecurity_table[];
85451 +
85452 static struct ctl_table kern_table[];
85453 static struct ctl_table vm_table[];
85454 static struct ctl_table fs_table[];
85455 @@ -225,6 +224,20 @@ extern struct ctl_table epoll_table[];
85456 int sysctl_legacy_va_layout;
85457 #endif
85458
85459 +#ifdef CONFIG_PAX_SOFTMODE
85460 +static ctl_table pax_table[] = {
85461 + {
85462 + .procname = "softmode",
85463 + .data = &pax_softmode,
85464 + .maxlen = sizeof(unsigned int),
85465 + .mode = 0600,
85466 + .proc_handler = &proc_dointvec,
85467 + },
85468 +
85469 + { }
85470 +};
85471 +#endif
85472 +
85473 /* The default sysctl tables: */
85474
85475 static struct ctl_table sysctl_base_table[] = {
85476 @@ -273,6 +286,22 @@ static int max_extfrag_threshold = 1000;
85477 #endif
85478
85479 static struct ctl_table kern_table[] = {
85480 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
85481 + {
85482 + .procname = "grsecurity",
85483 + .mode = 0500,
85484 + .child = grsecurity_table,
85485 + },
85486 +#endif
85487 +
85488 +#ifdef CONFIG_PAX_SOFTMODE
85489 + {
85490 + .procname = "pax",
85491 + .mode = 0500,
85492 + .child = pax_table,
85493 + },
85494 +#endif
85495 +
85496 {
85497 .procname = "sched_child_runs_first",
85498 .data = &sysctl_sched_child_runs_first,
85499 @@ -607,7 +636,7 @@ static struct ctl_table kern_table[] = {
85500 .data = &modprobe_path,
85501 .maxlen = KMOD_PATH_LEN,
85502 .mode = 0644,
85503 - .proc_handler = proc_dostring,
85504 + .proc_handler = proc_dostring_modpriv,
85505 },
85506 {
85507 .procname = "modules_disabled",
85508 @@ -774,16 +803,20 @@ static struct ctl_table kern_table[] = {
85509 .extra1 = &zero,
85510 .extra2 = &one,
85511 },
85512 +#endif
85513 {
85514 .procname = "kptr_restrict",
85515 .data = &kptr_restrict,
85516 .maxlen = sizeof(int),
85517 .mode = 0644,
85518 .proc_handler = proc_dointvec_minmax_sysadmin,
85519 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85520 + .extra1 = &two,
85521 +#else
85522 .extra1 = &zero,
85523 +#endif
85524 .extra2 = &two,
85525 },
85526 -#endif
85527 {
85528 .procname = "ngroups_max",
85529 .data = &ngroups_max,
85530 @@ -1025,10 +1058,17 @@ static struct ctl_table kern_table[] = {
85531 */
85532 {
85533 .procname = "perf_event_paranoid",
85534 - .data = &sysctl_perf_event_paranoid,
85535 - .maxlen = sizeof(sysctl_perf_event_paranoid),
85536 + .data = &sysctl_perf_event_legitimately_concerned,
85537 + .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
85538 .mode = 0644,
85539 - .proc_handler = proc_dointvec,
85540 + /* go ahead, be a hero */
85541 + .proc_handler = proc_dointvec_minmax_sysadmin,
85542 + .extra1 = &neg_one,
85543 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
85544 + .extra2 = &three,
85545 +#else
85546 + .extra2 = &two,
85547 +#endif
85548 },
85549 {
85550 .procname = "perf_event_mlock_kb",
85551 @@ -1282,6 +1322,13 @@ static struct ctl_table vm_table[] = {
85552 .proc_handler = proc_dointvec_minmax,
85553 .extra1 = &zero,
85554 },
85555 + {
85556 + .procname = "heap_stack_gap",
85557 + .data = &sysctl_heap_stack_gap,
85558 + .maxlen = sizeof(sysctl_heap_stack_gap),
85559 + .mode = 0644,
85560 + .proc_handler = proc_doulongvec_minmax,
85561 + },
85562 #else
85563 {
85564 .procname = "nr_trim_pages",
85565 @@ -1746,6 +1793,16 @@ int proc_dostring(struct ctl_table *table, int write,
85566 buffer, lenp, ppos);
85567 }
85568
85569 +int proc_dostring_modpriv(struct ctl_table *table, int write,
85570 + void __user *buffer, size_t *lenp, loff_t *ppos)
85571 +{
85572 + if (write && !capable(CAP_SYS_MODULE))
85573 + return -EPERM;
85574 +
85575 + return _proc_do_string(table->data, table->maxlen, write,
85576 + buffer, lenp, ppos);
85577 +}
85578 +
85579 static size_t proc_skip_spaces(char **buf)
85580 {
85581 size_t ret;
85582 @@ -1851,6 +1908,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
85583 len = strlen(tmp);
85584 if (len > *size)
85585 len = *size;
85586 + if (len > sizeof(tmp))
85587 + len = sizeof(tmp);
85588 if (copy_to_user(*buf, tmp, len))
85589 return -EFAULT;
85590 *size -= len;
85591 @@ -2015,7 +2074,7 @@ int proc_dointvec(struct ctl_table *table, int write,
85592 static int proc_taint(struct ctl_table *table, int write,
85593 void __user *buffer, size_t *lenp, loff_t *ppos)
85594 {
85595 - struct ctl_table t;
85596 + ctl_table_no_const t;
85597 unsigned long tmptaint = get_taint();
85598 int err;
85599
85600 @@ -2043,7 +2102,6 @@ static int proc_taint(struct ctl_table *table, int write,
85601 return err;
85602 }
85603
85604 -#ifdef CONFIG_PRINTK
85605 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
85606 void __user *buffer, size_t *lenp, loff_t *ppos)
85607 {
85608 @@ -2052,7 +2110,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
85609
85610 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
85611 }
85612 -#endif
85613
85614 struct do_proc_dointvec_minmax_conv_param {
85615 int *min;
85616 @@ -2199,8 +2256,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
85617 *i = val;
85618 } else {
85619 val = convdiv * (*i) / convmul;
85620 - if (!first)
85621 + if (!first) {
85622 err = proc_put_char(&buffer, &left, '\t');
85623 + if (err)
85624 + break;
85625 + }
85626 err = proc_put_long(&buffer, &left, val, false);
85627 if (err)
85628 break;
85629 @@ -2592,6 +2652,12 @@ int proc_dostring(struct ctl_table *table, int write,
85630 return -ENOSYS;
85631 }
85632
85633 +int proc_dostring_modpriv(struct ctl_table *table, int write,
85634 + void __user *buffer, size_t *lenp, loff_t *ppos)
85635 +{
85636 + return -ENOSYS;
85637 +}
85638 +
85639 int proc_dointvec(struct ctl_table *table, int write,
85640 void __user *buffer, size_t *lenp, loff_t *ppos)
85641 {
85642 @@ -2648,5 +2714,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
85643 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
85644 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
85645 EXPORT_SYMBOL(proc_dostring);
85646 +EXPORT_SYMBOL(proc_dostring_modpriv);
85647 EXPORT_SYMBOL(proc_doulongvec_minmax);
85648 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
85649 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
85650 index 145bb4d..b2aa969 100644
85651 --- a/kernel/taskstats.c
85652 +++ b/kernel/taskstats.c
85653 @@ -28,9 +28,12 @@
85654 #include <linux/fs.h>
85655 #include <linux/file.h>
85656 #include <linux/pid_namespace.h>
85657 +#include <linux/grsecurity.h>
85658 #include <net/genetlink.h>
85659 #include <linux/atomic.h>
85660
85661 +extern int gr_is_taskstats_denied(int pid);
85662 +
85663 /*
85664 * Maximum length of a cpumask that can be specified in
85665 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
85666 @@ -570,6 +573,9 @@ err:
85667
85668 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
85669 {
85670 + if (gr_is_taskstats_denied(current->pid))
85671 + return -EACCES;
85672 +
85673 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
85674 return cmd_attr_register_cpumask(info);
85675 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
85676 diff --git a/kernel/time.c b/kernel/time.c
85677 index d3617db..c98bbe9 100644
85678 --- a/kernel/time.c
85679 +++ b/kernel/time.c
85680 @@ -172,6 +172,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
85681 return error;
85682
85683 if (tz) {
85684 + /* we log in do_settimeofday called below, so don't log twice
85685 + */
85686 + if (!tv)
85687 + gr_log_timechange();
85688 +
85689 sys_tz = *tz;
85690 update_vsyscall_tz();
85691 if (firsttime) {
85692 @@ -502,7 +507,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
85693 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
85694 * value to a scaled second value.
85695 */
85696 -unsigned long
85697 +unsigned long __intentional_overflow(-1)
85698 timespec_to_jiffies(const struct timespec *value)
85699 {
85700 unsigned long sec = value->tv_sec;
85701 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
85702 index f11d83b..d016d91 100644
85703 --- a/kernel/time/alarmtimer.c
85704 +++ b/kernel/time/alarmtimer.c
85705 @@ -750,7 +750,7 @@ static int __init alarmtimer_init(void)
85706 struct platform_device *pdev;
85707 int error = 0;
85708 int i;
85709 - struct k_clock alarm_clock = {
85710 + static struct k_clock alarm_clock = {
85711 .clock_getres = alarm_clock_getres,
85712 .clock_get = alarm_clock_get,
85713 .timer_create = alarm_timer_create,
85714 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
85715 index baeeb5c..c22704a 100644
85716 --- a/kernel/time/timekeeping.c
85717 +++ b/kernel/time/timekeeping.c
85718 @@ -15,6 +15,7 @@
85719 #include <linux/init.h>
85720 #include <linux/mm.h>
85721 #include <linux/sched.h>
85722 +#include <linux/grsecurity.h>
85723 #include <linux/syscore_ops.h>
85724 #include <linux/clocksource.h>
85725 #include <linux/jiffies.h>
85726 @@ -495,6 +496,8 @@ int do_settimeofday(const struct timespec *tv)
85727 if (!timespec_valid_strict(tv))
85728 return -EINVAL;
85729
85730 + gr_log_timechange();
85731 +
85732 raw_spin_lock_irqsave(&timekeeper_lock, flags);
85733 write_seqcount_begin(&timekeeper_seq);
85734
85735 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
85736 index 3bdf283..cc68d83 100644
85737 --- a/kernel/time/timer_list.c
85738 +++ b/kernel/time/timer_list.c
85739 @@ -45,12 +45,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
85740
85741 static void print_name_offset(struct seq_file *m, void *sym)
85742 {
85743 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85744 + SEQ_printf(m, "<%p>", NULL);
85745 +#else
85746 char symname[KSYM_NAME_LEN];
85747
85748 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
85749 SEQ_printf(m, "<%pK>", sym);
85750 else
85751 SEQ_printf(m, "%s", symname);
85752 +#endif
85753 }
85754
85755 static void
85756 @@ -119,7 +123,11 @@ next_one:
85757 static void
85758 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
85759 {
85760 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85761 + SEQ_printf(m, " .base: %p\n", NULL);
85762 +#else
85763 SEQ_printf(m, " .base: %pK\n", base);
85764 +#endif
85765 SEQ_printf(m, " .index: %d\n",
85766 base->index);
85767 SEQ_printf(m, " .resolution: %Lu nsecs\n",
85768 @@ -355,7 +363,11 @@ static int __init init_timer_list_procfs(void)
85769 {
85770 struct proc_dir_entry *pe;
85771
85772 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
85773 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
85774 +#else
85775 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
85776 +#endif
85777 if (!pe)
85778 return -ENOMEM;
85779 return 0;
85780 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
85781 index 0b537f2..40d6c20 100644
85782 --- a/kernel/time/timer_stats.c
85783 +++ b/kernel/time/timer_stats.c
85784 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
85785 static unsigned long nr_entries;
85786 static struct entry entries[MAX_ENTRIES];
85787
85788 -static atomic_t overflow_count;
85789 +static atomic_unchecked_t overflow_count;
85790
85791 /*
85792 * The entries are in a hash-table, for fast lookup:
85793 @@ -140,7 +140,7 @@ static void reset_entries(void)
85794 nr_entries = 0;
85795 memset(entries, 0, sizeof(entries));
85796 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
85797 - atomic_set(&overflow_count, 0);
85798 + atomic_set_unchecked(&overflow_count, 0);
85799 }
85800
85801 static struct entry *alloc_entry(void)
85802 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
85803 if (likely(entry))
85804 entry->count++;
85805 else
85806 - atomic_inc(&overflow_count);
85807 + atomic_inc_unchecked(&overflow_count);
85808
85809 out_unlock:
85810 raw_spin_unlock_irqrestore(lock, flags);
85811 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
85812
85813 static void print_name_offset(struct seq_file *m, unsigned long addr)
85814 {
85815 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85816 + seq_printf(m, "<%p>", NULL);
85817 +#else
85818 char symname[KSYM_NAME_LEN];
85819
85820 if (lookup_symbol_name(addr, symname) < 0)
85821 - seq_printf(m, "<%p>", (void *)addr);
85822 + seq_printf(m, "<%pK>", (void *)addr);
85823 else
85824 seq_printf(m, "%s", symname);
85825 +#endif
85826 }
85827
85828 static int tstats_show(struct seq_file *m, void *v)
85829 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
85830
85831 seq_puts(m, "Timer Stats Version: v0.2\n");
85832 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
85833 - if (atomic_read(&overflow_count))
85834 + if (atomic_read_unchecked(&overflow_count))
85835 seq_printf(m, "Overflow: %d entries\n",
85836 - atomic_read(&overflow_count));
85837 + atomic_read_unchecked(&overflow_count));
85838
85839 for (i = 0; i < nr_entries; i++) {
85840 entry = entries + i;
85841 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
85842 {
85843 struct proc_dir_entry *pe;
85844
85845 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
85846 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
85847 +#else
85848 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
85849 +#endif
85850 if (!pe)
85851 return -ENOMEM;
85852 return 0;
85853 diff --git a/kernel/timer.c b/kernel/timer.c
85854 index 15bc1b4..32da49c 100644
85855 --- a/kernel/timer.c
85856 +++ b/kernel/timer.c
85857 @@ -1366,7 +1366,7 @@ void update_process_times(int user_tick)
85858 /*
85859 * This function runs timers and the timer-tq in bottom half context.
85860 */
85861 -static void run_timer_softirq(struct softirq_action *h)
85862 +static void run_timer_softirq(void)
85863 {
85864 struct tvec_base *base = __this_cpu_read(tvec_bases);
85865
85866 @@ -1429,7 +1429,7 @@ static void process_timeout(unsigned long __data)
85867 *
85868 * In all cases the return value is guaranteed to be non-negative.
85869 */
85870 -signed long __sched schedule_timeout(signed long timeout)
85871 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
85872 {
85873 struct timer_list timer;
85874 unsigned long expire;
85875 @@ -1635,7 +1635,7 @@ static int __cpuinit timer_cpu_notify(struct notifier_block *self,
85876 return NOTIFY_OK;
85877 }
85878
85879 -static struct notifier_block __cpuinitdata timers_nb = {
85880 +static struct notifier_block timers_nb = {
85881 .notifier_call = timer_cpu_notify,
85882 };
85883
85884 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
85885 index b8b8560..75b1a09 100644
85886 --- a/kernel/trace/blktrace.c
85887 +++ b/kernel/trace/blktrace.c
85888 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
85889 struct blk_trace *bt = filp->private_data;
85890 char buf[16];
85891
85892 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
85893 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
85894
85895 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
85896 }
85897 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
85898 return 1;
85899
85900 bt = buf->chan->private_data;
85901 - atomic_inc(&bt->dropped);
85902 + atomic_inc_unchecked(&bt->dropped);
85903 return 0;
85904 }
85905
85906 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
85907
85908 bt->dir = dir;
85909 bt->dev = dev;
85910 - atomic_set(&bt->dropped, 0);
85911 + atomic_set_unchecked(&bt->dropped, 0);
85912
85913 ret = -EIO;
85914 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
85915 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
85916 index f23449d..b8cc3a1 100644
85917 --- a/kernel/trace/ftrace.c
85918 +++ b/kernel/trace/ftrace.c
85919 @@ -1925,12 +1925,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
85920 if (unlikely(ftrace_disabled))
85921 return 0;
85922
85923 + ret = ftrace_arch_code_modify_prepare();
85924 + FTRACE_WARN_ON(ret);
85925 + if (ret)
85926 + return 0;
85927 +
85928 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
85929 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
85930 if (ret) {
85931 ftrace_bug(ret, ip);
85932 - return 0;
85933 }
85934 - return 1;
85935 + return ret ? 0 : 1;
85936 }
85937
85938 /*
85939 @@ -3994,8 +3999,10 @@ static int ftrace_process_locs(struct module *mod,
85940 if (!count)
85941 return 0;
85942
85943 + pax_open_kernel();
85944 sort(start, count, sizeof(*start),
85945 ftrace_cmp_ips, ftrace_swap_ips);
85946 + pax_close_kernel();
85947
85948 start_pg = ftrace_allocate_pages(count);
85949 if (!start_pg)
85950 @@ -4718,8 +4725,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
85951 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
85952
85953 static int ftrace_graph_active;
85954 -static struct notifier_block ftrace_suspend_notifier;
85955 -
85956 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
85957 {
85958 return 0;
85959 @@ -4863,6 +4868,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
85960 return NOTIFY_DONE;
85961 }
85962
85963 +static struct notifier_block ftrace_suspend_notifier = {
85964 + .notifier_call = ftrace_suspend_notifier_call
85965 +};
85966 +
85967 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
85968 trace_func_graph_ent_t entryfunc)
85969 {
85970 @@ -4876,7 +4885,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
85971 goto out;
85972 }
85973
85974 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
85975 register_pm_notifier(&ftrace_suspend_notifier);
85976
85977 ftrace_graph_active++;
85978 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
85979 index e444ff8..438b8f4 100644
85980 --- a/kernel/trace/ring_buffer.c
85981 +++ b/kernel/trace/ring_buffer.c
85982 @@ -352,9 +352,9 @@ struct buffer_data_page {
85983 */
85984 struct buffer_page {
85985 struct list_head list; /* list of buffer pages */
85986 - local_t write; /* index for next write */
85987 + local_unchecked_t write; /* index for next write */
85988 unsigned read; /* index for next read */
85989 - local_t entries; /* entries on this page */
85990 + local_unchecked_t entries; /* entries on this page */
85991 unsigned long real_end; /* real end of data */
85992 struct buffer_data_page *page; /* Actual data page */
85993 };
85994 @@ -473,8 +473,8 @@ struct ring_buffer_per_cpu {
85995 unsigned long last_overrun;
85996 local_t entries_bytes;
85997 local_t entries;
85998 - local_t overrun;
85999 - local_t commit_overrun;
86000 + local_unchecked_t overrun;
86001 + local_unchecked_t commit_overrun;
86002 local_t dropped_events;
86003 local_t committing;
86004 local_t commits;
86005 @@ -992,8 +992,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
86006 *
86007 * We add a counter to the write field to denote this.
86008 */
86009 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
86010 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
86011 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
86012 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
86013
86014 /*
86015 * Just make sure we have seen our old_write and synchronize
86016 @@ -1021,8 +1021,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
86017 * cmpxchg to only update if an interrupt did not already
86018 * do it for us. If the cmpxchg fails, we don't care.
86019 */
86020 - (void)local_cmpxchg(&next_page->write, old_write, val);
86021 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
86022 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
86023 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
86024
86025 /*
86026 * No need to worry about races with clearing out the commit.
86027 @@ -1386,12 +1386,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
86028
86029 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
86030 {
86031 - return local_read(&bpage->entries) & RB_WRITE_MASK;
86032 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
86033 }
86034
86035 static inline unsigned long rb_page_write(struct buffer_page *bpage)
86036 {
86037 - return local_read(&bpage->write) & RB_WRITE_MASK;
86038 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
86039 }
86040
86041 static int
86042 @@ -1486,7 +1486,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
86043 * bytes consumed in ring buffer from here.
86044 * Increment overrun to account for the lost events.
86045 */
86046 - local_add(page_entries, &cpu_buffer->overrun);
86047 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
86048 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
86049 }
86050
86051 @@ -2063,7 +2063,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
86052 * it is our responsibility to update
86053 * the counters.
86054 */
86055 - local_add(entries, &cpu_buffer->overrun);
86056 + local_add_unchecked(entries, &cpu_buffer->overrun);
86057 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
86058
86059 /*
86060 @@ -2213,7 +2213,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
86061 if (tail == BUF_PAGE_SIZE)
86062 tail_page->real_end = 0;
86063
86064 - local_sub(length, &tail_page->write);
86065 + local_sub_unchecked(length, &tail_page->write);
86066 return;
86067 }
86068
86069 @@ -2248,7 +2248,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
86070 rb_event_set_padding(event);
86071
86072 /* Set the write back to the previous setting */
86073 - local_sub(length, &tail_page->write);
86074 + local_sub_unchecked(length, &tail_page->write);
86075 return;
86076 }
86077
86078 @@ -2260,7 +2260,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
86079
86080 /* Set write to end of buffer */
86081 length = (tail + length) - BUF_PAGE_SIZE;
86082 - local_sub(length, &tail_page->write);
86083 + local_sub_unchecked(length, &tail_page->write);
86084 }
86085
86086 /*
86087 @@ -2286,7 +2286,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
86088 * about it.
86089 */
86090 if (unlikely(next_page == commit_page)) {
86091 - local_inc(&cpu_buffer->commit_overrun);
86092 + local_inc_unchecked(&cpu_buffer->commit_overrun);
86093 goto out_reset;
86094 }
86095
86096 @@ -2342,7 +2342,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
86097 cpu_buffer->tail_page) &&
86098 (cpu_buffer->commit_page ==
86099 cpu_buffer->reader_page))) {
86100 - local_inc(&cpu_buffer->commit_overrun);
86101 + local_inc_unchecked(&cpu_buffer->commit_overrun);
86102 goto out_reset;
86103 }
86104 }
86105 @@ -2390,7 +2390,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
86106 length += RB_LEN_TIME_EXTEND;
86107
86108 tail_page = cpu_buffer->tail_page;
86109 - write = local_add_return(length, &tail_page->write);
86110 + write = local_add_return_unchecked(length, &tail_page->write);
86111
86112 /* set write to only the index of the write */
86113 write &= RB_WRITE_MASK;
86114 @@ -2407,7 +2407,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
86115 kmemcheck_annotate_bitfield(event, bitfield);
86116 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
86117
86118 - local_inc(&tail_page->entries);
86119 + local_inc_unchecked(&tail_page->entries);
86120
86121 /*
86122 * If this is the first commit on the page, then update
86123 @@ -2440,7 +2440,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
86124
86125 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
86126 unsigned long write_mask =
86127 - local_read(&bpage->write) & ~RB_WRITE_MASK;
86128 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
86129 unsigned long event_length = rb_event_length(event);
86130 /*
86131 * This is on the tail page. It is possible that
86132 @@ -2450,7 +2450,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
86133 */
86134 old_index += write_mask;
86135 new_index += write_mask;
86136 - index = local_cmpxchg(&bpage->write, old_index, new_index);
86137 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
86138 if (index == old_index) {
86139 /* update counters */
86140 local_sub(event_length, &cpu_buffer->entries_bytes);
86141 @@ -2842,7 +2842,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
86142
86143 /* Do the likely case first */
86144 if (likely(bpage->page == (void *)addr)) {
86145 - local_dec(&bpage->entries);
86146 + local_dec_unchecked(&bpage->entries);
86147 return;
86148 }
86149
86150 @@ -2854,7 +2854,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
86151 start = bpage;
86152 do {
86153 if (bpage->page == (void *)addr) {
86154 - local_dec(&bpage->entries);
86155 + local_dec_unchecked(&bpage->entries);
86156 return;
86157 }
86158 rb_inc_page(cpu_buffer, &bpage);
86159 @@ -3138,7 +3138,7 @@ static inline unsigned long
86160 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
86161 {
86162 return local_read(&cpu_buffer->entries) -
86163 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
86164 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
86165 }
86166
86167 /**
86168 @@ -3227,7 +3227,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
86169 return 0;
86170
86171 cpu_buffer = buffer->buffers[cpu];
86172 - ret = local_read(&cpu_buffer->overrun);
86173 + ret = local_read_unchecked(&cpu_buffer->overrun);
86174
86175 return ret;
86176 }
86177 @@ -3250,7 +3250,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
86178 return 0;
86179
86180 cpu_buffer = buffer->buffers[cpu];
86181 - ret = local_read(&cpu_buffer->commit_overrun);
86182 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
86183
86184 return ret;
86185 }
86186 @@ -3335,7 +3335,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
86187 /* if you care about this being correct, lock the buffer */
86188 for_each_buffer_cpu(buffer, cpu) {
86189 cpu_buffer = buffer->buffers[cpu];
86190 - overruns += local_read(&cpu_buffer->overrun);
86191 + overruns += local_read_unchecked(&cpu_buffer->overrun);
86192 }
86193
86194 return overruns;
86195 @@ -3511,8 +3511,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
86196 /*
86197 * Reset the reader page to size zero.
86198 */
86199 - local_set(&cpu_buffer->reader_page->write, 0);
86200 - local_set(&cpu_buffer->reader_page->entries, 0);
86201 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
86202 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
86203 local_set(&cpu_buffer->reader_page->page->commit, 0);
86204 cpu_buffer->reader_page->real_end = 0;
86205
86206 @@ -3546,7 +3546,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
86207 * want to compare with the last_overrun.
86208 */
86209 smp_mb();
86210 - overwrite = local_read(&(cpu_buffer->overrun));
86211 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
86212
86213 /*
86214 * Here's the tricky part.
86215 @@ -4116,8 +4116,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
86216
86217 cpu_buffer->head_page
86218 = list_entry(cpu_buffer->pages, struct buffer_page, list);
86219 - local_set(&cpu_buffer->head_page->write, 0);
86220 - local_set(&cpu_buffer->head_page->entries, 0);
86221 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
86222 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
86223 local_set(&cpu_buffer->head_page->page->commit, 0);
86224
86225 cpu_buffer->head_page->read = 0;
86226 @@ -4127,14 +4127,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
86227
86228 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
86229 INIT_LIST_HEAD(&cpu_buffer->new_pages);
86230 - local_set(&cpu_buffer->reader_page->write, 0);
86231 - local_set(&cpu_buffer->reader_page->entries, 0);
86232 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
86233 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
86234 local_set(&cpu_buffer->reader_page->page->commit, 0);
86235 cpu_buffer->reader_page->read = 0;
86236
86237 local_set(&cpu_buffer->entries_bytes, 0);
86238 - local_set(&cpu_buffer->overrun, 0);
86239 - local_set(&cpu_buffer->commit_overrun, 0);
86240 + local_set_unchecked(&cpu_buffer->overrun, 0);
86241 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
86242 local_set(&cpu_buffer->dropped_events, 0);
86243 local_set(&cpu_buffer->entries, 0);
86244 local_set(&cpu_buffer->committing, 0);
86245 @@ -4538,8 +4538,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
86246 rb_init_page(bpage);
86247 bpage = reader->page;
86248 reader->page = *data_page;
86249 - local_set(&reader->write, 0);
86250 - local_set(&reader->entries, 0);
86251 + local_set_unchecked(&reader->write, 0);
86252 + local_set_unchecked(&reader->entries, 0);
86253 reader->read = 0;
86254 *data_page = bpage;
86255
86256 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
86257 index 0582a01..310bed1 100644
86258 --- a/kernel/trace/trace.c
86259 +++ b/kernel/trace/trace.c
86260 @@ -3327,7 +3327,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
86261 return 0;
86262 }
86263
86264 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
86265 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled)
86266 {
86267 /* do nothing if flag is already set */
86268 if (!!(trace_flags & mask) == !!enabled)
86269 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
86270 index 51b4448..7be601f 100644
86271 --- a/kernel/trace/trace.h
86272 +++ b/kernel/trace/trace.h
86273 @@ -1035,7 +1035,7 @@ extern const char *__stop___trace_bprintk_fmt[];
86274 void trace_printk_init_buffers(void);
86275 void trace_printk_start_comm(void);
86276 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
86277 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
86278 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled);
86279
86280 /*
86281 * Normal trace_printk() and friends allocates special buffers
86282 diff --git a/kernel/trace/trace_clock.c b/kernel/trace/trace_clock.c
86283 index 26dc348..8708ca7 100644
86284 --- a/kernel/trace/trace_clock.c
86285 +++ b/kernel/trace/trace_clock.c
86286 @@ -123,7 +123,7 @@ u64 notrace trace_clock_global(void)
86287 return now;
86288 }
86289
86290 -static atomic64_t trace_counter;
86291 +static atomic64_unchecked_t trace_counter;
86292
86293 /*
86294 * trace_clock_counter(): simply an atomic counter.
86295 @@ -132,5 +132,5 @@ static atomic64_t trace_counter;
86296 */
86297 u64 notrace trace_clock_counter(void)
86298 {
86299 - return atomic64_add_return(1, &trace_counter);
86300 + return atomic64_inc_return_unchecked(&trace_counter);
86301 }
86302 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
86303 index 3d18aad..d1be0eb 100644
86304 --- a/kernel/trace/trace_events.c
86305 +++ b/kernel/trace/trace_events.c
86306 @@ -1794,10 +1794,6 @@ static LIST_HEAD(ftrace_module_file_list);
86307 struct ftrace_module_file_ops {
86308 struct list_head list;
86309 struct module *mod;
86310 - struct file_operations id;
86311 - struct file_operations enable;
86312 - struct file_operations format;
86313 - struct file_operations filter;
86314 };
86315
86316 static struct ftrace_module_file_ops *
86317 @@ -1838,17 +1834,12 @@ trace_create_file_ops(struct module *mod)
86318
86319 file_ops->mod = mod;
86320
86321 - file_ops->id = ftrace_event_id_fops;
86322 - file_ops->id.owner = mod;
86323 -
86324 - file_ops->enable = ftrace_enable_fops;
86325 - file_ops->enable.owner = mod;
86326 -
86327 - file_ops->filter = ftrace_event_filter_fops;
86328 - file_ops->filter.owner = mod;
86329 -
86330 - file_ops->format = ftrace_event_format_fops;
86331 - file_ops->format.owner = mod;
86332 + pax_open_kernel();
86333 + mod->trace_id.owner = mod;
86334 + mod->trace_enable.owner = mod;
86335 + mod->trace_filter.owner = mod;
86336 + mod->trace_format.owner = mod;
86337 + pax_close_kernel();
86338
86339 list_add(&file_ops->list, &ftrace_module_file_list);
86340
86341 @@ -1941,8 +1932,8 @@ __trace_add_new_mod_event(struct ftrace_event_call *call,
86342 struct ftrace_module_file_ops *file_ops)
86343 {
86344 return __trace_add_new_event(call, tr,
86345 - &file_ops->id, &file_ops->enable,
86346 - &file_ops->filter, &file_ops->format);
86347 + &file_ops->mod->trace_id, &file_ops->mod->trace_enable,
86348 + &file_ops->mod->trace_filter, &file_ops->mod->trace_format);
86349 }
86350
86351 #else
86352 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
86353 index a5e8f48..a9690d2 100644
86354 --- a/kernel/trace/trace_mmiotrace.c
86355 +++ b/kernel/trace/trace_mmiotrace.c
86356 @@ -24,7 +24,7 @@ struct header_iter {
86357 static struct trace_array *mmio_trace_array;
86358 static bool overrun_detected;
86359 static unsigned long prev_overruns;
86360 -static atomic_t dropped_count;
86361 +static atomic_unchecked_t dropped_count;
86362
86363 static void mmio_reset_data(struct trace_array *tr)
86364 {
86365 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
86366
86367 static unsigned long count_overruns(struct trace_iterator *iter)
86368 {
86369 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
86370 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
86371 unsigned long over = ring_buffer_overruns(iter->trace_buffer->buffer);
86372
86373 if (over > prev_overruns)
86374 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
86375 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
86376 sizeof(*entry), 0, pc);
86377 if (!event) {
86378 - atomic_inc(&dropped_count);
86379 + atomic_inc_unchecked(&dropped_count);
86380 return;
86381 }
86382 entry = ring_buffer_event_data(event);
86383 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
86384 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
86385 sizeof(*entry), 0, pc);
86386 if (!event) {
86387 - atomic_inc(&dropped_count);
86388 + atomic_inc_unchecked(&dropped_count);
86389 return;
86390 }
86391 entry = ring_buffer_event_data(event);
86392 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
86393 index bb922d9..2a54a257 100644
86394 --- a/kernel/trace/trace_output.c
86395 +++ b/kernel/trace/trace_output.c
86396 @@ -294,7 +294,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
86397
86398 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
86399 if (!IS_ERR(p)) {
86400 - p = mangle_path(s->buffer + s->len, p, "\n");
86401 + p = mangle_path(s->buffer + s->len, p, "\n\\");
86402 if (p) {
86403 s->len = p - s->buffer;
86404 return 1;
86405 @@ -893,14 +893,16 @@ int register_ftrace_event(struct trace_event *event)
86406 goto out;
86407 }
86408
86409 + pax_open_kernel();
86410 if (event->funcs->trace == NULL)
86411 - event->funcs->trace = trace_nop_print;
86412 + *(void **)&event->funcs->trace = trace_nop_print;
86413 if (event->funcs->raw == NULL)
86414 - event->funcs->raw = trace_nop_print;
86415 + *(void **)&event->funcs->raw = trace_nop_print;
86416 if (event->funcs->hex == NULL)
86417 - event->funcs->hex = trace_nop_print;
86418 + *(void **)&event->funcs->hex = trace_nop_print;
86419 if (event->funcs->binary == NULL)
86420 - event->funcs->binary = trace_nop_print;
86421 + *(void **)&event->funcs->binary = trace_nop_print;
86422 + pax_close_kernel();
86423
86424 key = event->type & (EVENT_HASHSIZE - 1);
86425
86426 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
86427 index b20428c..4845a10 100644
86428 --- a/kernel/trace/trace_stack.c
86429 +++ b/kernel/trace/trace_stack.c
86430 @@ -68,7 +68,7 @@ check_stack(unsigned long ip, unsigned long *stack)
86431 return;
86432
86433 /* we do not handle interrupt stacks yet */
86434 - if (!object_is_on_stack(stack))
86435 + if (!object_starts_on_stack(stack))
86436 return;
86437
86438 local_irq_save(flags);
86439 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
86440 index 9064b91..1f5d2f8 100644
86441 --- a/kernel/user_namespace.c
86442 +++ b/kernel/user_namespace.c
86443 @@ -82,6 +82,21 @@ int create_user_ns(struct cred *new)
86444 !kgid_has_mapping(parent_ns, group))
86445 return -EPERM;
86446
86447 +#ifdef CONFIG_GRKERNSEC
86448 + /*
86449 + * This doesn't really inspire confidence:
86450 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
86451 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
86452 + * Increases kernel attack surface in areas developers
86453 + * previously cared little about ("low importance due
86454 + * to requiring "root" capability")
86455 + * To be removed when this code receives *proper* review
86456 + */
86457 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
86458 + !capable(CAP_SETGID))
86459 + return -EPERM;
86460 +#endif
86461 +
86462 ns = kmem_cache_zalloc(user_ns_cachep, GFP_KERNEL);
86463 if (!ns)
86464 return -ENOMEM;
86465 @@ -862,7 +877,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
86466 if (atomic_read(&current->mm->mm_users) > 1)
86467 return -EINVAL;
86468
86469 - if (current->fs->users != 1)
86470 + if (atomic_read(&current->fs->users) != 1)
86471 return -EINVAL;
86472
86473 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
86474 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
86475 index 4f69f9a..7c6f8f8 100644
86476 --- a/kernel/utsname_sysctl.c
86477 +++ b/kernel/utsname_sysctl.c
86478 @@ -47,7 +47,7 @@ static void put_uts(ctl_table *table, int write, void *which)
86479 static int proc_do_uts_string(ctl_table *table, int write,
86480 void __user *buffer, size_t *lenp, loff_t *ppos)
86481 {
86482 - struct ctl_table uts_table;
86483 + ctl_table_no_const uts_table;
86484 int r;
86485 memcpy(&uts_table, table, sizeof(uts_table));
86486 uts_table.data = get_uts(table, write);
86487 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
86488 index 05039e3..17490c7 100644
86489 --- a/kernel/watchdog.c
86490 +++ b/kernel/watchdog.c
86491 @@ -531,7 +531,7 @@ int proc_dowatchdog(struct ctl_table *table, int write,
86492 }
86493 #endif /* CONFIG_SYSCTL */
86494
86495 -static struct smp_hotplug_thread watchdog_threads = {
86496 +static struct smp_hotplug_thread watchdog_threads __read_only = {
86497 .store = &softlockup_watchdog,
86498 .thread_should_run = watchdog_should_run,
86499 .thread_fn = watchdog,
86500 diff --git a/kernel/workqueue.c b/kernel/workqueue.c
86501 index 6f01921..139869b 100644
86502 --- a/kernel/workqueue.c
86503 +++ b/kernel/workqueue.c
86504 @@ -4596,7 +4596,7 @@ static void rebind_workers(struct worker_pool *pool)
86505 WARN_ON_ONCE(!(worker_flags & WORKER_UNBOUND));
86506 worker_flags |= WORKER_REBOUND;
86507 worker_flags &= ~WORKER_UNBOUND;
86508 - ACCESS_ONCE(worker->flags) = worker_flags;
86509 + ACCESS_ONCE_RW(worker->flags) = worker_flags;
86510 }
86511
86512 spin_unlock_irq(&pool->lock);
86513 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
86514 index 74fdc5c..3310593 100644
86515 --- a/lib/Kconfig.debug
86516 +++ b/lib/Kconfig.debug
86517 @@ -549,7 +549,7 @@ config DEBUG_MUTEXES
86518
86519 config DEBUG_LOCK_ALLOC
86520 bool "Lock debugging: detect incorrect freeing of live locks"
86521 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
86522 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
86523 select DEBUG_SPINLOCK
86524 select DEBUG_MUTEXES
86525 select LOCKDEP
86526 @@ -563,7 +563,7 @@ config DEBUG_LOCK_ALLOC
86527
86528 config PROVE_LOCKING
86529 bool "Lock debugging: prove locking correctness"
86530 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
86531 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
86532 select LOCKDEP
86533 select DEBUG_SPINLOCK
86534 select DEBUG_MUTEXES
86535 @@ -614,7 +614,7 @@ config LOCKDEP
86536
86537 config LOCK_STAT
86538 bool "Lock usage statistics"
86539 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
86540 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
86541 select LOCKDEP
86542 select DEBUG_SPINLOCK
86543 select DEBUG_MUTEXES
86544 @@ -1282,6 +1282,7 @@ config LATENCYTOP
86545 depends on DEBUG_KERNEL
86546 depends on STACKTRACE_SUPPORT
86547 depends on PROC_FS
86548 + depends on !GRKERNSEC_HIDESYM
86549 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
86550 select KALLSYMS
86551 select KALLSYMS_ALL
86552 @@ -1298,7 +1299,7 @@ config ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
86553 config DEBUG_STRICT_USER_COPY_CHECKS
86554 bool "Strict user copy size checks"
86555 depends on ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
86556 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
86557 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
86558 help
86559 Enabling this option turns a certain set of sanity checks for user
86560 copy operations into compile time failures.
86561 @@ -1328,7 +1329,7 @@ config INTERVAL_TREE_TEST
86562
86563 config PROVIDE_OHCI1394_DMA_INIT
86564 bool "Remote debugging over FireWire early on boot"
86565 - depends on PCI && X86
86566 + depends on PCI && X86 && !GRKERNSEC
86567 help
86568 If you want to debug problems which hang or crash the kernel early
86569 on boot and the crashing machine has a FireWire port, you can use
86570 @@ -1357,7 +1358,7 @@ config PROVIDE_OHCI1394_DMA_INIT
86571
86572 config FIREWIRE_OHCI_REMOTE_DMA
86573 bool "Remote debugging over FireWire with firewire-ohci"
86574 - depends on FIREWIRE_OHCI
86575 + depends on FIREWIRE_OHCI && !GRKERNSEC
86576 help
86577 This option lets you use the FireWire bus for remote debugging
86578 with help of the firewire-ohci driver. It enables unfiltered
86579 diff --git a/lib/Makefile b/lib/Makefile
86580 index c55a037..fb46e3b 100644
86581 --- a/lib/Makefile
86582 +++ b/lib/Makefile
86583 @@ -50,7 +50,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
86584
86585 obj-$(CONFIG_BTREE) += btree.o
86586 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
86587 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
86588 +obj-y += list_debug.o
86589 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
86590
86591 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
86592 diff --git a/lib/bitmap.c b/lib/bitmap.c
86593 index 06f7e4f..f3cf2b0 100644
86594 --- a/lib/bitmap.c
86595 +++ b/lib/bitmap.c
86596 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
86597 {
86598 int c, old_c, totaldigits, ndigits, nchunks, nbits;
86599 u32 chunk;
86600 - const char __user __force *ubuf = (const char __user __force *)buf;
86601 + const char __user *ubuf = (const char __force_user *)buf;
86602
86603 bitmap_zero(maskp, nmaskbits);
86604
86605 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
86606 {
86607 if (!access_ok(VERIFY_READ, ubuf, ulen))
86608 return -EFAULT;
86609 - return __bitmap_parse((const char __force *)ubuf,
86610 + return __bitmap_parse((const char __force_kernel *)ubuf,
86611 ulen, 1, maskp, nmaskbits);
86612
86613 }
86614 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
86615 {
86616 unsigned a, b;
86617 int c, old_c, totaldigits;
86618 - const char __user __force *ubuf = (const char __user __force *)buf;
86619 + const char __user *ubuf = (const char __force_user *)buf;
86620 int exp_digit, in_range;
86621
86622 totaldigits = c = 0;
86623 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
86624 {
86625 if (!access_ok(VERIFY_READ, ubuf, ulen))
86626 return -EFAULT;
86627 - return __bitmap_parselist((const char __force *)ubuf,
86628 + return __bitmap_parselist((const char __force_kernel *)ubuf,
86629 ulen, 1, maskp, nmaskbits);
86630 }
86631 EXPORT_SYMBOL(bitmap_parselist_user);
86632 diff --git a/lib/bug.c b/lib/bug.c
86633 index 1686034..a9c00c8 100644
86634 --- a/lib/bug.c
86635 +++ b/lib/bug.c
86636 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
86637 return BUG_TRAP_TYPE_NONE;
86638
86639 bug = find_bug(bugaddr);
86640 + if (!bug)
86641 + return BUG_TRAP_TYPE_NONE;
86642
86643 file = NULL;
86644 line = 0;
86645 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
86646 index 37061ed..da83f48 100644
86647 --- a/lib/debugobjects.c
86648 +++ b/lib/debugobjects.c
86649 @@ -286,7 +286,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
86650 if (limit > 4)
86651 return;
86652
86653 - is_on_stack = object_is_on_stack(addr);
86654 + is_on_stack = object_starts_on_stack(addr);
86655 if (is_on_stack == onstack)
86656 return;
86657
86658 diff --git a/lib/devres.c b/lib/devres.c
86659 index 8235331..5881053 100644
86660 --- a/lib/devres.c
86661 +++ b/lib/devres.c
86662 @@ -81,7 +81,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
86663 void devm_iounmap(struct device *dev, void __iomem *addr)
86664 {
86665 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
86666 - (void *)addr));
86667 + (void __force *)addr));
86668 iounmap(addr);
86669 }
86670 EXPORT_SYMBOL(devm_iounmap);
86671 @@ -224,7 +224,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
86672 {
86673 ioport_unmap(addr);
86674 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
86675 - devm_ioport_map_match, (void *)addr));
86676 + devm_ioport_map_match, (void __force *)addr));
86677 }
86678 EXPORT_SYMBOL(devm_ioport_unmap);
86679 #endif /* CONFIG_HAS_IOPORT */
86680 diff --git a/lib/div64.c b/lib/div64.c
86681 index a163b6c..9618fa5 100644
86682 --- a/lib/div64.c
86683 +++ b/lib/div64.c
86684 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
86685 EXPORT_SYMBOL(__div64_32);
86686
86687 #ifndef div_s64_rem
86688 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
86689 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
86690 {
86691 u64 quotient;
86692
86693 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
86694 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
86695 */
86696 #ifndef div64_u64
86697 -u64 div64_u64(u64 dividend, u64 divisor)
86698 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
86699 {
86700 u32 high = divisor >> 32;
86701 u64 quot;
86702 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
86703 index d87a17a..ac0d79a 100644
86704 --- a/lib/dma-debug.c
86705 +++ b/lib/dma-debug.c
86706 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
86707
86708 void dma_debug_add_bus(struct bus_type *bus)
86709 {
86710 - struct notifier_block *nb;
86711 + notifier_block_no_const *nb;
86712
86713 if (global_disable)
86714 return;
86715 @@ -945,7 +945,7 @@ static void check_unmap(struct dma_debug_entry *ref)
86716
86717 static void check_for_stack(struct device *dev, void *addr)
86718 {
86719 - if (object_is_on_stack(addr))
86720 + if (object_starts_on_stack(addr))
86721 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
86722 "stack [addr=%p]\n", addr);
86723 }
86724 diff --git a/lib/inflate.c b/lib/inflate.c
86725 index 013a761..c28f3fc 100644
86726 --- a/lib/inflate.c
86727 +++ b/lib/inflate.c
86728 @@ -269,7 +269,7 @@ static void free(void *where)
86729 malloc_ptr = free_mem_ptr;
86730 }
86731 #else
86732 -#define malloc(a) kmalloc(a, GFP_KERNEL)
86733 +#define malloc(a) kmalloc((a), GFP_KERNEL)
86734 #define free(a) kfree(a)
86735 #endif
86736
86737 diff --git a/lib/ioremap.c b/lib/ioremap.c
86738 index 0c9216c..863bd89 100644
86739 --- a/lib/ioremap.c
86740 +++ b/lib/ioremap.c
86741 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
86742 unsigned long next;
86743
86744 phys_addr -= addr;
86745 - pmd = pmd_alloc(&init_mm, pud, addr);
86746 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
86747 if (!pmd)
86748 return -ENOMEM;
86749 do {
86750 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
86751 unsigned long next;
86752
86753 phys_addr -= addr;
86754 - pud = pud_alloc(&init_mm, pgd, addr);
86755 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
86756 if (!pud)
86757 return -ENOMEM;
86758 do {
86759 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
86760 index bd2bea9..6b3c95e 100644
86761 --- a/lib/is_single_threaded.c
86762 +++ b/lib/is_single_threaded.c
86763 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
86764 struct task_struct *p, *t;
86765 bool ret;
86766
86767 + if (!mm)
86768 + return true;
86769 +
86770 if (atomic_read(&task->signal->live) != 1)
86771 return false;
86772
86773 diff --git a/lib/kobject.c b/lib/kobject.c
86774 index b7e29a6..2f3ca75 100644
86775 --- a/lib/kobject.c
86776 +++ b/lib/kobject.c
86777 @@ -805,7 +805,7 @@ static struct kset *kset_create(const char *name,
86778 kset = kzalloc(sizeof(*kset), GFP_KERNEL);
86779 if (!kset)
86780 return NULL;
86781 - retval = kobject_set_name(&kset->kobj, name);
86782 + retval = kobject_set_name(&kset->kobj, "%s", name);
86783 if (retval) {
86784 kfree(kset);
86785 return NULL;
86786 @@ -859,9 +859,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
86787
86788
86789 static DEFINE_SPINLOCK(kobj_ns_type_lock);
86790 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
86791 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
86792
86793 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
86794 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
86795 {
86796 enum kobj_ns_type type = ops->type;
86797 int error;
86798 diff --git a/lib/list_debug.c b/lib/list_debug.c
86799 index c24c2f7..06e070b 100644
86800 --- a/lib/list_debug.c
86801 +++ b/lib/list_debug.c
86802 @@ -11,7 +11,9 @@
86803 #include <linux/bug.h>
86804 #include <linux/kernel.h>
86805 #include <linux/rculist.h>
86806 +#include <linux/mm.h>
86807
86808 +#ifdef CONFIG_DEBUG_LIST
86809 /*
86810 * Insert a new entry between two known consecutive entries.
86811 *
86812 @@ -19,21 +21,32 @@
86813 * the prev/next entries already!
86814 */
86815
86816 -void __list_add(struct list_head *new,
86817 - struct list_head *prev,
86818 - struct list_head *next)
86819 +static bool __list_add_debug(struct list_head *new,
86820 + struct list_head *prev,
86821 + struct list_head *next)
86822 {
86823 - WARN(next->prev != prev,
86824 + if (WARN(next->prev != prev,
86825 "list_add corruption. next->prev should be "
86826 "prev (%p), but was %p. (next=%p).\n",
86827 - prev, next->prev, next);
86828 - WARN(prev->next != next,
86829 + prev, next->prev, next) ||
86830 + WARN(prev->next != next,
86831 "list_add corruption. prev->next should be "
86832 "next (%p), but was %p. (prev=%p).\n",
86833 - next, prev->next, prev);
86834 - WARN(new == prev || new == next,
86835 - "list_add double add: new=%p, prev=%p, next=%p.\n",
86836 - new, prev, next);
86837 + next, prev->next, prev) ||
86838 + WARN(new == prev || new == next,
86839 + "list_add double add: new=%p, prev=%p, next=%p.\n",
86840 + new, prev, next))
86841 + return false;
86842 + return true;
86843 +}
86844 +
86845 +void __list_add(struct list_head *new,
86846 + struct list_head *prev,
86847 + struct list_head *next)
86848 +{
86849 + if (!__list_add_debug(new, prev, next))
86850 + return;
86851 +
86852 next->prev = new;
86853 new->next = next;
86854 new->prev = prev;
86855 @@ -41,7 +54,7 @@ void __list_add(struct list_head *new,
86856 }
86857 EXPORT_SYMBOL(__list_add);
86858
86859 -void __list_del_entry(struct list_head *entry)
86860 +static bool __list_del_entry_debug(struct list_head *entry)
86861 {
86862 struct list_head *prev, *next;
86863
86864 @@ -60,9 +73,16 @@ void __list_del_entry(struct list_head *entry)
86865 WARN(next->prev != entry,
86866 "list_del corruption. next->prev should be %p, "
86867 "but was %p\n", entry, next->prev))
86868 + return false;
86869 + return true;
86870 +}
86871 +
86872 +void __list_del_entry(struct list_head *entry)
86873 +{
86874 + if (!__list_del_entry_debug(entry))
86875 return;
86876
86877 - __list_del(prev, next);
86878 + __list_del(entry->prev, entry->next);
86879 }
86880 EXPORT_SYMBOL(__list_del_entry);
86881
86882 @@ -86,15 +106,85 @@ EXPORT_SYMBOL(list_del);
86883 void __list_add_rcu(struct list_head *new,
86884 struct list_head *prev, struct list_head *next)
86885 {
86886 - WARN(next->prev != prev,
86887 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
86888 - prev, next->prev, next);
86889 - WARN(prev->next != next,
86890 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
86891 - next, prev->next, prev);
86892 + if (!__list_add_debug(new, prev, next))
86893 + return;
86894 +
86895 new->next = next;
86896 new->prev = prev;
86897 rcu_assign_pointer(list_next_rcu(prev), new);
86898 next->prev = new;
86899 }
86900 EXPORT_SYMBOL(__list_add_rcu);
86901 +#endif
86902 +
86903 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
86904 +{
86905 +#ifdef CONFIG_DEBUG_LIST
86906 + if (!__list_add_debug(new, prev, next))
86907 + return;
86908 +#endif
86909 +
86910 + pax_open_kernel();
86911 + next->prev = new;
86912 + new->next = next;
86913 + new->prev = prev;
86914 + prev->next = new;
86915 + pax_close_kernel();
86916 +}
86917 +EXPORT_SYMBOL(__pax_list_add);
86918 +
86919 +void pax_list_del(struct list_head *entry)
86920 +{
86921 +#ifdef CONFIG_DEBUG_LIST
86922 + if (!__list_del_entry_debug(entry))
86923 + return;
86924 +#endif
86925 +
86926 + pax_open_kernel();
86927 + __list_del(entry->prev, entry->next);
86928 + entry->next = LIST_POISON1;
86929 + entry->prev = LIST_POISON2;
86930 + pax_close_kernel();
86931 +}
86932 +EXPORT_SYMBOL(pax_list_del);
86933 +
86934 +void pax_list_del_init(struct list_head *entry)
86935 +{
86936 + pax_open_kernel();
86937 + __list_del(entry->prev, entry->next);
86938 + INIT_LIST_HEAD(entry);
86939 + pax_close_kernel();
86940 +}
86941 +EXPORT_SYMBOL(pax_list_del_init);
86942 +
86943 +void __pax_list_add_rcu(struct list_head *new,
86944 + struct list_head *prev, struct list_head *next)
86945 +{
86946 +#ifdef CONFIG_DEBUG_LIST
86947 + if (!__list_add_debug(new, prev, next))
86948 + return;
86949 +#endif
86950 +
86951 + pax_open_kernel();
86952 + new->next = next;
86953 + new->prev = prev;
86954 + rcu_assign_pointer(list_next_rcu(prev), new);
86955 + next->prev = new;
86956 + pax_close_kernel();
86957 +}
86958 +EXPORT_SYMBOL(__pax_list_add_rcu);
86959 +
86960 +void pax_list_del_rcu(struct list_head *entry)
86961 +{
86962 +#ifdef CONFIG_DEBUG_LIST
86963 + if (!__list_del_entry_debug(entry))
86964 + return;
86965 +#endif
86966 +
86967 + pax_open_kernel();
86968 + __list_del(entry->prev, entry->next);
86969 + entry->next = LIST_POISON1;
86970 + entry->prev = LIST_POISON2;
86971 + pax_close_kernel();
86972 +}
86973 +EXPORT_SYMBOL(pax_list_del_rcu);
86974 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
86975 index e796429..6e38f9f 100644
86976 --- a/lib/radix-tree.c
86977 +++ b/lib/radix-tree.c
86978 @@ -92,7 +92,7 @@ struct radix_tree_preload {
86979 int nr;
86980 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
86981 };
86982 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
86983 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
86984
86985 static inline void *ptr_to_indirect(void *ptr)
86986 {
86987 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
86988 index bb2b201..46abaf9 100644
86989 --- a/lib/strncpy_from_user.c
86990 +++ b/lib/strncpy_from_user.c
86991 @@ -21,7 +21,7 @@
86992 */
86993 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
86994 {
86995 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
86996 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
86997 long res = 0;
86998
86999 /*
87000 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
87001 index a28df52..3d55877 100644
87002 --- a/lib/strnlen_user.c
87003 +++ b/lib/strnlen_user.c
87004 @@ -26,7 +26,7 @@
87005 */
87006 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
87007 {
87008 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
87009 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
87010 long align, res = 0;
87011 unsigned long c;
87012
87013 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
87014 index d23762e..e21eab2 100644
87015 --- a/lib/swiotlb.c
87016 +++ b/lib/swiotlb.c
87017 @@ -664,7 +664,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
87018
87019 void
87020 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
87021 - dma_addr_t dev_addr)
87022 + dma_addr_t dev_addr, struct dma_attrs *attrs)
87023 {
87024 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
87025
87026 diff --git a/lib/usercopy.c b/lib/usercopy.c
87027 index 4f5b1dd..7cab418 100644
87028 --- a/lib/usercopy.c
87029 +++ b/lib/usercopy.c
87030 @@ -7,3 +7,9 @@ void copy_from_user_overflow(void)
87031 WARN(1, "Buffer overflow detected!\n");
87032 }
87033 EXPORT_SYMBOL(copy_from_user_overflow);
87034 +
87035 +void copy_to_user_overflow(void)
87036 +{
87037 + WARN(1, "Buffer overflow detected!\n");
87038 +}
87039 +EXPORT_SYMBOL(copy_to_user_overflow);
87040 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
87041 index e149c64..24aa71a 100644
87042 --- a/lib/vsprintf.c
87043 +++ b/lib/vsprintf.c
87044 @@ -16,6 +16,9 @@
87045 * - scnprintf and vscnprintf
87046 */
87047
87048 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87049 +#define __INCLUDED_BY_HIDESYM 1
87050 +#endif
87051 #include <stdarg.h>
87052 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
87053 #include <linux/types.h>
87054 @@ -981,7 +984,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
87055 return number(buf, end, *(const netdev_features_t *)addr, spec);
87056 }
87057
87058 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87059 +int kptr_restrict __read_mostly = 2;
87060 +#else
87061 int kptr_restrict __read_mostly;
87062 +#endif
87063
87064 /*
87065 * Show a '%p' thing. A kernel extension is that the '%p' is followed
87066 @@ -994,6 +1001,7 @@ int kptr_restrict __read_mostly;
87067 * - 'f' For simple symbolic function names without offset
87068 * - 'S' For symbolic direct pointers with offset
87069 * - 's' For symbolic direct pointers without offset
87070 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
87071 * - '[FfSs]R' as above with __builtin_extract_return_addr() translation
87072 * - 'B' For backtraced symbolic direct pointers with offset
87073 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
87074 @@ -1052,12 +1060,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
87075
87076 if (!ptr && *fmt != 'K') {
87077 /*
87078 - * Print (null) with the same width as a pointer so it makes
87079 + * Print (nil) with the same width as a pointer so it makes
87080 * tabular output look nice.
87081 */
87082 if (spec.field_width == -1)
87083 spec.field_width = default_width;
87084 - return string(buf, end, "(null)", spec);
87085 + return string(buf, end, "(nil)", spec);
87086 }
87087
87088 switch (*fmt) {
87089 @@ -1067,6 +1075,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
87090 /* Fallthrough */
87091 case 'S':
87092 case 's':
87093 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87094 + break;
87095 +#else
87096 + return symbol_string(buf, end, ptr, spec, fmt);
87097 +#endif
87098 + case 'A':
87099 case 'B':
87100 return symbol_string(buf, end, ptr, spec, fmt);
87101 case 'R':
87102 @@ -1107,6 +1121,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
87103 va_end(va);
87104 return buf;
87105 }
87106 + case 'P':
87107 + break;
87108 case 'K':
87109 /*
87110 * %pK cannot be used in IRQ context because its test
87111 @@ -1136,6 +1152,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
87112 return number(buf, end,
87113 (unsigned long long) *((phys_addr_t *)ptr), spec);
87114 }
87115 +
87116 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87117 + /* 'P' = approved pointers to copy to userland,
87118 + as in the /proc/kallsyms case, as we make it display nothing
87119 + for non-root users, and the real contents for root users
87120 + Also ignore 'K' pointers, since we force their NULLing for non-root users
87121 + above
87122 + */
87123 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
87124 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
87125 + dump_stack();
87126 + ptr = NULL;
87127 + }
87128 +#endif
87129 +
87130 spec.flags |= SMALL;
87131 if (spec.field_width == -1) {
87132 spec.field_width = default_width;
87133 @@ -1857,11 +1888,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
87134 typeof(type) value; \
87135 if (sizeof(type) == 8) { \
87136 args = PTR_ALIGN(args, sizeof(u32)); \
87137 - *(u32 *)&value = *(u32 *)args; \
87138 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
87139 + *(u32 *)&value = *(const u32 *)args; \
87140 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
87141 } else { \
87142 args = PTR_ALIGN(args, sizeof(type)); \
87143 - value = *(typeof(type) *)args; \
87144 + value = *(const typeof(type) *)args; \
87145 } \
87146 args += sizeof(type); \
87147 value; \
87148 @@ -1924,7 +1955,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
87149 case FORMAT_TYPE_STR: {
87150 const char *str_arg = args;
87151 args += strlen(str_arg) + 1;
87152 - str = string(str, end, (char *)str_arg, spec);
87153 + str = string(str, end, str_arg, spec);
87154 break;
87155 }
87156
87157 diff --git a/localversion-grsec b/localversion-grsec
87158 new file mode 100644
87159 index 0000000..7cd6065
87160 --- /dev/null
87161 +++ b/localversion-grsec
87162 @@ -0,0 +1 @@
87163 +-grsec
87164 diff --git a/mm/Kconfig b/mm/Kconfig
87165 index e742d06..c56fdd8 100644
87166 --- a/mm/Kconfig
87167 +++ b/mm/Kconfig
87168 @@ -317,10 +317,10 @@ config KSM
87169 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
87170
87171 config DEFAULT_MMAP_MIN_ADDR
87172 - int "Low address space to protect from user allocation"
87173 + int "Low address space to protect from user allocation"
87174 depends on MMU
87175 - default 4096
87176 - help
87177 + default 65536
87178 + help
87179 This is the portion of low virtual memory which should be protected
87180 from userspace allocation. Keeping a user from writing to low pages
87181 can help reduce the impact of kernel NULL pointer bugs.
87182 @@ -351,7 +351,7 @@ config MEMORY_FAILURE
87183
87184 config HWPOISON_INJECT
87185 tristate "HWPoison pages injector"
87186 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
87187 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
87188 select PROC_PAGE_MONITOR
87189
87190 config NOMMU_INITIAL_TRIM_EXCESS
87191 diff --git a/mm/backing-dev.c b/mm/backing-dev.c
87192 index 5025174..9d67dcd 100644
87193 --- a/mm/backing-dev.c
87194 +++ b/mm/backing-dev.c
87195 @@ -12,7 +12,7 @@
87196 #include <linux/device.h>
87197 #include <trace/events/writeback.h>
87198
87199 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
87200 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
87201
87202 struct backing_dev_info default_backing_dev_info = {
87203 .name = "default",
87204 @@ -515,7 +515,6 @@ EXPORT_SYMBOL(bdi_destroy);
87205 int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
87206 unsigned int cap)
87207 {
87208 - char tmp[32];
87209 int err;
87210
87211 bdi->name = name;
87212 @@ -524,8 +523,7 @@ int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
87213 if (err)
87214 return err;
87215
87216 - sprintf(tmp, "%.28s%s", name, "-%d");
87217 - err = bdi_register(bdi, NULL, tmp, atomic_long_inc_return(&bdi_seq));
87218 + err = bdi_register(bdi, NULL, "%.28s-%ld", name, atomic_long_inc_return_unchecked(&bdi_seq));
87219 if (err) {
87220 bdi_destroy(bdi);
87221 return err;
87222 diff --git a/mm/filemap.c b/mm/filemap.c
87223 index 7905fe7..f59502b 100644
87224 --- a/mm/filemap.c
87225 +++ b/mm/filemap.c
87226 @@ -1766,7 +1766,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
87227 struct address_space *mapping = file->f_mapping;
87228
87229 if (!mapping->a_ops->readpage)
87230 - return -ENOEXEC;
87231 + return -ENODEV;
87232 file_accessed(file);
87233 vma->vm_ops = &generic_file_vm_ops;
87234 return 0;
87235 @@ -1948,7 +1948,7 @@ static size_t __iovec_copy_from_user_inatomic(char *vaddr,
87236
87237 while (bytes) {
87238 char __user *buf = iov->iov_base + base;
87239 - int copy = min(bytes, iov->iov_len - base);
87240 + size_t copy = min(bytes, iov->iov_len - base);
87241
87242 base = 0;
87243 left = __copy_from_user_inatomic(vaddr, buf, copy);
87244 @@ -1977,7 +1977,7 @@ size_t iov_iter_copy_from_user_atomic(struct page *page,
87245 BUG_ON(!in_atomic());
87246 kaddr = kmap_atomic(page);
87247 if (likely(i->nr_segs == 1)) {
87248 - int left;
87249 + size_t left;
87250 char __user *buf = i->iov->iov_base + i->iov_offset;
87251 left = __copy_from_user_inatomic(kaddr + offset, buf, bytes);
87252 copied = bytes - left;
87253 @@ -2005,7 +2005,7 @@ size_t iov_iter_copy_from_user(struct page *page,
87254
87255 kaddr = kmap(page);
87256 if (likely(i->nr_segs == 1)) {
87257 - int left;
87258 + size_t left;
87259 char __user *buf = i->iov->iov_base + i->iov_offset;
87260 left = __copy_from_user(kaddr + offset, buf, bytes);
87261 copied = bytes - left;
87262 @@ -2035,7 +2035,7 @@ void iov_iter_advance(struct iov_iter *i, size_t bytes)
87263 * zero-length segments (without overruning the iovec).
87264 */
87265 while (bytes || unlikely(i->count && !iov->iov_len)) {
87266 - int copy;
87267 + size_t copy;
87268
87269 copy = min(bytes, iov->iov_len - base);
87270 BUG_ON(!i->count || i->count < copy);
87271 @@ -2106,6 +2106,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
87272 *pos = i_size_read(inode);
87273
87274 if (limit != RLIM_INFINITY) {
87275 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
87276 if (*pos >= limit) {
87277 send_sig(SIGXFSZ, current, 0);
87278 return -EFBIG;
87279 diff --git a/mm/fremap.c b/mm/fremap.c
87280 index 87da359..3f41cb1 100644
87281 --- a/mm/fremap.c
87282 +++ b/mm/fremap.c
87283 @@ -158,6 +158,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
87284 retry:
87285 vma = find_vma(mm, start);
87286
87287 +#ifdef CONFIG_PAX_SEGMEXEC
87288 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
87289 + goto out;
87290 +#endif
87291 +
87292 /*
87293 * Make sure the vma is shared, that it supports prefaulting,
87294 * and that the remapped range is valid and fully within
87295 diff --git a/mm/highmem.c b/mm/highmem.c
87296 index b32b70c..e512eb0 100644
87297 --- a/mm/highmem.c
87298 +++ b/mm/highmem.c
87299 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
87300 * So no dangers, even with speculative execution.
87301 */
87302 page = pte_page(pkmap_page_table[i]);
87303 + pax_open_kernel();
87304 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
87305 -
87306 + pax_close_kernel();
87307 set_page_address(page, NULL);
87308 need_flush = 1;
87309 }
87310 @@ -198,9 +199,11 @@ start:
87311 }
87312 }
87313 vaddr = PKMAP_ADDR(last_pkmap_nr);
87314 +
87315 + pax_open_kernel();
87316 set_pte_at(&init_mm, vaddr,
87317 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
87318 -
87319 + pax_close_kernel();
87320 pkmap_count[last_pkmap_nr] = 1;
87321 set_page_address(page, (void *)vaddr);
87322
87323 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
87324 index 7c5eb85..5c01c2f 100644
87325 --- a/mm/hugetlb.c
87326 +++ b/mm/hugetlb.c
87327 @@ -2022,15 +2022,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
87328 struct hstate *h = &default_hstate;
87329 unsigned long tmp;
87330 int ret;
87331 + ctl_table_no_const hugetlb_table;
87332
87333 tmp = h->max_huge_pages;
87334
87335 if (write && h->order >= MAX_ORDER)
87336 return -EINVAL;
87337
87338 - table->data = &tmp;
87339 - table->maxlen = sizeof(unsigned long);
87340 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
87341 + hugetlb_table = *table;
87342 + hugetlb_table.data = &tmp;
87343 + hugetlb_table.maxlen = sizeof(unsigned long);
87344 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
87345 if (ret)
87346 goto out;
87347
87348 @@ -2087,15 +2089,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
87349 struct hstate *h = &default_hstate;
87350 unsigned long tmp;
87351 int ret;
87352 + ctl_table_no_const hugetlb_table;
87353
87354 tmp = h->nr_overcommit_huge_pages;
87355
87356 if (write && h->order >= MAX_ORDER)
87357 return -EINVAL;
87358
87359 - table->data = &tmp;
87360 - table->maxlen = sizeof(unsigned long);
87361 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
87362 + hugetlb_table = *table;
87363 + hugetlb_table.data = &tmp;
87364 + hugetlb_table.maxlen = sizeof(unsigned long);
87365 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
87366 if (ret)
87367 goto out;
87368
87369 @@ -2545,6 +2549,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
87370 return 1;
87371 }
87372
87373 +#ifdef CONFIG_PAX_SEGMEXEC
87374 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
87375 +{
87376 + struct mm_struct *mm = vma->vm_mm;
87377 + struct vm_area_struct *vma_m;
87378 + unsigned long address_m;
87379 + pte_t *ptep_m;
87380 +
87381 + vma_m = pax_find_mirror_vma(vma);
87382 + if (!vma_m)
87383 + return;
87384 +
87385 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
87386 + address_m = address + SEGMEXEC_TASK_SIZE;
87387 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
87388 + get_page(page_m);
87389 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
87390 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
87391 +}
87392 +#endif
87393 +
87394 /*
87395 * Hugetlb_cow() should be called with page lock of the original hugepage held.
87396 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
87397 @@ -2663,6 +2688,11 @@ retry_avoidcopy:
87398 make_huge_pte(vma, new_page, 1));
87399 page_remove_rmap(old_page);
87400 hugepage_add_new_anon_rmap(new_page, vma, address);
87401 +
87402 +#ifdef CONFIG_PAX_SEGMEXEC
87403 + pax_mirror_huge_pte(vma, address, new_page);
87404 +#endif
87405 +
87406 /* Make the old page be freed below */
87407 new_page = old_page;
87408 }
87409 @@ -2821,6 +2851,10 @@ retry:
87410 && (vma->vm_flags & VM_SHARED)));
87411 set_huge_pte_at(mm, address, ptep, new_pte);
87412
87413 +#ifdef CONFIG_PAX_SEGMEXEC
87414 + pax_mirror_huge_pte(vma, address, page);
87415 +#endif
87416 +
87417 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
87418 /* Optimization, do the COW without a second fault */
87419 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
87420 @@ -2850,6 +2884,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87421 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
87422 struct hstate *h = hstate_vma(vma);
87423
87424 +#ifdef CONFIG_PAX_SEGMEXEC
87425 + struct vm_area_struct *vma_m;
87426 +#endif
87427 +
87428 address &= huge_page_mask(h);
87429
87430 ptep = huge_pte_offset(mm, address);
87431 @@ -2863,6 +2901,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87432 VM_FAULT_SET_HINDEX(hstate_index(h));
87433 }
87434
87435 +#ifdef CONFIG_PAX_SEGMEXEC
87436 + vma_m = pax_find_mirror_vma(vma);
87437 + if (vma_m) {
87438 + unsigned long address_m;
87439 +
87440 + if (vma->vm_start > vma_m->vm_start) {
87441 + address_m = address;
87442 + address -= SEGMEXEC_TASK_SIZE;
87443 + vma = vma_m;
87444 + h = hstate_vma(vma);
87445 + } else
87446 + address_m = address + SEGMEXEC_TASK_SIZE;
87447 +
87448 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
87449 + return VM_FAULT_OOM;
87450 + address_m &= HPAGE_MASK;
87451 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
87452 + }
87453 +#endif
87454 +
87455 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
87456 if (!ptep)
87457 return VM_FAULT_OOM;
87458 diff --git a/mm/internal.h b/mm/internal.h
87459 index 8562de0..92b2073 100644
87460 --- a/mm/internal.h
87461 +++ b/mm/internal.h
87462 @@ -100,6 +100,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
87463 * in mm/page_alloc.c
87464 */
87465 extern void __free_pages_bootmem(struct page *page, unsigned int order);
87466 +extern void free_compound_page(struct page *page);
87467 extern void prep_compound_page(struct page *page, unsigned long order);
87468 #ifdef CONFIG_MEMORY_FAILURE
87469 extern bool is_free_buddy_page(struct page *page);
87470 @@ -355,7 +356,7 @@ extern u32 hwpoison_filter_enable;
87471
87472 extern unsigned long vm_mmap_pgoff(struct file *, unsigned long,
87473 unsigned long, unsigned long,
87474 - unsigned long, unsigned long);
87475 + unsigned long, unsigned long) __intentional_overflow(-1);
87476
87477 extern void set_pageblock_order(void);
87478 unsigned long reclaim_clean_pages_from_list(struct zone *zone,
87479 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
87480 index c8d7f31..2dbeffd 100644
87481 --- a/mm/kmemleak.c
87482 +++ b/mm/kmemleak.c
87483 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
87484
87485 for (i = 0; i < object->trace_len; i++) {
87486 void *ptr = (void *)object->trace[i];
87487 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
87488 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
87489 }
87490 }
87491
87492 @@ -1851,7 +1851,7 @@ static int __init kmemleak_late_init(void)
87493 return -ENOMEM;
87494 }
87495
87496 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
87497 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
87498 &kmemleak_fops);
87499 if (!dentry)
87500 pr_warning("Failed to create the debugfs kmemleak file\n");
87501 diff --git a/mm/maccess.c b/mm/maccess.c
87502 index d53adf9..03a24bf 100644
87503 --- a/mm/maccess.c
87504 +++ b/mm/maccess.c
87505 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
87506 set_fs(KERNEL_DS);
87507 pagefault_disable();
87508 ret = __copy_from_user_inatomic(dst,
87509 - (__force const void __user *)src, size);
87510 + (const void __force_user *)src, size);
87511 pagefault_enable();
87512 set_fs(old_fs);
87513
87514 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
87515
87516 set_fs(KERNEL_DS);
87517 pagefault_disable();
87518 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
87519 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
87520 pagefault_enable();
87521 set_fs(old_fs);
87522
87523 diff --git a/mm/madvise.c b/mm/madvise.c
87524 index 7055883..aafb1ed 100644
87525 --- a/mm/madvise.c
87526 +++ b/mm/madvise.c
87527 @@ -51,6 +51,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
87528 pgoff_t pgoff;
87529 unsigned long new_flags = vma->vm_flags;
87530
87531 +#ifdef CONFIG_PAX_SEGMEXEC
87532 + struct vm_area_struct *vma_m;
87533 +#endif
87534 +
87535 switch (behavior) {
87536 case MADV_NORMAL:
87537 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
87538 @@ -126,6 +130,13 @@ success:
87539 /*
87540 * vm_flags is protected by the mmap_sem held in write mode.
87541 */
87542 +
87543 +#ifdef CONFIG_PAX_SEGMEXEC
87544 + vma_m = pax_find_mirror_vma(vma);
87545 + if (vma_m)
87546 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
87547 +#endif
87548 +
87549 vma->vm_flags = new_flags;
87550
87551 out:
87552 @@ -274,6 +285,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
87553 struct vm_area_struct ** prev,
87554 unsigned long start, unsigned long end)
87555 {
87556 +
87557 +#ifdef CONFIG_PAX_SEGMEXEC
87558 + struct vm_area_struct *vma_m;
87559 +#endif
87560 +
87561 *prev = vma;
87562 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
87563 return -EINVAL;
87564 @@ -286,6 +302,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
87565 zap_page_range(vma, start, end - start, &details);
87566 } else
87567 zap_page_range(vma, start, end - start, NULL);
87568 +
87569 +#ifdef CONFIG_PAX_SEGMEXEC
87570 + vma_m = pax_find_mirror_vma(vma);
87571 + if (vma_m) {
87572 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
87573 + struct zap_details details = {
87574 + .nonlinear_vma = vma_m,
87575 + .last_index = ULONG_MAX,
87576 + };
87577 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
87578 + } else
87579 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
87580 + }
87581 +#endif
87582 +
87583 return 0;
87584 }
87585
87586 @@ -485,6 +516,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
87587 if (end < start)
87588 return error;
87589
87590 +#ifdef CONFIG_PAX_SEGMEXEC
87591 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
87592 + if (end > SEGMEXEC_TASK_SIZE)
87593 + return error;
87594 + } else
87595 +#endif
87596 +
87597 + if (end > TASK_SIZE)
87598 + return error;
87599 +
87600 error = 0;
87601 if (end == start)
87602 return error;
87603 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
87604 index ceb0c7f..b2b8e94 100644
87605 --- a/mm/memory-failure.c
87606 +++ b/mm/memory-failure.c
87607 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
87608
87609 int sysctl_memory_failure_recovery __read_mostly = 1;
87610
87611 -atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
87612 +atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
87613
87614 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
87615
87616 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
87617 pfn, t->comm, t->pid);
87618 si.si_signo = SIGBUS;
87619 si.si_errno = 0;
87620 - si.si_addr = (void *)addr;
87621 + si.si_addr = (void __user *)addr;
87622 #ifdef __ARCH_SI_TRAPNO
87623 si.si_trapno = trapno;
87624 #endif
87625 @@ -760,7 +760,7 @@ static struct page_state {
87626 unsigned long res;
87627 char *msg;
87628 int (*action)(struct page *p, unsigned long pfn);
87629 -} error_states[] = {
87630 +} __do_const error_states[] = {
87631 { reserved, reserved, "reserved kernel", me_kernel },
87632 /*
87633 * free pages are specially detected outside this table:
87634 @@ -1051,7 +1051,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
87635 nr_pages = 1 << compound_order(hpage);
87636 else /* normal page or thp */
87637 nr_pages = 1;
87638 - atomic_long_add(nr_pages, &num_poisoned_pages);
87639 + atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
87640
87641 /*
87642 * We need/can do nothing about count=0 pages.
87643 @@ -1081,7 +1081,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
87644 if (!PageHWPoison(hpage)
87645 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
87646 || (p != hpage && TestSetPageHWPoison(hpage))) {
87647 - atomic_long_sub(nr_pages, &num_poisoned_pages);
87648 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
87649 return 0;
87650 }
87651 set_page_hwpoison_huge_page(hpage);
87652 @@ -1148,7 +1148,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
87653 }
87654 if (hwpoison_filter(p)) {
87655 if (TestClearPageHWPoison(p))
87656 - atomic_long_sub(nr_pages, &num_poisoned_pages);
87657 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
87658 unlock_page(hpage);
87659 put_page(hpage);
87660 return 0;
87661 @@ -1350,7 +1350,7 @@ int unpoison_memory(unsigned long pfn)
87662 return 0;
87663 }
87664 if (TestClearPageHWPoison(p))
87665 - atomic_long_sub(nr_pages, &num_poisoned_pages);
87666 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
87667 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
87668 return 0;
87669 }
87670 @@ -1364,7 +1364,7 @@ int unpoison_memory(unsigned long pfn)
87671 */
87672 if (TestClearPageHWPoison(page)) {
87673 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
87674 - atomic_long_sub(nr_pages, &num_poisoned_pages);
87675 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
87676 freeit = 1;
87677 if (PageHuge(page))
87678 clear_page_hwpoison_huge_page(page);
87679 @@ -1491,7 +1491,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
87680 } else {
87681 set_page_hwpoison_huge_page(hpage);
87682 dequeue_hwpoisoned_huge_page(hpage);
87683 - atomic_long_add(1 << compound_trans_order(hpage),
87684 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
87685 &num_poisoned_pages);
87686 }
87687 /* keep elevated page count for bad page */
87688 @@ -1552,11 +1552,11 @@ int soft_offline_page(struct page *page, int flags)
87689 if (PageHuge(page)) {
87690 set_page_hwpoison_huge_page(hpage);
87691 dequeue_hwpoisoned_huge_page(hpage);
87692 - atomic_long_add(1 << compound_trans_order(hpage),
87693 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
87694 &num_poisoned_pages);
87695 } else {
87696 SetPageHWPoison(page);
87697 - atomic_long_inc(&num_poisoned_pages);
87698 + atomic_long_inc_unchecked(&num_poisoned_pages);
87699 }
87700 }
87701 /* keep elevated page count for bad page */
87702 @@ -1596,7 +1596,7 @@ static int __soft_offline_page(struct page *page, int flags)
87703 put_page(page);
87704 pr_info("soft_offline: %#lx: invalidated\n", pfn);
87705 SetPageHWPoison(page);
87706 - atomic_long_inc(&num_poisoned_pages);
87707 + atomic_long_inc_unchecked(&num_poisoned_pages);
87708 return 0;
87709 }
87710
87711 @@ -1626,7 +1626,7 @@ static int __soft_offline_page(struct page *page, int flags)
87712 ret = -EIO;
87713 } else {
87714 SetPageHWPoison(page);
87715 - atomic_long_inc(&num_poisoned_pages);
87716 + atomic_long_inc_unchecked(&num_poisoned_pages);
87717 }
87718 } else {
87719 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
87720 diff --git a/mm/memory.c b/mm/memory.c
87721 index 5a35443..7c0340f 100644
87722 --- a/mm/memory.c
87723 +++ b/mm/memory.c
87724 @@ -428,6 +428,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
87725 free_pte_range(tlb, pmd, addr);
87726 } while (pmd++, addr = next, addr != end);
87727
87728 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
87729 start &= PUD_MASK;
87730 if (start < floor)
87731 return;
87732 @@ -442,6 +443,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
87733 pmd = pmd_offset(pud, start);
87734 pud_clear(pud);
87735 pmd_free_tlb(tlb, pmd, start);
87736 +#endif
87737 +
87738 }
87739
87740 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
87741 @@ -461,6 +464,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
87742 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
87743 } while (pud++, addr = next, addr != end);
87744
87745 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
87746 start &= PGDIR_MASK;
87747 if (start < floor)
87748 return;
87749 @@ -475,6 +479,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
87750 pud = pud_offset(pgd, start);
87751 pgd_clear(pgd);
87752 pud_free_tlb(tlb, pud, start);
87753 +#endif
87754 +
87755 }
87756
87757 /*
87758 @@ -1644,12 +1650,6 @@ no_page_table:
87759 return page;
87760 }
87761
87762 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
87763 -{
87764 - return stack_guard_page_start(vma, addr) ||
87765 - stack_guard_page_end(vma, addr+PAGE_SIZE);
87766 -}
87767 -
87768 /**
87769 * __get_user_pages() - pin user pages in memory
87770 * @tsk: task_struct of target task
87771 @@ -1736,10 +1736,10 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
87772
87773 i = 0;
87774
87775 - do {
87776 + while (nr_pages) {
87777 struct vm_area_struct *vma;
87778
87779 - vma = find_extend_vma(mm, start);
87780 + vma = find_vma(mm, start);
87781 if (!vma && in_gate_area(mm, start)) {
87782 unsigned long pg = start & PAGE_MASK;
87783 pgd_t *pgd;
87784 @@ -1788,7 +1788,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
87785 goto next_page;
87786 }
87787
87788 - if (!vma ||
87789 + if (!vma || start < vma->vm_start ||
87790 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
87791 !(vm_flags & vma->vm_flags))
87792 return i ? : -EFAULT;
87793 @@ -1817,11 +1817,6 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
87794 int ret;
87795 unsigned int fault_flags = 0;
87796
87797 - /* For mlock, just skip the stack guard page. */
87798 - if (foll_flags & FOLL_MLOCK) {
87799 - if (stack_guard_page(vma, start))
87800 - goto next_page;
87801 - }
87802 if (foll_flags & FOLL_WRITE)
87803 fault_flags |= FAULT_FLAG_WRITE;
87804 if (nonblocking)
87805 @@ -1901,7 +1896,7 @@ next_page:
87806 start += page_increm * PAGE_SIZE;
87807 nr_pages -= page_increm;
87808 } while (nr_pages && start < vma->vm_end);
87809 - } while (nr_pages);
87810 + }
87811 return i;
87812 }
87813 EXPORT_SYMBOL(__get_user_pages);
87814 @@ -2108,6 +2103,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
87815 page_add_file_rmap(page);
87816 set_pte_at(mm, addr, pte, mk_pte(page, prot));
87817
87818 +#ifdef CONFIG_PAX_SEGMEXEC
87819 + pax_mirror_file_pte(vma, addr, page, ptl);
87820 +#endif
87821 +
87822 retval = 0;
87823 pte_unmap_unlock(pte, ptl);
87824 return retval;
87825 @@ -2152,9 +2151,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
87826 if (!page_count(page))
87827 return -EINVAL;
87828 if (!(vma->vm_flags & VM_MIXEDMAP)) {
87829 +
87830 +#ifdef CONFIG_PAX_SEGMEXEC
87831 + struct vm_area_struct *vma_m;
87832 +#endif
87833 +
87834 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
87835 BUG_ON(vma->vm_flags & VM_PFNMAP);
87836 vma->vm_flags |= VM_MIXEDMAP;
87837 +
87838 +#ifdef CONFIG_PAX_SEGMEXEC
87839 + vma_m = pax_find_mirror_vma(vma);
87840 + if (vma_m)
87841 + vma_m->vm_flags |= VM_MIXEDMAP;
87842 +#endif
87843 +
87844 }
87845 return insert_page(vma, addr, page, vma->vm_page_prot);
87846 }
87847 @@ -2237,6 +2248,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
87848 unsigned long pfn)
87849 {
87850 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
87851 + BUG_ON(vma->vm_mirror);
87852
87853 if (addr < vma->vm_start || addr >= vma->vm_end)
87854 return -EFAULT;
87855 @@ -2484,7 +2496,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
87856
87857 BUG_ON(pud_huge(*pud));
87858
87859 - pmd = pmd_alloc(mm, pud, addr);
87860 + pmd = (mm == &init_mm) ?
87861 + pmd_alloc_kernel(mm, pud, addr) :
87862 + pmd_alloc(mm, pud, addr);
87863 if (!pmd)
87864 return -ENOMEM;
87865 do {
87866 @@ -2504,7 +2518,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
87867 unsigned long next;
87868 int err;
87869
87870 - pud = pud_alloc(mm, pgd, addr);
87871 + pud = (mm == &init_mm) ?
87872 + pud_alloc_kernel(mm, pgd, addr) :
87873 + pud_alloc(mm, pgd, addr);
87874 if (!pud)
87875 return -ENOMEM;
87876 do {
87877 @@ -2592,6 +2608,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
87878 copy_user_highpage(dst, src, va, vma);
87879 }
87880
87881 +#ifdef CONFIG_PAX_SEGMEXEC
87882 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
87883 +{
87884 + struct mm_struct *mm = vma->vm_mm;
87885 + spinlock_t *ptl;
87886 + pte_t *pte, entry;
87887 +
87888 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
87889 + entry = *pte;
87890 + if (!pte_present(entry)) {
87891 + if (!pte_none(entry)) {
87892 + BUG_ON(pte_file(entry));
87893 + free_swap_and_cache(pte_to_swp_entry(entry));
87894 + pte_clear_not_present_full(mm, address, pte, 0);
87895 + }
87896 + } else {
87897 + struct page *page;
87898 +
87899 + flush_cache_page(vma, address, pte_pfn(entry));
87900 + entry = ptep_clear_flush(vma, address, pte);
87901 + BUG_ON(pte_dirty(entry));
87902 + page = vm_normal_page(vma, address, entry);
87903 + if (page) {
87904 + update_hiwater_rss(mm);
87905 + if (PageAnon(page))
87906 + dec_mm_counter_fast(mm, MM_ANONPAGES);
87907 + else
87908 + dec_mm_counter_fast(mm, MM_FILEPAGES);
87909 + page_remove_rmap(page);
87910 + page_cache_release(page);
87911 + }
87912 + }
87913 + pte_unmap_unlock(pte, ptl);
87914 +}
87915 +
87916 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
87917 + *
87918 + * the ptl of the lower mapped page is held on entry and is not released on exit
87919 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
87920 + */
87921 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
87922 +{
87923 + struct mm_struct *mm = vma->vm_mm;
87924 + unsigned long address_m;
87925 + spinlock_t *ptl_m;
87926 + struct vm_area_struct *vma_m;
87927 + pmd_t *pmd_m;
87928 + pte_t *pte_m, entry_m;
87929 +
87930 + BUG_ON(!page_m || !PageAnon(page_m));
87931 +
87932 + vma_m = pax_find_mirror_vma(vma);
87933 + if (!vma_m)
87934 + return;
87935 +
87936 + BUG_ON(!PageLocked(page_m));
87937 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
87938 + address_m = address + SEGMEXEC_TASK_SIZE;
87939 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
87940 + pte_m = pte_offset_map(pmd_m, address_m);
87941 + ptl_m = pte_lockptr(mm, pmd_m);
87942 + if (ptl != ptl_m) {
87943 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
87944 + if (!pte_none(*pte_m))
87945 + goto out;
87946 + }
87947 +
87948 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
87949 + page_cache_get(page_m);
87950 + page_add_anon_rmap(page_m, vma_m, address_m);
87951 + inc_mm_counter_fast(mm, MM_ANONPAGES);
87952 + set_pte_at(mm, address_m, pte_m, entry_m);
87953 + update_mmu_cache(vma_m, address_m, pte_m);
87954 +out:
87955 + if (ptl != ptl_m)
87956 + spin_unlock(ptl_m);
87957 + pte_unmap(pte_m);
87958 + unlock_page(page_m);
87959 +}
87960 +
87961 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
87962 +{
87963 + struct mm_struct *mm = vma->vm_mm;
87964 + unsigned long address_m;
87965 + spinlock_t *ptl_m;
87966 + struct vm_area_struct *vma_m;
87967 + pmd_t *pmd_m;
87968 + pte_t *pte_m, entry_m;
87969 +
87970 + BUG_ON(!page_m || PageAnon(page_m));
87971 +
87972 + vma_m = pax_find_mirror_vma(vma);
87973 + if (!vma_m)
87974 + return;
87975 +
87976 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
87977 + address_m = address + SEGMEXEC_TASK_SIZE;
87978 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
87979 + pte_m = pte_offset_map(pmd_m, address_m);
87980 + ptl_m = pte_lockptr(mm, pmd_m);
87981 + if (ptl != ptl_m) {
87982 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
87983 + if (!pte_none(*pte_m))
87984 + goto out;
87985 + }
87986 +
87987 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
87988 + page_cache_get(page_m);
87989 + page_add_file_rmap(page_m);
87990 + inc_mm_counter_fast(mm, MM_FILEPAGES);
87991 + set_pte_at(mm, address_m, pte_m, entry_m);
87992 + update_mmu_cache(vma_m, address_m, pte_m);
87993 +out:
87994 + if (ptl != ptl_m)
87995 + spin_unlock(ptl_m);
87996 + pte_unmap(pte_m);
87997 +}
87998 +
87999 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
88000 +{
88001 + struct mm_struct *mm = vma->vm_mm;
88002 + unsigned long address_m;
88003 + spinlock_t *ptl_m;
88004 + struct vm_area_struct *vma_m;
88005 + pmd_t *pmd_m;
88006 + pte_t *pte_m, entry_m;
88007 +
88008 + vma_m = pax_find_mirror_vma(vma);
88009 + if (!vma_m)
88010 + return;
88011 +
88012 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
88013 + address_m = address + SEGMEXEC_TASK_SIZE;
88014 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
88015 + pte_m = pte_offset_map(pmd_m, address_m);
88016 + ptl_m = pte_lockptr(mm, pmd_m);
88017 + if (ptl != ptl_m) {
88018 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
88019 + if (!pte_none(*pte_m))
88020 + goto out;
88021 + }
88022 +
88023 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
88024 + set_pte_at(mm, address_m, pte_m, entry_m);
88025 +out:
88026 + if (ptl != ptl_m)
88027 + spin_unlock(ptl_m);
88028 + pte_unmap(pte_m);
88029 +}
88030 +
88031 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
88032 +{
88033 + struct page *page_m;
88034 + pte_t entry;
88035 +
88036 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
88037 + goto out;
88038 +
88039 + entry = *pte;
88040 + page_m = vm_normal_page(vma, address, entry);
88041 + if (!page_m)
88042 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
88043 + else if (PageAnon(page_m)) {
88044 + if (pax_find_mirror_vma(vma)) {
88045 + pte_unmap_unlock(pte, ptl);
88046 + lock_page(page_m);
88047 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
88048 + if (pte_same(entry, *pte))
88049 + pax_mirror_anon_pte(vma, address, page_m, ptl);
88050 + else
88051 + unlock_page(page_m);
88052 + }
88053 + } else
88054 + pax_mirror_file_pte(vma, address, page_m, ptl);
88055 +
88056 +out:
88057 + pte_unmap_unlock(pte, ptl);
88058 +}
88059 +#endif
88060 +
88061 /*
88062 * This routine handles present pages, when users try to write
88063 * to a shared page. It is done by copying the page to a new address
88064 @@ -2808,6 +3004,12 @@ gotten:
88065 */
88066 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
88067 if (likely(pte_same(*page_table, orig_pte))) {
88068 +
88069 +#ifdef CONFIG_PAX_SEGMEXEC
88070 + if (pax_find_mirror_vma(vma))
88071 + BUG_ON(!trylock_page(new_page));
88072 +#endif
88073 +
88074 if (old_page) {
88075 if (!PageAnon(old_page)) {
88076 dec_mm_counter_fast(mm, MM_FILEPAGES);
88077 @@ -2859,6 +3061,10 @@ gotten:
88078 page_remove_rmap(old_page);
88079 }
88080
88081 +#ifdef CONFIG_PAX_SEGMEXEC
88082 + pax_mirror_anon_pte(vma, address, new_page, ptl);
88083 +#endif
88084 +
88085 /* Free the old page.. */
88086 new_page = old_page;
88087 ret |= VM_FAULT_WRITE;
88088 @@ -3134,6 +3340,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
88089 swap_free(entry);
88090 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
88091 try_to_free_swap(page);
88092 +
88093 +#ifdef CONFIG_PAX_SEGMEXEC
88094 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
88095 +#endif
88096 +
88097 unlock_page(page);
88098 if (page != swapcache) {
88099 /*
88100 @@ -3157,6 +3368,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
88101
88102 /* No need to invalidate - it was non-present before */
88103 update_mmu_cache(vma, address, page_table);
88104 +
88105 +#ifdef CONFIG_PAX_SEGMEXEC
88106 + pax_mirror_anon_pte(vma, address, page, ptl);
88107 +#endif
88108 +
88109 unlock:
88110 pte_unmap_unlock(page_table, ptl);
88111 out:
88112 @@ -3176,40 +3392,6 @@ out_release:
88113 }
88114
88115 /*
88116 - * This is like a special single-page "expand_{down|up}wards()",
88117 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
88118 - * doesn't hit another vma.
88119 - */
88120 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
88121 -{
88122 - address &= PAGE_MASK;
88123 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
88124 - struct vm_area_struct *prev = vma->vm_prev;
88125 -
88126 - /*
88127 - * Is there a mapping abutting this one below?
88128 - *
88129 - * That's only ok if it's the same stack mapping
88130 - * that has gotten split..
88131 - */
88132 - if (prev && prev->vm_end == address)
88133 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
88134 -
88135 - expand_downwards(vma, address - PAGE_SIZE);
88136 - }
88137 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
88138 - struct vm_area_struct *next = vma->vm_next;
88139 -
88140 - /* As VM_GROWSDOWN but s/below/above/ */
88141 - if (next && next->vm_start == address + PAGE_SIZE)
88142 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
88143 -
88144 - expand_upwards(vma, address + PAGE_SIZE);
88145 - }
88146 - return 0;
88147 -}
88148 -
88149 -/*
88150 * We enter with non-exclusive mmap_sem (to exclude vma changes,
88151 * but allow concurrent faults), and pte mapped but not yet locked.
88152 * We return with mmap_sem still held, but pte unmapped and unlocked.
88153 @@ -3218,27 +3400,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
88154 unsigned long address, pte_t *page_table, pmd_t *pmd,
88155 unsigned int flags)
88156 {
88157 - struct page *page;
88158 + struct page *page = NULL;
88159 spinlock_t *ptl;
88160 pte_t entry;
88161
88162 - pte_unmap(page_table);
88163 -
88164 - /* Check if we need to add a guard page to the stack */
88165 - if (check_stack_guard_page(vma, address) < 0)
88166 - return VM_FAULT_SIGBUS;
88167 -
88168 - /* Use the zero-page for reads */
88169 if (!(flags & FAULT_FLAG_WRITE)) {
88170 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
88171 vma->vm_page_prot));
88172 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
88173 + ptl = pte_lockptr(mm, pmd);
88174 + spin_lock(ptl);
88175 if (!pte_none(*page_table))
88176 goto unlock;
88177 goto setpte;
88178 }
88179
88180 /* Allocate our own private page. */
88181 + pte_unmap(page_table);
88182 +
88183 if (unlikely(anon_vma_prepare(vma)))
88184 goto oom;
88185 page = alloc_zeroed_user_highpage_movable(vma, address);
88186 @@ -3262,6 +3440,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
88187 if (!pte_none(*page_table))
88188 goto release;
88189
88190 +#ifdef CONFIG_PAX_SEGMEXEC
88191 + if (pax_find_mirror_vma(vma))
88192 + BUG_ON(!trylock_page(page));
88193 +#endif
88194 +
88195 inc_mm_counter_fast(mm, MM_ANONPAGES);
88196 page_add_new_anon_rmap(page, vma, address);
88197 setpte:
88198 @@ -3269,6 +3452,12 @@ setpte:
88199
88200 /* No need to invalidate - it was non-present before */
88201 update_mmu_cache(vma, address, page_table);
88202 +
88203 +#ifdef CONFIG_PAX_SEGMEXEC
88204 + if (page)
88205 + pax_mirror_anon_pte(vma, address, page, ptl);
88206 +#endif
88207 +
88208 unlock:
88209 pte_unmap_unlock(page_table, ptl);
88210 return 0;
88211 @@ -3412,6 +3601,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
88212 */
88213 /* Only go through if we didn't race with anybody else... */
88214 if (likely(pte_same(*page_table, orig_pte))) {
88215 +
88216 +#ifdef CONFIG_PAX_SEGMEXEC
88217 + if (anon && pax_find_mirror_vma(vma))
88218 + BUG_ON(!trylock_page(page));
88219 +#endif
88220 +
88221 flush_icache_page(vma, page);
88222 entry = mk_pte(page, vma->vm_page_prot);
88223 if (flags & FAULT_FLAG_WRITE)
88224 @@ -3431,6 +3626,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
88225
88226 /* no need to invalidate: a not-present page won't be cached */
88227 update_mmu_cache(vma, address, page_table);
88228 +
88229 +#ifdef CONFIG_PAX_SEGMEXEC
88230 + if (anon)
88231 + pax_mirror_anon_pte(vma, address, page, ptl);
88232 + else
88233 + pax_mirror_file_pte(vma, address, page, ptl);
88234 +#endif
88235 +
88236 } else {
88237 if (cow_page)
88238 mem_cgroup_uncharge_page(cow_page);
88239 @@ -3752,6 +3955,12 @@ int handle_pte_fault(struct mm_struct *mm,
88240 if (flags & FAULT_FLAG_WRITE)
88241 flush_tlb_fix_spurious_fault(vma, address);
88242 }
88243 +
88244 +#ifdef CONFIG_PAX_SEGMEXEC
88245 + pax_mirror_pte(vma, address, pte, pmd, ptl);
88246 + return 0;
88247 +#endif
88248 +
88249 unlock:
88250 pte_unmap_unlock(pte, ptl);
88251 return 0;
88252 @@ -3768,6 +3977,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
88253 pmd_t *pmd;
88254 pte_t *pte;
88255
88256 +#ifdef CONFIG_PAX_SEGMEXEC
88257 + struct vm_area_struct *vma_m;
88258 +#endif
88259 +
88260 __set_current_state(TASK_RUNNING);
88261
88262 count_vm_event(PGFAULT);
88263 @@ -3779,6 +3992,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
88264 if (unlikely(is_vm_hugetlb_page(vma)))
88265 return hugetlb_fault(mm, vma, address, flags);
88266
88267 +#ifdef CONFIG_PAX_SEGMEXEC
88268 + vma_m = pax_find_mirror_vma(vma);
88269 + if (vma_m) {
88270 + unsigned long address_m;
88271 + pgd_t *pgd_m;
88272 + pud_t *pud_m;
88273 + pmd_t *pmd_m;
88274 +
88275 + if (vma->vm_start > vma_m->vm_start) {
88276 + address_m = address;
88277 + address -= SEGMEXEC_TASK_SIZE;
88278 + vma = vma_m;
88279 + } else
88280 + address_m = address + SEGMEXEC_TASK_SIZE;
88281 +
88282 + pgd_m = pgd_offset(mm, address_m);
88283 + pud_m = pud_alloc(mm, pgd_m, address_m);
88284 + if (!pud_m)
88285 + return VM_FAULT_OOM;
88286 + pmd_m = pmd_alloc(mm, pud_m, address_m);
88287 + if (!pmd_m)
88288 + return VM_FAULT_OOM;
88289 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
88290 + return VM_FAULT_OOM;
88291 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
88292 + }
88293 +#endif
88294 +
88295 retry:
88296 pgd = pgd_offset(mm, address);
88297 pud = pud_alloc(mm, pgd, address);
88298 @@ -3877,6 +4118,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
88299 spin_unlock(&mm->page_table_lock);
88300 return 0;
88301 }
88302 +
88303 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
88304 +{
88305 + pud_t *new = pud_alloc_one(mm, address);
88306 + if (!new)
88307 + return -ENOMEM;
88308 +
88309 + smp_wmb(); /* See comment in __pte_alloc */
88310 +
88311 + spin_lock(&mm->page_table_lock);
88312 + if (pgd_present(*pgd)) /* Another has populated it */
88313 + pud_free(mm, new);
88314 + else
88315 + pgd_populate_kernel(mm, pgd, new);
88316 + spin_unlock(&mm->page_table_lock);
88317 + return 0;
88318 +}
88319 #endif /* __PAGETABLE_PUD_FOLDED */
88320
88321 #ifndef __PAGETABLE_PMD_FOLDED
88322 @@ -3907,6 +4165,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
88323 spin_unlock(&mm->page_table_lock);
88324 return 0;
88325 }
88326 +
88327 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
88328 +{
88329 + pmd_t *new = pmd_alloc_one(mm, address);
88330 + if (!new)
88331 + return -ENOMEM;
88332 +
88333 + smp_wmb(); /* See comment in __pte_alloc */
88334 +
88335 + spin_lock(&mm->page_table_lock);
88336 +#ifndef __ARCH_HAS_4LEVEL_HACK
88337 + if (pud_present(*pud)) /* Another has populated it */
88338 + pmd_free(mm, new);
88339 + else
88340 + pud_populate_kernel(mm, pud, new);
88341 +#else
88342 + if (pgd_present(*pud)) /* Another has populated it */
88343 + pmd_free(mm, new);
88344 + else
88345 + pgd_populate_kernel(mm, pud, new);
88346 +#endif /* __ARCH_HAS_4LEVEL_HACK */
88347 + spin_unlock(&mm->page_table_lock);
88348 + return 0;
88349 +}
88350 #endif /* __PAGETABLE_PMD_FOLDED */
88351
88352 #if !defined(__HAVE_ARCH_GATE_AREA)
88353 @@ -3920,7 +4202,7 @@ static int __init gate_vma_init(void)
88354 gate_vma.vm_start = FIXADDR_USER_START;
88355 gate_vma.vm_end = FIXADDR_USER_END;
88356 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
88357 - gate_vma.vm_page_prot = __P101;
88358 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
88359
88360 return 0;
88361 }
88362 @@ -4054,8 +4336,8 @@ out:
88363 return ret;
88364 }
88365
88366 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
88367 - void *buf, int len, int write)
88368 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
88369 + void *buf, size_t len, int write)
88370 {
88371 resource_size_t phys_addr;
88372 unsigned long prot = 0;
88373 @@ -4080,8 +4362,8 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
88374 * Access another process' address space as given in mm. If non-NULL, use the
88375 * given task for page fault accounting.
88376 */
88377 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88378 - unsigned long addr, void *buf, int len, int write)
88379 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88380 + unsigned long addr, void *buf, size_t len, int write)
88381 {
88382 struct vm_area_struct *vma;
88383 void *old_buf = buf;
88384 @@ -4089,7 +4371,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88385 down_read(&mm->mmap_sem);
88386 /* ignore errors, just check how much was successfully transferred */
88387 while (len) {
88388 - int bytes, ret, offset;
88389 + ssize_t bytes, ret, offset;
88390 void *maddr;
88391 struct page *page = NULL;
88392
88393 @@ -4148,8 +4430,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88394 *
88395 * The caller must hold a reference on @mm.
88396 */
88397 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
88398 - void *buf, int len, int write)
88399 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
88400 + void *buf, size_t len, int write)
88401 {
88402 return __access_remote_vm(NULL, mm, addr, buf, len, write);
88403 }
88404 @@ -4159,11 +4441,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
88405 * Source/target buffer must be kernel space,
88406 * Do not walk the page table directly, use get_user_pages
88407 */
88408 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
88409 - void *buf, int len, int write)
88410 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
88411 + void *buf, size_t len, int write)
88412 {
88413 struct mm_struct *mm;
88414 - int ret;
88415 + ssize_t ret;
88416
88417 mm = get_task_mm(tsk);
88418 if (!mm)
88419 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
88420 index 4baf12e..5497066 100644
88421 --- a/mm/mempolicy.c
88422 +++ b/mm/mempolicy.c
88423 @@ -708,6 +708,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
88424 unsigned long vmstart;
88425 unsigned long vmend;
88426
88427 +#ifdef CONFIG_PAX_SEGMEXEC
88428 + struct vm_area_struct *vma_m;
88429 +#endif
88430 +
88431 vma = find_vma(mm, start);
88432 if (!vma || vma->vm_start > start)
88433 return -EFAULT;
88434 @@ -751,6 +755,16 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
88435 err = vma_replace_policy(vma, new_pol);
88436 if (err)
88437 goto out;
88438 +
88439 +#ifdef CONFIG_PAX_SEGMEXEC
88440 + vma_m = pax_find_mirror_vma(vma);
88441 + if (vma_m) {
88442 + err = vma_replace_policy(vma_m, new_pol);
88443 + if (err)
88444 + goto out;
88445 + }
88446 +#endif
88447 +
88448 }
88449
88450 out:
88451 @@ -1206,6 +1220,17 @@ static long do_mbind(unsigned long start, unsigned long len,
88452
88453 if (end < start)
88454 return -EINVAL;
88455 +
88456 +#ifdef CONFIG_PAX_SEGMEXEC
88457 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
88458 + if (end > SEGMEXEC_TASK_SIZE)
88459 + return -EINVAL;
88460 + } else
88461 +#endif
88462 +
88463 + if (end > TASK_SIZE)
88464 + return -EINVAL;
88465 +
88466 if (end == start)
88467 return 0;
88468
88469 @@ -1434,8 +1459,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
88470 */
88471 tcred = __task_cred(task);
88472 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
88473 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
88474 - !capable(CAP_SYS_NICE)) {
88475 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
88476 rcu_read_unlock();
88477 err = -EPERM;
88478 goto out_put;
88479 @@ -1466,6 +1490,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
88480 goto out;
88481 }
88482
88483 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
88484 + if (mm != current->mm &&
88485 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
88486 + mmput(mm);
88487 + err = -EPERM;
88488 + goto out;
88489 + }
88490 +#endif
88491 +
88492 err = do_migrate_pages(mm, old, new,
88493 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
88494
88495 diff --git a/mm/migrate.c b/mm/migrate.c
88496 index 6f0c244..6d1ae32 100644
88497 --- a/mm/migrate.c
88498 +++ b/mm/migrate.c
88499 @@ -1399,8 +1399,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
88500 */
88501 tcred = __task_cred(task);
88502 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
88503 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
88504 - !capable(CAP_SYS_NICE)) {
88505 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
88506 rcu_read_unlock();
88507 err = -EPERM;
88508 goto out;
88509 diff --git a/mm/mlock.c b/mm/mlock.c
88510 index 79b7cf7..9944291 100644
88511 --- a/mm/mlock.c
88512 +++ b/mm/mlock.c
88513 @@ -13,6 +13,7 @@
88514 #include <linux/pagemap.h>
88515 #include <linux/mempolicy.h>
88516 #include <linux/syscalls.h>
88517 +#include <linux/security.h>
88518 #include <linux/sched.h>
88519 #include <linux/export.h>
88520 #include <linux/rmap.h>
88521 @@ -334,7 +335,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
88522 {
88523 unsigned long nstart, end, tmp;
88524 struct vm_area_struct * vma, * prev;
88525 - int error;
88526 + int error = 0;
88527
88528 VM_BUG_ON(start & ~PAGE_MASK);
88529 VM_BUG_ON(len != PAGE_ALIGN(len));
88530 @@ -343,6 +344,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
88531 return -EINVAL;
88532 if (end == start)
88533 return 0;
88534 + if (end > TASK_SIZE)
88535 + return -EINVAL;
88536 +
88537 vma = find_vma(current->mm, start);
88538 if (!vma || vma->vm_start > start)
88539 return -ENOMEM;
88540 @@ -354,6 +358,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
88541 for (nstart = start ; ; ) {
88542 vm_flags_t newflags;
88543
88544 +#ifdef CONFIG_PAX_SEGMEXEC
88545 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
88546 + break;
88547 +#endif
88548 +
88549 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
88550
88551 newflags = vma->vm_flags & ~VM_LOCKED;
88552 @@ -466,6 +475,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
88553 lock_limit >>= PAGE_SHIFT;
88554
88555 /* check against resource limits */
88556 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
88557 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
88558 error = do_mlock(start, len, 1);
88559 up_write(&current->mm->mmap_sem);
88560 @@ -500,6 +510,11 @@ static int do_mlockall(int flags)
88561 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
88562 vm_flags_t newflags;
88563
88564 +#ifdef CONFIG_PAX_SEGMEXEC
88565 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
88566 + break;
88567 +#endif
88568 +
88569 newflags = vma->vm_flags & ~VM_LOCKED;
88570 if (flags & MCL_CURRENT)
88571 newflags |= VM_LOCKED;
88572 @@ -532,6 +547,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
88573 lock_limit >>= PAGE_SHIFT;
88574
88575 ret = -ENOMEM;
88576 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
88577 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
88578 capable(CAP_IPC_LOCK))
88579 ret = do_mlockall(flags);
88580 diff --git a/mm/mmap.c b/mm/mmap.c
88581 index 8d25fdc..bfb7626 100644
88582 --- a/mm/mmap.c
88583 +++ b/mm/mmap.c
88584 @@ -36,6 +36,7 @@
88585 #include <linux/sched/sysctl.h>
88586 #include <linux/notifier.h>
88587 #include <linux/memory.h>
88588 +#include <linux/random.h>
88589
88590 #include <asm/uaccess.h>
88591 #include <asm/cacheflush.h>
88592 @@ -52,6 +53,16 @@
88593 #define arch_rebalance_pgtables(addr, len) (addr)
88594 #endif
88595
88596 +static inline void verify_mm_writelocked(struct mm_struct *mm)
88597 +{
88598 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
88599 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
88600 + up_read(&mm->mmap_sem);
88601 + BUG();
88602 + }
88603 +#endif
88604 +}
88605 +
88606 static void unmap_region(struct mm_struct *mm,
88607 struct vm_area_struct *vma, struct vm_area_struct *prev,
88608 unsigned long start, unsigned long end);
88609 @@ -71,16 +82,25 @@ static void unmap_region(struct mm_struct *mm,
88610 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
88611 *
88612 */
88613 -pgprot_t protection_map[16] = {
88614 +pgprot_t protection_map[16] __read_only = {
88615 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
88616 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
88617 };
88618
88619 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
88620 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
88621 {
88622 - return __pgprot(pgprot_val(protection_map[vm_flags &
88623 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
88624 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
88625 pgprot_val(arch_vm_get_page_prot(vm_flags)));
88626 +
88627 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
88628 + if (!(__supported_pte_mask & _PAGE_NX) &&
88629 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
88630 + (vm_flags & (VM_READ | VM_WRITE)))
88631 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
88632 +#endif
88633 +
88634 + return prot;
88635 }
88636 EXPORT_SYMBOL(vm_get_page_prot);
88637
88638 @@ -89,6 +109,7 @@ int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
88639 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
88640 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
88641 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
88642 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
88643 /*
88644 * Make sure vm_committed_as in one cacheline and not cacheline shared with
88645 * other variables. It can be updated by several CPUs frequently.
88646 @@ -247,6 +268,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
88647 struct vm_area_struct *next = vma->vm_next;
88648
88649 might_sleep();
88650 + BUG_ON(vma->vm_mirror);
88651 if (vma->vm_ops && vma->vm_ops->close)
88652 vma->vm_ops->close(vma);
88653 if (vma->vm_file)
88654 @@ -291,6 +313,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
88655 * not page aligned -Ram Gupta
88656 */
88657 rlim = rlimit(RLIMIT_DATA);
88658 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
88659 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
88660 (mm->end_data - mm->start_data) > rlim)
88661 goto out;
88662 @@ -933,6 +956,12 @@ static int
88663 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
88664 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
88665 {
88666 +
88667 +#ifdef CONFIG_PAX_SEGMEXEC
88668 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
88669 + return 0;
88670 +#endif
88671 +
88672 if (is_mergeable_vma(vma, file, vm_flags) &&
88673 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
88674 if (vma->vm_pgoff == vm_pgoff)
88675 @@ -952,6 +981,12 @@ static int
88676 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
88677 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
88678 {
88679 +
88680 +#ifdef CONFIG_PAX_SEGMEXEC
88681 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
88682 + return 0;
88683 +#endif
88684 +
88685 if (is_mergeable_vma(vma, file, vm_flags) &&
88686 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
88687 pgoff_t vm_pglen;
88688 @@ -994,13 +1029,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
88689 struct vm_area_struct *vma_merge(struct mm_struct *mm,
88690 struct vm_area_struct *prev, unsigned long addr,
88691 unsigned long end, unsigned long vm_flags,
88692 - struct anon_vma *anon_vma, struct file *file,
88693 + struct anon_vma *anon_vma, struct file *file,
88694 pgoff_t pgoff, struct mempolicy *policy)
88695 {
88696 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
88697 struct vm_area_struct *area, *next;
88698 int err;
88699
88700 +#ifdef CONFIG_PAX_SEGMEXEC
88701 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
88702 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
88703 +
88704 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
88705 +#endif
88706 +
88707 /*
88708 * We later require that vma->vm_flags == vm_flags,
88709 * so this tests vma->vm_flags & VM_SPECIAL, too.
88710 @@ -1016,6 +1058,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
88711 if (next && next->vm_end == end) /* cases 6, 7, 8 */
88712 next = next->vm_next;
88713
88714 +#ifdef CONFIG_PAX_SEGMEXEC
88715 + if (prev)
88716 + prev_m = pax_find_mirror_vma(prev);
88717 + if (area)
88718 + area_m = pax_find_mirror_vma(area);
88719 + if (next)
88720 + next_m = pax_find_mirror_vma(next);
88721 +#endif
88722 +
88723 /*
88724 * Can it merge with the predecessor?
88725 */
88726 @@ -1035,9 +1086,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
88727 /* cases 1, 6 */
88728 err = vma_adjust(prev, prev->vm_start,
88729 next->vm_end, prev->vm_pgoff, NULL);
88730 - } else /* cases 2, 5, 7 */
88731 +
88732 +#ifdef CONFIG_PAX_SEGMEXEC
88733 + if (!err && prev_m)
88734 + err = vma_adjust(prev_m, prev_m->vm_start,
88735 + next_m->vm_end, prev_m->vm_pgoff, NULL);
88736 +#endif
88737 +
88738 + } else { /* cases 2, 5, 7 */
88739 err = vma_adjust(prev, prev->vm_start,
88740 end, prev->vm_pgoff, NULL);
88741 +
88742 +#ifdef CONFIG_PAX_SEGMEXEC
88743 + if (!err && prev_m)
88744 + err = vma_adjust(prev_m, prev_m->vm_start,
88745 + end_m, prev_m->vm_pgoff, NULL);
88746 +#endif
88747 +
88748 + }
88749 if (err)
88750 return NULL;
88751 khugepaged_enter_vma_merge(prev);
88752 @@ -1051,12 +1117,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
88753 mpol_equal(policy, vma_policy(next)) &&
88754 can_vma_merge_before(next, vm_flags,
88755 anon_vma, file, pgoff+pglen)) {
88756 - if (prev && addr < prev->vm_end) /* case 4 */
88757 + if (prev && addr < prev->vm_end) { /* case 4 */
88758 err = vma_adjust(prev, prev->vm_start,
88759 addr, prev->vm_pgoff, NULL);
88760 - else /* cases 3, 8 */
88761 +
88762 +#ifdef CONFIG_PAX_SEGMEXEC
88763 + if (!err && prev_m)
88764 + err = vma_adjust(prev_m, prev_m->vm_start,
88765 + addr_m, prev_m->vm_pgoff, NULL);
88766 +#endif
88767 +
88768 + } else { /* cases 3, 8 */
88769 err = vma_adjust(area, addr, next->vm_end,
88770 next->vm_pgoff - pglen, NULL);
88771 +
88772 +#ifdef CONFIG_PAX_SEGMEXEC
88773 + if (!err && area_m)
88774 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
88775 + next_m->vm_pgoff - pglen, NULL);
88776 +#endif
88777 +
88778 + }
88779 if (err)
88780 return NULL;
88781 khugepaged_enter_vma_merge(area);
88782 @@ -1165,8 +1246,10 @@ none:
88783 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
88784 struct file *file, long pages)
88785 {
88786 - const unsigned long stack_flags
88787 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
88788 +
88789 +#ifdef CONFIG_PAX_RANDMMAP
88790 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
88791 +#endif
88792
88793 mm->total_vm += pages;
88794
88795 @@ -1174,7 +1257,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
88796 mm->shared_vm += pages;
88797 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
88798 mm->exec_vm += pages;
88799 - } else if (flags & stack_flags)
88800 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
88801 mm->stack_vm += pages;
88802 }
88803 #endif /* CONFIG_PROC_FS */
88804 @@ -1213,7 +1296,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
88805 * (the exception is when the underlying filesystem is noexec
88806 * mounted, in which case we dont add PROT_EXEC.)
88807 */
88808 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
88809 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
88810 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
88811 prot |= PROT_EXEC;
88812
88813 @@ -1239,7 +1322,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
88814 /* Obtain the address to map to. we verify (or select) it and ensure
88815 * that it represents a valid section of the address space.
88816 */
88817 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
88818 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
88819 if (addr & ~PAGE_MASK)
88820 return addr;
88821
88822 @@ -1250,6 +1333,43 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
88823 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
88824 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
88825
88826 +#ifdef CONFIG_PAX_MPROTECT
88827 + if (mm->pax_flags & MF_PAX_MPROTECT) {
88828 +
88829 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
88830 + if (file && !pgoff && (vm_flags & VM_EXEC) && mm->binfmt &&
88831 + mm->binfmt->handle_mmap)
88832 + mm->binfmt->handle_mmap(file);
88833 +#endif
88834 +
88835 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
88836 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
88837 + gr_log_rwxmmap(file);
88838 +
88839 +#ifdef CONFIG_PAX_EMUPLT
88840 + vm_flags &= ~VM_EXEC;
88841 +#else
88842 + return -EPERM;
88843 +#endif
88844 +
88845 + }
88846 +
88847 + if (!(vm_flags & VM_EXEC))
88848 + vm_flags &= ~VM_MAYEXEC;
88849 +#else
88850 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
88851 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
88852 +#endif
88853 + else
88854 + vm_flags &= ~VM_MAYWRITE;
88855 + }
88856 +#endif
88857 +
88858 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
88859 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
88860 + vm_flags &= ~VM_PAGEEXEC;
88861 +#endif
88862 +
88863 if (flags & MAP_LOCKED)
88864 if (!can_do_mlock())
88865 return -EPERM;
88866 @@ -1261,6 +1381,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
88867 locked += mm->locked_vm;
88868 lock_limit = rlimit(RLIMIT_MEMLOCK);
88869 lock_limit >>= PAGE_SHIFT;
88870 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
88871 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
88872 return -EAGAIN;
88873 }
88874 @@ -1341,6 +1462,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
88875 vm_flags |= VM_NORESERVE;
88876 }
88877
88878 + if (!gr_acl_handle_mmap(file, prot))
88879 + return -EACCES;
88880 +
88881 addr = mmap_region(file, addr, len, vm_flags, pgoff);
88882 if (!IS_ERR_VALUE(addr) &&
88883 ((vm_flags & VM_LOCKED) ||
88884 @@ -1432,7 +1556,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
88885 vm_flags_t vm_flags = vma->vm_flags;
88886
88887 /* If it was private or non-writable, the write bit is already clear */
88888 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
88889 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
88890 return 0;
88891
88892 /* The backer wishes to know when pages are first written to? */
88893 @@ -1480,7 +1604,22 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
88894 unsigned long charged = 0;
88895 struct inode *inode = file ? file_inode(file) : NULL;
88896
88897 +#ifdef CONFIG_PAX_SEGMEXEC
88898 + struct vm_area_struct *vma_m = NULL;
88899 +#endif
88900 +
88901 + /*
88902 + * mm->mmap_sem is required to protect against another thread
88903 + * changing the mappings in case we sleep.
88904 + */
88905 + verify_mm_writelocked(mm);
88906 +
88907 /* Check against address space limit. */
88908 +
88909 +#ifdef CONFIG_PAX_RANDMMAP
88910 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
88911 +#endif
88912 +
88913 if (!may_expand_vm(mm, len >> PAGE_SHIFT)) {
88914 unsigned long nr_pages;
88915
88916 @@ -1499,11 +1638,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
88917
88918 /* Clear old maps */
88919 error = -ENOMEM;
88920 -munmap_back:
88921 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
88922 if (do_munmap(mm, addr, len))
88923 return -ENOMEM;
88924 - goto munmap_back;
88925 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
88926 }
88927
88928 /*
88929 @@ -1534,6 +1672,16 @@ munmap_back:
88930 goto unacct_error;
88931 }
88932
88933 +#ifdef CONFIG_PAX_SEGMEXEC
88934 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
88935 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
88936 + if (!vma_m) {
88937 + error = -ENOMEM;
88938 + goto free_vma;
88939 + }
88940 + }
88941 +#endif
88942 +
88943 vma->vm_mm = mm;
88944 vma->vm_start = addr;
88945 vma->vm_end = addr + len;
88946 @@ -1558,6 +1706,13 @@ munmap_back:
88947 if (error)
88948 goto unmap_and_free_vma;
88949
88950 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
88951 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
88952 + vma->vm_flags |= VM_PAGEEXEC;
88953 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
88954 + }
88955 +#endif
88956 +
88957 /* Can addr have changed??
88958 *
88959 * Answer: Yes, several device drivers can do it in their
88960 @@ -1596,6 +1751,11 @@ munmap_back:
88961 vma_link(mm, vma, prev, rb_link, rb_parent);
88962 file = vma->vm_file;
88963
88964 +#ifdef CONFIG_PAX_SEGMEXEC
88965 + if (vma_m)
88966 + BUG_ON(pax_mirror_vma(vma_m, vma));
88967 +#endif
88968 +
88969 /* Once vma denies write, undo our temporary denial count */
88970 if (correct_wcount)
88971 atomic_inc(&inode->i_writecount);
88972 @@ -1603,6 +1763,7 @@ out:
88973 perf_event_mmap(vma);
88974
88975 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
88976 + track_exec_limit(mm, addr, addr + len, vm_flags);
88977 if (vm_flags & VM_LOCKED) {
88978 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
88979 vma == get_gate_vma(current->mm)))
88980 @@ -1626,6 +1787,12 @@ unmap_and_free_vma:
88981 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
88982 charged = 0;
88983 free_vma:
88984 +
88985 +#ifdef CONFIG_PAX_SEGMEXEC
88986 + if (vma_m)
88987 + kmem_cache_free(vm_area_cachep, vma_m);
88988 +#endif
88989 +
88990 kmem_cache_free(vm_area_cachep, vma);
88991 unacct_error:
88992 if (charged)
88993 @@ -1633,7 +1800,63 @@ unacct_error:
88994 return error;
88995 }
88996
88997 -unsigned long unmapped_area(struct vm_unmapped_area_info *info)
88998 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
88999 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
89000 +{
89001 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
89002 + return ((prandom_u32() & 0xFF) + 1) << PAGE_SHIFT;
89003 +
89004 + return 0;
89005 +}
89006 +#endif
89007 +
89008 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
89009 +{
89010 + if (!vma) {
89011 +#ifdef CONFIG_STACK_GROWSUP
89012 + if (addr > sysctl_heap_stack_gap)
89013 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
89014 + else
89015 + vma = find_vma(current->mm, 0);
89016 + if (vma && (vma->vm_flags & VM_GROWSUP))
89017 + return false;
89018 +#endif
89019 + return true;
89020 + }
89021 +
89022 + if (addr + len > vma->vm_start)
89023 + return false;
89024 +
89025 + if (vma->vm_flags & VM_GROWSDOWN)
89026 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
89027 +#ifdef CONFIG_STACK_GROWSUP
89028 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
89029 + return addr - vma->vm_prev->vm_end >= sysctl_heap_stack_gap;
89030 +#endif
89031 + else if (offset)
89032 + return offset <= vma->vm_start - addr - len;
89033 +
89034 + return true;
89035 +}
89036 +
89037 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
89038 +{
89039 + if (vma->vm_start < len)
89040 + return -ENOMEM;
89041 +
89042 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
89043 + if (offset <= vma->vm_start - len)
89044 + return vma->vm_start - len - offset;
89045 + else
89046 + return -ENOMEM;
89047 + }
89048 +
89049 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
89050 + return vma->vm_start - len - sysctl_heap_stack_gap;
89051 + return -ENOMEM;
89052 +}
89053 +
89054 +unsigned long unmapped_area(const struct vm_unmapped_area_info *info)
89055 {
89056 /*
89057 * We implement the search by looking for an rbtree node that
89058 @@ -1681,11 +1904,29 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
89059 }
89060 }
89061
89062 - gap_start = vma->vm_prev ? vma->vm_prev->vm_end : 0;
89063 + gap_start = vma->vm_prev ? vma->vm_prev->vm_end: 0;
89064 check_current:
89065 /* Check if current node has a suitable gap */
89066 if (gap_start > high_limit)
89067 return -ENOMEM;
89068 +
89069 + if (gap_end - gap_start > info->threadstack_offset)
89070 + gap_start += info->threadstack_offset;
89071 + else
89072 + gap_start = gap_end;
89073 +
89074 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
89075 + if (gap_end - gap_start > sysctl_heap_stack_gap)
89076 + gap_start += sysctl_heap_stack_gap;
89077 + else
89078 + gap_start = gap_end;
89079 + }
89080 + if (vma->vm_flags & VM_GROWSDOWN) {
89081 + if (gap_end - gap_start > sysctl_heap_stack_gap)
89082 + gap_end -= sysctl_heap_stack_gap;
89083 + else
89084 + gap_end = gap_start;
89085 + }
89086 if (gap_end >= low_limit && gap_end - gap_start >= length)
89087 goto found;
89088
89089 @@ -1735,7 +1976,7 @@ found:
89090 return gap_start;
89091 }
89092
89093 -unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
89094 +unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info)
89095 {
89096 struct mm_struct *mm = current->mm;
89097 struct vm_area_struct *vma;
89098 @@ -1789,6 +2030,24 @@ check_current:
89099 gap_end = vma->vm_start;
89100 if (gap_end < low_limit)
89101 return -ENOMEM;
89102 +
89103 + if (gap_end - gap_start > info->threadstack_offset)
89104 + gap_end -= info->threadstack_offset;
89105 + else
89106 + gap_end = gap_start;
89107 +
89108 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
89109 + if (gap_end - gap_start > sysctl_heap_stack_gap)
89110 + gap_start += sysctl_heap_stack_gap;
89111 + else
89112 + gap_start = gap_end;
89113 + }
89114 + if (vma->vm_flags & VM_GROWSDOWN) {
89115 + if (gap_end - gap_start > sysctl_heap_stack_gap)
89116 + gap_end -= sysctl_heap_stack_gap;
89117 + else
89118 + gap_end = gap_start;
89119 + }
89120 if (gap_start <= high_limit && gap_end - gap_start >= length)
89121 goto found;
89122
89123 @@ -1852,6 +2111,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
89124 struct mm_struct *mm = current->mm;
89125 struct vm_area_struct *vma;
89126 struct vm_unmapped_area_info info;
89127 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
89128
89129 if (len > TASK_SIZE)
89130 return -ENOMEM;
89131 @@ -1859,29 +2119,45 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
89132 if (flags & MAP_FIXED)
89133 return addr;
89134
89135 +#ifdef CONFIG_PAX_RANDMMAP
89136 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
89137 +#endif
89138 +
89139 if (addr) {
89140 addr = PAGE_ALIGN(addr);
89141 vma = find_vma(mm, addr);
89142 - if (TASK_SIZE - len >= addr &&
89143 - (!vma || addr + len <= vma->vm_start))
89144 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
89145 return addr;
89146 }
89147
89148 info.flags = 0;
89149 info.length = len;
89150 info.low_limit = TASK_UNMAPPED_BASE;
89151 +
89152 +#ifdef CONFIG_PAX_RANDMMAP
89153 + if (mm->pax_flags & MF_PAX_RANDMMAP)
89154 + info.low_limit += mm->delta_mmap;
89155 +#endif
89156 +
89157 info.high_limit = TASK_SIZE;
89158 info.align_mask = 0;
89159 + info.threadstack_offset = offset;
89160 return vm_unmapped_area(&info);
89161 }
89162 #endif
89163
89164 void arch_unmap_area(struct mm_struct *mm, unsigned long addr)
89165 {
89166 +
89167 +#ifdef CONFIG_PAX_SEGMEXEC
89168 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
89169 + return;
89170 +#endif
89171 +
89172 /*
89173 * Is this a new hole at the lowest possible address?
89174 */
89175 - if (addr >= TASK_UNMAPPED_BASE && addr < mm->free_area_cache)
89176 + if (addr >= mm->mmap_base && addr < mm->free_area_cache)
89177 mm->free_area_cache = addr;
89178 }
89179
89180 @@ -1899,6 +2175,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
89181 struct mm_struct *mm = current->mm;
89182 unsigned long addr = addr0;
89183 struct vm_unmapped_area_info info;
89184 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
89185
89186 /* requested length too big for entire address space */
89187 if (len > TASK_SIZE)
89188 @@ -1907,12 +2184,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
89189 if (flags & MAP_FIXED)
89190 return addr;
89191
89192 +#ifdef CONFIG_PAX_RANDMMAP
89193 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
89194 +#endif
89195 +
89196 /* requesting a specific address */
89197 if (addr) {
89198 addr = PAGE_ALIGN(addr);
89199 vma = find_vma(mm, addr);
89200 - if (TASK_SIZE - len >= addr &&
89201 - (!vma || addr + len <= vma->vm_start))
89202 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
89203 return addr;
89204 }
89205
89206 @@ -1921,6 +2201,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
89207 info.low_limit = PAGE_SIZE;
89208 info.high_limit = mm->mmap_base;
89209 info.align_mask = 0;
89210 + info.threadstack_offset = offset;
89211 addr = vm_unmapped_area(&info);
89212
89213 /*
89214 @@ -1933,6 +2214,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
89215 VM_BUG_ON(addr != -ENOMEM);
89216 info.flags = 0;
89217 info.low_limit = TASK_UNMAPPED_BASE;
89218 +
89219 +#ifdef CONFIG_PAX_RANDMMAP
89220 + if (mm->pax_flags & MF_PAX_RANDMMAP)
89221 + info.low_limit += mm->delta_mmap;
89222 +#endif
89223 +
89224 info.high_limit = TASK_SIZE;
89225 addr = vm_unmapped_area(&info);
89226 }
89227 @@ -1943,6 +2230,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
89228
89229 void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
89230 {
89231 +
89232 +#ifdef CONFIG_PAX_SEGMEXEC
89233 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
89234 + return;
89235 +#endif
89236 +
89237 /*
89238 * Is this a new hole at the highest possible address?
89239 */
89240 @@ -1950,8 +2243,10 @@ void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
89241 mm->free_area_cache = addr;
89242
89243 /* dont allow allocations above current base */
89244 - if (mm->free_area_cache > mm->mmap_base)
89245 + if (mm->free_area_cache > mm->mmap_base) {
89246 mm->free_area_cache = mm->mmap_base;
89247 + mm->cached_hole_size = ~0UL;
89248 + }
89249 }
89250
89251 unsigned long
89252 @@ -2047,6 +2342,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
89253 return vma;
89254 }
89255
89256 +#ifdef CONFIG_PAX_SEGMEXEC
89257 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
89258 +{
89259 + struct vm_area_struct *vma_m;
89260 +
89261 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
89262 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
89263 + BUG_ON(vma->vm_mirror);
89264 + return NULL;
89265 + }
89266 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
89267 + vma_m = vma->vm_mirror;
89268 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
89269 + BUG_ON(vma->vm_file != vma_m->vm_file);
89270 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
89271 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
89272 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
89273 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
89274 + return vma_m;
89275 +}
89276 +#endif
89277 +
89278 /*
89279 * Verify that the stack growth is acceptable and
89280 * update accounting. This is shared with both the
89281 @@ -2063,6 +2380,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
89282 return -ENOMEM;
89283
89284 /* Stack limit test */
89285 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
89286 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
89287 return -ENOMEM;
89288
89289 @@ -2073,6 +2391,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
89290 locked = mm->locked_vm + grow;
89291 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
89292 limit >>= PAGE_SHIFT;
89293 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
89294 if (locked > limit && !capable(CAP_IPC_LOCK))
89295 return -ENOMEM;
89296 }
89297 @@ -2102,37 +2421,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
89298 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
89299 * vma is the last one with address > vma->vm_end. Have to extend vma.
89300 */
89301 +#ifndef CONFIG_IA64
89302 +static
89303 +#endif
89304 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
89305 {
89306 int error;
89307 + bool locknext;
89308
89309 if (!(vma->vm_flags & VM_GROWSUP))
89310 return -EFAULT;
89311
89312 + /* Also guard against wrapping around to address 0. */
89313 + if (address < PAGE_ALIGN(address+1))
89314 + address = PAGE_ALIGN(address+1);
89315 + else
89316 + return -ENOMEM;
89317 +
89318 /*
89319 * We must make sure the anon_vma is allocated
89320 * so that the anon_vma locking is not a noop.
89321 */
89322 if (unlikely(anon_vma_prepare(vma)))
89323 return -ENOMEM;
89324 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
89325 + if (locknext && anon_vma_prepare(vma->vm_next))
89326 + return -ENOMEM;
89327 vma_lock_anon_vma(vma);
89328 + if (locknext)
89329 + vma_lock_anon_vma(vma->vm_next);
89330
89331 /*
89332 * vma->vm_start/vm_end cannot change under us because the caller
89333 * is required to hold the mmap_sem in read mode. We need the
89334 - * anon_vma lock to serialize against concurrent expand_stacks.
89335 - * Also guard against wrapping around to address 0.
89336 + * anon_vma locks to serialize against concurrent expand_stacks
89337 + * and expand_upwards.
89338 */
89339 - if (address < PAGE_ALIGN(address+4))
89340 - address = PAGE_ALIGN(address+4);
89341 - else {
89342 - vma_unlock_anon_vma(vma);
89343 - return -ENOMEM;
89344 - }
89345 error = 0;
89346
89347 /* Somebody else might have raced and expanded it already */
89348 - if (address > vma->vm_end) {
89349 + 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)
89350 + error = -ENOMEM;
89351 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
89352 unsigned long size, grow;
89353
89354 size = address - vma->vm_start;
89355 @@ -2167,6 +2497,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
89356 }
89357 }
89358 }
89359 + if (locknext)
89360 + vma_unlock_anon_vma(vma->vm_next);
89361 vma_unlock_anon_vma(vma);
89362 khugepaged_enter_vma_merge(vma);
89363 validate_mm(vma->vm_mm);
89364 @@ -2181,6 +2513,8 @@ int expand_downwards(struct vm_area_struct *vma,
89365 unsigned long address)
89366 {
89367 int error;
89368 + bool lockprev = false;
89369 + struct vm_area_struct *prev;
89370
89371 /*
89372 * We must make sure the anon_vma is allocated
89373 @@ -2194,6 +2528,15 @@ int expand_downwards(struct vm_area_struct *vma,
89374 if (error)
89375 return error;
89376
89377 + prev = vma->vm_prev;
89378 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
89379 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
89380 +#endif
89381 + if (lockprev && anon_vma_prepare(prev))
89382 + return -ENOMEM;
89383 + if (lockprev)
89384 + vma_lock_anon_vma(prev);
89385 +
89386 vma_lock_anon_vma(vma);
89387
89388 /*
89389 @@ -2203,9 +2546,17 @@ int expand_downwards(struct vm_area_struct *vma,
89390 */
89391
89392 /* Somebody else might have raced and expanded it already */
89393 - if (address < vma->vm_start) {
89394 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
89395 + error = -ENOMEM;
89396 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
89397 unsigned long size, grow;
89398
89399 +#ifdef CONFIG_PAX_SEGMEXEC
89400 + struct vm_area_struct *vma_m;
89401 +
89402 + vma_m = pax_find_mirror_vma(vma);
89403 +#endif
89404 +
89405 size = vma->vm_end - address;
89406 grow = (vma->vm_start - address) >> PAGE_SHIFT;
89407
89408 @@ -2230,13 +2581,27 @@ int expand_downwards(struct vm_area_struct *vma,
89409 vma->vm_pgoff -= grow;
89410 anon_vma_interval_tree_post_update_vma(vma);
89411 vma_gap_update(vma);
89412 +
89413 +#ifdef CONFIG_PAX_SEGMEXEC
89414 + if (vma_m) {
89415 + anon_vma_interval_tree_pre_update_vma(vma_m);
89416 + vma_m->vm_start -= grow << PAGE_SHIFT;
89417 + vma_m->vm_pgoff -= grow;
89418 + anon_vma_interval_tree_post_update_vma(vma_m);
89419 + vma_gap_update(vma_m);
89420 + }
89421 +#endif
89422 +
89423 spin_unlock(&vma->vm_mm->page_table_lock);
89424
89425 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
89426 perf_event_mmap(vma);
89427 }
89428 }
89429 }
89430 vma_unlock_anon_vma(vma);
89431 + if (lockprev)
89432 + vma_unlock_anon_vma(prev);
89433 khugepaged_enter_vma_merge(vma);
89434 validate_mm(vma->vm_mm);
89435 return error;
89436 @@ -2334,6 +2699,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
89437 do {
89438 long nrpages = vma_pages(vma);
89439
89440 +#ifdef CONFIG_PAX_SEGMEXEC
89441 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
89442 + vma = remove_vma(vma);
89443 + continue;
89444 + }
89445 +#endif
89446 +
89447 if (vma->vm_flags & VM_ACCOUNT)
89448 nr_accounted += nrpages;
89449 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
89450 @@ -2379,6 +2751,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
89451 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
89452 vma->vm_prev = NULL;
89453 do {
89454 +
89455 +#ifdef CONFIG_PAX_SEGMEXEC
89456 + if (vma->vm_mirror) {
89457 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
89458 + vma->vm_mirror->vm_mirror = NULL;
89459 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
89460 + vma->vm_mirror = NULL;
89461 + }
89462 +#endif
89463 +
89464 vma_rb_erase(vma, &mm->mm_rb);
89465 mm->map_count--;
89466 tail_vma = vma;
89467 @@ -2410,14 +2792,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
89468 struct vm_area_struct *new;
89469 int err = -ENOMEM;
89470
89471 +#ifdef CONFIG_PAX_SEGMEXEC
89472 + struct vm_area_struct *vma_m, *new_m = NULL;
89473 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
89474 +#endif
89475 +
89476 if (is_vm_hugetlb_page(vma) && (addr &
89477 ~(huge_page_mask(hstate_vma(vma)))))
89478 return -EINVAL;
89479
89480 +#ifdef CONFIG_PAX_SEGMEXEC
89481 + vma_m = pax_find_mirror_vma(vma);
89482 +#endif
89483 +
89484 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
89485 if (!new)
89486 goto out_err;
89487
89488 +#ifdef CONFIG_PAX_SEGMEXEC
89489 + if (vma_m) {
89490 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
89491 + if (!new_m) {
89492 + kmem_cache_free(vm_area_cachep, new);
89493 + goto out_err;
89494 + }
89495 + }
89496 +#endif
89497 +
89498 /* most fields are the same, copy all, and then fixup */
89499 *new = *vma;
89500
89501 @@ -2430,6 +2831,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
89502 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
89503 }
89504
89505 +#ifdef CONFIG_PAX_SEGMEXEC
89506 + if (vma_m) {
89507 + *new_m = *vma_m;
89508 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
89509 + new_m->vm_mirror = new;
89510 + new->vm_mirror = new_m;
89511 +
89512 + if (new_below)
89513 + new_m->vm_end = addr_m;
89514 + else {
89515 + new_m->vm_start = addr_m;
89516 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
89517 + }
89518 + }
89519 +#endif
89520 +
89521 pol = mpol_dup(vma_policy(vma));
89522 if (IS_ERR(pol)) {
89523 err = PTR_ERR(pol);
89524 @@ -2452,6 +2869,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
89525 else
89526 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
89527
89528 +#ifdef CONFIG_PAX_SEGMEXEC
89529 + if (!err && vma_m) {
89530 + if (anon_vma_clone(new_m, vma_m))
89531 + goto out_free_mpol;
89532 +
89533 + mpol_get(pol);
89534 + vma_set_policy(new_m, pol);
89535 +
89536 + if (new_m->vm_file)
89537 + get_file(new_m->vm_file);
89538 +
89539 + if (new_m->vm_ops && new_m->vm_ops->open)
89540 + new_m->vm_ops->open(new_m);
89541 +
89542 + if (new_below)
89543 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
89544 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
89545 + else
89546 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
89547 +
89548 + if (err) {
89549 + if (new_m->vm_ops && new_m->vm_ops->close)
89550 + new_m->vm_ops->close(new_m);
89551 + if (new_m->vm_file)
89552 + fput(new_m->vm_file);
89553 + mpol_put(pol);
89554 + }
89555 + }
89556 +#endif
89557 +
89558 /* Success. */
89559 if (!err)
89560 return 0;
89561 @@ -2461,10 +2908,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
89562 new->vm_ops->close(new);
89563 if (new->vm_file)
89564 fput(new->vm_file);
89565 - unlink_anon_vmas(new);
89566 out_free_mpol:
89567 mpol_put(pol);
89568 out_free_vma:
89569 +
89570 +#ifdef CONFIG_PAX_SEGMEXEC
89571 + if (new_m) {
89572 + unlink_anon_vmas(new_m);
89573 + kmem_cache_free(vm_area_cachep, new_m);
89574 + }
89575 +#endif
89576 +
89577 + unlink_anon_vmas(new);
89578 kmem_cache_free(vm_area_cachep, new);
89579 out_err:
89580 return err;
89581 @@ -2477,6 +2932,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
89582 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
89583 unsigned long addr, int new_below)
89584 {
89585 +
89586 +#ifdef CONFIG_PAX_SEGMEXEC
89587 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
89588 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
89589 + if (mm->map_count >= sysctl_max_map_count-1)
89590 + return -ENOMEM;
89591 + } else
89592 +#endif
89593 +
89594 if (mm->map_count >= sysctl_max_map_count)
89595 return -ENOMEM;
89596
89597 @@ -2488,11 +2952,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
89598 * work. This now handles partial unmappings.
89599 * Jeremy Fitzhardinge <jeremy@goop.org>
89600 */
89601 +#ifdef CONFIG_PAX_SEGMEXEC
89602 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
89603 {
89604 + int ret = __do_munmap(mm, start, len);
89605 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
89606 + return ret;
89607 +
89608 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
89609 +}
89610 +
89611 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
89612 +#else
89613 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
89614 +#endif
89615 +{
89616 unsigned long end;
89617 struct vm_area_struct *vma, *prev, *last;
89618
89619 + /*
89620 + * mm->mmap_sem is required to protect against another thread
89621 + * changing the mappings in case we sleep.
89622 + */
89623 + verify_mm_writelocked(mm);
89624 +
89625 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
89626 return -EINVAL;
89627
89628 @@ -2567,6 +3050,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
89629 /* Fix up all other VM information */
89630 remove_vma_list(mm, vma);
89631
89632 + track_exec_limit(mm, start, end, 0UL);
89633 +
89634 return 0;
89635 }
89636
89637 @@ -2575,6 +3060,13 @@ int vm_munmap(unsigned long start, size_t len)
89638 int ret;
89639 struct mm_struct *mm = current->mm;
89640
89641 +
89642 +#ifdef CONFIG_PAX_SEGMEXEC
89643 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
89644 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
89645 + return -EINVAL;
89646 +#endif
89647 +
89648 down_write(&mm->mmap_sem);
89649 ret = do_munmap(mm, start, len);
89650 up_write(&mm->mmap_sem);
89651 @@ -2588,16 +3080,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
89652 return vm_munmap(addr, len);
89653 }
89654
89655 -static inline void verify_mm_writelocked(struct mm_struct *mm)
89656 -{
89657 -#ifdef CONFIG_DEBUG_VM
89658 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
89659 - WARN_ON(1);
89660 - up_read(&mm->mmap_sem);
89661 - }
89662 -#endif
89663 -}
89664 -
89665 /*
89666 * this is really a simplified "do_mmap". it only handles
89667 * anonymous maps. eventually we may be able to do some
89668 @@ -2611,6 +3093,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
89669 struct rb_node ** rb_link, * rb_parent;
89670 pgoff_t pgoff = addr >> PAGE_SHIFT;
89671 int error;
89672 + unsigned long charged;
89673
89674 len = PAGE_ALIGN(len);
89675 if (!len)
89676 @@ -2618,16 +3101,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
89677
89678 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
89679
89680 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
89681 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
89682 + flags &= ~VM_EXEC;
89683 +
89684 +#ifdef CONFIG_PAX_MPROTECT
89685 + if (mm->pax_flags & MF_PAX_MPROTECT)
89686 + flags &= ~VM_MAYEXEC;
89687 +#endif
89688 +
89689 + }
89690 +#endif
89691 +
89692 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
89693 if (error & ~PAGE_MASK)
89694 return error;
89695
89696 + charged = len >> PAGE_SHIFT;
89697 +
89698 /*
89699 * mlock MCL_FUTURE?
89700 */
89701 if (mm->def_flags & VM_LOCKED) {
89702 unsigned long locked, lock_limit;
89703 - locked = len >> PAGE_SHIFT;
89704 + locked = charged;
89705 locked += mm->locked_vm;
89706 lock_limit = rlimit(RLIMIT_MEMLOCK);
89707 lock_limit >>= PAGE_SHIFT;
89708 @@ -2644,21 +3141,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
89709 /*
89710 * Clear old maps. this also does some error checking for us
89711 */
89712 - munmap_back:
89713 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
89714 if (do_munmap(mm, addr, len))
89715 return -ENOMEM;
89716 - goto munmap_back;
89717 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
89718 }
89719
89720 /* Check against address space limits *after* clearing old maps... */
89721 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
89722 + if (!may_expand_vm(mm, charged))
89723 return -ENOMEM;
89724
89725 if (mm->map_count > sysctl_max_map_count)
89726 return -ENOMEM;
89727
89728 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
89729 + if (security_vm_enough_memory_mm(mm, charged))
89730 return -ENOMEM;
89731
89732 /* Can we just expand an old private anonymous mapping? */
89733 @@ -2672,7 +3168,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
89734 */
89735 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
89736 if (!vma) {
89737 - vm_unacct_memory(len >> PAGE_SHIFT);
89738 + vm_unacct_memory(charged);
89739 return -ENOMEM;
89740 }
89741
89742 @@ -2686,9 +3182,10 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
89743 vma_link(mm, vma, prev, rb_link, rb_parent);
89744 out:
89745 perf_event_mmap(vma);
89746 - mm->total_vm += len >> PAGE_SHIFT;
89747 + mm->total_vm += charged;
89748 if (flags & VM_LOCKED)
89749 - mm->locked_vm += (len >> PAGE_SHIFT);
89750 + mm->locked_vm += charged;
89751 + track_exec_limit(mm, addr, addr + len, flags);
89752 return addr;
89753 }
89754
89755 @@ -2750,6 +3247,7 @@ void exit_mmap(struct mm_struct *mm)
89756 while (vma) {
89757 if (vma->vm_flags & VM_ACCOUNT)
89758 nr_accounted += vma_pages(vma);
89759 + vma->vm_mirror = NULL;
89760 vma = remove_vma(vma);
89761 }
89762 vm_unacct_memory(nr_accounted);
89763 @@ -2766,6 +3264,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
89764 struct vm_area_struct *prev;
89765 struct rb_node **rb_link, *rb_parent;
89766
89767 +#ifdef CONFIG_PAX_SEGMEXEC
89768 + struct vm_area_struct *vma_m = NULL;
89769 +#endif
89770 +
89771 + if (security_mmap_addr(vma->vm_start))
89772 + return -EPERM;
89773 +
89774 /*
89775 * The vm_pgoff of a purely anonymous vma should be irrelevant
89776 * until its first write fault, when page's anon_vma and index
89777 @@ -2789,7 +3294,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
89778 security_vm_enough_memory_mm(mm, vma_pages(vma)))
89779 return -ENOMEM;
89780
89781 +#ifdef CONFIG_PAX_SEGMEXEC
89782 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
89783 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
89784 + if (!vma_m)
89785 + return -ENOMEM;
89786 + }
89787 +#endif
89788 +
89789 vma_link(mm, vma, prev, rb_link, rb_parent);
89790 +
89791 +#ifdef CONFIG_PAX_SEGMEXEC
89792 + if (vma_m)
89793 + BUG_ON(pax_mirror_vma(vma_m, vma));
89794 +#endif
89795 +
89796 return 0;
89797 }
89798
89799 @@ -2809,6 +3328,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
89800 struct mempolicy *pol;
89801 bool faulted_in_anon_vma = true;
89802
89803 + BUG_ON(vma->vm_mirror);
89804 +
89805 /*
89806 * If anonymous vma has not yet been faulted, update new pgoff
89807 * to match new location, to increase its chance of merging.
89808 @@ -2875,6 +3396,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
89809 return NULL;
89810 }
89811
89812 +#ifdef CONFIG_PAX_SEGMEXEC
89813 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
89814 +{
89815 + struct vm_area_struct *prev_m;
89816 + struct rb_node **rb_link_m, *rb_parent_m;
89817 + struct mempolicy *pol_m;
89818 +
89819 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
89820 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
89821 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
89822 + *vma_m = *vma;
89823 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
89824 + if (anon_vma_clone(vma_m, vma))
89825 + return -ENOMEM;
89826 + pol_m = vma_policy(vma_m);
89827 + mpol_get(pol_m);
89828 + vma_set_policy(vma_m, pol_m);
89829 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
89830 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
89831 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
89832 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
89833 + if (vma_m->vm_file)
89834 + get_file(vma_m->vm_file);
89835 + if (vma_m->vm_ops && vma_m->vm_ops->open)
89836 + vma_m->vm_ops->open(vma_m);
89837 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
89838 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
89839 + vma_m->vm_mirror = vma;
89840 + vma->vm_mirror = vma_m;
89841 + return 0;
89842 +}
89843 +#endif
89844 +
89845 /*
89846 * Return true if the calling process may expand its vm space by the passed
89847 * number of pages
89848 @@ -2886,6 +3440,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
89849
89850 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
89851
89852 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
89853 if (cur + npages > lim)
89854 return 0;
89855 return 1;
89856 @@ -2956,6 +3511,22 @@ int install_special_mapping(struct mm_struct *mm,
89857 vma->vm_start = addr;
89858 vma->vm_end = addr + len;
89859
89860 +#ifdef CONFIG_PAX_MPROTECT
89861 + if (mm->pax_flags & MF_PAX_MPROTECT) {
89862 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
89863 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
89864 + return -EPERM;
89865 + if (!(vm_flags & VM_EXEC))
89866 + vm_flags &= ~VM_MAYEXEC;
89867 +#else
89868 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
89869 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
89870 +#endif
89871 + else
89872 + vm_flags &= ~VM_MAYWRITE;
89873 + }
89874 +#endif
89875 +
89876 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
89877 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
89878
89879 diff --git a/mm/mprotect.c b/mm/mprotect.c
89880 index 94722a4..e661e29 100644
89881 --- a/mm/mprotect.c
89882 +++ b/mm/mprotect.c
89883 @@ -23,10 +23,18 @@
89884 #include <linux/mmu_notifier.h>
89885 #include <linux/migrate.h>
89886 #include <linux/perf_event.h>
89887 +#include <linux/sched/sysctl.h>
89888 +
89889 +#ifdef CONFIG_PAX_MPROTECT
89890 +#include <linux/elf.h>
89891 +#include <linux/binfmts.h>
89892 +#endif
89893 +
89894 #include <asm/uaccess.h>
89895 #include <asm/pgtable.h>
89896 #include <asm/cacheflush.h>
89897 #include <asm/tlbflush.h>
89898 +#include <asm/mmu_context.h>
89899
89900 #ifndef pgprot_modify
89901 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
89902 @@ -233,6 +241,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
89903 return pages;
89904 }
89905
89906 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
89907 +/* called while holding the mmap semaphor for writing except stack expansion */
89908 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
89909 +{
89910 + unsigned long oldlimit, newlimit = 0UL;
89911 +
89912 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
89913 + return;
89914 +
89915 + spin_lock(&mm->page_table_lock);
89916 + oldlimit = mm->context.user_cs_limit;
89917 + if ((prot & VM_EXEC) && oldlimit < end)
89918 + /* USER_CS limit moved up */
89919 + newlimit = end;
89920 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
89921 + /* USER_CS limit moved down */
89922 + newlimit = start;
89923 +
89924 + if (newlimit) {
89925 + mm->context.user_cs_limit = newlimit;
89926 +
89927 +#ifdef CONFIG_SMP
89928 + wmb();
89929 + cpus_clear(mm->context.cpu_user_cs_mask);
89930 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
89931 +#endif
89932 +
89933 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
89934 + }
89935 + spin_unlock(&mm->page_table_lock);
89936 + if (newlimit == end) {
89937 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
89938 +
89939 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
89940 + if (is_vm_hugetlb_page(vma))
89941 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
89942 + else
89943 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
89944 + }
89945 +}
89946 +#endif
89947 +
89948 int
89949 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
89950 unsigned long start, unsigned long end, unsigned long newflags)
89951 @@ -245,11 +295,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
89952 int error;
89953 int dirty_accountable = 0;
89954
89955 +#ifdef CONFIG_PAX_SEGMEXEC
89956 + struct vm_area_struct *vma_m = NULL;
89957 + unsigned long start_m, end_m;
89958 +
89959 + start_m = start + SEGMEXEC_TASK_SIZE;
89960 + end_m = end + SEGMEXEC_TASK_SIZE;
89961 +#endif
89962 +
89963 if (newflags == oldflags) {
89964 *pprev = vma;
89965 return 0;
89966 }
89967
89968 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
89969 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
89970 +
89971 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
89972 + return -ENOMEM;
89973 +
89974 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
89975 + return -ENOMEM;
89976 + }
89977 +
89978 /*
89979 * If we make a private mapping writable we increase our commit;
89980 * but (without finer accounting) cannot reduce our commit if we
89981 @@ -266,6 +334,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
89982 }
89983 }
89984
89985 +#ifdef CONFIG_PAX_SEGMEXEC
89986 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
89987 + if (start != vma->vm_start) {
89988 + error = split_vma(mm, vma, start, 1);
89989 + if (error)
89990 + goto fail;
89991 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
89992 + *pprev = (*pprev)->vm_next;
89993 + }
89994 +
89995 + if (end != vma->vm_end) {
89996 + error = split_vma(mm, vma, end, 0);
89997 + if (error)
89998 + goto fail;
89999 + }
90000 +
90001 + if (pax_find_mirror_vma(vma)) {
90002 + error = __do_munmap(mm, start_m, end_m - start_m);
90003 + if (error)
90004 + goto fail;
90005 + } else {
90006 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
90007 + if (!vma_m) {
90008 + error = -ENOMEM;
90009 + goto fail;
90010 + }
90011 + vma->vm_flags = newflags;
90012 + error = pax_mirror_vma(vma_m, vma);
90013 + if (error) {
90014 + vma->vm_flags = oldflags;
90015 + goto fail;
90016 + }
90017 + }
90018 + }
90019 +#endif
90020 +
90021 /*
90022 * First try to merge with previous and/or next vma.
90023 */
90024 @@ -296,9 +400,21 @@ success:
90025 * vm_flags and vm_page_prot are protected by the mmap_sem
90026 * held in write mode.
90027 */
90028 +
90029 +#ifdef CONFIG_PAX_SEGMEXEC
90030 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
90031 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
90032 +#endif
90033 +
90034 vma->vm_flags = newflags;
90035 +
90036 +#ifdef CONFIG_PAX_MPROTECT
90037 + if (mm->binfmt && mm->binfmt->handle_mprotect)
90038 + mm->binfmt->handle_mprotect(vma, newflags);
90039 +#endif
90040 +
90041 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
90042 - vm_get_page_prot(newflags));
90043 + vm_get_page_prot(vma->vm_flags));
90044
90045 if (vma_wants_writenotify(vma)) {
90046 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
90047 @@ -337,6 +453,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
90048 end = start + len;
90049 if (end <= start)
90050 return -ENOMEM;
90051 +
90052 +#ifdef CONFIG_PAX_SEGMEXEC
90053 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
90054 + if (end > SEGMEXEC_TASK_SIZE)
90055 + return -EINVAL;
90056 + } else
90057 +#endif
90058 +
90059 + if (end > TASK_SIZE)
90060 + return -EINVAL;
90061 +
90062 if (!arch_validate_prot(prot))
90063 return -EINVAL;
90064
90065 @@ -344,7 +471,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
90066 /*
90067 * Does the application expect PROT_READ to imply PROT_EXEC:
90068 */
90069 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
90070 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
90071 prot |= PROT_EXEC;
90072
90073 vm_flags = calc_vm_prot_bits(prot);
90074 @@ -376,6 +503,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
90075 if (start > vma->vm_start)
90076 prev = vma;
90077
90078 +#ifdef CONFIG_PAX_MPROTECT
90079 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
90080 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
90081 +#endif
90082 +
90083 for (nstart = start ; ; ) {
90084 unsigned long newflags;
90085
90086 @@ -386,6 +518,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
90087
90088 /* newflags >> 4 shift VM_MAY% in place of VM_% */
90089 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
90090 + if (prot & (PROT_WRITE | PROT_EXEC))
90091 + gr_log_rwxmprotect(vma);
90092 +
90093 + error = -EACCES;
90094 + goto out;
90095 + }
90096 +
90097 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
90098 error = -EACCES;
90099 goto out;
90100 }
90101 @@ -400,6 +540,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
90102 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
90103 if (error)
90104 goto out;
90105 +
90106 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
90107 +
90108 nstart = tmp;
90109
90110 if (nstart < prev->vm_end)
90111 diff --git a/mm/mremap.c b/mm/mremap.c
90112 index 463a257..c0c7a92 100644
90113 --- a/mm/mremap.c
90114 +++ b/mm/mremap.c
90115 @@ -126,6 +126,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
90116 continue;
90117 pte = ptep_get_and_clear(mm, old_addr, old_pte);
90118 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
90119 +
90120 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
90121 + if (!(__supported_pte_mask & _PAGE_NX) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
90122 + pte = pte_exprotect(pte);
90123 +#endif
90124 +
90125 set_pte_at(mm, new_addr, new_pte, pte);
90126 }
90127
90128 @@ -318,6 +324,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
90129 if (is_vm_hugetlb_page(vma))
90130 goto Einval;
90131
90132 +#ifdef CONFIG_PAX_SEGMEXEC
90133 + if (pax_find_mirror_vma(vma))
90134 + goto Einval;
90135 +#endif
90136 +
90137 /* We can't remap across vm area boundaries */
90138 if (old_len > vma->vm_end - addr)
90139 goto Efault;
90140 @@ -373,20 +384,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
90141 unsigned long ret = -EINVAL;
90142 unsigned long charged = 0;
90143 unsigned long map_flags;
90144 + unsigned long pax_task_size = TASK_SIZE;
90145
90146 if (new_addr & ~PAGE_MASK)
90147 goto out;
90148
90149 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
90150 +#ifdef CONFIG_PAX_SEGMEXEC
90151 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
90152 + pax_task_size = SEGMEXEC_TASK_SIZE;
90153 +#endif
90154 +
90155 + pax_task_size -= PAGE_SIZE;
90156 +
90157 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
90158 goto out;
90159
90160 /* Check if the location we're moving into overlaps the
90161 * old location at all, and fail if it does.
90162 */
90163 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
90164 - goto out;
90165 -
90166 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
90167 + if (addr + old_len > new_addr && new_addr + new_len > addr)
90168 goto out;
90169
90170 ret = do_munmap(mm, new_addr, new_len);
90171 @@ -455,6 +471,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
90172 unsigned long ret = -EINVAL;
90173 unsigned long charged = 0;
90174 bool locked = false;
90175 + unsigned long pax_task_size = TASK_SIZE;
90176
90177 down_write(&current->mm->mmap_sem);
90178
90179 @@ -475,6 +492,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
90180 if (!new_len)
90181 goto out;
90182
90183 +#ifdef CONFIG_PAX_SEGMEXEC
90184 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
90185 + pax_task_size = SEGMEXEC_TASK_SIZE;
90186 +#endif
90187 +
90188 + pax_task_size -= PAGE_SIZE;
90189 +
90190 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
90191 + old_len > pax_task_size || addr > pax_task_size-old_len)
90192 + goto out;
90193 +
90194 if (flags & MREMAP_FIXED) {
90195 if (flags & MREMAP_MAYMOVE)
90196 ret = mremap_to(addr, old_len, new_addr, new_len,
90197 @@ -524,6 +552,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
90198 new_addr = addr;
90199 }
90200 ret = addr;
90201 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
90202 goto out;
90203 }
90204 }
90205 @@ -547,7 +576,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
90206 goto out;
90207 }
90208
90209 + map_flags = vma->vm_flags;
90210 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
90211 + if (!(ret & ~PAGE_MASK)) {
90212 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
90213 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
90214 + }
90215 }
90216 out:
90217 if (ret & ~PAGE_MASK)
90218 diff --git a/mm/nommu.c b/mm/nommu.c
90219 index 298884d..5f74980 100644
90220 --- a/mm/nommu.c
90221 +++ b/mm/nommu.c
90222 @@ -65,7 +65,6 @@ int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
90223 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
90224 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
90225 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
90226 -int heap_stack_gap = 0;
90227
90228 atomic_long_t mmap_pages_allocated;
90229
90230 @@ -842,15 +841,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
90231 EXPORT_SYMBOL(find_vma);
90232
90233 /*
90234 - * find a VMA
90235 - * - we don't extend stack VMAs under NOMMU conditions
90236 - */
90237 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
90238 -{
90239 - return find_vma(mm, addr);
90240 -}
90241 -
90242 -/*
90243 * expand a stack to a given address
90244 * - not supported under NOMMU conditions
90245 */
90246 @@ -1561,6 +1551,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
90247
90248 /* most fields are the same, copy all, and then fixup */
90249 *new = *vma;
90250 + INIT_LIST_HEAD(&new->anon_vma_chain);
90251 *region = *vma->vm_region;
90252 new->vm_region = region;
90253
90254 @@ -1995,8 +1986,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
90255 }
90256 EXPORT_SYMBOL(generic_file_remap_pages);
90257
90258 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
90259 - unsigned long addr, void *buf, int len, int write)
90260 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
90261 + unsigned long addr, void *buf, size_t len, int write)
90262 {
90263 struct vm_area_struct *vma;
90264
90265 @@ -2037,8 +2028,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
90266 *
90267 * The caller must hold a reference on @mm.
90268 */
90269 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
90270 - void *buf, int len, int write)
90271 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
90272 + void *buf, size_t len, int write)
90273 {
90274 return __access_remote_vm(NULL, mm, addr, buf, len, write);
90275 }
90276 @@ -2047,7 +2038,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
90277 * Access another process' address space.
90278 * - source/target buffer must be kernel space
90279 */
90280 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
90281 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
90282 {
90283 struct mm_struct *mm;
90284
90285 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
90286 index 4514ad7..92eaa1c 100644
90287 --- a/mm/page-writeback.c
90288 +++ b/mm/page-writeback.c
90289 @@ -659,7 +659,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
90290 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
90291 * - the bdi dirty thresh drops quickly due to change of JBOD workload
90292 */
90293 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
90294 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
90295 unsigned long thresh,
90296 unsigned long bg_thresh,
90297 unsigned long dirty,
90298 @@ -1634,7 +1634,7 @@ ratelimit_handler(struct notifier_block *self, unsigned long action,
90299 }
90300 }
90301
90302 -static struct notifier_block __cpuinitdata ratelimit_nb = {
90303 +static struct notifier_block ratelimit_nb = {
90304 .notifier_call = ratelimit_handler,
90305 .next = NULL,
90306 };
90307 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
90308 index 2ee0fd3..6e2edfb 100644
90309 --- a/mm/page_alloc.c
90310 +++ b/mm/page_alloc.c
90311 @@ -60,6 +60,7 @@
90312 #include <linux/page-debug-flags.h>
90313 #include <linux/hugetlb.h>
90314 #include <linux/sched/rt.h>
90315 +#include <linux/random.h>
90316
90317 #include <asm/tlbflush.h>
90318 #include <asm/div64.h>
90319 @@ -345,7 +346,7 @@ out:
90320 * This usage means that zero-order pages may not be compound.
90321 */
90322
90323 -static void free_compound_page(struct page *page)
90324 +void free_compound_page(struct page *page)
90325 {
90326 __free_pages_ok(page, compound_order(page));
90327 }
90328 @@ -702,6 +703,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
90329 int i;
90330 int bad = 0;
90331
90332 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90333 + unsigned long index = 1UL << order;
90334 +#endif
90335 +
90336 trace_mm_page_free(page, order);
90337 kmemcheck_free_shadow(page, order);
90338
90339 @@ -717,6 +722,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
90340 debug_check_no_obj_freed(page_address(page),
90341 PAGE_SIZE << order);
90342 }
90343 +
90344 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90345 + for (; index; --index)
90346 + sanitize_highpage(page + index - 1);
90347 +#endif
90348 +
90349 arch_free_page(page, order);
90350 kernel_map_pages(page, 1 << order, 0);
90351
90352 @@ -739,6 +750,19 @@ static void __free_pages_ok(struct page *page, unsigned int order)
90353 local_irq_restore(flags);
90354 }
90355
90356 +#ifdef CONFIG_PAX_LATENT_ENTROPY
90357 +bool __meminitdata extra_latent_entropy;
90358 +
90359 +static int __init setup_pax_extra_latent_entropy(char *str)
90360 +{
90361 + extra_latent_entropy = true;
90362 + return 0;
90363 +}
90364 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
90365 +
90366 +volatile u64 latent_entropy;
90367 +#endif
90368 +
90369 /*
90370 * Read access to zone->managed_pages is safe because it's unsigned long,
90371 * but we still need to serialize writers. Currently all callers of
90372 @@ -761,6 +785,19 @@ void __meminit __free_pages_bootmem(struct page *page, unsigned int order)
90373 set_page_count(p, 0);
90374 }
90375
90376 +#ifdef CONFIG_PAX_LATENT_ENTROPY
90377 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
90378 + u64 hash = 0;
90379 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
90380 + const u64 *data = lowmem_page_address(page);
90381 +
90382 + for (index = 0; index < end; index++)
90383 + hash ^= hash + data[index];
90384 + latent_entropy ^= hash;
90385 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
90386 + }
90387 +#endif
90388 +
90389 page_zone(page)->managed_pages += 1 << order;
90390 set_page_refcounted(page);
90391 __free_pages(page, order);
90392 @@ -870,8 +907,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
90393 arch_alloc_page(page, order);
90394 kernel_map_pages(page, 1 << order, 1);
90395
90396 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
90397 if (gfp_flags & __GFP_ZERO)
90398 prep_zero_page(page, order, gfp_flags);
90399 +#endif
90400
90401 if (order && (gfp_flags & __GFP_COMP))
90402 prep_compound_page(page, order);
90403 diff --git a/mm/page_io.c b/mm/page_io.c
90404 index a8a3ef4..7260a60 100644
90405 --- a/mm/page_io.c
90406 +++ b/mm/page_io.c
90407 @@ -214,7 +214,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
90408 struct file *swap_file = sis->swap_file;
90409 struct address_space *mapping = swap_file->f_mapping;
90410 struct iovec iov = {
90411 - .iov_base = kmap(page),
90412 + .iov_base = (void __force_user *)kmap(page),
90413 .iov_len = PAGE_SIZE,
90414 };
90415
90416 diff --git a/mm/percpu.c b/mm/percpu.c
90417 index 8c8e08f..73a5cda 100644
90418 --- a/mm/percpu.c
90419 +++ b/mm/percpu.c
90420 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
90421 static unsigned int pcpu_high_unit_cpu __read_mostly;
90422
90423 /* the address of the first chunk which starts with the kernel static area */
90424 -void *pcpu_base_addr __read_mostly;
90425 +void *pcpu_base_addr __read_only;
90426 EXPORT_SYMBOL_GPL(pcpu_base_addr);
90427
90428 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
90429 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
90430 index fd26d04..0cea1b0 100644
90431 --- a/mm/process_vm_access.c
90432 +++ b/mm/process_vm_access.c
90433 @@ -13,6 +13,7 @@
90434 #include <linux/uio.h>
90435 #include <linux/sched.h>
90436 #include <linux/highmem.h>
90437 +#include <linux/security.h>
90438 #include <linux/ptrace.h>
90439 #include <linux/slab.h>
90440 #include <linux/syscalls.h>
90441 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
90442 size_t iov_l_curr_offset = 0;
90443 ssize_t iov_len;
90444
90445 + return -ENOSYS; // PaX: until properly audited
90446 +
90447 /*
90448 * Work out how many pages of struct pages we're going to need
90449 * when eventually calling get_user_pages
90450 */
90451 for (i = 0; i < riovcnt; i++) {
90452 iov_len = rvec[i].iov_len;
90453 - if (iov_len > 0) {
90454 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
90455 - + iov_len)
90456 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
90457 - / PAGE_SIZE + 1;
90458 - nr_pages = max(nr_pages, nr_pages_iov);
90459 - }
90460 + if (iov_len <= 0)
90461 + continue;
90462 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
90463 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
90464 + nr_pages = max(nr_pages, nr_pages_iov);
90465 }
90466
90467 if (nr_pages == 0)
90468 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
90469 goto free_proc_pages;
90470 }
90471
90472 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
90473 + rc = -EPERM;
90474 + goto put_task_struct;
90475 + }
90476 +
90477 mm = mm_access(task, PTRACE_MODE_ATTACH);
90478 if (!mm || IS_ERR(mm)) {
90479 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
90480 diff --git a/mm/rmap.c b/mm/rmap.c
90481 index 6280da8..b5c090e 100644
90482 --- a/mm/rmap.c
90483 +++ b/mm/rmap.c
90484 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
90485 struct anon_vma *anon_vma = vma->anon_vma;
90486 struct anon_vma_chain *avc;
90487
90488 +#ifdef CONFIG_PAX_SEGMEXEC
90489 + struct anon_vma_chain *avc_m = NULL;
90490 +#endif
90491 +
90492 might_sleep();
90493 if (unlikely(!anon_vma)) {
90494 struct mm_struct *mm = vma->vm_mm;
90495 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
90496 if (!avc)
90497 goto out_enomem;
90498
90499 +#ifdef CONFIG_PAX_SEGMEXEC
90500 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
90501 + if (!avc_m)
90502 + goto out_enomem_free_avc;
90503 +#endif
90504 +
90505 anon_vma = find_mergeable_anon_vma(vma);
90506 allocated = NULL;
90507 if (!anon_vma) {
90508 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
90509 /* page_table_lock to protect against threads */
90510 spin_lock(&mm->page_table_lock);
90511 if (likely(!vma->anon_vma)) {
90512 +
90513 +#ifdef CONFIG_PAX_SEGMEXEC
90514 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
90515 +
90516 + if (vma_m) {
90517 + BUG_ON(vma_m->anon_vma);
90518 + vma_m->anon_vma = anon_vma;
90519 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
90520 + avc_m = NULL;
90521 + }
90522 +#endif
90523 +
90524 vma->anon_vma = anon_vma;
90525 anon_vma_chain_link(vma, avc, anon_vma);
90526 allocated = NULL;
90527 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
90528
90529 if (unlikely(allocated))
90530 put_anon_vma(allocated);
90531 +
90532 +#ifdef CONFIG_PAX_SEGMEXEC
90533 + if (unlikely(avc_m))
90534 + anon_vma_chain_free(avc_m);
90535 +#endif
90536 +
90537 if (unlikely(avc))
90538 anon_vma_chain_free(avc);
90539 }
90540 return 0;
90541
90542 out_enomem_free_avc:
90543 +
90544 +#ifdef CONFIG_PAX_SEGMEXEC
90545 + if (avc_m)
90546 + anon_vma_chain_free(avc_m);
90547 +#endif
90548 +
90549 anon_vma_chain_free(avc);
90550 out_enomem:
90551 return -ENOMEM;
90552 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
90553 * Attach the anon_vmas from src to dst.
90554 * Returns 0 on success, -ENOMEM on failure.
90555 */
90556 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
90557 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
90558 {
90559 struct anon_vma_chain *avc, *pavc;
90560 struct anon_vma *root = NULL;
90561 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
90562 * the corresponding VMA in the parent process is attached to.
90563 * Returns 0 on success, non-zero on failure.
90564 */
90565 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
90566 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
90567 {
90568 struct anon_vma_chain *avc;
90569 struct anon_vma *anon_vma;
90570 @@ -373,8 +407,10 @@ static void anon_vma_ctor(void *data)
90571 void __init anon_vma_init(void)
90572 {
90573 anon_vma_cachep = kmem_cache_create("anon_vma", sizeof(struct anon_vma),
90574 - 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC, anon_vma_ctor);
90575 - anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain, SLAB_PANIC);
90576 + 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC|SLAB_NO_SANITIZE,
90577 + anon_vma_ctor);
90578 + anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain,
90579 + SLAB_PANIC|SLAB_NO_SANITIZE);
90580 }
90581
90582 /*
90583 diff --git a/mm/shmem.c b/mm/shmem.c
90584 index 5e6a842..b41916e 100644
90585 --- a/mm/shmem.c
90586 +++ b/mm/shmem.c
90587 @@ -33,7 +33,7 @@
90588 #include <linux/swap.h>
90589 #include <linux/aio.h>
90590
90591 -static struct vfsmount *shm_mnt;
90592 +struct vfsmount *shm_mnt;
90593
90594 #ifdef CONFIG_SHMEM
90595 /*
90596 @@ -77,7 +77,7 @@ static struct vfsmount *shm_mnt;
90597 #define BOGO_DIRENT_SIZE 20
90598
90599 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
90600 -#define SHORT_SYMLINK_LEN 128
90601 +#define SHORT_SYMLINK_LEN 64
90602
90603 /*
90604 * shmem_fallocate and shmem_writepage communicate via inode->i_private
90605 @@ -2203,6 +2203,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
90606 static int shmem_xattr_validate(const char *name)
90607 {
90608 struct { const char *prefix; size_t len; } arr[] = {
90609 +
90610 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
90611 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
90612 +#endif
90613 +
90614 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
90615 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
90616 };
90617 @@ -2258,6 +2263,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
90618 if (err)
90619 return err;
90620
90621 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
90622 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
90623 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
90624 + return -EOPNOTSUPP;
90625 + if (size > 8)
90626 + return -EINVAL;
90627 + }
90628 +#endif
90629 +
90630 return simple_xattr_set(&info->xattrs, name, value, size, flags);
90631 }
90632
90633 @@ -2570,8 +2584,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
90634 int err = -ENOMEM;
90635
90636 /* Round up to L1_CACHE_BYTES to resist false sharing */
90637 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
90638 - L1_CACHE_BYTES), GFP_KERNEL);
90639 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
90640 if (!sbinfo)
90641 return -ENOMEM;
90642
90643 diff --git a/mm/slab.c b/mm/slab.c
90644 index bd88411..2d46fd6 100644
90645 --- a/mm/slab.c
90646 +++ b/mm/slab.c
90647 @@ -366,10 +366,12 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
90648 if ((x)->max_freeable < i) \
90649 (x)->max_freeable = i; \
90650 } while (0)
90651 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
90652 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
90653 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
90654 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
90655 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
90656 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
90657 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
90658 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
90659 +#define STATS_INC_SANITIZED(x) atomic_inc_unchecked(&(x)->sanitized)
90660 +#define STATS_INC_NOT_SANITIZED(x) atomic_inc_unchecked(&(x)->not_sanitized)
90661 #else
90662 #define STATS_INC_ACTIVE(x) do { } while (0)
90663 #define STATS_DEC_ACTIVE(x) do { } while (0)
90664 @@ -386,6 +388,8 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
90665 #define STATS_INC_ALLOCMISS(x) do { } while (0)
90666 #define STATS_INC_FREEHIT(x) do { } while (0)
90667 #define STATS_INC_FREEMISS(x) do { } while (0)
90668 +#define STATS_INC_SANITIZED(x) do { } while (0)
90669 +#define STATS_INC_NOT_SANITIZED(x) do { } while (0)
90670 #endif
90671
90672 #if DEBUG
90673 @@ -477,7 +481,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
90674 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
90675 */
90676 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
90677 - const struct slab *slab, void *obj)
90678 + const struct slab *slab, const void *obj)
90679 {
90680 u32 offset = (obj - slab->s_mem);
90681 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
90682 @@ -1384,7 +1388,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
90683 return notifier_from_errno(err);
90684 }
90685
90686 -static struct notifier_block __cpuinitdata cpucache_notifier = {
90687 +static struct notifier_block cpucache_notifier = {
90688 &cpuup_callback, NULL, 0
90689 };
90690
90691 @@ -1565,12 +1569,12 @@ void __init kmem_cache_init(void)
90692 */
90693
90694 kmalloc_caches[INDEX_AC] = create_kmalloc_cache("kmalloc-ac",
90695 - kmalloc_size(INDEX_AC), ARCH_KMALLOC_FLAGS);
90696 + kmalloc_size(INDEX_AC), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
90697
90698 if (INDEX_AC != INDEX_NODE)
90699 kmalloc_caches[INDEX_NODE] =
90700 create_kmalloc_cache("kmalloc-node",
90701 - kmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS);
90702 + kmalloc_size(INDEX_NODE), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
90703
90704 slab_early_init = 0;
90705
90706 @@ -3583,6 +3587,21 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp,
90707 struct array_cache *ac = cpu_cache_get(cachep);
90708
90709 check_irq_off();
90710 +
90711 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90712 + if (pax_sanitize_slab) {
90713 + if (!(cachep->flags & (SLAB_POISON | SLAB_NO_SANITIZE))) {
90714 + memset(objp, PAX_MEMORY_SANITIZE_VALUE, cachep->object_size);
90715 +
90716 + if (cachep->ctor)
90717 + cachep->ctor(objp);
90718 +
90719 + STATS_INC_SANITIZED(cachep);
90720 + } else
90721 + STATS_INC_NOT_SANITIZED(cachep);
90722 + }
90723 +#endif
90724 +
90725 kmemleak_free_recursive(objp, cachep->flags);
90726 objp = cache_free_debugcheck(cachep, objp, caller);
90727
90728 @@ -3800,6 +3819,7 @@ void kfree(const void *objp)
90729
90730 if (unlikely(ZERO_OR_NULL_PTR(objp)))
90731 return;
90732 + VM_BUG_ON(!virt_addr_valid(objp));
90733 local_irq_save(flags);
90734 kfree_debugcheck(objp);
90735 c = virt_to_cache(objp);
90736 @@ -4241,14 +4261,22 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
90737 }
90738 /* cpu stats */
90739 {
90740 - unsigned long allochit = atomic_read(&cachep->allochit);
90741 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
90742 - unsigned long freehit = atomic_read(&cachep->freehit);
90743 - unsigned long freemiss = atomic_read(&cachep->freemiss);
90744 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
90745 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
90746 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
90747 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
90748
90749 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
90750 allochit, allocmiss, freehit, freemiss);
90751 }
90752 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90753 + {
90754 + unsigned long sanitized = atomic_read_unchecked(&cachep->sanitized);
90755 + unsigned long not_sanitized = atomic_read_unchecked(&cachep->not_sanitized);
90756 +
90757 + seq_printf(m, " : pax %6lu %6lu", sanitized, not_sanitized);
90758 + }
90759 +#endif
90760 #endif
90761 }
90762
90763 @@ -4476,13 +4504,71 @@ static const struct file_operations proc_slabstats_operations = {
90764 static int __init slab_proc_init(void)
90765 {
90766 #ifdef CONFIG_DEBUG_SLAB_LEAK
90767 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
90768 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
90769 #endif
90770 return 0;
90771 }
90772 module_init(slab_proc_init);
90773 #endif
90774
90775 +bool is_usercopy_object(const void *ptr)
90776 +{
90777 + struct page *page;
90778 + struct kmem_cache *cachep;
90779 +
90780 + if (ZERO_OR_NULL_PTR(ptr))
90781 + return false;
90782 +
90783 + if (!slab_is_available())
90784 + return false;
90785 +
90786 + if (!virt_addr_valid(ptr))
90787 + return false;
90788 +
90789 + page = virt_to_head_page(ptr);
90790 +
90791 + if (!PageSlab(page))
90792 + return false;
90793 +
90794 + cachep = page->slab_cache;
90795 + return cachep->flags & SLAB_USERCOPY;
90796 +}
90797 +
90798 +#ifdef CONFIG_PAX_USERCOPY
90799 +const char *check_heap_object(const void *ptr, unsigned long n)
90800 +{
90801 + struct page *page;
90802 + struct kmem_cache *cachep;
90803 + struct slab *slabp;
90804 + unsigned int objnr;
90805 + unsigned long offset;
90806 +
90807 + if (ZERO_OR_NULL_PTR(ptr))
90808 + return "<null>";
90809 +
90810 + if (!virt_addr_valid(ptr))
90811 + return NULL;
90812 +
90813 + page = virt_to_head_page(ptr);
90814 +
90815 + if (!PageSlab(page))
90816 + return NULL;
90817 +
90818 + cachep = page->slab_cache;
90819 + if (!(cachep->flags & SLAB_USERCOPY))
90820 + return cachep->name;
90821 +
90822 + slabp = page->slab_page;
90823 + objnr = obj_to_index(cachep, slabp, ptr);
90824 + BUG_ON(objnr >= cachep->num);
90825 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
90826 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
90827 + return NULL;
90828 +
90829 + return cachep->name;
90830 +}
90831 +#endif
90832 +
90833 /**
90834 * ksize - get the actual amount of memory allocated for a given object
90835 * @objp: Pointer to the object
90836 diff --git a/mm/slab.h b/mm/slab.h
90837 index f96b49e..db1d204 100644
90838 --- a/mm/slab.h
90839 +++ b/mm/slab.h
90840 @@ -32,6 +32,15 @@ extern struct list_head slab_caches;
90841 /* The slab cache that manages slab cache information */
90842 extern struct kmem_cache *kmem_cache;
90843
90844 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90845 +#ifdef CONFIG_X86_64
90846 +#define PAX_MEMORY_SANITIZE_VALUE '\xfe'
90847 +#else
90848 +#define PAX_MEMORY_SANITIZE_VALUE '\xff'
90849 +#endif
90850 +extern bool pax_sanitize_slab;
90851 +#endif
90852 +
90853 unsigned long calculate_alignment(unsigned long flags,
90854 unsigned long align, unsigned long size);
90855
90856 @@ -67,7 +76,8 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
90857
90858 /* Legal flag mask for kmem_cache_create(), for various configurations */
90859 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
90860 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
90861 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | \
90862 + SLAB_USERCOPY | SLAB_NO_SANITIZE)
90863
90864 #if defined(CONFIG_DEBUG_SLAB)
90865 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
90866 @@ -229,6 +239,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
90867 return s;
90868
90869 page = virt_to_head_page(x);
90870 +
90871 + BUG_ON(!PageSlab(page));
90872 +
90873 cachep = page->slab_cache;
90874 if (slab_equal_or_root(cachep, s))
90875 return cachep;
90876 diff --git a/mm/slab_common.c b/mm/slab_common.c
90877 index 2d41450..4efe6ee 100644
90878 --- a/mm/slab_common.c
90879 +++ b/mm/slab_common.c
90880 @@ -22,11 +22,22 @@
90881
90882 #include "slab.h"
90883
90884 -enum slab_state slab_state;
90885 +enum slab_state slab_state __read_only;
90886 LIST_HEAD(slab_caches);
90887 DEFINE_MUTEX(slab_mutex);
90888 struct kmem_cache *kmem_cache;
90889
90890 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90891 +bool pax_sanitize_slab __read_only = true;
90892 +static int __init pax_sanitize_slab_setup(char *str)
90893 +{
90894 + pax_sanitize_slab = !!simple_strtol(str, NULL, 0);
90895 + printk("%sabled PaX slab sanitization\n", pax_sanitize_slab ? "En" : "Dis");
90896 + return 1;
90897 +}
90898 +__setup("pax_sanitize_slab=", pax_sanitize_slab_setup);
90899 +#endif
90900 +
90901 #ifdef CONFIG_DEBUG_VM
90902 static int kmem_cache_sanity_check(struct mem_cgroup *memcg, const char *name,
90903 size_t size)
90904 @@ -209,7 +220,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
90905
90906 err = __kmem_cache_create(s, flags);
90907 if (!err) {
90908 - s->refcount = 1;
90909 + atomic_set(&s->refcount, 1);
90910 list_add(&s->list, &slab_caches);
90911 memcg_cache_list_add(memcg, s);
90912 } else {
90913 @@ -255,8 +266,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
90914
90915 get_online_cpus();
90916 mutex_lock(&slab_mutex);
90917 - s->refcount--;
90918 - if (!s->refcount) {
90919 + if (atomic_dec_and_test(&s->refcount)) {
90920 list_del(&s->list);
90921
90922 if (!__kmem_cache_shutdown(s)) {
90923 @@ -302,7 +312,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
90924 panic("Creation of kmalloc slab %s size=%zu failed. Reason %d\n",
90925 name, size, err);
90926
90927 - s->refcount = -1; /* Exempt from merging for now */
90928 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
90929 }
90930
90931 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
90932 @@ -315,7 +325,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
90933
90934 create_boot_cache(s, name, size, flags);
90935 list_add(&s->list, &slab_caches);
90936 - s->refcount = 1;
90937 + atomic_set(&s->refcount, 1);
90938 return s;
90939 }
90940
90941 @@ -327,6 +337,11 @@ struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
90942 EXPORT_SYMBOL(kmalloc_dma_caches);
90943 #endif
90944
90945 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90946 +struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
90947 +EXPORT_SYMBOL(kmalloc_usercopy_caches);
90948 +#endif
90949 +
90950 /*
90951 * Conversion table for small slabs sizes / 8 to the index in the
90952 * kmalloc array. This is necessary for slabs < 192 since we have non power
90953 @@ -391,6 +406,13 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
90954 return kmalloc_dma_caches[index];
90955
90956 #endif
90957 +
90958 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90959 + if (unlikely((flags & GFP_USERCOPY)))
90960 + return kmalloc_usercopy_caches[index];
90961 +
90962 +#endif
90963 +
90964 return kmalloc_caches[index];
90965 }
90966
90967 @@ -447,7 +469,7 @@ void __init create_kmalloc_caches(unsigned long flags)
90968 for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
90969 if (!kmalloc_caches[i]) {
90970 kmalloc_caches[i] = create_kmalloc_cache(NULL,
90971 - 1 << i, flags);
90972 + 1 << i, SLAB_USERCOPY | flags);
90973 }
90974
90975 /*
90976 @@ -456,10 +478,10 @@ void __init create_kmalloc_caches(unsigned long flags)
90977 * earlier power of two caches
90978 */
90979 if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1] && i == 6)
90980 - kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, flags);
90981 + kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, SLAB_USERCOPY | flags);
90982
90983 if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2] && i == 7)
90984 - kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, flags);
90985 + kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, SLAB_USERCOPY | flags);
90986 }
90987
90988 /* Kmalloc array is now usable */
90989 @@ -492,6 +514,23 @@ void __init create_kmalloc_caches(unsigned long flags)
90990 }
90991 }
90992 #endif
90993 +
90994 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90995 + for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) {
90996 + struct kmem_cache *s = kmalloc_caches[i];
90997 +
90998 + if (s) {
90999 + int size = kmalloc_size(i);
91000 + char *n = kasprintf(GFP_NOWAIT,
91001 + "usercopy-kmalloc-%d", size);
91002 +
91003 + BUG_ON(!n);
91004 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(n,
91005 + size, SLAB_USERCOPY | flags);
91006 + }
91007 + }
91008 +#endif
91009 +
91010 }
91011 #endif /* !CONFIG_SLOB */
91012
91013 @@ -516,6 +555,9 @@ void print_slabinfo_header(struct seq_file *m)
91014 seq_puts(m, " : globalstat <listallocs> <maxobjs> <grown> <reaped> "
91015 "<error> <maxfreeable> <nodeallocs> <remotefrees> <alienoverflow>");
91016 seq_puts(m, " : cpustat <allochit> <allocmiss> <freehit> <freemiss>");
91017 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91018 + seq_puts(m, " : pax <sanitized> <not_sanitized>");
91019 +#endif
91020 #endif
91021 seq_putc(m, '\n');
91022 }
91023 diff --git a/mm/slob.c b/mm/slob.c
91024 index eeed4a0..bb0e9ab 100644
91025 --- a/mm/slob.c
91026 +++ b/mm/slob.c
91027 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
91028 /*
91029 * Return the size of a slob block.
91030 */
91031 -static slobidx_t slob_units(slob_t *s)
91032 +static slobidx_t slob_units(const slob_t *s)
91033 {
91034 if (s->units > 0)
91035 return s->units;
91036 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
91037 /*
91038 * Return the next free slob block pointer after this one.
91039 */
91040 -static slob_t *slob_next(slob_t *s)
91041 +static slob_t *slob_next(const slob_t *s)
91042 {
91043 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
91044 slobidx_t next;
91045 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
91046 /*
91047 * Returns true if s is the last free block in its page.
91048 */
91049 -static int slob_last(slob_t *s)
91050 +static int slob_last(const slob_t *s)
91051 {
91052 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
91053 }
91054
91055 -static void *slob_new_pages(gfp_t gfp, int order, int node)
91056 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
91057 {
91058 - void *page;
91059 + struct page *page;
91060
91061 #ifdef CONFIG_NUMA
91062 if (node != NUMA_NO_NODE)
91063 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
91064 if (!page)
91065 return NULL;
91066
91067 - return page_address(page);
91068 + __SetPageSlab(page);
91069 + return page;
91070 }
91071
91072 -static void slob_free_pages(void *b, int order)
91073 +static void slob_free_pages(struct page *sp, int order)
91074 {
91075 if (current->reclaim_state)
91076 current->reclaim_state->reclaimed_slab += 1 << order;
91077 - free_pages((unsigned long)b, order);
91078 + __ClearPageSlab(sp);
91079 + page_mapcount_reset(sp);
91080 + sp->private = 0;
91081 + __free_pages(sp, order);
91082 }
91083
91084 /*
91085 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
91086
91087 /* Not enough space: must allocate a new page */
91088 if (!b) {
91089 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
91090 - if (!b)
91091 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
91092 + if (!sp)
91093 return NULL;
91094 - sp = virt_to_page(b);
91095 - __SetPageSlab(sp);
91096 + b = page_address(sp);
91097
91098 spin_lock_irqsave(&slob_lock, flags);
91099 sp->units = SLOB_UNITS(PAGE_SIZE);
91100 sp->freelist = b;
91101 + sp->private = 0;
91102 INIT_LIST_HEAD(&sp->list);
91103 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
91104 set_slob_page_free(sp, slob_list);
91105 @@ -359,12 +363,15 @@ static void slob_free(void *block, int size)
91106 if (slob_page_free(sp))
91107 clear_slob_page_free(sp);
91108 spin_unlock_irqrestore(&slob_lock, flags);
91109 - __ClearPageSlab(sp);
91110 - page_mapcount_reset(sp);
91111 - slob_free_pages(b, 0);
91112 + slob_free_pages(sp, 0);
91113 return;
91114 }
91115
91116 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91117 + if (pax_sanitize_slab)
91118 + memset(block, PAX_MEMORY_SANITIZE_VALUE, size);
91119 +#endif
91120 +
91121 if (!slob_page_free(sp)) {
91122 /* This slob page is about to become partially free. Easy! */
91123 sp->units = units;
91124 @@ -424,11 +431,10 @@ out:
91125 */
91126
91127 static __always_inline void *
91128 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
91129 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
91130 {
91131 - unsigned int *m;
91132 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
91133 - void *ret;
91134 + slob_t *m;
91135 + void *ret = NULL;
91136
91137 gfp &= gfp_allowed_mask;
91138
91139 @@ -442,23 +448,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
91140
91141 if (!m)
91142 return NULL;
91143 - *m = size;
91144 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
91145 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
91146 + m[0].units = size;
91147 + m[1].units = align;
91148 ret = (void *)m + align;
91149
91150 trace_kmalloc_node(caller, ret,
91151 size, size + align, gfp, node);
91152 } else {
91153 unsigned int order = get_order(size);
91154 + struct page *page;
91155
91156 if (likely(order))
91157 gfp |= __GFP_COMP;
91158 - ret = slob_new_pages(gfp, order, node);
91159 + page = slob_new_pages(gfp, order, node);
91160 + if (page) {
91161 + ret = page_address(page);
91162 + page->private = size;
91163 + }
91164
91165 trace_kmalloc_node(caller, ret,
91166 size, PAGE_SIZE << order, gfp, node);
91167 }
91168
91169 - kmemleak_alloc(ret, size, 1, gfp);
91170 + return ret;
91171 +}
91172 +
91173 +static __always_inline void *
91174 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
91175 +{
91176 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
91177 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
91178 +
91179 + if (!ZERO_OR_NULL_PTR(ret))
91180 + kmemleak_alloc(ret, size, 1, gfp);
91181 return ret;
91182 }
91183
91184 @@ -493,34 +517,112 @@ void kfree(const void *block)
91185 return;
91186 kmemleak_free(block);
91187
91188 + VM_BUG_ON(!virt_addr_valid(block));
91189 sp = virt_to_page(block);
91190 - if (PageSlab(sp)) {
91191 + VM_BUG_ON(!PageSlab(sp));
91192 + if (!sp->private) {
91193 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
91194 - unsigned int *m = (unsigned int *)(block - align);
91195 - slob_free(m, *m + align);
91196 - } else
91197 + slob_t *m = (slob_t *)(block - align);
91198 + slob_free(m, m[0].units + align);
91199 + } else {
91200 + __ClearPageSlab(sp);
91201 + page_mapcount_reset(sp);
91202 + sp->private = 0;
91203 __free_pages(sp, compound_order(sp));
91204 + }
91205 }
91206 EXPORT_SYMBOL(kfree);
91207
91208 +bool is_usercopy_object(const void *ptr)
91209 +{
91210 + if (!slab_is_available())
91211 + return false;
91212 +
91213 + // PAX: TODO
91214 +
91215 + return false;
91216 +}
91217 +
91218 +#ifdef CONFIG_PAX_USERCOPY
91219 +const char *check_heap_object(const void *ptr, unsigned long n)
91220 +{
91221 + struct page *page;
91222 + const slob_t *free;
91223 + const void *base;
91224 + unsigned long flags;
91225 +
91226 + if (ZERO_OR_NULL_PTR(ptr))
91227 + return "<null>";
91228 +
91229 + if (!virt_addr_valid(ptr))
91230 + return NULL;
91231 +
91232 + page = virt_to_head_page(ptr);
91233 + if (!PageSlab(page))
91234 + return NULL;
91235 +
91236 + if (page->private) {
91237 + base = page;
91238 + if (base <= ptr && n <= page->private - (ptr - base))
91239 + return NULL;
91240 + return "<slob>";
91241 + }
91242 +
91243 + /* some tricky double walking to find the chunk */
91244 + spin_lock_irqsave(&slob_lock, flags);
91245 + base = (void *)((unsigned long)ptr & PAGE_MASK);
91246 + free = page->freelist;
91247 +
91248 + while (!slob_last(free) && (void *)free <= ptr) {
91249 + base = free + slob_units(free);
91250 + free = slob_next(free);
91251 + }
91252 +
91253 + while (base < (void *)free) {
91254 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
91255 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
91256 + int offset;
91257 +
91258 + if (ptr < base + align)
91259 + break;
91260 +
91261 + offset = ptr - base - align;
91262 + if (offset >= m) {
91263 + base += size;
91264 + continue;
91265 + }
91266 +
91267 + if (n > m - offset)
91268 + break;
91269 +
91270 + spin_unlock_irqrestore(&slob_lock, flags);
91271 + return NULL;
91272 + }
91273 +
91274 + spin_unlock_irqrestore(&slob_lock, flags);
91275 + return "<slob>";
91276 +}
91277 +#endif
91278 +
91279 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
91280 size_t ksize(const void *block)
91281 {
91282 struct page *sp;
91283 int align;
91284 - unsigned int *m;
91285 + slob_t *m;
91286
91287 BUG_ON(!block);
91288 if (unlikely(block == ZERO_SIZE_PTR))
91289 return 0;
91290
91291 sp = virt_to_page(block);
91292 - if (unlikely(!PageSlab(sp)))
91293 - return PAGE_SIZE << compound_order(sp);
91294 + VM_BUG_ON(!PageSlab(sp));
91295 + if (sp->private)
91296 + return sp->private;
91297
91298 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
91299 - m = (unsigned int *)(block - align);
91300 - return SLOB_UNITS(*m) * SLOB_UNIT;
91301 + m = (slob_t *)(block - align);
91302 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
91303 }
91304 EXPORT_SYMBOL(ksize);
91305
91306 @@ -536,23 +638,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
91307
91308 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
91309 {
91310 - void *b;
91311 + void *b = NULL;
91312
91313 flags &= gfp_allowed_mask;
91314
91315 lockdep_trace_alloc(flags);
91316
91317 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91318 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
91319 +#else
91320 if (c->size < PAGE_SIZE) {
91321 b = slob_alloc(c->size, flags, c->align, node);
91322 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
91323 SLOB_UNITS(c->size) * SLOB_UNIT,
91324 flags, node);
91325 } else {
91326 - b = slob_new_pages(flags, get_order(c->size), node);
91327 + struct page *sp;
91328 +
91329 + sp = slob_new_pages(flags, get_order(c->size), node);
91330 + if (sp) {
91331 + b = page_address(sp);
91332 + sp->private = c->size;
91333 + }
91334 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
91335 PAGE_SIZE << get_order(c->size),
91336 flags, node);
91337 }
91338 +#endif
91339
91340 if (c->ctor)
91341 c->ctor(b);
91342 @@ -564,10 +676,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
91343
91344 static void __kmem_cache_free(void *b, int size)
91345 {
91346 - if (size < PAGE_SIZE)
91347 + struct page *sp;
91348 +
91349 + sp = virt_to_page(b);
91350 + BUG_ON(!PageSlab(sp));
91351 + if (!sp->private)
91352 slob_free(b, size);
91353 else
91354 - slob_free_pages(b, get_order(size));
91355 + slob_free_pages(sp, get_order(size));
91356 }
91357
91358 static void kmem_rcu_free(struct rcu_head *head)
91359 @@ -580,17 +696,31 @@ static void kmem_rcu_free(struct rcu_head *head)
91360
91361 void kmem_cache_free(struct kmem_cache *c, void *b)
91362 {
91363 + int size = c->size;
91364 +
91365 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91366 + if (size + c->align < PAGE_SIZE) {
91367 + size += c->align;
91368 + b -= c->align;
91369 + }
91370 +#endif
91371 +
91372 kmemleak_free_recursive(b, c->flags);
91373 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
91374 struct slob_rcu *slob_rcu;
91375 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
91376 - slob_rcu->size = c->size;
91377 + slob_rcu = b + (size - sizeof(struct slob_rcu));
91378 + slob_rcu->size = size;
91379 call_rcu(&slob_rcu->head, kmem_rcu_free);
91380 } else {
91381 - __kmem_cache_free(b, c->size);
91382 + __kmem_cache_free(b, size);
91383 }
91384
91385 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91386 + trace_kfree(_RET_IP_, b);
91387 +#else
91388 trace_kmem_cache_free(_RET_IP_, b);
91389 +#endif
91390 +
91391 }
91392 EXPORT_SYMBOL(kmem_cache_free);
91393
91394 diff --git a/mm/slub.c b/mm/slub.c
91395 index 57707f0..7857bd3 100644
91396 --- a/mm/slub.c
91397 +++ b/mm/slub.c
91398 @@ -198,7 +198,7 @@ struct track {
91399
91400 enum track_item { TRACK_ALLOC, TRACK_FREE };
91401
91402 -#ifdef CONFIG_SYSFS
91403 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
91404 static int sysfs_slab_add(struct kmem_cache *);
91405 static int sysfs_slab_alias(struct kmem_cache *, const char *);
91406 static void sysfs_slab_remove(struct kmem_cache *);
91407 @@ -519,7 +519,7 @@ static void print_track(const char *s, struct track *t)
91408 if (!t->addr)
91409 return;
91410
91411 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
91412 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
91413 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
91414 #ifdef CONFIG_STACKTRACE
91415 {
91416 @@ -2594,6 +2594,14 @@ static __always_inline void slab_free(struct kmem_cache *s,
91417
91418 slab_free_hook(s, x);
91419
91420 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91421 + if (pax_sanitize_slab && !(s->flags & SLAB_NO_SANITIZE)) {
91422 + memset(x, PAX_MEMORY_SANITIZE_VALUE, s->object_size);
91423 + if (s->ctor)
91424 + s->ctor(x);
91425 + }
91426 +#endif
91427 +
91428 redo:
91429 /*
91430 * Determine the currently cpus per cpu slab.
91431 @@ -2661,7 +2669,7 @@ static int slub_min_objects;
91432 * Merge control. If this is set then no merging of slab caches will occur.
91433 * (Could be removed. This was introduced to pacify the merge skeptics.)
91434 */
91435 -static int slub_nomerge;
91436 +static int slub_nomerge = 1;
91437
91438 /*
91439 * Calculate the order of allocation given an slab object size.
91440 @@ -2938,6 +2946,9 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)
91441 s->inuse = size;
91442
91443 if (((flags & (SLAB_DESTROY_BY_RCU | SLAB_POISON)) ||
91444 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91445 + (pax_sanitize_slab && !(flags & SLAB_NO_SANITIZE)) ||
91446 +#endif
91447 s->ctor)) {
91448 /*
91449 * Relocate free pointer after the object if it is not
91450 @@ -3283,6 +3294,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
91451 EXPORT_SYMBOL(__kmalloc_node);
91452 #endif
91453
91454 +bool is_usercopy_object(const void *ptr)
91455 +{
91456 + struct page *page;
91457 + struct kmem_cache *s;
91458 +
91459 + if (ZERO_OR_NULL_PTR(ptr))
91460 + return false;
91461 +
91462 + if (!slab_is_available())
91463 + return false;
91464 +
91465 + if (!virt_addr_valid(ptr))
91466 + return false;
91467 +
91468 + page = virt_to_head_page(ptr);
91469 +
91470 + if (!PageSlab(page))
91471 + return false;
91472 +
91473 + s = page->slab_cache;
91474 + return s->flags & SLAB_USERCOPY;
91475 +}
91476 +
91477 +#ifdef CONFIG_PAX_USERCOPY
91478 +const char *check_heap_object(const void *ptr, unsigned long n)
91479 +{
91480 + struct page *page;
91481 + struct kmem_cache *s;
91482 + unsigned long offset;
91483 +
91484 + if (ZERO_OR_NULL_PTR(ptr))
91485 + return "<null>";
91486 +
91487 + if (!virt_addr_valid(ptr))
91488 + return NULL;
91489 +
91490 + page = virt_to_head_page(ptr);
91491 +
91492 + if (!PageSlab(page))
91493 + return NULL;
91494 +
91495 + s = page->slab_cache;
91496 + if (!(s->flags & SLAB_USERCOPY))
91497 + return s->name;
91498 +
91499 + offset = (ptr - page_address(page)) % s->size;
91500 + if (offset <= s->object_size && n <= s->object_size - offset)
91501 + return NULL;
91502 +
91503 + return s->name;
91504 +}
91505 +#endif
91506 +
91507 size_t ksize(const void *object)
91508 {
91509 struct page *page;
91510 @@ -3347,6 +3411,7 @@ void kfree(const void *x)
91511 if (unlikely(ZERO_OR_NULL_PTR(x)))
91512 return;
91513
91514 + VM_BUG_ON(!virt_addr_valid(x));
91515 page = virt_to_head_page(x);
91516 if (unlikely(!PageSlab(page))) {
91517 BUG_ON(!PageCompound(page));
91518 @@ -3652,7 +3717,7 @@ static int slab_unmergeable(struct kmem_cache *s)
91519 /*
91520 * We may have set a slab to be unmergeable during bootstrap.
91521 */
91522 - if (s->refcount < 0)
91523 + if (atomic_read(&s->refcount) < 0)
91524 return 1;
91525
91526 return 0;
91527 @@ -3710,7 +3775,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
91528
91529 s = find_mergeable(memcg, size, align, flags, name, ctor);
91530 if (s) {
91531 - s->refcount++;
91532 + atomic_inc(&s->refcount);
91533 /*
91534 * Adjust the object sizes so that we clear
91535 * the complete object on kzalloc.
91536 @@ -3719,7 +3784,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
91537 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
91538
91539 if (sysfs_slab_alias(s, name)) {
91540 - s->refcount--;
91541 + atomic_dec(&s->refcount);
91542 s = NULL;
91543 }
91544 }
91545 @@ -3781,7 +3846,7 @@ static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb,
91546 return NOTIFY_OK;
91547 }
91548
91549 -static struct notifier_block __cpuinitdata slab_notifier = {
91550 +static struct notifier_block slab_notifier = {
91551 .notifier_call = slab_cpuup_callback
91552 };
91553
91554 @@ -3839,7 +3904,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
91555 }
91556 #endif
91557
91558 -#ifdef CONFIG_SYSFS
91559 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
91560 static int count_inuse(struct page *page)
91561 {
91562 return page->inuse;
91563 @@ -4226,12 +4291,12 @@ static void resiliency_test(void)
91564 validate_slab_cache(kmalloc_caches[9]);
91565 }
91566 #else
91567 -#ifdef CONFIG_SYSFS
91568 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
91569 static void resiliency_test(void) {};
91570 #endif
91571 #endif
91572
91573 -#ifdef CONFIG_SYSFS
91574 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
91575 enum slab_stat_type {
91576 SL_ALL, /* All slabs */
91577 SL_PARTIAL, /* Only partially allocated slabs */
91578 @@ -4475,7 +4540,7 @@ SLAB_ATTR_RO(ctor);
91579
91580 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
91581 {
91582 - return sprintf(buf, "%d\n", s->refcount - 1);
91583 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
91584 }
91585 SLAB_ATTR_RO(aliases);
91586
91587 @@ -4563,6 +4628,14 @@ static ssize_t cache_dma_show(struct kmem_cache *s, char *buf)
91588 SLAB_ATTR_RO(cache_dma);
91589 #endif
91590
91591 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91592 +static ssize_t usercopy_show(struct kmem_cache *s, char *buf)
91593 +{
91594 + return sprintf(buf, "%d\n", !!(s->flags & SLAB_USERCOPY));
91595 +}
91596 +SLAB_ATTR_RO(usercopy);
91597 +#endif
91598 +
91599 static ssize_t destroy_by_rcu_show(struct kmem_cache *s, char *buf)
91600 {
91601 return sprintf(buf, "%d\n", !!(s->flags & SLAB_DESTROY_BY_RCU));
91602 @@ -4897,6 +4970,9 @@ static struct attribute *slab_attrs[] = {
91603 #ifdef CONFIG_ZONE_DMA
91604 &cache_dma_attr.attr,
91605 #endif
91606 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91607 + &usercopy_attr.attr,
91608 +#endif
91609 #ifdef CONFIG_NUMA
91610 &remote_node_defrag_ratio_attr.attr,
91611 #endif
91612 @@ -5128,6 +5204,7 @@ static char *create_unique_id(struct kmem_cache *s)
91613 return name;
91614 }
91615
91616 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
91617 static int sysfs_slab_add(struct kmem_cache *s)
91618 {
91619 int err;
91620 @@ -5151,7 +5228,7 @@ static int sysfs_slab_add(struct kmem_cache *s)
91621 }
91622
91623 s->kobj.kset = slab_kset;
91624 - err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, name);
91625 + err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name);
91626 if (err) {
91627 kobject_put(&s->kobj);
91628 return err;
91629 @@ -5185,6 +5262,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
91630 kobject_del(&s->kobj);
91631 kobject_put(&s->kobj);
91632 }
91633 +#endif
91634
91635 /*
91636 * Need to buffer aliases during bootup until sysfs becomes
91637 @@ -5198,6 +5276,7 @@ struct saved_alias {
91638
91639 static struct saved_alias *alias_list;
91640
91641 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
91642 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
91643 {
91644 struct saved_alias *al;
91645 @@ -5220,6 +5299,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
91646 alias_list = al;
91647 return 0;
91648 }
91649 +#endif
91650
91651 static int __init slab_sysfs_init(void)
91652 {
91653 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
91654 index 27eeab3..7c3f7f2 100644
91655 --- a/mm/sparse-vmemmap.c
91656 +++ b/mm/sparse-vmemmap.c
91657 @@ -130,7 +130,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
91658 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
91659 if (!p)
91660 return NULL;
91661 - pud_populate(&init_mm, pud, p);
91662 + pud_populate_kernel(&init_mm, pud, p);
91663 }
91664 return pud;
91665 }
91666 @@ -142,7 +142,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
91667 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
91668 if (!p)
91669 return NULL;
91670 - pgd_populate(&init_mm, pgd, p);
91671 + pgd_populate_kernel(&init_mm, pgd, p);
91672 }
91673 return pgd;
91674 }
91675 diff --git a/mm/sparse.c b/mm/sparse.c
91676 index 1c91f0d3..485470a 100644
91677 --- a/mm/sparse.c
91678 +++ b/mm/sparse.c
91679 @@ -761,7 +761,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
91680
91681 for (i = 0; i < PAGES_PER_SECTION; i++) {
91682 if (PageHWPoison(&memmap[i])) {
91683 - atomic_long_sub(1, &num_poisoned_pages);
91684 + atomic_long_sub_unchecked(1, &num_poisoned_pages);
91685 ClearPageHWPoison(&memmap[i]);
91686 }
91687 }
91688 diff --git a/mm/swap.c b/mm/swap.c
91689 index dfd7d71..ccdf688 100644
91690 --- a/mm/swap.c
91691 +++ b/mm/swap.c
91692 @@ -31,6 +31,7 @@
91693 #include <linux/memcontrol.h>
91694 #include <linux/gfp.h>
91695 #include <linux/uio.h>
91696 +#include <linux/hugetlb.h>
91697
91698 #include "internal.h"
91699
91700 @@ -73,6 +74,8 @@ static void __put_compound_page(struct page *page)
91701
91702 __page_cache_release(page);
91703 dtor = get_compound_page_dtor(page);
91704 + if (!PageHuge(page))
91705 + BUG_ON(dtor != free_compound_page);
91706 (*dtor)(page);
91707 }
91708
91709 diff --git a/mm/swapfile.c b/mm/swapfile.c
91710 index 746af55b..7ac94ae 100644
91711 --- a/mm/swapfile.c
91712 +++ b/mm/swapfile.c
91713 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(swapon_mutex);
91714
91715 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
91716 /* Activity counter to indicate that a swapon or swapoff has occurred */
91717 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
91718 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
91719
91720 static inline unsigned char swap_count(unsigned char ent)
91721 {
91722 @@ -1684,7 +1684,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
91723 }
91724 filp_close(swap_file, NULL);
91725 err = 0;
91726 - atomic_inc(&proc_poll_event);
91727 + atomic_inc_unchecked(&proc_poll_event);
91728 wake_up_interruptible(&proc_poll_wait);
91729
91730 out_dput:
91731 @@ -1701,8 +1701,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
91732
91733 poll_wait(file, &proc_poll_wait, wait);
91734
91735 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
91736 - seq->poll_event = atomic_read(&proc_poll_event);
91737 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
91738 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
91739 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
91740 }
91741
91742 @@ -1800,7 +1800,7 @@ static int swaps_open(struct inode *inode, struct file *file)
91743 return ret;
91744
91745 seq = file->private_data;
91746 - seq->poll_event = atomic_read(&proc_poll_event);
91747 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
91748 return 0;
91749 }
91750
91751 @@ -2143,7 +2143,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
91752 (frontswap_map) ? "FS" : "");
91753
91754 mutex_unlock(&swapon_mutex);
91755 - atomic_inc(&proc_poll_event);
91756 + atomic_inc_unchecked(&proc_poll_event);
91757 wake_up_interruptible(&proc_poll_wait);
91758
91759 if (S_ISREG(inode->i_mode))
91760 diff --git a/mm/util.c b/mm/util.c
91761 index ab1424d..7c5bd5a 100644
91762 --- a/mm/util.c
91763 +++ b/mm/util.c
91764 @@ -294,6 +294,12 @@ done:
91765 void arch_pick_mmap_layout(struct mm_struct *mm)
91766 {
91767 mm->mmap_base = TASK_UNMAPPED_BASE;
91768 +
91769 +#ifdef CONFIG_PAX_RANDMMAP
91770 + if (mm->pax_flags & MF_PAX_RANDMMAP)
91771 + mm->mmap_base += mm->delta_mmap;
91772 +#endif
91773 +
91774 mm->get_unmapped_area = arch_get_unmapped_area;
91775 mm->unmap_area = arch_unmap_area;
91776 }
91777 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
91778 index d365724..6cae7c2 100644
91779 --- a/mm/vmalloc.c
91780 +++ b/mm/vmalloc.c
91781 @@ -59,8 +59,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
91782
91783 pte = pte_offset_kernel(pmd, addr);
91784 do {
91785 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
91786 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
91787 +
91788 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
91789 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
91790 + BUG_ON(!pte_exec(*pte));
91791 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
91792 + continue;
91793 + }
91794 +#endif
91795 +
91796 + {
91797 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
91798 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
91799 + }
91800 } while (pte++, addr += PAGE_SIZE, addr != end);
91801 }
91802
91803 @@ -120,16 +131,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
91804 pte = pte_alloc_kernel(pmd, addr);
91805 if (!pte)
91806 return -ENOMEM;
91807 +
91808 + pax_open_kernel();
91809 do {
91810 struct page *page = pages[*nr];
91811
91812 - if (WARN_ON(!pte_none(*pte)))
91813 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
91814 + if (pgprot_val(prot) & _PAGE_NX)
91815 +#endif
91816 +
91817 + if (!pte_none(*pte)) {
91818 + pax_close_kernel();
91819 + WARN_ON(1);
91820 return -EBUSY;
91821 - if (WARN_ON(!page))
91822 + }
91823 + if (!page) {
91824 + pax_close_kernel();
91825 + WARN_ON(1);
91826 return -ENOMEM;
91827 + }
91828 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
91829 (*nr)++;
91830 } while (pte++, addr += PAGE_SIZE, addr != end);
91831 + pax_close_kernel();
91832 return 0;
91833 }
91834
91835 @@ -139,7 +163,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
91836 pmd_t *pmd;
91837 unsigned long next;
91838
91839 - pmd = pmd_alloc(&init_mm, pud, addr);
91840 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
91841 if (!pmd)
91842 return -ENOMEM;
91843 do {
91844 @@ -156,7 +180,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
91845 pud_t *pud;
91846 unsigned long next;
91847
91848 - pud = pud_alloc(&init_mm, pgd, addr);
91849 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
91850 if (!pud)
91851 return -ENOMEM;
91852 do {
91853 @@ -216,6 +240,12 @@ int is_vmalloc_or_module_addr(const void *x)
91854 if (addr >= MODULES_VADDR && addr < MODULES_END)
91855 return 1;
91856 #endif
91857 +
91858 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
91859 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
91860 + return 1;
91861 +#endif
91862 +
91863 return is_vmalloc_addr(x);
91864 }
91865
91866 @@ -236,8 +266,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
91867
91868 if (!pgd_none(*pgd)) {
91869 pud_t *pud = pud_offset(pgd, addr);
91870 +#ifdef CONFIG_X86
91871 + if (!pud_large(*pud))
91872 +#endif
91873 if (!pud_none(*pud)) {
91874 pmd_t *pmd = pmd_offset(pud, addr);
91875 +#ifdef CONFIG_X86
91876 + if (!pmd_large(*pmd))
91877 +#endif
91878 if (!pmd_none(*pmd)) {
91879 pte_t *ptep, pte;
91880
91881 @@ -339,7 +375,7 @@ static void purge_vmap_area_lazy(void);
91882 * Allocate a region of KVA of the specified size and alignment, within the
91883 * vstart and vend.
91884 */
91885 -static struct vmap_area *alloc_vmap_area(unsigned long size,
91886 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
91887 unsigned long align,
91888 unsigned long vstart, unsigned long vend,
91889 int node, gfp_t gfp_mask)
91890 @@ -1337,6 +1373,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
91891 struct vm_struct *area;
91892
91893 BUG_ON(in_interrupt());
91894 +
91895 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
91896 + if (flags & VM_KERNEXEC) {
91897 + if (start != VMALLOC_START || end != VMALLOC_END)
91898 + return NULL;
91899 + start = (unsigned long)MODULES_EXEC_VADDR;
91900 + end = (unsigned long)MODULES_EXEC_END;
91901 + }
91902 +#endif
91903 +
91904 if (flags & VM_IOREMAP) {
91905 int bit = fls(size);
91906
91907 @@ -1581,6 +1627,11 @@ void *vmap(struct page **pages, unsigned int count,
91908 if (count > totalram_pages)
91909 return NULL;
91910
91911 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
91912 + if (!(pgprot_val(prot) & _PAGE_NX))
91913 + flags |= VM_KERNEXEC;
91914 +#endif
91915 +
91916 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
91917 __builtin_return_address(0));
91918 if (!area)
91919 @@ -1682,6 +1733,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
91920 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
91921 goto fail;
91922
91923 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
91924 + if (!(pgprot_val(prot) & _PAGE_NX))
91925 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST | VM_KERNEXEC,
91926 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
91927 + else
91928 +#endif
91929 +
91930 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST,
91931 start, end, node, gfp_mask, caller);
91932 if (!area)
91933 @@ -1858,10 +1916,9 @@ EXPORT_SYMBOL(vzalloc_node);
91934 * For tight control over page level allocator and protection flags
91935 * use __vmalloc() instead.
91936 */
91937 -
91938 void *vmalloc_exec(unsigned long size)
91939 {
91940 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
91941 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
91942 NUMA_NO_NODE, __builtin_return_address(0));
91943 }
91944
91945 @@ -2168,6 +2225,8 @@ int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
91946 unsigned long uaddr = vma->vm_start;
91947 unsigned long usize = vma->vm_end - vma->vm_start;
91948
91949 + BUG_ON(vma->vm_mirror);
91950 +
91951 if ((PAGE_SIZE-1) & (unsigned long)addr)
91952 return -EINVAL;
91953
91954 @@ -2629,7 +2688,11 @@ static int s_show(struct seq_file *m, void *p)
91955 v->addr, v->addr + v->size, v->size);
91956
91957 if (v->caller)
91958 +#ifdef CONFIG_GRKERNSEC_HIDESYM
91959 + seq_printf(m, " %pK", v->caller);
91960 +#else
91961 seq_printf(m, " %pS", v->caller);
91962 +#endif
91963
91964 if (v->nr_pages)
91965 seq_printf(m, " pages=%d", v->nr_pages);
91966 diff --git a/mm/vmstat.c b/mm/vmstat.c
91967 index f42745e..62f8346 100644
91968 --- a/mm/vmstat.c
91969 +++ b/mm/vmstat.c
91970 @@ -76,7 +76,7 @@ void vm_events_fold_cpu(int cpu)
91971 *
91972 * vm_stat contains the global counters
91973 */
91974 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
91975 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
91976 EXPORT_SYMBOL(vm_stat);
91977
91978 #ifdef CONFIG_SMP
91979 @@ -452,7 +452,7 @@ void refresh_cpu_vm_stats(int cpu)
91980 v = p->vm_stat_diff[i];
91981 p->vm_stat_diff[i] = 0;
91982 local_irq_restore(flags);
91983 - atomic_long_add(v, &zone->vm_stat[i]);
91984 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
91985 global_diff[i] += v;
91986 #ifdef CONFIG_NUMA
91987 /* 3 seconds idle till flush */
91988 @@ -490,7 +490,7 @@ void refresh_cpu_vm_stats(int cpu)
91989
91990 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
91991 if (global_diff[i])
91992 - atomic_long_add(global_diff[i], &vm_stat[i]);
91993 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
91994 }
91995
91996 /*
91997 @@ -505,8 +505,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
91998 if (pset->vm_stat_diff[i]) {
91999 int v = pset->vm_stat_diff[i];
92000 pset->vm_stat_diff[i] = 0;
92001 - atomic_long_add(v, &zone->vm_stat[i]);
92002 - atomic_long_add(v, &vm_stat[i]);
92003 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
92004 + atomic_long_add_unchecked(v, &vm_stat[i]);
92005 }
92006 }
92007 #endif
92008 @@ -1226,7 +1226,7 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb,
92009 return NOTIFY_OK;
92010 }
92011
92012 -static struct notifier_block __cpuinitdata vmstat_notifier =
92013 +static struct notifier_block vmstat_notifier =
92014 { &vmstat_cpuup_callback, NULL, 0 };
92015 #endif
92016
92017 @@ -1241,10 +1241,20 @@ static int __init setup_vmstat(void)
92018 start_cpu_timer(cpu);
92019 #endif
92020 #ifdef CONFIG_PROC_FS
92021 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
92022 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
92023 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
92024 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
92025 + {
92026 + mode_t gr_mode = S_IRUGO;
92027 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
92028 + gr_mode = S_IRUSR;
92029 +#endif
92030 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
92031 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
92032 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
92033 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
92034 +#else
92035 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
92036 +#endif
92037 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
92038 + }
92039 #endif
92040 return 0;
92041 }
92042 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
92043 index 9424f37..6aabf19 100644
92044 --- a/net/8021q/vlan.c
92045 +++ b/net/8021q/vlan.c
92046 @@ -469,7 +469,7 @@ out:
92047 return NOTIFY_DONE;
92048 }
92049
92050 -static struct notifier_block vlan_notifier_block __read_mostly = {
92051 +static struct notifier_block vlan_notifier_block = {
92052 .notifier_call = vlan_device_event,
92053 };
92054
92055 @@ -544,8 +544,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
92056 err = -EPERM;
92057 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
92058 break;
92059 - if ((args.u.name_type >= 0) &&
92060 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
92061 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
92062 struct vlan_net *vn;
92063
92064 vn = net_generic(net, vlan_net_id);
92065 diff --git a/net/9p/mod.c b/net/9p/mod.c
92066 index 6ab36ae..6f1841b 100644
92067 --- a/net/9p/mod.c
92068 +++ b/net/9p/mod.c
92069 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
92070 void v9fs_register_trans(struct p9_trans_module *m)
92071 {
92072 spin_lock(&v9fs_trans_lock);
92073 - list_add_tail(&m->list, &v9fs_trans_list);
92074 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
92075 spin_unlock(&v9fs_trans_lock);
92076 }
92077 EXPORT_SYMBOL(v9fs_register_trans);
92078 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
92079 void v9fs_unregister_trans(struct p9_trans_module *m)
92080 {
92081 spin_lock(&v9fs_trans_lock);
92082 - list_del_init(&m->list);
92083 + pax_list_del_init((struct list_head *)&m->list);
92084 spin_unlock(&v9fs_trans_lock);
92085 }
92086 EXPORT_SYMBOL(v9fs_unregister_trans);
92087 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
92088 index 02efb25..41541a9 100644
92089 --- a/net/9p/trans_fd.c
92090 +++ b/net/9p/trans_fd.c
92091 @@ -425,7 +425,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
92092 oldfs = get_fs();
92093 set_fs(get_ds());
92094 /* The cast to a user pointer is valid due to the set_fs() */
92095 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
92096 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
92097 set_fs(oldfs);
92098
92099 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
92100 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
92101 index 876fbe8..8bbea9f 100644
92102 --- a/net/atm/atm_misc.c
92103 +++ b/net/atm/atm_misc.c
92104 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
92105 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
92106 return 1;
92107 atm_return(vcc, truesize);
92108 - atomic_inc(&vcc->stats->rx_drop);
92109 + atomic_inc_unchecked(&vcc->stats->rx_drop);
92110 return 0;
92111 }
92112 EXPORT_SYMBOL(atm_charge);
92113 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
92114 }
92115 }
92116 atm_return(vcc, guess);
92117 - atomic_inc(&vcc->stats->rx_drop);
92118 + atomic_inc_unchecked(&vcc->stats->rx_drop);
92119 return NULL;
92120 }
92121 EXPORT_SYMBOL(atm_alloc_charge);
92122 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
92123
92124 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
92125 {
92126 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
92127 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
92128 __SONET_ITEMS
92129 #undef __HANDLE_ITEM
92130 }
92131 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
92132
92133 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
92134 {
92135 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
92136 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
92137 __SONET_ITEMS
92138 #undef __HANDLE_ITEM
92139 }
92140 diff --git a/net/atm/lec.h b/net/atm/lec.h
92141 index 4149db1..f2ab682 100644
92142 --- a/net/atm/lec.h
92143 +++ b/net/atm/lec.h
92144 @@ -48,7 +48,7 @@ struct lane2_ops {
92145 const u8 *tlvs, u32 sizeoftlvs);
92146 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
92147 const u8 *tlvs, u32 sizeoftlvs);
92148 -};
92149 +} __no_const;
92150
92151 /*
92152 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
92153 diff --git a/net/atm/proc.c b/net/atm/proc.c
92154 index bbb6461..cf04016 100644
92155 --- a/net/atm/proc.c
92156 +++ b/net/atm/proc.c
92157 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
92158 const struct k_atm_aal_stats *stats)
92159 {
92160 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
92161 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
92162 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
92163 - atomic_read(&stats->rx_drop));
92164 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
92165 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
92166 + atomic_read_unchecked(&stats->rx_drop));
92167 }
92168
92169 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
92170 diff --git a/net/atm/resources.c b/net/atm/resources.c
92171 index 0447d5d..3cf4728 100644
92172 --- a/net/atm/resources.c
92173 +++ b/net/atm/resources.c
92174 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
92175 static void copy_aal_stats(struct k_atm_aal_stats *from,
92176 struct atm_aal_stats *to)
92177 {
92178 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
92179 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
92180 __AAL_STAT_ITEMS
92181 #undef __HANDLE_ITEM
92182 }
92183 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
92184 static void subtract_aal_stats(struct k_atm_aal_stats *from,
92185 struct atm_aal_stats *to)
92186 {
92187 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
92188 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
92189 __AAL_STAT_ITEMS
92190 #undef __HANDLE_ITEM
92191 }
92192 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
92193 index d5744b7..506bae3 100644
92194 --- a/net/ax25/sysctl_net_ax25.c
92195 +++ b/net/ax25/sysctl_net_ax25.c
92196 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
92197 {
92198 char path[sizeof("net/ax25/") + IFNAMSIZ];
92199 int k;
92200 - struct ctl_table *table;
92201 + ctl_table_no_const *table;
92202
92203 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
92204 if (!table)
92205 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
92206 index f680ee1..97e3542 100644
92207 --- a/net/batman-adv/bat_iv_ogm.c
92208 +++ b/net/batman-adv/bat_iv_ogm.c
92209 @@ -79,7 +79,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
92210
92211 /* randomize initial seqno to avoid collision */
92212 get_random_bytes(&random_seqno, sizeof(random_seqno));
92213 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
92214 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
92215
92216 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
92217 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
92218 @@ -627,9 +627,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
92219 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
92220
92221 /* change sequence number to network order */
92222 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
92223 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
92224 batadv_ogm_packet->seqno = htonl(seqno);
92225 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
92226 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
92227
92228 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
92229 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
92230 @@ -1037,7 +1037,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
92231 return;
92232
92233 /* could be changed by schedule_own_packet() */
92234 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
92235 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
92236
92237 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
92238 has_directlink_flag = 1;
92239 diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
92240 index de27b31..7058bfe 100644
92241 --- a/net/batman-adv/bridge_loop_avoidance.c
92242 +++ b/net/batman-adv/bridge_loop_avoidance.c
92243 @@ -1522,6 +1522,8 @@ out:
92244 * in these cases, the skb is further handled by this function and
92245 * returns 1, otherwise it returns 0 and the caller shall further
92246 * process the skb.
92247 + *
92248 + * This call might reallocate skb data.
92249 */
92250 int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid)
92251 {
92252 diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c
92253 index f105219..7614af3 100644
92254 --- a/net/batman-adv/gateway_client.c
92255 +++ b/net/batman-adv/gateway_client.c
92256 @@ -508,6 +508,7 @@ out:
92257 return 0;
92258 }
92259
92260 +/* this call might reallocate skb data */
92261 static bool batadv_is_type_dhcprequest(struct sk_buff *skb, int header_len)
92262 {
92263 int ret = false;
92264 @@ -568,6 +569,7 @@ out:
92265 return ret;
92266 }
92267
92268 +/* this call might reallocate skb data */
92269 bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len)
92270 {
92271 struct ethhdr *ethhdr;
92272 @@ -619,6 +621,12 @@ bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len)
92273
92274 if (!pskb_may_pull(skb, *header_len + sizeof(*udphdr)))
92275 return false;
92276 +
92277 + /* skb->data might have been reallocated by pskb_may_pull() */
92278 + ethhdr = (struct ethhdr *)skb->data;
92279 + if (ntohs(ethhdr->h_proto) == ETH_P_8021Q)
92280 + ethhdr = (struct ethhdr *)(skb->data + VLAN_HLEN);
92281 +
92282 udphdr = (struct udphdr *)(skb->data + *header_len);
92283 *header_len += sizeof(*udphdr);
92284
92285 @@ -634,12 +642,14 @@ bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len)
92286 return true;
92287 }
92288
92289 +/* this call might reallocate skb data */
92290 bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,
92291 - struct sk_buff *skb, struct ethhdr *ethhdr)
92292 + struct sk_buff *skb)
92293 {
92294 struct batadv_neigh_node *neigh_curr = NULL, *neigh_old = NULL;
92295 struct batadv_orig_node *orig_dst_node = NULL;
92296 struct batadv_gw_node *curr_gw = NULL;
92297 + struct ethhdr *ethhdr;
92298 bool ret, out_of_range = false;
92299 unsigned int header_len = 0;
92300 uint8_t curr_tq_avg;
92301 @@ -648,6 +658,7 @@ bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,
92302 if (!ret)
92303 goto out;
92304
92305 + ethhdr = (struct ethhdr *)skb->data;
92306 orig_dst_node = batadv_transtable_search(bat_priv, ethhdr->h_source,
92307 ethhdr->h_dest);
92308 if (!orig_dst_node)
92309 diff --git a/net/batman-adv/gateway_client.h b/net/batman-adv/gateway_client.h
92310 index 039902d..1037d75 100644
92311 --- a/net/batman-adv/gateway_client.h
92312 +++ b/net/batman-adv/gateway_client.h
92313 @@ -34,7 +34,6 @@ void batadv_gw_node_delete(struct batadv_priv *bat_priv,
92314 void batadv_gw_node_purge(struct batadv_priv *bat_priv);
92315 int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset);
92316 bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len);
92317 -bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,
92318 - struct sk_buff *skb, struct ethhdr *ethhdr);
92319 +bool batadv_gw_out_of_range(struct batadv_priv *bat_priv, struct sk_buff *skb);
92320
92321 #endif /* _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ */
92322 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
92323 index 522243a..b48c0ef 100644
92324 --- a/net/batman-adv/hard-interface.c
92325 +++ b/net/batman-adv/hard-interface.c
92326 @@ -401,7 +401,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
92327 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
92328 dev_add_pack(&hard_iface->batman_adv_ptype);
92329
92330 - atomic_set(&hard_iface->frag_seqno, 1);
92331 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
92332 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
92333 hard_iface->net_dev->name);
92334
92335 @@ -550,7 +550,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)
92336 /* This can't be called via a bat_priv callback because
92337 * we have no bat_priv yet.
92338 */
92339 - atomic_set(&hard_iface->bat_iv.ogm_seqno, 1);
92340 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, 1);
92341 hard_iface->bat_iv.ogm_buff = NULL;
92342
92343 return hard_iface;
92344 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
92345 index 819dfb0..226bacd 100644
92346 --- a/net/batman-adv/soft-interface.c
92347 +++ b/net/batman-adv/soft-interface.c
92348 @@ -180,6 +180,9 @@ static int batadv_interface_tx(struct sk_buff *skb,
92349 if (batadv_bla_tx(bat_priv, skb, vid))
92350 goto dropped;
92351
92352 + /* skb->data might have been reallocated by batadv_bla_tx() */
92353 + ethhdr = (struct ethhdr *)skb->data;
92354 +
92355 /* Register the client MAC in the transtable */
92356 if (!is_multicast_ether_addr(ethhdr->h_source))
92357 batadv_tt_local_add(soft_iface, ethhdr->h_source, skb->skb_iif);
92358 @@ -220,6 +223,10 @@ static int batadv_interface_tx(struct sk_buff *skb,
92359 default:
92360 break;
92361 }
92362 +
92363 + /* reminder: ethhdr might have become unusable from here on
92364 + * (batadv_gw_is_dhcp_target() might have reallocated skb data)
92365 + */
92366 }
92367
92368 /* ethernet packet should be broadcasted */
92369 @@ -253,7 +260,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
92370 primary_if->net_dev->dev_addr, ETH_ALEN);
92371
92372 /* set broadcast sequence number */
92373 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
92374 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
92375 bcast_packet->seqno = htonl(seqno);
92376
92377 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
92378 @@ -266,7 +273,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
92379 /* unicast packet */
92380 } else {
92381 if (atomic_read(&bat_priv->gw_mode) != BATADV_GW_MODE_OFF) {
92382 - ret = batadv_gw_out_of_range(bat_priv, skb, ethhdr);
92383 + ret = batadv_gw_out_of_range(bat_priv, skb);
92384 if (ret)
92385 goto dropped;
92386 }
92387 @@ -472,7 +479,7 @@ static int batadv_softif_init_late(struct net_device *dev)
92388 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
92389
92390 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
92391 - atomic_set(&bat_priv->bcast_seqno, 1);
92392 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
92393 atomic_set(&bat_priv->tt.vn, 0);
92394 atomic_set(&bat_priv->tt.local_changes, 0);
92395 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
92396 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
92397 index aba8364..50fcbb8 100644
92398 --- a/net/batman-adv/types.h
92399 +++ b/net/batman-adv/types.h
92400 @@ -51,7 +51,7 @@
92401 struct batadv_hard_iface_bat_iv {
92402 unsigned char *ogm_buff;
92403 int ogm_buff_len;
92404 - atomic_t ogm_seqno;
92405 + atomic_unchecked_t ogm_seqno;
92406 };
92407
92408 /**
92409 @@ -75,7 +75,7 @@ struct batadv_hard_iface {
92410 int16_t if_num;
92411 char if_status;
92412 struct net_device *net_dev;
92413 - atomic_t frag_seqno;
92414 + atomic_unchecked_t frag_seqno;
92415 struct kobject *hardif_obj;
92416 atomic_t refcount;
92417 struct packet_type batman_adv_ptype;
92418 @@ -558,7 +558,7 @@ struct batadv_priv {
92419 #ifdef CONFIG_BATMAN_ADV_DEBUG
92420 atomic_t log_level;
92421 #endif
92422 - atomic_t bcast_seqno;
92423 + atomic_unchecked_t bcast_seqno;
92424 atomic_t bcast_queue_left;
92425 atomic_t batman_queue_left;
92426 char num_ifaces;
92427 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
92428 index 0bb3b59..0e3052e 100644
92429 --- a/net/batman-adv/unicast.c
92430 +++ b/net/batman-adv/unicast.c
92431 @@ -270,7 +270,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
92432 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
92433 frag2->flags = large_tail;
92434
92435 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
92436 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
92437 frag1->seqno = htons(seqno - 1);
92438 frag2->seqno = htons(seqno);
92439
92440 @@ -326,7 +326,9 @@ static bool batadv_unicast_push_and_fill_skb(struct sk_buff *skb, int hdr_size,
92441 * @skb: the skb containing the payload to encapsulate
92442 * @orig_node: the destination node
92443 *
92444 - * Returns false if the payload could not be encapsulated or true otherwise
92445 + * Returns false if the payload could not be encapsulated or true otherwise.
92446 + *
92447 + * This call might reallocate skb data.
92448 */
92449 static bool batadv_unicast_prepare_skb(struct sk_buff *skb,
92450 struct batadv_orig_node *orig_node)
92451 @@ -343,7 +345,9 @@ static bool batadv_unicast_prepare_skb(struct sk_buff *skb,
92452 * @orig_node: the destination node
92453 * @packet_subtype: the batman 4addr packet subtype to use
92454 *
92455 - * Returns false if the payload could not be encapsulated or true otherwise
92456 + * Returns false if the payload could not be encapsulated or true otherwise.
92457 + *
92458 + * This call might reallocate skb data.
92459 */
92460 bool batadv_unicast_4addr_prepare_skb(struct batadv_priv *bat_priv,
92461 struct sk_buff *skb,
92462 @@ -401,7 +405,7 @@ int batadv_unicast_generic_send_skb(struct batadv_priv *bat_priv,
92463 struct batadv_neigh_node *neigh_node;
92464 int data_len = skb->len;
92465 int ret = NET_RX_DROP;
92466 - unsigned int dev_mtu;
92467 + unsigned int dev_mtu, header_len;
92468
92469 /* get routing information */
92470 if (is_multicast_ether_addr(ethhdr->h_dest)) {
92471 @@ -429,10 +433,12 @@ find_router:
92472 switch (packet_type) {
92473 case BATADV_UNICAST:
92474 batadv_unicast_prepare_skb(skb, orig_node);
92475 + header_len = sizeof(struct batadv_unicast_packet);
92476 break;
92477 case BATADV_UNICAST_4ADDR:
92478 batadv_unicast_4addr_prepare_skb(bat_priv, skb, orig_node,
92479 packet_subtype);
92480 + header_len = sizeof(struct batadv_unicast_4addr_packet);
92481 break;
92482 default:
92483 /* this function supports UNICAST and UNICAST_4ADDR only. It
92484 @@ -441,6 +447,7 @@ find_router:
92485 goto out;
92486 }
92487
92488 + ethhdr = (struct ethhdr *)(skb->data + header_len);
92489 unicast_packet = (struct batadv_unicast_packet *)skb->data;
92490
92491 /* inform the destination node that we are still missing a correct route
92492 diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
92493 index ace5e55..a65a1c0 100644
92494 --- a/net/bluetooth/hci_core.c
92495 +++ b/net/bluetooth/hci_core.c
92496 @@ -2211,16 +2211,16 @@ int hci_register_dev(struct hci_dev *hdev)
92497 list_add(&hdev->list, &hci_dev_list);
92498 write_unlock(&hci_dev_list_lock);
92499
92500 - hdev->workqueue = alloc_workqueue(hdev->name, WQ_HIGHPRI | WQ_UNBOUND |
92501 - WQ_MEM_RECLAIM, 1);
92502 + hdev->workqueue = alloc_workqueue("%s", WQ_HIGHPRI | WQ_UNBOUND |
92503 + WQ_MEM_RECLAIM, 1, hdev->name);
92504 if (!hdev->workqueue) {
92505 error = -ENOMEM;
92506 goto err;
92507 }
92508
92509 - hdev->req_workqueue = alloc_workqueue(hdev->name,
92510 + hdev->req_workqueue = alloc_workqueue("%s",
92511 WQ_HIGHPRI | WQ_UNBOUND |
92512 - WQ_MEM_RECLAIM, 1);
92513 + WQ_MEM_RECLAIM, 1, hdev->name);
92514 if (!hdev->req_workqueue) {
92515 destroy_workqueue(hdev->workqueue);
92516 error = -ENOMEM;
92517 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
92518 index 9bd7d95..6c4884f 100644
92519 --- a/net/bluetooth/hci_sock.c
92520 +++ b/net/bluetooth/hci_sock.c
92521 @@ -934,7 +934,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
92522 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
92523 }
92524
92525 - len = min_t(unsigned int, len, sizeof(uf));
92526 + len = min((size_t)len, sizeof(uf));
92527 if (copy_from_user(&uf, optval, len)) {
92528 err = -EFAULT;
92529 break;
92530 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
92531 index 68843a2..30e9342 100644
92532 --- a/net/bluetooth/l2cap_core.c
92533 +++ b/net/bluetooth/l2cap_core.c
92534 @@ -3507,8 +3507,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
92535 break;
92536
92537 case L2CAP_CONF_RFC:
92538 - if (olen == sizeof(rfc))
92539 - memcpy(&rfc, (void *)val, olen);
92540 + if (olen != sizeof(rfc))
92541 + break;
92542 +
92543 + memcpy(&rfc, (void *)val, olen);
92544
92545 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
92546 rfc.mode != chan->mode)
92547 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
92548 index 36fed40..be2eeb2 100644
92549 --- a/net/bluetooth/l2cap_sock.c
92550 +++ b/net/bluetooth/l2cap_sock.c
92551 @@ -485,7 +485,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
92552 struct sock *sk = sock->sk;
92553 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
92554 struct l2cap_options opts;
92555 - int len, err = 0;
92556 + int err = 0;
92557 + size_t len = optlen;
92558 u32 opt;
92559
92560 BT_DBG("sk %p", sk);
92561 @@ -507,7 +508,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
92562 opts.max_tx = chan->max_tx;
92563 opts.txwin_size = chan->tx_win;
92564
92565 - len = min_t(unsigned int, sizeof(opts), optlen);
92566 + len = min(sizeof(opts), len);
92567 if (copy_from_user((char *) &opts, optval, len)) {
92568 err = -EFAULT;
92569 break;
92570 @@ -587,7 +588,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
92571 struct bt_security sec;
92572 struct bt_power pwr;
92573 struct l2cap_conn *conn;
92574 - int len, err = 0;
92575 + int err = 0;
92576 + size_t len = optlen;
92577 u32 opt;
92578
92579 BT_DBG("sk %p", sk);
92580 @@ -610,7 +612,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
92581
92582 sec.level = BT_SECURITY_LOW;
92583
92584 - len = min_t(unsigned int, sizeof(sec), optlen);
92585 + len = min(sizeof(sec), len);
92586 if (copy_from_user((char *) &sec, optval, len)) {
92587 err = -EFAULT;
92588 break;
92589 @@ -707,7 +709,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
92590
92591 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
92592
92593 - len = min_t(unsigned int, sizeof(pwr), optlen);
92594 + len = min(sizeof(pwr), len);
92595 if (copy_from_user((char *) &pwr, optval, len)) {
92596 err = -EFAULT;
92597 break;
92598 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
92599 index 30b3721..c1bd0a0 100644
92600 --- a/net/bluetooth/rfcomm/sock.c
92601 +++ b/net/bluetooth/rfcomm/sock.c
92602 @@ -666,7 +666,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
92603 struct sock *sk = sock->sk;
92604 struct bt_security sec;
92605 int err = 0;
92606 - size_t len;
92607 + size_t len = optlen;
92608 u32 opt;
92609
92610 BT_DBG("sk %p", sk);
92611 @@ -688,7 +688,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
92612
92613 sec.level = BT_SECURITY_LOW;
92614
92615 - len = min_t(unsigned int, sizeof(sec), optlen);
92616 + len = min(sizeof(sec), len);
92617 if (copy_from_user((char *) &sec, optval, len)) {
92618 err = -EFAULT;
92619 break;
92620 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
92621 index b6e44ad..5b0d514 100644
92622 --- a/net/bluetooth/rfcomm/tty.c
92623 +++ b/net/bluetooth/rfcomm/tty.c
92624 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
92625 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
92626
92627 spin_lock_irqsave(&dev->port.lock, flags);
92628 - if (dev->port.count > 0) {
92629 + if (atomic_read(&dev->port.count) > 0) {
92630 spin_unlock_irqrestore(&dev->port.lock, flags);
92631 return;
92632 }
92633 @@ -659,10 +659,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
92634 return -ENODEV;
92635
92636 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
92637 - dev->channel, dev->port.count);
92638 + dev->channel, atomic_read(&dev->port.count));
92639
92640 spin_lock_irqsave(&dev->port.lock, flags);
92641 - if (++dev->port.count > 1) {
92642 + if (atomic_inc_return(&dev->port.count) > 1) {
92643 spin_unlock_irqrestore(&dev->port.lock, flags);
92644 return 0;
92645 }
92646 @@ -727,10 +727,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
92647 return;
92648
92649 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
92650 - dev->port.count);
92651 + atomic_read(&dev->port.count));
92652
92653 spin_lock_irqsave(&dev->port.lock, flags);
92654 - if (!--dev->port.count) {
92655 + if (!atomic_dec_return(&dev->port.count)) {
92656 spin_unlock_irqrestore(&dev->port.lock, flags);
92657 if (dev->tty_dev->parent)
92658 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
92659 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
92660 index 3d110c4..4e1b2eb 100644
92661 --- a/net/bridge/netfilter/ebtables.c
92662 +++ b/net/bridge/netfilter/ebtables.c
92663 @@ -1525,7 +1525,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
92664 tmp.valid_hooks = t->table->valid_hooks;
92665 }
92666 mutex_unlock(&ebt_mutex);
92667 - if (copy_to_user(user, &tmp, *len) != 0){
92668 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
92669 BUGPRINT("c2u Didn't work\n");
92670 ret = -EFAULT;
92671 break;
92672 @@ -2331,7 +2331,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
92673 goto out;
92674 tmp.valid_hooks = t->valid_hooks;
92675
92676 - if (copy_to_user(user, &tmp, *len) != 0) {
92677 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
92678 ret = -EFAULT;
92679 break;
92680 }
92681 @@ -2342,7 +2342,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
92682 tmp.entries_size = t->table->entries_size;
92683 tmp.valid_hooks = t->table->valid_hooks;
92684
92685 - if (copy_to_user(user, &tmp, *len) != 0) {
92686 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
92687 ret = -EFAULT;
92688 break;
92689 }
92690 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
92691 index 2bd4b58..0dc30a1 100644
92692 --- a/net/caif/cfctrl.c
92693 +++ b/net/caif/cfctrl.c
92694 @@ -10,6 +10,7 @@
92695 #include <linux/spinlock.h>
92696 #include <linux/slab.h>
92697 #include <linux/pkt_sched.h>
92698 +#include <linux/sched.h>
92699 #include <net/caif/caif_layer.h>
92700 #include <net/caif/cfpkt.h>
92701 #include <net/caif/cfctrl.h>
92702 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
92703 memset(&dev_info, 0, sizeof(dev_info));
92704 dev_info.id = 0xff;
92705 cfsrvl_init(&this->serv, 0, &dev_info, false);
92706 - atomic_set(&this->req_seq_no, 1);
92707 - atomic_set(&this->rsp_seq_no, 1);
92708 + atomic_set_unchecked(&this->req_seq_no, 1);
92709 + atomic_set_unchecked(&this->rsp_seq_no, 1);
92710 this->serv.layer.receive = cfctrl_recv;
92711 sprintf(this->serv.layer.name, "ctrl");
92712 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
92713 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
92714 struct cfctrl_request_info *req)
92715 {
92716 spin_lock_bh(&ctrl->info_list_lock);
92717 - atomic_inc(&ctrl->req_seq_no);
92718 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
92719 + atomic_inc_unchecked(&ctrl->req_seq_no);
92720 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
92721 list_add_tail(&req->list, &ctrl->list);
92722 spin_unlock_bh(&ctrl->info_list_lock);
92723 }
92724 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
92725 if (p != first)
92726 pr_warn("Requests are not received in order\n");
92727
92728 - atomic_set(&ctrl->rsp_seq_no,
92729 + atomic_set_unchecked(&ctrl->rsp_seq_no,
92730 p->sequence_no);
92731 list_del(&p->list);
92732 goto out;
92733 diff --git a/net/can/af_can.c b/net/can/af_can.c
92734 index c4e5085..aa9efdf 100644
92735 --- a/net/can/af_can.c
92736 +++ b/net/can/af_can.c
92737 @@ -862,7 +862,7 @@ static const struct net_proto_family can_family_ops = {
92738 };
92739
92740 /* notifier block for netdevice event */
92741 -static struct notifier_block can_netdev_notifier __read_mostly = {
92742 +static struct notifier_block can_netdev_notifier = {
92743 .notifier_call = can_notifier,
92744 };
92745
92746 diff --git a/net/can/gw.c b/net/can/gw.c
92747 index 3ee690e..00d581b 100644
92748 --- a/net/can/gw.c
92749 +++ b/net/can/gw.c
92750 @@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
92751 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
92752
92753 static HLIST_HEAD(cgw_list);
92754 -static struct notifier_block notifier;
92755
92756 static struct kmem_cache *cgw_cache __read_mostly;
92757
92758 @@ -927,6 +926,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh)
92759 return err;
92760 }
92761
92762 +static struct notifier_block notifier = {
92763 + .notifier_call = cgw_notifier
92764 +};
92765 +
92766 static __init int cgw_module_init(void)
92767 {
92768 /* sanitize given module parameter */
92769 @@ -942,7 +945,6 @@ static __init int cgw_module_init(void)
92770 return -ENOMEM;
92771
92772 /* set notifier */
92773 - notifier.notifier_call = cgw_notifier;
92774 register_netdevice_notifier(&notifier);
92775
92776 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
92777 diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
92778 index eb0a46a..5f3bae8 100644
92779 --- a/net/ceph/messenger.c
92780 +++ b/net/ceph/messenger.c
92781 @@ -186,7 +186,7 @@ static void con_fault(struct ceph_connection *con);
92782 #define MAX_ADDR_STR_LEN 64 /* 54 is enough */
92783
92784 static char addr_str[ADDR_STR_COUNT][MAX_ADDR_STR_LEN];
92785 -static atomic_t addr_str_seq = ATOMIC_INIT(0);
92786 +static atomic_unchecked_t addr_str_seq = ATOMIC_INIT(0);
92787
92788 static struct page *zero_page; /* used in certain error cases */
92789
92790 @@ -197,7 +197,7 @@ const char *ceph_pr_addr(const struct sockaddr_storage *ss)
92791 struct sockaddr_in *in4 = (struct sockaddr_in *) ss;
92792 struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) ss;
92793
92794 - i = atomic_inc_return(&addr_str_seq) & ADDR_STR_COUNT_MASK;
92795 + i = atomic_inc_return_unchecked(&addr_str_seq) & ADDR_STR_COUNT_MASK;
92796 s = addr_str[i];
92797
92798 switch (ss->ss_family) {
92799 diff --git a/net/compat.c b/net/compat.c
92800 index f0a1ba6..0541331 100644
92801 --- a/net/compat.c
92802 +++ b/net/compat.c
92803 @@ -71,9 +71,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
92804 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
92805 __get_user(kmsg->msg_flags, &umsg->msg_flags))
92806 return -EFAULT;
92807 - kmsg->msg_name = compat_ptr(tmp1);
92808 - kmsg->msg_iov = compat_ptr(tmp2);
92809 - kmsg->msg_control = compat_ptr(tmp3);
92810 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
92811 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
92812 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
92813 return 0;
92814 }
92815
92816 @@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
92817
92818 if (kern_msg->msg_namelen) {
92819 if (mode == VERIFY_READ) {
92820 - int err = move_addr_to_kernel(kern_msg->msg_name,
92821 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
92822 kern_msg->msg_namelen,
92823 kern_address);
92824 if (err < 0)
92825 @@ -96,7 +96,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
92826 kern_msg->msg_name = NULL;
92827
92828 tot_len = iov_from_user_compat_to_kern(kern_iov,
92829 - (struct compat_iovec __user *)kern_msg->msg_iov,
92830 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
92831 kern_msg->msg_iovlen);
92832 if (tot_len >= 0)
92833 kern_msg->msg_iov = kern_iov;
92834 @@ -116,20 +116,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
92835
92836 #define CMSG_COMPAT_FIRSTHDR(msg) \
92837 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
92838 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
92839 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
92840 (struct compat_cmsghdr __user *)NULL)
92841
92842 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
92843 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
92844 (ucmlen) <= (unsigned long) \
92845 ((mhdr)->msg_controllen - \
92846 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
92847 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
92848
92849 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
92850 struct compat_cmsghdr __user *cmsg, int cmsg_len)
92851 {
92852 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
92853 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
92854 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
92855 msg->msg_controllen)
92856 return NULL;
92857 return (struct compat_cmsghdr __user *)ptr;
92858 @@ -219,7 +219,7 @@ Efault:
92859
92860 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
92861 {
92862 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
92863 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
92864 struct compat_cmsghdr cmhdr;
92865 struct compat_timeval ctv;
92866 struct compat_timespec cts[3];
92867 @@ -275,7 +275,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
92868
92869 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
92870 {
92871 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
92872 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
92873 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
92874 int fdnum = scm->fp->count;
92875 struct file **fp = scm->fp->fp;
92876 @@ -363,7 +363,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
92877 return -EFAULT;
92878 old_fs = get_fs();
92879 set_fs(KERNEL_DS);
92880 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
92881 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
92882 set_fs(old_fs);
92883
92884 return err;
92885 @@ -424,7 +424,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
92886 len = sizeof(ktime);
92887 old_fs = get_fs();
92888 set_fs(KERNEL_DS);
92889 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
92890 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
92891 set_fs(old_fs);
92892
92893 if (!err) {
92894 @@ -567,7 +567,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
92895 case MCAST_JOIN_GROUP:
92896 case MCAST_LEAVE_GROUP:
92897 {
92898 - struct compat_group_req __user *gr32 = (void *)optval;
92899 + struct compat_group_req __user *gr32 = (void __user *)optval;
92900 struct group_req __user *kgr =
92901 compat_alloc_user_space(sizeof(struct group_req));
92902 u32 interface;
92903 @@ -588,7 +588,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
92904 case MCAST_BLOCK_SOURCE:
92905 case MCAST_UNBLOCK_SOURCE:
92906 {
92907 - struct compat_group_source_req __user *gsr32 = (void *)optval;
92908 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
92909 struct group_source_req __user *kgsr = compat_alloc_user_space(
92910 sizeof(struct group_source_req));
92911 u32 interface;
92912 @@ -609,7 +609,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
92913 }
92914 case MCAST_MSFILTER:
92915 {
92916 - struct compat_group_filter __user *gf32 = (void *)optval;
92917 + struct compat_group_filter __user *gf32 = (void __user *)optval;
92918 struct group_filter __user *kgf;
92919 u32 interface, fmode, numsrc;
92920
92921 @@ -647,7 +647,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
92922 char __user *optval, int __user *optlen,
92923 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
92924 {
92925 - struct compat_group_filter __user *gf32 = (void *)optval;
92926 + struct compat_group_filter __user *gf32 = (void __user *)optval;
92927 struct group_filter __user *kgf;
92928 int __user *koptlen;
92929 u32 interface, fmode, numsrc;
92930 @@ -805,7 +805,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
92931
92932 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
92933 return -EINVAL;
92934 - if (copy_from_user(a, args, nas[call]))
92935 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
92936 return -EFAULT;
92937 a0 = a[0];
92938 a1 = a[1];
92939 diff --git a/net/core/datagram.c b/net/core/datagram.c
92940 index b71423d..0360434 100644
92941 --- a/net/core/datagram.c
92942 +++ b/net/core/datagram.c
92943 @@ -295,7 +295,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
92944 }
92945
92946 kfree_skb(skb);
92947 - atomic_inc(&sk->sk_drops);
92948 + atomic_inc_unchecked(&sk->sk_drops);
92949 sk_mem_reclaim_partial(sk);
92950
92951 return err;
92952 diff --git a/net/core/dev.c b/net/core/dev.c
92953 index 7ddbb31..3902452 100644
92954 --- a/net/core/dev.c
92955 +++ b/net/core/dev.c
92956 @@ -1649,7 +1649,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
92957 {
92958 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
92959 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
92960 - atomic_long_inc(&dev->rx_dropped);
92961 + atomic_long_inc_unchecked(&dev->rx_dropped);
92962 kfree_skb(skb);
92963 return NET_RX_DROP;
92964 }
92965 @@ -1658,7 +1658,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
92966 skb_orphan(skb);
92967
92968 if (unlikely(!is_skb_forwardable(dev, skb))) {
92969 - atomic_long_inc(&dev->rx_dropped);
92970 + atomic_long_inc_unchecked(&dev->rx_dropped);
92971 kfree_skb(skb);
92972 return NET_RX_DROP;
92973 }
92974 @@ -2404,7 +2404,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
92975
92976 struct dev_gso_cb {
92977 void (*destructor)(struct sk_buff *skb);
92978 -};
92979 +} __no_const;
92980
92981 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
92982
92983 @@ -3139,7 +3139,7 @@ enqueue:
92984
92985 local_irq_restore(flags);
92986
92987 - atomic_long_inc(&skb->dev->rx_dropped);
92988 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
92989 kfree_skb(skb);
92990 return NET_RX_DROP;
92991 }
92992 @@ -3211,7 +3211,7 @@ int netif_rx_ni(struct sk_buff *skb)
92993 }
92994 EXPORT_SYMBOL(netif_rx_ni);
92995
92996 -static void net_tx_action(struct softirq_action *h)
92997 +static void net_tx_action(void)
92998 {
92999 struct softnet_data *sd = &__get_cpu_var(softnet_data);
93000
93001 @@ -3545,7 +3545,7 @@ ncls:
93002 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
93003 } else {
93004 drop:
93005 - atomic_long_inc(&skb->dev->rx_dropped);
93006 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
93007 kfree_skb(skb);
93008 /* Jamal, now you will not able to escape explaining
93009 * me how you were going to use this. :-)
93010 @@ -4153,7 +4153,7 @@ void netif_napi_del(struct napi_struct *napi)
93011 }
93012 EXPORT_SYMBOL(netif_napi_del);
93013
93014 -static void net_rx_action(struct softirq_action *h)
93015 +static void net_rx_action(void)
93016 {
93017 struct softnet_data *sd = &__get_cpu_var(softnet_data);
93018 unsigned long time_limit = jiffies + 2;
93019 @@ -5590,7 +5590,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
93020 } else {
93021 netdev_stats_to_stats64(storage, &dev->stats);
93022 }
93023 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
93024 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
93025 return storage;
93026 }
93027 EXPORT_SYMBOL(dev_get_stats);
93028 diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
93029 index 5b7d0e1..cb960fc 100644
93030 --- a/net/core/dev_ioctl.c
93031 +++ b/net/core/dev_ioctl.c
93032 @@ -365,9 +365,13 @@ void dev_load(struct net *net, const char *name)
93033 if (no_module && capable(CAP_NET_ADMIN))
93034 no_module = request_module("netdev-%s", name);
93035 if (no_module && capable(CAP_SYS_MODULE)) {
93036 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
93037 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
93038 +#else
93039 if (!request_module("%s", name))
93040 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
93041 name);
93042 +#endif
93043 }
93044 }
93045 EXPORT_SYMBOL(dev_load);
93046 diff --git a/net/core/ethtool.c b/net/core/ethtool.c
93047 index ce91766..3b71cdb 100644
93048 --- a/net/core/ethtool.c
93049 +++ b/net/core/ethtool.c
93050 @@ -1319,10 +1319,19 @@ static int ethtool_get_dump_data(struct net_device *dev,
93051 if (ret)
93052 return ret;
93053
93054 - len = (tmp.len > dump.len) ? dump.len : tmp.len;
93055 + len = min(tmp.len, dump.len);
93056 if (!len)
93057 return -EFAULT;
93058
93059 + /* Don't ever let the driver think there's more space available
93060 + * than it requested with .get_dump_flag().
93061 + */
93062 + dump.len = len;
93063 +
93064 + /* Always allocate enough space to hold the whole thing so that the
93065 + * driver does not need to check the length and bother with partial
93066 + * dumping.
93067 + */
93068 data = vzalloc(tmp.len);
93069 if (!data)
93070 return -ENOMEM;
93071 @@ -1330,6 +1339,16 @@ static int ethtool_get_dump_data(struct net_device *dev,
93072 if (ret)
93073 goto out;
93074
93075 + /* There are two sane possibilities:
93076 + * 1. The driver's .get_dump_data() does not touch dump.len.
93077 + * 2. Or it may set dump.len to how much it really writes, which
93078 + * should be tmp.len (or len if it can do a partial dump).
93079 + * In any case respond to userspace with the actual length of data
93080 + * it's receiving.
93081 + */
93082 + WARN_ON(dump.len != len && dump.len != tmp.len);
93083 + dump.len = len;
93084 +
93085 if (copy_to_user(useraddr, &dump, sizeof(dump))) {
93086 ret = -EFAULT;
93087 goto out;
93088 diff --git a/net/core/flow.c b/net/core/flow.c
93089 index 7102f16..146b4bd 100644
93090 --- a/net/core/flow.c
93091 +++ b/net/core/flow.c
93092 @@ -61,7 +61,7 @@ struct flow_cache {
93093 struct timer_list rnd_timer;
93094 };
93095
93096 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
93097 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
93098 EXPORT_SYMBOL(flow_cache_genid);
93099 static struct flow_cache flow_cache_global;
93100 static struct kmem_cache *flow_cachep __read_mostly;
93101 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
93102
93103 static int flow_entry_valid(struct flow_cache_entry *fle)
93104 {
93105 - if (atomic_read(&flow_cache_genid) != fle->genid)
93106 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
93107 return 0;
93108 if (fle->object && !fle->object->ops->check(fle->object))
93109 return 0;
93110 @@ -258,7 +258,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
93111 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
93112 fcp->hash_count++;
93113 }
93114 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
93115 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
93116 flo = fle->object;
93117 if (!flo)
93118 goto ret_object;
93119 @@ -279,7 +279,7 @@ nocache:
93120 }
93121 flo = resolver(net, key, family, dir, flo, ctx);
93122 if (fle) {
93123 - fle->genid = atomic_read(&flow_cache_genid);
93124 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
93125 if (!IS_ERR(flo))
93126 fle->object = flo;
93127 else
93128 diff --git a/net/core/iovec.c b/net/core/iovec.c
93129 index de178e4..1dabd8b 100644
93130 --- a/net/core/iovec.c
93131 +++ b/net/core/iovec.c
93132 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
93133 if (m->msg_namelen) {
93134 if (mode == VERIFY_READ) {
93135 void __user *namep;
93136 - namep = (void __user __force *) m->msg_name;
93137 + namep = (void __force_user *) m->msg_name;
93138 err = move_addr_to_kernel(namep, m->msg_namelen,
93139 address);
93140 if (err < 0)
93141 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
93142 }
93143
93144 size = m->msg_iovlen * sizeof(struct iovec);
93145 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
93146 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
93147 return -EFAULT;
93148
93149 m->msg_iov = iov;
93150 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
93151 index ce90b02..8752627 100644
93152 --- a/net/core/neighbour.c
93153 +++ b/net/core/neighbour.c
93154 @@ -2771,7 +2771,7 @@ static int proc_unres_qlen(ctl_table *ctl, int write, void __user *buffer,
93155 size_t *lenp, loff_t *ppos)
93156 {
93157 int size, ret;
93158 - ctl_table tmp = *ctl;
93159 + ctl_table_no_const tmp = *ctl;
93160
93161 tmp.extra1 = &zero;
93162 tmp.extra2 = &unres_qlen_max;
93163 diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
93164 index 569d355..79cf2d0 100644
93165 --- a/net/core/net-procfs.c
93166 +++ b/net/core/net-procfs.c
93167 @@ -271,8 +271,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
93168 else
93169 seq_printf(seq, "%04x", ntohs(pt->type));
93170
93171 +#ifdef CONFIG_GRKERNSEC_HIDESYM
93172 + seq_printf(seq, " %-8s %pf\n",
93173 + pt->dev ? pt->dev->name : "", NULL);
93174 +#else
93175 seq_printf(seq, " %-8s %pf\n",
93176 pt->dev ? pt->dev->name : "", pt->func);
93177 +#endif
93178 }
93179
93180 return 0;
93181 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
93182 index 981fed3..536af34 100644
93183 --- a/net/core/net-sysfs.c
93184 +++ b/net/core/net-sysfs.c
93185 @@ -1311,7 +1311,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
93186 }
93187 EXPORT_SYMBOL(netdev_class_remove_file);
93188
93189 -int netdev_kobject_init(void)
93190 +int __init netdev_kobject_init(void)
93191 {
93192 kobj_ns_type_register(&net_ns_type_operations);
93193 return class_register(&net_class);
93194 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
93195 index f9765203..9feaef8 100644
93196 --- a/net/core/net_namespace.c
93197 +++ b/net/core/net_namespace.c
93198 @@ -443,7 +443,7 @@ static int __register_pernet_operations(struct list_head *list,
93199 int error;
93200 LIST_HEAD(net_exit_list);
93201
93202 - list_add_tail(&ops->list, list);
93203 + pax_list_add_tail((struct list_head *)&ops->list, list);
93204 if (ops->init || (ops->id && ops->size)) {
93205 for_each_net(net) {
93206 error = ops_init(ops, net);
93207 @@ -456,7 +456,7 @@ static int __register_pernet_operations(struct list_head *list,
93208
93209 out_undo:
93210 /* If I have an error cleanup all namespaces I initialized */
93211 - list_del(&ops->list);
93212 + pax_list_del((struct list_head *)&ops->list);
93213 ops_exit_list(ops, &net_exit_list);
93214 ops_free_list(ops, &net_exit_list);
93215 return error;
93216 @@ -467,7 +467,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
93217 struct net *net;
93218 LIST_HEAD(net_exit_list);
93219
93220 - list_del(&ops->list);
93221 + pax_list_del((struct list_head *)&ops->list);
93222 for_each_net(net)
93223 list_add_tail(&net->exit_list, &net_exit_list);
93224 ops_exit_list(ops, &net_exit_list);
93225 @@ -601,7 +601,7 @@ int register_pernet_device(struct pernet_operations *ops)
93226 mutex_lock(&net_mutex);
93227 error = register_pernet_operations(&pernet_list, ops);
93228 if (!error && (first_device == &pernet_list))
93229 - first_device = &ops->list;
93230 + first_device = (struct list_head *)&ops->list;
93231 mutex_unlock(&net_mutex);
93232 return error;
93233 }
93234 diff --git a/net/core/netpoll.c b/net/core/netpoll.c
93235 index cec074b..a53a938 100644
93236 --- a/net/core/netpoll.c
93237 +++ b/net/core/netpoll.c
93238 @@ -428,7 +428,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
93239 struct udphdr *udph;
93240 struct iphdr *iph;
93241 struct ethhdr *eth;
93242 - static atomic_t ip_ident;
93243 + static atomic_unchecked_t ip_ident;
93244 struct ipv6hdr *ip6h;
93245
93246 udp_len = len + sizeof(*udph);
93247 @@ -499,7 +499,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
93248 put_unaligned(0x45, (unsigned char *)iph);
93249 iph->tos = 0;
93250 put_unaligned(htons(ip_len), &(iph->tot_len));
93251 - iph->id = htons(atomic_inc_return(&ip_ident));
93252 + iph->id = htons(atomic_inc_return_unchecked(&ip_ident));
93253 iph->frag_off = 0;
93254 iph->ttl = 64;
93255 iph->protocol = IPPROTO_UDP;
93256 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
93257 index a08bd2b..c59bd7c 100644
93258 --- a/net/core/rtnetlink.c
93259 +++ b/net/core/rtnetlink.c
93260 @@ -58,7 +58,7 @@ struct rtnl_link {
93261 rtnl_doit_func doit;
93262 rtnl_dumpit_func dumpit;
93263 rtnl_calcit_func calcit;
93264 -};
93265 +} __no_const;
93266
93267 static DEFINE_MUTEX(rtnl_mutex);
93268
93269 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
93270 if (rtnl_link_ops_get(ops->kind))
93271 return -EEXIST;
93272
93273 - if (!ops->dellink)
93274 - ops->dellink = unregister_netdevice_queue;
93275 + if (!ops->dellink) {
93276 + pax_open_kernel();
93277 + *(void **)&ops->dellink = unregister_netdevice_queue;
93278 + pax_close_kernel();
93279 + }
93280
93281 - list_add_tail(&ops->list, &link_ops);
93282 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
93283 return 0;
93284 }
93285 EXPORT_SYMBOL_GPL(__rtnl_link_register);
93286 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
93287 for_each_net(net) {
93288 __rtnl_kill_links(net, ops);
93289 }
93290 - list_del(&ops->list);
93291 + pax_list_del((struct list_head *)&ops->list);
93292 }
93293 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
93294
93295 @@ -2374,7 +2377,7 @@ static int rtnl_bridge_getlink(struct sk_buff *skb, struct netlink_callback *cb)
93296 struct nlattr *extfilt;
93297 u32 filter_mask = 0;
93298
93299 - extfilt = nlmsg_find_attr(cb->nlh, sizeof(struct rtgenmsg),
93300 + extfilt = nlmsg_find_attr(cb->nlh, sizeof(struct ifinfomsg),
93301 IFLA_EXT_MASK);
93302 if (extfilt)
93303 filter_mask = nla_get_u32(extfilt);
93304 diff --git a/net/core/scm.c b/net/core/scm.c
93305 index 03795d0..98d6bdb 100644
93306 --- a/net/core/scm.c
93307 +++ b/net/core/scm.c
93308 @@ -54,7 +54,7 @@ static __inline__ int scm_check_creds(struct ucred *creds)
93309 return -EINVAL;
93310
93311 if ((creds->pid == task_tgid_vnr(current) ||
93312 - ns_capable(current->nsproxy->pid_ns->user_ns, CAP_SYS_ADMIN)) &&
93313 + ns_capable(task_active_pid_ns(current)->user_ns, CAP_SYS_ADMIN)) &&
93314 ((uid_eq(uid, cred->uid) || uid_eq(uid, cred->euid) ||
93315 uid_eq(uid, cred->suid)) || nsown_capable(CAP_SETUID)) &&
93316 ((gid_eq(gid, cred->gid) || gid_eq(gid, cred->egid) ||
93317 @@ -210,7 +210,7 @@ EXPORT_SYMBOL(__scm_send);
93318 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
93319 {
93320 struct cmsghdr __user *cm
93321 - = (__force struct cmsghdr __user *)msg->msg_control;
93322 + = (struct cmsghdr __force_user *)msg->msg_control;
93323 struct cmsghdr cmhdr;
93324 int cmlen = CMSG_LEN(len);
93325 int err;
93326 @@ -233,7 +233,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
93327 err = -EFAULT;
93328 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
93329 goto out;
93330 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
93331 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
93332 goto out;
93333 cmlen = CMSG_SPACE(len);
93334 if (msg->msg_controllen < cmlen)
93335 @@ -249,7 +249,7 @@ EXPORT_SYMBOL(put_cmsg);
93336 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
93337 {
93338 struct cmsghdr __user *cm
93339 - = (__force struct cmsghdr __user*)msg->msg_control;
93340 + = (struct cmsghdr __force_user *)msg->msg_control;
93341
93342 int fdmax = 0;
93343 int fdnum = scm->fp->count;
93344 @@ -269,7 +269,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
93345 if (fdnum < fdmax)
93346 fdmax = fdnum;
93347
93348 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
93349 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
93350 i++, cmfptr++)
93351 {
93352 struct socket *sock;
93353 diff --git a/net/core/skbuff.c b/net/core/skbuff.c
93354 index 1c1738c..4cab7f0 100644
93355 --- a/net/core/skbuff.c
93356 +++ b/net/core/skbuff.c
93357 @@ -3087,13 +3087,15 @@ void __init skb_init(void)
93358 skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
93359 sizeof(struct sk_buff),
93360 0,
93361 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
93362 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
93363 + SLAB_NO_SANITIZE,
93364 NULL);
93365 skbuff_fclone_cache = kmem_cache_create("skbuff_fclone_cache",
93366 (2*sizeof(struct sk_buff)) +
93367 sizeof(atomic_t),
93368 0,
93369 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
93370 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
93371 + SLAB_NO_SANITIZE,
93372 NULL);
93373 }
93374
93375 diff --git a/net/core/sock.c b/net/core/sock.c
93376 index d6d024c..6ea7ab4 100644
93377 --- a/net/core/sock.c
93378 +++ b/net/core/sock.c
93379 @@ -390,7 +390,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
93380 struct sk_buff_head *list = &sk->sk_receive_queue;
93381
93382 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
93383 - atomic_inc(&sk->sk_drops);
93384 + atomic_inc_unchecked(&sk->sk_drops);
93385 trace_sock_rcvqueue_full(sk, skb);
93386 return -ENOMEM;
93387 }
93388 @@ -400,7 +400,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
93389 return err;
93390
93391 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
93392 - atomic_inc(&sk->sk_drops);
93393 + atomic_inc_unchecked(&sk->sk_drops);
93394 return -ENOBUFS;
93395 }
93396
93397 @@ -420,7 +420,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
93398 skb_dst_force(skb);
93399
93400 spin_lock_irqsave(&list->lock, flags);
93401 - skb->dropcount = atomic_read(&sk->sk_drops);
93402 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
93403 __skb_queue_tail(list, skb);
93404 spin_unlock_irqrestore(&list->lock, flags);
93405
93406 @@ -440,7 +440,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
93407 skb->dev = NULL;
93408
93409 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
93410 - atomic_inc(&sk->sk_drops);
93411 + atomic_inc_unchecked(&sk->sk_drops);
93412 goto discard_and_relse;
93413 }
93414 if (nested)
93415 @@ -458,7 +458,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
93416 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
93417 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
93418 bh_unlock_sock(sk);
93419 - atomic_inc(&sk->sk_drops);
93420 + atomic_inc_unchecked(&sk->sk_drops);
93421 goto discard_and_relse;
93422 }
93423
93424 @@ -933,12 +933,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
93425 struct timeval tm;
93426 } v;
93427
93428 - int lv = sizeof(int);
93429 - int len;
93430 + unsigned int lv = sizeof(int);
93431 + unsigned int len;
93432
93433 if (get_user(len, optlen))
93434 return -EFAULT;
93435 - if (len < 0)
93436 + if (len > INT_MAX)
93437 return -EINVAL;
93438
93439 memset(&v, 0, sizeof(v));
93440 @@ -1090,11 +1090,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
93441
93442 case SO_PEERNAME:
93443 {
93444 - char address[128];
93445 + char address[_K_SS_MAXSIZE];
93446
93447 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
93448 return -ENOTCONN;
93449 - if (lv < len)
93450 + if (lv < len || sizeof address < len)
93451 return -EINVAL;
93452 if (copy_to_user(optval, address, len))
93453 return -EFAULT;
93454 @@ -1161,7 +1161,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
93455
93456 if (len > lv)
93457 len = lv;
93458 - if (copy_to_user(optval, &v, len))
93459 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
93460 return -EFAULT;
93461 lenout:
93462 if (put_user(len, optlen))
93463 @@ -2277,7 +2277,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
93464 */
93465 smp_wmb();
93466 atomic_set(&sk->sk_refcnt, 1);
93467 - atomic_set(&sk->sk_drops, 0);
93468 + atomic_set_unchecked(&sk->sk_drops, 0);
93469 }
93470 EXPORT_SYMBOL(sock_init_data);
93471
93472 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
93473 index a0e9cf6..ef7f9ed 100644
93474 --- a/net/core/sock_diag.c
93475 +++ b/net/core/sock_diag.c
93476 @@ -9,26 +9,33 @@
93477 #include <linux/inet_diag.h>
93478 #include <linux/sock_diag.h>
93479
93480 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
93481 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
93482 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
93483 static DEFINE_MUTEX(sock_diag_table_mutex);
93484
93485 int sock_diag_check_cookie(void *sk, __u32 *cookie)
93486 {
93487 +#ifndef CONFIG_GRKERNSEC_HIDESYM
93488 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
93489 cookie[1] != INET_DIAG_NOCOOKIE) &&
93490 ((u32)(unsigned long)sk != cookie[0] ||
93491 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
93492 return -ESTALE;
93493 else
93494 +#endif
93495 return 0;
93496 }
93497 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
93498
93499 void sock_diag_save_cookie(void *sk, __u32 *cookie)
93500 {
93501 +#ifdef CONFIG_GRKERNSEC_HIDESYM
93502 + cookie[0] = 0;
93503 + cookie[1] = 0;
93504 +#else
93505 cookie[0] = (u32)(unsigned long)sk;
93506 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
93507 +#endif
93508 }
93509 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
93510
93511 @@ -113,8 +120,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
93512 mutex_lock(&sock_diag_table_mutex);
93513 if (sock_diag_handlers[hndl->family])
93514 err = -EBUSY;
93515 - else
93516 + else {
93517 + pax_open_kernel();
93518 sock_diag_handlers[hndl->family] = hndl;
93519 + pax_close_kernel();
93520 + }
93521 mutex_unlock(&sock_diag_table_mutex);
93522
93523 return err;
93524 @@ -130,7 +140,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
93525
93526 mutex_lock(&sock_diag_table_mutex);
93527 BUG_ON(sock_diag_handlers[family] != hnld);
93528 + pax_open_kernel();
93529 sock_diag_handlers[family] = NULL;
93530 + pax_close_kernel();
93531 mutex_unlock(&sock_diag_table_mutex);
93532 }
93533 EXPORT_SYMBOL_GPL(sock_diag_unregister);
93534 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
93535 index cfdb46a..cef55e1 100644
93536 --- a/net/core/sysctl_net_core.c
93537 +++ b/net/core/sysctl_net_core.c
93538 @@ -28,7 +28,7 @@ static int rps_sock_flow_sysctl(ctl_table *table, int write,
93539 {
93540 unsigned int orig_size, size;
93541 int ret, i;
93542 - ctl_table tmp = {
93543 + ctl_table_no_const tmp = {
93544 .data = &size,
93545 .maxlen = sizeof(size),
93546 .mode = table->mode
93547 @@ -211,13 +211,12 @@ static struct ctl_table netns_core_table[] = {
93548
93549 static __net_init int sysctl_core_net_init(struct net *net)
93550 {
93551 - struct ctl_table *tbl;
93552 + ctl_table_no_const *tbl = NULL;
93553
93554 net->core.sysctl_somaxconn = SOMAXCONN;
93555
93556 - tbl = netns_core_table;
93557 if (!net_eq(net, &init_net)) {
93558 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
93559 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
93560 if (tbl == NULL)
93561 goto err_dup;
93562
93563 @@ -227,17 +226,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
93564 if (net->user_ns != &init_user_ns) {
93565 tbl[0].procname = NULL;
93566 }
93567 - }
93568 -
93569 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
93570 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
93571 + } else
93572 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
93573 if (net->core.sysctl_hdr == NULL)
93574 goto err_reg;
93575
93576 return 0;
93577
93578 err_reg:
93579 - if (tbl != netns_core_table)
93580 - kfree(tbl);
93581 + kfree(tbl);
93582 err_dup:
93583 return -ENOMEM;
93584 }
93585 @@ -252,7 +250,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
93586 kfree(tbl);
93587 }
93588
93589 -static __net_initdata struct pernet_operations sysctl_core_ops = {
93590 +static __net_initconst struct pernet_operations sysctl_core_ops = {
93591 .init = sysctl_core_net_init,
93592 .exit = sysctl_core_net_exit,
93593 };
93594 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
93595 index c21f200..bc4565b 100644
93596 --- a/net/decnet/af_decnet.c
93597 +++ b/net/decnet/af_decnet.c
93598 @@ -465,6 +465,7 @@ static struct proto dn_proto = {
93599 .sysctl_rmem = sysctl_decnet_rmem,
93600 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
93601 .obj_size = sizeof(struct dn_sock),
93602 + .slab_flags = SLAB_USERCOPY,
93603 };
93604
93605 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
93606 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
93607 index a55eecc..dd8428c 100644
93608 --- a/net/decnet/sysctl_net_decnet.c
93609 +++ b/net/decnet/sysctl_net_decnet.c
93610 @@ -174,7 +174,7 @@ static int dn_node_address_handler(ctl_table *table, int write,
93611
93612 if (len > *lenp) len = *lenp;
93613
93614 - if (copy_to_user(buffer, addr, len))
93615 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
93616 return -EFAULT;
93617
93618 *lenp = len;
93619 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(ctl_table *table, int write,
93620
93621 if (len > *lenp) len = *lenp;
93622
93623 - if (copy_to_user(buffer, devname, len))
93624 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
93625 return -EFAULT;
93626
93627 *lenp = len;
93628 diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
93629 index 55e1fd5..fd602b8 100644
93630 --- a/net/ieee802154/6lowpan.c
93631 +++ b/net/ieee802154/6lowpan.c
93632 @@ -459,7 +459,7 @@ static int lowpan_header_create(struct sk_buff *skb,
93633 hc06_ptr += 3;
93634 } else {
93635 /* compress nothing */
93636 - memcpy(hc06_ptr, &hdr, 4);
93637 + memcpy(hc06_ptr, hdr, 4);
93638 /* replace the top byte with new ECN | DSCP format */
93639 *hc06_ptr = tmp;
93640 hc06_ptr += 4;
93641 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
93642 index d01be2a..8976537 100644
93643 --- a/net/ipv4/af_inet.c
93644 +++ b/net/ipv4/af_inet.c
93645 @@ -1703,13 +1703,9 @@ static int __init inet_init(void)
93646
93647 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb));
93648
93649 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
93650 - if (!sysctl_local_reserved_ports)
93651 - goto out;
93652 -
93653 rc = proto_register(&tcp_prot, 1);
93654 if (rc)
93655 - goto out_free_reserved_ports;
93656 + goto out;
93657
93658 rc = proto_register(&udp_prot, 1);
93659 if (rc)
93660 @@ -1818,8 +1814,6 @@ out_unregister_udp_proto:
93661 proto_unregister(&udp_prot);
93662 out_unregister_tcp_proto:
93663 proto_unregister(&tcp_prot);
93664 -out_free_reserved_ports:
93665 - kfree(sysctl_local_reserved_ports);
93666 goto out;
93667 }
93668
93669 diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
93670 index 2e7f194..0fa4d6d 100644
93671 --- a/net/ipv4/ah4.c
93672 +++ b/net/ipv4/ah4.c
93673 @@ -420,7 +420,7 @@ static void ah4_err(struct sk_buff *skb, u32 info)
93674 return;
93675
93676 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
93677 - atomic_inc(&flow_cache_genid);
93678 + atomic_inc_unchecked(&flow_cache_genid);
93679 rt_genid_bump(net);
93680
93681 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_AH, 0);
93682 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
93683 index dfc39d4..0d4fa52 100644
93684 --- a/net/ipv4/devinet.c
93685 +++ b/net/ipv4/devinet.c
93686 @@ -771,7 +771,7 @@ static struct in_ifaddr *rtm_to_ifaddr(struct net *net, struct nlmsghdr *nlh,
93687 ci = nla_data(tb[IFA_CACHEINFO]);
93688 if (!ci->ifa_valid || ci->ifa_prefered > ci->ifa_valid) {
93689 err = -EINVAL;
93690 - goto errout;
93691 + goto errout_free;
93692 }
93693 *pvalid_lft = ci->ifa_valid;
93694 *pprefered_lft = ci->ifa_prefered;
93695 @@ -779,6 +779,8 @@ static struct in_ifaddr *rtm_to_ifaddr(struct net *net, struct nlmsghdr *nlh,
93696
93697 return ifa;
93698
93699 +errout_free:
93700 + inet_free_ifa(ifa);
93701 errout:
93702 return ERR_PTR(err);
93703 }
93704 @@ -1529,7 +1531,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
93705 idx = 0;
93706 head = &net->dev_index_head[h];
93707 rcu_read_lock();
93708 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
93709 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
93710 net->dev_base_seq;
93711 hlist_for_each_entry_rcu(dev, head, index_hlist) {
93712 if (idx < s_idx)
93713 @@ -1840,7 +1842,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb,
93714 idx = 0;
93715 head = &net->dev_index_head[h];
93716 rcu_read_lock();
93717 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
93718 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
93719 net->dev_base_seq;
93720 hlist_for_each_entry_rcu(dev, head, index_hlist) {
93721 if (idx < s_idx)
93722 @@ -2065,7 +2067,7 @@ static int ipv4_doint_and_flush(ctl_table *ctl, int write,
93723 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
93724 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
93725
93726 -static struct devinet_sysctl_table {
93727 +static const struct devinet_sysctl_table {
93728 struct ctl_table_header *sysctl_header;
93729 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
93730 } devinet_sysctl = {
93731 @@ -2183,7 +2185,7 @@ static __net_init int devinet_init_net(struct net *net)
93732 int err;
93733 struct ipv4_devconf *all, *dflt;
93734 #ifdef CONFIG_SYSCTL
93735 - struct ctl_table *tbl = ctl_forward_entry;
93736 + ctl_table_no_const *tbl = NULL;
93737 struct ctl_table_header *forw_hdr;
93738 #endif
93739
93740 @@ -2201,7 +2203,7 @@ static __net_init int devinet_init_net(struct net *net)
93741 goto err_alloc_dflt;
93742
93743 #ifdef CONFIG_SYSCTL
93744 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
93745 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
93746 if (tbl == NULL)
93747 goto err_alloc_ctl;
93748
93749 @@ -2221,7 +2223,10 @@ static __net_init int devinet_init_net(struct net *net)
93750 goto err_reg_dflt;
93751
93752 err = -ENOMEM;
93753 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
93754 + if (!net_eq(net, &init_net))
93755 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
93756 + else
93757 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
93758 if (forw_hdr == NULL)
93759 goto err_reg_ctl;
93760 net->ipv4.forw_hdr = forw_hdr;
93761 @@ -2237,8 +2242,7 @@ err_reg_ctl:
93762 err_reg_dflt:
93763 __devinet_sysctl_unregister(all);
93764 err_reg_all:
93765 - if (tbl != ctl_forward_entry)
93766 - kfree(tbl);
93767 + kfree(tbl);
93768 err_alloc_ctl:
93769 #endif
93770 if (dflt != &ipv4_devconf_dflt)
93771 diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
93772 index 4cfe34d..d2fac8a 100644
93773 --- a/net/ipv4/esp4.c
93774 +++ b/net/ipv4/esp4.c
93775 @@ -477,7 +477,7 @@ static u32 esp4_get_mtu(struct xfrm_state *x, int mtu)
93776 }
93777
93778 return ((mtu - x->props.header_len - crypto_aead_authsize(esp->aead) -
93779 - net_adj) & ~(align - 1)) + (net_adj - 2);
93780 + net_adj) & ~(align - 1)) + net_adj - 2;
93781 }
93782
93783 static void esp4_err(struct sk_buff *skb, u32 info)
93784 @@ -503,7 +503,7 @@ static void esp4_err(struct sk_buff *skb, u32 info)
93785 return;
93786
93787 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
93788 - atomic_inc(&flow_cache_genid);
93789 + atomic_inc_unchecked(&flow_cache_genid);
93790 rt_genid_bump(net);
93791
93792 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_ESP, 0);
93793 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
93794 index c7629a2..b62d139 100644
93795 --- a/net/ipv4/fib_frontend.c
93796 +++ b/net/ipv4/fib_frontend.c
93797 @@ -1017,12 +1017,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
93798 #ifdef CONFIG_IP_ROUTE_MULTIPATH
93799 fib_sync_up(dev);
93800 #endif
93801 - atomic_inc(&net->ipv4.dev_addr_genid);
93802 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
93803 rt_cache_flush(dev_net(dev));
93804 break;
93805 case NETDEV_DOWN:
93806 fib_del_ifaddr(ifa, NULL);
93807 - atomic_inc(&net->ipv4.dev_addr_genid);
93808 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
93809 if (ifa->ifa_dev->ifa_list == NULL) {
93810 /* Last address was deleted from this interface.
93811 * Disable IP.
93812 @@ -1058,7 +1058,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
93813 #ifdef CONFIG_IP_ROUTE_MULTIPATH
93814 fib_sync_up(dev);
93815 #endif
93816 - atomic_inc(&net->ipv4.dev_addr_genid);
93817 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
93818 rt_cache_flush(net);
93819 break;
93820 case NETDEV_DOWN:
93821 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
93822 index 8f6cb7a..34507f9 100644
93823 --- a/net/ipv4/fib_semantics.c
93824 +++ b/net/ipv4/fib_semantics.c
93825 @@ -765,7 +765,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
93826 nh->nh_saddr = inet_select_addr(nh->nh_dev,
93827 nh->nh_gw,
93828 nh->nh_parent->fib_scope);
93829 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
93830 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
93831
93832 return nh->nh_saddr;
93833 }
93834 diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
93835 index 49616fe..6e8a13d 100644
93836 --- a/net/ipv4/fib_trie.c
93837 +++ b/net/ipv4/fib_trie.c
93838 @@ -71,7 +71,6 @@
93839 #include <linux/init.h>
93840 #include <linux/list.h>
93841 #include <linux/slab.h>
93842 -#include <linux/prefetch.h>
93843 #include <linux/export.h>
93844 #include <net/net_namespace.h>
93845 #include <net/ip.h>
93846 @@ -1761,10 +1760,8 @@ static struct leaf *leaf_walk_rcu(struct tnode *p, struct rt_trie_node *c)
93847 if (!c)
93848 continue;
93849
93850 - if (IS_LEAF(c)) {
93851 - prefetch(rcu_dereference_rtnl(p->child[idx]));
93852 + if (IS_LEAF(c))
93853 return (struct leaf *) c;
93854 - }
93855
93856 /* Rescan start scanning in new node */
93857 p = (struct tnode *) c;
93858 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
93859 index 6acb541..9ea617d 100644
93860 --- a/net/ipv4/inet_connection_sock.c
93861 +++ b/net/ipv4/inet_connection_sock.c
93862 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
93863 .range = { 32768, 61000 },
93864 };
93865
93866 -unsigned long *sysctl_local_reserved_ports;
93867 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
93868 EXPORT_SYMBOL(sysctl_local_reserved_ports);
93869
93870 void inet_get_local_port_range(int *low, int *high)
93871 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
93872 index 6af375a..c493c74 100644
93873 --- a/net/ipv4/inet_hashtables.c
93874 +++ b/net/ipv4/inet_hashtables.c
93875 @@ -18,12 +18,15 @@
93876 #include <linux/sched.h>
93877 #include <linux/slab.h>
93878 #include <linux/wait.h>
93879 +#include <linux/security.h>
93880
93881 #include <net/inet_connection_sock.h>
93882 #include <net/inet_hashtables.h>
93883 #include <net/secure_seq.h>
93884 #include <net/ip.h>
93885
93886 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
93887 +
93888 /*
93889 * Allocate and initialize a new local port bind bucket.
93890 * The bindhash mutex for snum's hash chain must be held here.
93891 @@ -554,6 +557,8 @@ ok:
93892 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
93893 spin_unlock(&head->lock);
93894
93895 + gr_update_task_in_ip_table(current, inet_sk(sk));
93896 +
93897 if (tw) {
93898 inet_twsk_deschedule(tw, death_row);
93899 while (twrefcnt) {
93900 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
93901 index 000e3d2..5472da3 100644
93902 --- a/net/ipv4/inetpeer.c
93903 +++ b/net/ipv4/inetpeer.c
93904 @@ -503,8 +503,8 @@ relookup:
93905 if (p) {
93906 p->daddr = *daddr;
93907 atomic_set(&p->refcnt, 1);
93908 - atomic_set(&p->rid, 0);
93909 - atomic_set(&p->ip_id_count,
93910 + atomic_set_unchecked(&p->rid, 0);
93911 + atomic_set_unchecked(&p->ip_id_count,
93912 (daddr->family == AF_INET) ?
93913 secure_ip_id(daddr->addr.a4) :
93914 secure_ipv6_id(daddr->addr.a6));
93915 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
93916 index b66910a..cfe416e 100644
93917 --- a/net/ipv4/ip_fragment.c
93918 +++ b/net/ipv4/ip_fragment.c
93919 @@ -282,7 +282,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
93920 return 0;
93921
93922 start = qp->rid;
93923 - end = atomic_inc_return(&peer->rid);
93924 + end = atomic_inc_return_unchecked(&peer->rid);
93925 qp->rid = end;
93926
93927 rc = qp->q.fragments && (end - start) > max;
93928 @@ -759,12 +759,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
93929
93930 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
93931 {
93932 - struct ctl_table *table;
93933 + ctl_table_no_const *table = NULL;
93934 struct ctl_table_header *hdr;
93935
93936 - table = ip4_frags_ns_ctl_table;
93937 if (!net_eq(net, &init_net)) {
93938 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
93939 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
93940 if (table == NULL)
93941 goto err_alloc;
93942
93943 @@ -775,9 +774,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
93944 /* Don't export sysctls to unprivileged users */
93945 if (net->user_ns != &init_user_ns)
93946 table[0].procname = NULL;
93947 - }
93948 + hdr = register_net_sysctl(net, "net/ipv4", table);
93949 + } else
93950 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
93951
93952 - hdr = register_net_sysctl(net, "net/ipv4", table);
93953 if (hdr == NULL)
93954 goto err_reg;
93955
93956 @@ -785,8 +785,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
93957 return 0;
93958
93959 err_reg:
93960 - if (!net_eq(net, &init_net))
93961 - kfree(table);
93962 + kfree(table);
93963 err_alloc:
93964 return -ENOMEM;
93965 }
93966 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
93967 index 855004f..9644112 100644
93968 --- a/net/ipv4/ip_gre.c
93969 +++ b/net/ipv4/ip_gre.c
93970 @@ -115,7 +115,7 @@ static bool log_ecn_error = true;
93971 module_param(log_ecn_error, bool, 0644);
93972 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
93973
93974 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
93975 +static struct rtnl_link_ops ipgre_link_ops;
93976 static int ipgre_tunnel_init(struct net_device *dev);
93977
93978 static int ipgre_net_id __read_mostly;
93979 @@ -572,7 +572,7 @@ static int ipgre_header(struct sk_buff *skb, struct net_device *dev,
93980 if (daddr)
93981 memcpy(&iph->daddr, daddr, 4);
93982 if (iph->daddr)
93983 - return t->hlen;
93984 + return t->hlen + sizeof(*iph);
93985
93986 return -(t->hlen + sizeof(*iph));
93987 }
93988 @@ -919,7 +919,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
93989 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
93990 };
93991
93992 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
93993 +static struct rtnl_link_ops ipgre_link_ops = {
93994 .kind = "gre",
93995 .maxtype = IFLA_GRE_MAX,
93996 .policy = ipgre_policy,
93997 @@ -933,7 +933,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
93998 .fill_info = ipgre_fill_info,
93999 };
94000
94001 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
94002 +static struct rtnl_link_ops ipgre_tap_ops = {
94003 .kind = "gretap",
94004 .maxtype = IFLA_GRE_MAX,
94005 .policy = ipgre_policy,
94006 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
94007 index d9c4f11..02b82dbc 100644
94008 --- a/net/ipv4/ip_sockglue.c
94009 +++ b/net/ipv4/ip_sockglue.c
94010 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
94011 len = min_t(unsigned int, len, opt->optlen);
94012 if (put_user(len, optlen))
94013 return -EFAULT;
94014 - if (copy_to_user(optval, opt->__data, len))
94015 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
94016 + copy_to_user(optval, opt->__data, len))
94017 return -EFAULT;
94018 return 0;
94019 }
94020 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
94021 if (sk->sk_type != SOCK_STREAM)
94022 return -ENOPROTOOPT;
94023
94024 - msg.msg_control = optval;
94025 + msg.msg_control = (void __force_kernel *)optval;
94026 msg.msg_controllen = len;
94027 msg.msg_flags = flags;
94028
94029 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
94030 index 17cc0ff..63856c4 100644
94031 --- a/net/ipv4/ip_vti.c
94032 +++ b/net/ipv4/ip_vti.c
94033 @@ -47,7 +47,7 @@
94034 #define HASH_SIZE 16
94035 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
94036
94037 -static struct rtnl_link_ops vti_link_ops __read_mostly;
94038 +static struct rtnl_link_ops vti_link_ops;
94039
94040 static int vti_net_id __read_mostly;
94041 struct vti_net {
94042 @@ -840,7 +840,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
94043 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
94044 };
94045
94046 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
94047 +static struct rtnl_link_ops vti_link_ops = {
94048 .kind = "vti",
94049 .maxtype = IFLA_VTI_MAX,
94050 .policy = vti_policy,
94051 diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
94052 index 59cb8c7..a72160c 100644
94053 --- a/net/ipv4/ipcomp.c
94054 +++ b/net/ipv4/ipcomp.c
94055 @@ -48,7 +48,7 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
94056 return;
94057
94058 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
94059 - atomic_inc(&flow_cache_genid);
94060 + atomic_inc_unchecked(&flow_cache_genid);
94061 rt_genid_bump(net);
94062
94063 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_COMP, 0);
94064 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
94065 index efa1138..20dbba0 100644
94066 --- a/net/ipv4/ipconfig.c
94067 +++ b/net/ipv4/ipconfig.c
94068 @@ -334,7 +334,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
94069
94070 mm_segment_t oldfs = get_fs();
94071 set_fs(get_ds());
94072 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
94073 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
94074 set_fs(oldfs);
94075 return res;
94076 }
94077 @@ -345,7 +345,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
94078
94079 mm_segment_t oldfs = get_fs();
94080 set_fs(get_ds());
94081 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
94082 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
94083 set_fs(oldfs);
94084 return res;
94085 }
94086 @@ -356,7 +356,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
94087
94088 mm_segment_t oldfs = get_fs();
94089 set_fs(get_ds());
94090 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
94091 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
94092 set_fs(oldfs);
94093 return res;
94094 }
94095 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
94096 index 7cfc456..e726868 100644
94097 --- a/net/ipv4/ipip.c
94098 +++ b/net/ipv4/ipip.c
94099 @@ -124,7 +124,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
94100 static int ipip_net_id __read_mostly;
94101
94102 static int ipip_tunnel_init(struct net_device *dev);
94103 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
94104 +static struct rtnl_link_ops ipip_link_ops;
94105
94106 static int ipip_err(struct sk_buff *skb, u32 info)
94107 {
94108 @@ -406,7 +406,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
94109 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
94110 };
94111
94112 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
94113 +static struct rtnl_link_ops ipip_link_ops = {
94114 .kind = "ipip",
94115 .maxtype = IFLA_IPTUN_MAX,
94116 .policy = ipip_policy,
94117 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
94118 index 85a4f21..1beb1f5 100644
94119 --- a/net/ipv4/netfilter/arp_tables.c
94120 +++ b/net/ipv4/netfilter/arp_tables.c
94121 @@ -880,14 +880,14 @@ static int compat_table_info(const struct xt_table_info *info,
94122 #endif
94123
94124 static int get_info(struct net *net, void __user *user,
94125 - const int *len, int compat)
94126 + int len, int compat)
94127 {
94128 char name[XT_TABLE_MAXNAMELEN];
94129 struct xt_table *t;
94130 int ret;
94131
94132 - if (*len != sizeof(struct arpt_getinfo)) {
94133 - duprintf("length %u != %Zu\n", *len,
94134 + if (len != sizeof(struct arpt_getinfo)) {
94135 + duprintf("length %u != %Zu\n", len,
94136 sizeof(struct arpt_getinfo));
94137 return -EINVAL;
94138 }
94139 @@ -924,7 +924,7 @@ static int get_info(struct net *net, void __user *user,
94140 info.size = private->size;
94141 strcpy(info.name, name);
94142
94143 - if (copy_to_user(user, &info, *len) != 0)
94144 + if (copy_to_user(user, &info, len) != 0)
94145 ret = -EFAULT;
94146 else
94147 ret = 0;
94148 @@ -1683,7 +1683,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
94149
94150 switch (cmd) {
94151 case ARPT_SO_GET_INFO:
94152 - ret = get_info(sock_net(sk), user, len, 1);
94153 + ret = get_info(sock_net(sk), user, *len, 1);
94154 break;
94155 case ARPT_SO_GET_ENTRIES:
94156 ret = compat_get_entries(sock_net(sk), user, len);
94157 @@ -1728,7 +1728,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
94158
94159 switch (cmd) {
94160 case ARPT_SO_GET_INFO:
94161 - ret = get_info(sock_net(sk), user, len, 0);
94162 + ret = get_info(sock_net(sk), user, *len, 0);
94163 break;
94164
94165 case ARPT_SO_GET_ENTRIES:
94166 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
94167 index d23118d..6ad7277 100644
94168 --- a/net/ipv4/netfilter/ip_tables.c
94169 +++ b/net/ipv4/netfilter/ip_tables.c
94170 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
94171 #endif
94172
94173 static int get_info(struct net *net, void __user *user,
94174 - const int *len, int compat)
94175 + int len, int compat)
94176 {
94177 char name[XT_TABLE_MAXNAMELEN];
94178 struct xt_table *t;
94179 int ret;
94180
94181 - if (*len != sizeof(struct ipt_getinfo)) {
94182 - duprintf("length %u != %zu\n", *len,
94183 + if (len != sizeof(struct ipt_getinfo)) {
94184 + duprintf("length %u != %zu\n", len,
94185 sizeof(struct ipt_getinfo));
94186 return -EINVAL;
94187 }
94188 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
94189 info.size = private->size;
94190 strcpy(info.name, name);
94191
94192 - if (copy_to_user(user, &info, *len) != 0)
94193 + if (copy_to_user(user, &info, len) != 0)
94194 ret = -EFAULT;
94195 else
94196 ret = 0;
94197 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
94198
94199 switch (cmd) {
94200 case IPT_SO_GET_INFO:
94201 - ret = get_info(sock_net(sk), user, len, 1);
94202 + ret = get_info(sock_net(sk), user, *len, 1);
94203 break;
94204 case IPT_SO_GET_ENTRIES:
94205 ret = compat_get_entries(sock_net(sk), user, len);
94206 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
94207
94208 switch (cmd) {
94209 case IPT_SO_GET_INFO:
94210 - ret = get_info(sock_net(sk), user, len, 0);
94211 + ret = get_info(sock_net(sk), user, *len, 0);
94212 break;
94213
94214 case IPT_SO_GET_ENTRIES:
94215 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
94216 index 7d93d62..cbbf2a3 100644
94217 --- a/net/ipv4/ping.c
94218 +++ b/net/ipv4/ping.c
94219 @@ -843,7 +843,7 @@ static void ping_format_sock(struct sock *sp, struct seq_file *f,
94220 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
94221 0, sock_i_ino(sp),
94222 atomic_read(&sp->sk_refcnt), sp,
94223 - atomic_read(&sp->sk_drops), len);
94224 + atomic_read_unchecked(&sp->sk_drops), len);
94225 }
94226
94227 static int ping_seq_show(struct seq_file *seq, void *v)
94228 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
94229 index dd44e0a..06dcca4 100644
94230 --- a/net/ipv4/raw.c
94231 +++ b/net/ipv4/raw.c
94232 @@ -309,7 +309,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
94233 int raw_rcv(struct sock *sk, struct sk_buff *skb)
94234 {
94235 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
94236 - atomic_inc(&sk->sk_drops);
94237 + atomic_inc_unchecked(&sk->sk_drops);
94238 kfree_skb(skb);
94239 return NET_RX_DROP;
94240 }
94241 @@ -745,16 +745,20 @@ static int raw_init(struct sock *sk)
94242
94243 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
94244 {
94245 + struct icmp_filter filter;
94246 +
94247 if (optlen > sizeof(struct icmp_filter))
94248 optlen = sizeof(struct icmp_filter);
94249 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
94250 + if (copy_from_user(&filter, optval, optlen))
94251 return -EFAULT;
94252 + raw_sk(sk)->filter = filter;
94253 return 0;
94254 }
94255
94256 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
94257 {
94258 int len, ret = -EFAULT;
94259 + struct icmp_filter filter;
94260
94261 if (get_user(len, optlen))
94262 goto out;
94263 @@ -764,8 +768,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
94264 if (len > sizeof(struct icmp_filter))
94265 len = sizeof(struct icmp_filter);
94266 ret = -EFAULT;
94267 - if (put_user(len, optlen) ||
94268 - copy_to_user(optval, &raw_sk(sk)->filter, len))
94269 + filter = raw_sk(sk)->filter;
94270 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
94271 goto out;
94272 ret = 0;
94273 out: return ret;
94274 @@ -994,7 +998,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
94275 0, 0L, 0,
94276 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
94277 0, sock_i_ino(sp),
94278 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
94279 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
94280 }
94281
94282 static int raw_seq_show(struct seq_file *seq, void *v)
94283 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
94284 index d35bbf0..faa3ab8 100644
94285 --- a/net/ipv4/route.c
94286 +++ b/net/ipv4/route.c
94287 @@ -2558,34 +2558,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
94288 .maxlen = sizeof(int),
94289 .mode = 0200,
94290 .proc_handler = ipv4_sysctl_rtcache_flush,
94291 + .extra1 = &init_net,
94292 },
94293 { },
94294 };
94295
94296 static __net_init int sysctl_route_net_init(struct net *net)
94297 {
94298 - struct ctl_table *tbl;
94299 + ctl_table_no_const *tbl = NULL;
94300
94301 - tbl = ipv4_route_flush_table;
94302 if (!net_eq(net, &init_net)) {
94303 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
94304 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
94305 if (tbl == NULL)
94306 goto err_dup;
94307
94308 /* Don't export sysctls to unprivileged users */
94309 if (net->user_ns != &init_user_ns)
94310 tbl[0].procname = NULL;
94311 - }
94312 - tbl[0].extra1 = net;
94313 + tbl[0].extra1 = net;
94314 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
94315 + } else
94316 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
94317
94318 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
94319 if (net->ipv4.route_hdr == NULL)
94320 goto err_reg;
94321 return 0;
94322
94323 err_reg:
94324 - if (tbl != ipv4_route_flush_table)
94325 - kfree(tbl);
94326 + kfree(tbl);
94327 err_dup:
94328 return -ENOMEM;
94329 }
94330 @@ -2608,7 +2608,7 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
94331
94332 static __net_init int rt_genid_init(struct net *net)
94333 {
94334 - atomic_set(&net->rt_genid, 0);
94335 + atomic_set_unchecked(&net->rt_genid, 0);
94336 get_random_bytes(&net->ipv4.dev_addr_genid,
94337 sizeof(net->ipv4.dev_addr_genid));
94338 return 0;
94339 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
94340 index 3f25e75..3ae0f4d 100644
94341 --- a/net/ipv4/sysctl_net_ipv4.c
94342 +++ b/net/ipv4/sysctl_net_ipv4.c
94343 @@ -57,7 +57,7 @@ static int ipv4_local_port_range(ctl_table *table, int write,
94344 {
94345 int ret;
94346 int range[2];
94347 - ctl_table tmp = {
94348 + ctl_table_no_const tmp = {
94349 .data = &range,
94350 .maxlen = sizeof(range),
94351 .mode = table->mode,
94352 @@ -110,7 +110,7 @@ static int ipv4_ping_group_range(ctl_table *table, int write,
94353 int ret;
94354 gid_t urange[2];
94355 kgid_t low, high;
94356 - ctl_table tmp = {
94357 + ctl_table_no_const tmp = {
94358 .data = &urange,
94359 .maxlen = sizeof(urange),
94360 .mode = table->mode,
94361 @@ -141,7 +141,7 @@ static int proc_tcp_congestion_control(ctl_table *ctl, int write,
94362 void __user *buffer, size_t *lenp, loff_t *ppos)
94363 {
94364 char val[TCP_CA_NAME_MAX];
94365 - ctl_table tbl = {
94366 + ctl_table_no_const tbl = {
94367 .data = val,
94368 .maxlen = TCP_CA_NAME_MAX,
94369 };
94370 @@ -160,7 +160,7 @@ static int proc_tcp_available_congestion_control(ctl_table *ctl,
94371 void __user *buffer, size_t *lenp,
94372 loff_t *ppos)
94373 {
94374 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
94375 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
94376 int ret;
94377
94378 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
94379 @@ -177,7 +177,7 @@ static int proc_allowed_congestion_control(ctl_table *ctl,
94380 void __user *buffer, size_t *lenp,
94381 loff_t *ppos)
94382 {
94383 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
94384 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
94385 int ret;
94386
94387 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
94388 @@ -203,15 +203,17 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
94389 struct mem_cgroup *memcg;
94390 #endif
94391
94392 - ctl_table tmp = {
94393 + ctl_table_no_const tmp = {
94394 .data = &vec,
94395 .maxlen = sizeof(vec),
94396 .mode = ctl->mode,
94397 };
94398
94399 if (!write) {
94400 - ctl->data = &net->ipv4.sysctl_tcp_mem;
94401 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
94402 + ctl_table_no_const tcp_mem = *ctl;
94403 +
94404 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
94405 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
94406 }
94407
94408 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
94409 @@ -238,7 +240,7 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
94410 static int proc_tcp_fastopen_key(ctl_table *ctl, int write, void __user *buffer,
94411 size_t *lenp, loff_t *ppos)
94412 {
94413 - ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
94414 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
94415 struct tcp_fastopen_context *ctxt;
94416 int ret;
94417 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
94418 @@ -481,7 +483,7 @@ static struct ctl_table ipv4_table[] = {
94419 },
94420 {
94421 .procname = "ip_local_reserved_ports",
94422 - .data = NULL, /* initialized in sysctl_ipv4_init */
94423 + .data = sysctl_local_reserved_ports,
94424 .maxlen = 65536,
94425 .mode = 0644,
94426 .proc_handler = proc_do_large_bitmap,
94427 @@ -846,11 +848,10 @@ static struct ctl_table ipv4_net_table[] = {
94428
94429 static __net_init int ipv4_sysctl_init_net(struct net *net)
94430 {
94431 - struct ctl_table *table;
94432 + ctl_table_no_const *table = NULL;
94433
94434 - table = ipv4_net_table;
94435 if (!net_eq(net, &init_net)) {
94436 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
94437 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
94438 if (table == NULL)
94439 goto err_alloc;
94440
94441 @@ -885,15 +886,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
94442
94443 tcp_init_mem(net);
94444
94445 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
94446 + if (!net_eq(net, &init_net))
94447 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
94448 + else
94449 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
94450 if (net->ipv4.ipv4_hdr == NULL)
94451 goto err_reg;
94452
94453 return 0;
94454
94455 err_reg:
94456 - if (!net_eq(net, &init_net))
94457 - kfree(table);
94458 + kfree(table);
94459 err_alloc:
94460 return -ENOMEM;
94461 }
94462 @@ -915,16 +918,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
94463 static __init int sysctl_ipv4_init(void)
94464 {
94465 struct ctl_table_header *hdr;
94466 - struct ctl_table *i;
94467 -
94468 - for (i = ipv4_table; i->procname; i++) {
94469 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
94470 - i->data = sysctl_local_reserved_ports;
94471 - break;
94472 - }
94473 - }
94474 - if (!i->procname)
94475 - return -EINVAL;
94476
94477 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
94478 if (hdr == NULL)
94479 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
94480 index 9c62257..651cc27 100644
94481 --- a/net/ipv4/tcp_input.c
94482 +++ b/net/ipv4/tcp_input.c
94483 @@ -4436,7 +4436,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
94484 * simplifies code)
94485 */
94486 static void
94487 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
94488 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
94489 struct sk_buff *head, struct sk_buff *tail,
94490 u32 start, u32 end)
94491 {
94492 @@ -5522,6 +5522,7 @@ discard:
94493 tcp_paws_reject(&tp->rx_opt, 0))
94494 goto discard_and_undo;
94495
94496 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
94497 if (th->syn) {
94498 /* We see SYN without ACK. It is attempt of
94499 * simultaneous connect with crossed SYNs.
94500 @@ -5572,6 +5573,7 @@ discard:
94501 goto discard;
94502 #endif
94503 }
94504 +#endif
94505 /* "fifth, if neither of the SYN or RST bits is set then
94506 * drop the segment and return."
94507 */
94508 @@ -5616,7 +5618,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
94509 goto discard;
94510
94511 if (th->syn) {
94512 - if (th->fin)
94513 + if (th->fin || th->urg || th->psh)
94514 goto discard;
94515 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
94516 return 1;
94517 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
94518 index 7999fc5..c812f42 100644
94519 --- a/net/ipv4/tcp_ipv4.c
94520 +++ b/net/ipv4/tcp_ipv4.c
94521 @@ -90,6 +90,10 @@ int sysctl_tcp_low_latency __read_mostly;
94522 EXPORT_SYMBOL(sysctl_tcp_low_latency);
94523
94524
94525 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94526 +extern int grsec_enable_blackhole;
94527 +#endif
94528 +
94529 #ifdef CONFIG_TCP_MD5SIG
94530 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
94531 __be32 daddr, __be32 saddr, const struct tcphdr *th);
94532 @@ -1855,6 +1859,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
94533 return 0;
94534
94535 reset:
94536 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94537 + if (!grsec_enable_blackhole)
94538 +#endif
94539 tcp_v4_send_reset(rsk, skb);
94540 discard:
94541 kfree_skb(skb);
94542 @@ -2000,12 +2007,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
94543 TCP_SKB_CB(skb)->sacked = 0;
94544
94545 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
94546 - if (!sk)
94547 + if (!sk) {
94548 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94549 + ret = 1;
94550 +#endif
94551 goto no_tcp_socket;
94552 -
94553 + }
94554 process:
94555 - if (sk->sk_state == TCP_TIME_WAIT)
94556 + if (sk->sk_state == TCP_TIME_WAIT) {
94557 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94558 + ret = 2;
94559 +#endif
94560 goto do_time_wait;
94561 + }
94562
94563 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
94564 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
94565 @@ -2058,6 +2072,10 @@ csum_error:
94566 bad_packet:
94567 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
94568 } else {
94569 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94570 + if (!grsec_enable_blackhole || (ret == 1 &&
94571 + (skb->dev->flags & IFF_LOOPBACK)))
94572 +#endif
94573 tcp_v4_send_reset(NULL, skb);
94574 }
94575
94576 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
94577 index 0f01788..d52a859 100644
94578 --- a/net/ipv4/tcp_minisocks.c
94579 +++ b/net/ipv4/tcp_minisocks.c
94580 @@ -27,6 +27,10 @@
94581 #include <net/inet_common.h>
94582 #include <net/xfrm.h>
94583
94584 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94585 +extern int grsec_enable_blackhole;
94586 +#endif
94587 +
94588 int sysctl_tcp_syncookies __read_mostly = 1;
94589 EXPORT_SYMBOL(sysctl_tcp_syncookies);
94590
94591 @@ -717,7 +721,10 @@ embryonic_reset:
94592 * avoid becoming vulnerable to outside attack aiming at
94593 * resetting legit local connections.
94594 */
94595 - req->rsk_ops->send_reset(sk, skb);
94596 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94597 + if (!grsec_enable_blackhole)
94598 +#endif
94599 + req->rsk_ops->send_reset(sk, skb);
94600 } else if (fastopen) { /* received a valid RST pkt */
94601 reqsk_fastopen_remove(sk, req, true);
94602 tcp_reset(sk);
94603 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
94604 index d4943f6..e7a74a5 100644
94605 --- a/net/ipv4/tcp_probe.c
94606 +++ b/net/ipv4/tcp_probe.c
94607 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
94608 if (cnt + width >= len)
94609 break;
94610
94611 - if (copy_to_user(buf + cnt, tbuf, width))
94612 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
94613 return -EFAULT;
94614 cnt += width;
94615 }
94616 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
94617 index 4b85e6f..22f9ac9 100644
94618 --- a/net/ipv4/tcp_timer.c
94619 +++ b/net/ipv4/tcp_timer.c
94620 @@ -22,6 +22,10 @@
94621 #include <linux/gfp.h>
94622 #include <net/tcp.h>
94623
94624 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94625 +extern int grsec_lastack_retries;
94626 +#endif
94627 +
94628 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
94629 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
94630 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
94631 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
94632 }
94633 }
94634
94635 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94636 + if ((sk->sk_state == TCP_LAST_ACK) &&
94637 + (grsec_lastack_retries > 0) &&
94638 + (grsec_lastack_retries < retry_until))
94639 + retry_until = grsec_lastack_retries;
94640 +#endif
94641 +
94642 if (retransmits_timed_out(sk, retry_until,
94643 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
94644 /* Has it gone just too far? */
94645 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
94646 index 93b731d..5a2dd92 100644
94647 --- a/net/ipv4/udp.c
94648 +++ b/net/ipv4/udp.c
94649 @@ -87,6 +87,7 @@
94650 #include <linux/types.h>
94651 #include <linux/fcntl.h>
94652 #include <linux/module.h>
94653 +#include <linux/security.h>
94654 #include <linux/socket.h>
94655 #include <linux/sockios.h>
94656 #include <linux/igmp.h>
94657 @@ -111,6 +112,10 @@
94658 #include <trace/events/skb.h>
94659 #include "udp_impl.h"
94660
94661 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94662 +extern int grsec_enable_blackhole;
94663 +#endif
94664 +
94665 struct udp_table udp_table __read_mostly;
94666 EXPORT_SYMBOL(udp_table);
94667
94668 @@ -594,6 +599,9 @@ found:
94669 return s;
94670 }
94671
94672 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
94673 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
94674 +
94675 /*
94676 * This routine is called by the ICMP module when it gets some
94677 * sort of error condition. If err < 0 then the socket should
94678 @@ -890,9 +898,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
94679 dport = usin->sin_port;
94680 if (dport == 0)
94681 return -EINVAL;
94682 +
94683 + err = gr_search_udp_sendmsg(sk, usin);
94684 + if (err)
94685 + return err;
94686 } else {
94687 if (sk->sk_state != TCP_ESTABLISHED)
94688 return -EDESTADDRREQ;
94689 +
94690 + err = gr_search_udp_sendmsg(sk, NULL);
94691 + if (err)
94692 + return err;
94693 +
94694 daddr = inet->inet_daddr;
94695 dport = inet->inet_dport;
94696 /* Open fast path for connected socket.
94697 @@ -1136,7 +1153,7 @@ static unsigned int first_packet_length(struct sock *sk)
94698 IS_UDPLITE(sk));
94699 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
94700 IS_UDPLITE(sk));
94701 - atomic_inc(&sk->sk_drops);
94702 + atomic_inc_unchecked(&sk->sk_drops);
94703 __skb_unlink(skb, rcvq);
94704 __skb_queue_tail(&list_kill, skb);
94705 }
94706 @@ -1222,6 +1239,10 @@ try_again:
94707 if (!skb)
94708 goto out;
94709
94710 + err = gr_search_udp_recvmsg(sk, skb);
94711 + if (err)
94712 + goto out_free;
94713 +
94714 ulen = skb->len - sizeof(struct udphdr);
94715 copied = len;
94716 if (copied > ulen)
94717 @@ -1255,7 +1276,7 @@ try_again:
94718 if (unlikely(err)) {
94719 trace_kfree_skb(skb, udp_recvmsg);
94720 if (!peeked) {
94721 - atomic_inc(&sk->sk_drops);
94722 + atomic_inc_unchecked(&sk->sk_drops);
94723 UDP_INC_STATS_USER(sock_net(sk),
94724 UDP_MIB_INERRORS, is_udplite);
94725 }
94726 @@ -1542,7 +1563,7 @@ csum_error:
94727 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
94728 drop:
94729 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
94730 - atomic_inc(&sk->sk_drops);
94731 + atomic_inc_unchecked(&sk->sk_drops);
94732 kfree_skb(skb);
94733 return -1;
94734 }
94735 @@ -1561,7 +1582,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
94736 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
94737
94738 if (!skb1) {
94739 - atomic_inc(&sk->sk_drops);
94740 + atomic_inc_unchecked(&sk->sk_drops);
94741 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
94742 IS_UDPLITE(sk));
94743 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
94744 @@ -1730,6 +1751,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
94745 goto csum_error;
94746
94747 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
94748 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94749 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
94750 +#endif
94751 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
94752
94753 /*
94754 @@ -2160,7 +2184,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
94755 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
94756 0, sock_i_ino(sp),
94757 atomic_read(&sp->sk_refcnt), sp,
94758 - atomic_read(&sp->sk_drops), len);
94759 + atomic_read_unchecked(&sp->sk_drops), len);
94760 }
94761
94762 int udp4_seq_show(struct seq_file *seq, void *v)
94763 diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
94764 index 9a459be..086b866 100644
94765 --- a/net/ipv4/xfrm4_policy.c
94766 +++ b/net/ipv4/xfrm4_policy.c
94767 @@ -264,19 +264,18 @@ static struct ctl_table xfrm4_policy_table[] = {
94768
94769 static int __net_init xfrm4_net_init(struct net *net)
94770 {
94771 - struct ctl_table *table;
94772 + ctl_table_no_const *table = NULL;
94773 struct ctl_table_header *hdr;
94774
94775 - table = xfrm4_policy_table;
94776 if (!net_eq(net, &init_net)) {
94777 - table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
94778 + table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
94779 if (!table)
94780 goto err_alloc;
94781
94782 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
94783 - }
94784 -
94785 - hdr = register_net_sysctl(net, "net/ipv4", table);
94786 + hdr = register_net_sysctl(net, "net/ipv4", table);
94787 + } else
94788 + hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
94789 if (!hdr)
94790 goto err_reg;
94791
94792 @@ -284,8 +283,7 @@ static int __net_init xfrm4_net_init(struct net *net)
94793 return 0;
94794
94795 err_reg:
94796 - if (!net_eq(net, &init_net))
94797 - kfree(table);
94798 + kfree(table);
94799 err_alloc:
94800 return -ENOMEM;
94801 }
94802 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
94803 index fb8c94c..80a31d8 100644
94804 --- a/net/ipv6/addrconf.c
94805 +++ b/net/ipv6/addrconf.c
94806 @@ -621,7 +621,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb,
94807 idx = 0;
94808 head = &net->dev_index_head[h];
94809 rcu_read_lock();
94810 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^
94811 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^
94812 net->dev_base_seq;
94813 hlist_for_each_entry_rcu(dev, head, index_hlist) {
94814 if (idx < s_idx)
94815 @@ -1124,12 +1124,10 @@ retry:
94816 if (ifp->flags & IFA_F_OPTIMISTIC)
94817 addr_flags |= IFA_F_OPTIMISTIC;
94818
94819 - ift = !max_addresses ||
94820 - ipv6_count_addresses(idev) < max_addresses ?
94821 - ipv6_add_addr(idev, &addr, tmp_plen,
94822 - ipv6_addr_type(&addr)&IPV6_ADDR_SCOPE_MASK,
94823 - addr_flags) : NULL;
94824 - if (IS_ERR_OR_NULL(ift)) {
94825 + ift = ipv6_add_addr(idev, &addr, tmp_plen,
94826 + ipv6_addr_type(&addr)&IPV6_ADDR_SCOPE_MASK,
94827 + addr_flags);
94828 + if (IS_ERR(ift)) {
94829 in6_ifa_put(ifp);
94830 in6_dev_put(idev);
94831 pr_info("%s: retry temporary address regeneration\n", __func__);
94832 @@ -2380,7 +2378,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
94833 p.iph.ihl = 5;
94834 p.iph.protocol = IPPROTO_IPV6;
94835 p.iph.ttl = 64;
94836 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
94837 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
94838
94839 if (ops->ndo_do_ioctl) {
94840 mm_segment_t oldfs = get_fs();
94841 @@ -4002,7 +4000,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
94842 s_ip_idx = ip_idx = cb->args[2];
94843
94844 rcu_read_lock();
94845 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
94846 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
94847 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
94848 idx = 0;
94849 head = &net->dev_index_head[h];
94850 @@ -4587,7 +4585,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
94851 dst_free(&ifp->rt->dst);
94852 break;
94853 }
94854 - atomic_inc(&net->ipv6.dev_addr_genid);
94855 + atomic_inc_unchecked(&net->ipv6.dev_addr_genid);
94856 }
94857
94858 static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
94859 @@ -4607,7 +4605,7 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write,
94860 int *valp = ctl->data;
94861 int val = *valp;
94862 loff_t pos = *ppos;
94863 - ctl_table lctl;
94864 + ctl_table_no_const lctl;
94865 int ret;
94866
94867 /*
94868 @@ -4689,7 +4687,7 @@ int addrconf_sysctl_disable(ctl_table *ctl, int write,
94869 int *valp = ctl->data;
94870 int val = *valp;
94871 loff_t pos = *ppos;
94872 - ctl_table lctl;
94873 + ctl_table_no_const lctl;
94874 int ret;
94875
94876 /*
94877 diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
94878 index 40ffd72..aeac0dc 100644
94879 --- a/net/ipv6/esp6.c
94880 +++ b/net/ipv6/esp6.c
94881 @@ -425,7 +425,7 @@ static u32 esp6_get_mtu(struct xfrm_state *x, int mtu)
94882 net_adj = 0;
94883
94884 return ((mtu - x->props.header_len - crypto_aead_authsize(esp->aead) -
94885 - net_adj) & ~(align - 1)) + (net_adj - 2);
94886 + net_adj) & ~(align - 1)) + net_adj - 2;
94887 }
94888
94889 static void esp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
94890 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
94891 index b4ff0a4..db9b764 100644
94892 --- a/net/ipv6/icmp.c
94893 +++ b/net/ipv6/icmp.c
94894 @@ -980,7 +980,7 @@ ctl_table ipv6_icmp_table_template[] = {
94895
94896 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
94897 {
94898 - struct ctl_table *table;
94899 + ctl_table_no_const *table;
94900
94901 table = kmemdup(ipv6_icmp_table_template,
94902 sizeof(ipv6_icmp_table_template),
94903 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
94904 index ecd6073..58162ae 100644
94905 --- a/net/ipv6/ip6_gre.c
94906 +++ b/net/ipv6/ip6_gre.c
94907 @@ -74,7 +74,7 @@ struct ip6gre_net {
94908 struct net_device *fb_tunnel_dev;
94909 };
94910
94911 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
94912 +static struct rtnl_link_ops ip6gre_link_ops;
94913 static int ip6gre_tunnel_init(struct net_device *dev);
94914 static void ip6gre_tunnel_setup(struct net_device *dev);
94915 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
94916 @@ -1283,7 +1283,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
94917 }
94918
94919
94920 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
94921 +static struct inet6_protocol ip6gre_protocol = {
94922 .handler = ip6gre_rcv,
94923 .err_handler = ip6gre_err,
94924 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
94925 @@ -1617,7 +1617,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
94926 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
94927 };
94928
94929 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
94930 +static struct rtnl_link_ops ip6gre_link_ops = {
94931 .kind = "ip6gre",
94932 .maxtype = IFLA_GRE_MAX,
94933 .policy = ip6gre_policy,
94934 @@ -1630,7 +1630,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
94935 .fill_info = ip6gre_fill_info,
94936 };
94937
94938 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
94939 +static struct rtnl_link_ops ip6gre_tap_ops = {
94940 .kind = "ip6gretap",
94941 .maxtype = IFLA_GRE_MAX,
94942 .policy = ip6gre_policy,
94943 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
94944 index 1e55866..b398dab 100644
94945 --- a/net/ipv6/ip6_tunnel.c
94946 +++ b/net/ipv6/ip6_tunnel.c
94947 @@ -88,7 +88,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
94948
94949 static int ip6_tnl_dev_init(struct net_device *dev);
94950 static void ip6_tnl_dev_setup(struct net_device *dev);
94951 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
94952 +static struct rtnl_link_ops ip6_link_ops;
94953
94954 static int ip6_tnl_net_id __read_mostly;
94955 struct ip6_tnl_net {
94956 @@ -1672,7 +1672,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
94957 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
94958 };
94959
94960 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
94961 +static struct rtnl_link_ops ip6_link_ops = {
94962 .kind = "ip6tnl",
94963 .maxtype = IFLA_IPTUN_MAX,
94964 .policy = ip6_tnl_policy,
94965 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
94966 index d1e2e8e..51c19ae 100644
94967 --- a/net/ipv6/ipv6_sockglue.c
94968 +++ b/net/ipv6/ipv6_sockglue.c
94969 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
94970 if (sk->sk_type != SOCK_STREAM)
94971 return -ENOPROTOOPT;
94972
94973 - msg.msg_control = optval;
94974 + msg.msg_control = (void __force_kernel *)optval;
94975 msg.msg_controllen = len;
94976 msg.msg_flags = flags;
94977
94978 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
94979 index 44400c2..8e11f52 100644
94980 --- a/net/ipv6/netfilter/ip6_tables.c
94981 +++ b/net/ipv6/netfilter/ip6_tables.c
94982 @@ -1078,14 +1078,14 @@ static int compat_table_info(const struct xt_table_info *info,
94983 #endif
94984
94985 static int get_info(struct net *net, void __user *user,
94986 - const int *len, int compat)
94987 + int len, int compat)
94988 {
94989 char name[XT_TABLE_MAXNAMELEN];
94990 struct xt_table *t;
94991 int ret;
94992
94993 - if (*len != sizeof(struct ip6t_getinfo)) {
94994 - duprintf("length %u != %zu\n", *len,
94995 + if (len != sizeof(struct ip6t_getinfo)) {
94996 + duprintf("length %u != %zu\n", len,
94997 sizeof(struct ip6t_getinfo));
94998 return -EINVAL;
94999 }
95000 @@ -1122,7 +1122,7 @@ static int get_info(struct net *net, void __user *user,
95001 info.size = private->size;
95002 strcpy(info.name, name);
95003
95004 - if (copy_to_user(user, &info, *len) != 0)
95005 + if (copy_to_user(user, &info, len) != 0)
95006 ret = -EFAULT;
95007 else
95008 ret = 0;
95009 @@ -1976,7 +1976,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
95010
95011 switch (cmd) {
95012 case IP6T_SO_GET_INFO:
95013 - ret = get_info(sock_net(sk), user, len, 1);
95014 + ret = get_info(sock_net(sk), user, *len, 1);
95015 break;
95016 case IP6T_SO_GET_ENTRIES:
95017 ret = compat_get_entries(sock_net(sk), user, len);
95018 @@ -2023,7 +2023,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
95019
95020 switch (cmd) {
95021 case IP6T_SO_GET_INFO:
95022 - ret = get_info(sock_net(sk), user, len, 0);
95023 + ret = get_info(sock_net(sk), user, *len, 0);
95024 break;
95025
95026 case IP6T_SO_GET_ENTRIES:
95027 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
95028 index dffdc1a..ccc6678 100644
95029 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
95030 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
95031 @@ -90,12 +90,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
95032
95033 static int nf_ct_frag6_sysctl_register(struct net *net)
95034 {
95035 - struct ctl_table *table;
95036 + ctl_table_no_const *table = NULL;
95037 struct ctl_table_header *hdr;
95038
95039 - table = nf_ct_frag6_sysctl_table;
95040 if (!net_eq(net, &init_net)) {
95041 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
95042 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
95043 GFP_KERNEL);
95044 if (table == NULL)
95045 goto err_alloc;
95046 @@ -103,9 +102,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
95047 table[0].data = &net->nf_frag.frags.timeout;
95048 table[1].data = &net->nf_frag.frags.low_thresh;
95049 table[2].data = &net->nf_frag.frags.high_thresh;
95050 - }
95051 -
95052 - hdr = register_net_sysctl(net, "net/netfilter", table);
95053 + hdr = register_net_sysctl(net, "net/netfilter", table);
95054 + } else
95055 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
95056 if (hdr == NULL)
95057 goto err_reg;
95058
95059 @@ -113,8 +112,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
95060 return 0;
95061
95062 err_reg:
95063 - if (!net_eq(net, &init_net))
95064 - kfree(table);
95065 + kfree(table);
95066 err_alloc:
95067 return -ENOMEM;
95068 }
95069 diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c
95070 index c2e73e6..12cca6f 100644
95071 --- a/net/ipv6/output_core.c
95072 +++ b/net/ipv6/output_core.c
95073 @@ -8,8 +8,8 @@
95074
95075 void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
95076 {
95077 - static atomic_t ipv6_fragmentation_id;
95078 - int old, new;
95079 + static atomic_unchecked_t ipv6_fragmentation_id;
95080 + int id;
95081
95082 #if IS_ENABLED(CONFIG_IPV6)
95083 if (rt && !(rt->dst.flags & DST_NOPEER)) {
95084 @@ -25,13 +25,10 @@ void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
95085 }
95086 }
95087 #endif
95088 - do {
95089 - old = atomic_read(&ipv6_fragmentation_id);
95090 - new = old + 1;
95091 - if (!new)
95092 - new = 1;
95093 - } while (atomic_cmpxchg(&ipv6_fragmentation_id, old, new) != old);
95094 - fhdr->identification = htonl(new);
95095 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
95096 + if (!id)
95097 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
95098 + fhdr->identification = htonl(id);
95099 }
95100 EXPORT_SYMBOL(ipv6_select_ident);
95101
95102 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
95103 index eedff8c..7d7e24a 100644
95104 --- a/net/ipv6/raw.c
95105 +++ b/net/ipv6/raw.c
95106 @@ -108,7 +108,7 @@ found:
95107 */
95108 static int icmpv6_filter(const struct sock *sk, const struct sk_buff *skb)
95109 {
95110 - struct icmp6hdr *_hdr;
95111 + struct icmp6hdr _hdr;
95112 const struct icmp6hdr *hdr;
95113
95114 hdr = skb_header_pointer(skb, skb_transport_offset(skb),
95115 @@ -378,7 +378,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
95116 {
95117 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
95118 skb_checksum_complete(skb)) {
95119 - atomic_inc(&sk->sk_drops);
95120 + atomic_inc_unchecked(&sk->sk_drops);
95121 kfree_skb(skb);
95122 return NET_RX_DROP;
95123 }
95124 @@ -406,7 +406,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
95125 struct raw6_sock *rp = raw6_sk(sk);
95126
95127 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
95128 - atomic_inc(&sk->sk_drops);
95129 + atomic_inc_unchecked(&sk->sk_drops);
95130 kfree_skb(skb);
95131 return NET_RX_DROP;
95132 }
95133 @@ -430,7 +430,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
95134
95135 if (inet->hdrincl) {
95136 if (skb_checksum_complete(skb)) {
95137 - atomic_inc(&sk->sk_drops);
95138 + atomic_inc_unchecked(&sk->sk_drops);
95139 kfree_skb(skb);
95140 return NET_RX_DROP;
95141 }
95142 @@ -602,7 +602,7 @@ out:
95143 return err;
95144 }
95145
95146 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
95147 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
95148 struct flowi6 *fl6, struct dst_entry **dstp,
95149 unsigned int flags)
95150 {
95151 @@ -914,12 +914,15 @@ do_confirm:
95152 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
95153 char __user *optval, int optlen)
95154 {
95155 + struct icmp6_filter filter;
95156 +
95157 switch (optname) {
95158 case ICMPV6_FILTER:
95159 if (optlen > sizeof(struct icmp6_filter))
95160 optlen = sizeof(struct icmp6_filter);
95161 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
95162 + if (copy_from_user(&filter, optval, optlen))
95163 return -EFAULT;
95164 + raw6_sk(sk)->filter = filter;
95165 return 0;
95166 default:
95167 return -ENOPROTOOPT;
95168 @@ -932,6 +935,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
95169 char __user *optval, int __user *optlen)
95170 {
95171 int len;
95172 + struct icmp6_filter filter;
95173
95174 switch (optname) {
95175 case ICMPV6_FILTER:
95176 @@ -943,7 +947,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
95177 len = sizeof(struct icmp6_filter);
95178 if (put_user(len, optlen))
95179 return -EFAULT;
95180 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
95181 + filter = raw6_sk(sk)->filter;
95182 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
95183 return -EFAULT;
95184 return 0;
95185 default:
95186 @@ -1251,7 +1256,7 @@ static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
95187 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
95188 0,
95189 sock_i_ino(sp),
95190 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
95191 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
95192 }
95193
95194 static int raw6_seq_show(struct seq_file *seq, void *v)
95195 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
95196 index 790d9f4..68ae078 100644
95197 --- a/net/ipv6/reassembly.c
95198 +++ b/net/ipv6/reassembly.c
95199 @@ -621,12 +621,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
95200
95201 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
95202 {
95203 - struct ctl_table *table;
95204 + ctl_table_no_const *table = NULL;
95205 struct ctl_table_header *hdr;
95206
95207 - table = ip6_frags_ns_ctl_table;
95208 if (!net_eq(net, &init_net)) {
95209 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
95210 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
95211 if (table == NULL)
95212 goto err_alloc;
95213
95214 @@ -637,9 +636,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
95215 /* Don't export sysctls to unprivileged users */
95216 if (net->user_ns != &init_user_ns)
95217 table[0].procname = NULL;
95218 - }
95219 + hdr = register_net_sysctl(net, "net/ipv6", table);
95220 + } else
95221 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
95222
95223 - hdr = register_net_sysctl(net, "net/ipv6", table);
95224 if (hdr == NULL)
95225 goto err_reg;
95226
95227 @@ -647,8 +647,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
95228 return 0;
95229
95230 err_reg:
95231 - if (!net_eq(net, &init_net))
95232 - kfree(table);
95233 + kfree(table);
95234 err_alloc:
95235 return -ENOMEM;
95236 }
95237 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
95238 index bacce6c..9d1741a 100644
95239 --- a/net/ipv6/route.c
95240 +++ b/net/ipv6/route.c
95241 @@ -2903,7 +2903,7 @@ ctl_table ipv6_route_table_template[] = {
95242
95243 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
95244 {
95245 - struct ctl_table *table;
95246 + ctl_table_no_const *table;
95247
95248 table = kmemdup(ipv6_route_table_template,
95249 sizeof(ipv6_route_table_template),
95250 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
95251 index 60df36d..f3ab7c8 100644
95252 --- a/net/ipv6/sit.c
95253 +++ b/net/ipv6/sit.c
95254 @@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
95255 static void ipip6_dev_free(struct net_device *dev);
95256 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
95257 __be32 *v4dst);
95258 -static struct rtnl_link_ops sit_link_ops __read_mostly;
95259 +static struct rtnl_link_ops sit_link_ops;
95260
95261 static int sit_net_id __read_mostly;
95262 struct sit_net {
95263 @@ -1453,7 +1453,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
95264 #endif
95265 };
95266
95267 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
95268 +static struct rtnl_link_ops sit_link_ops = {
95269 .kind = "sit",
95270 .maxtype = IFLA_IPTUN_MAX,
95271 .policy = ipip6_policy,
95272 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
95273 index e85c48b..b8268d3 100644
95274 --- a/net/ipv6/sysctl_net_ipv6.c
95275 +++ b/net/ipv6/sysctl_net_ipv6.c
95276 @@ -40,7 +40,7 @@ static ctl_table ipv6_rotable[] = {
95277
95278 static int __net_init ipv6_sysctl_net_init(struct net *net)
95279 {
95280 - struct ctl_table *ipv6_table;
95281 + ctl_table_no_const *ipv6_table;
95282 struct ctl_table *ipv6_route_table;
95283 struct ctl_table *ipv6_icmp_table;
95284 int err;
95285 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
95286 index 0a17ed9..2526cc3 100644
95287 --- a/net/ipv6/tcp_ipv6.c
95288 +++ b/net/ipv6/tcp_ipv6.c
95289 @@ -103,6 +103,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
95290 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
95291 }
95292
95293 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95294 +extern int grsec_enable_blackhole;
95295 +#endif
95296 +
95297 static void tcp_v6_hash(struct sock *sk)
95298 {
95299 if (sk->sk_state != TCP_CLOSE) {
95300 @@ -1398,6 +1402,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
95301 return 0;
95302
95303 reset:
95304 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95305 + if (!grsec_enable_blackhole)
95306 +#endif
95307 tcp_v6_send_reset(sk, skb);
95308 discard:
95309 if (opt_skb)
95310 @@ -1480,12 +1487,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
95311 TCP_SKB_CB(skb)->sacked = 0;
95312
95313 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
95314 - if (!sk)
95315 + if (!sk) {
95316 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95317 + ret = 1;
95318 +#endif
95319 goto no_tcp_socket;
95320 + }
95321
95322 process:
95323 - if (sk->sk_state == TCP_TIME_WAIT)
95324 + if (sk->sk_state == TCP_TIME_WAIT) {
95325 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95326 + ret = 2;
95327 +#endif
95328 goto do_time_wait;
95329 + }
95330
95331 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
95332 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
95333 @@ -1536,6 +1551,10 @@ csum_error:
95334 bad_packet:
95335 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
95336 } else {
95337 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95338 + if (!grsec_enable_blackhole || (ret == 1 &&
95339 + (skb->dev->flags & IFF_LOOPBACK)))
95340 +#endif
95341 tcp_v6_send_reset(NULL, skb);
95342 }
95343
95344 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
95345 index e7b28f9..d09c290 100644
95346 --- a/net/ipv6/udp.c
95347 +++ b/net/ipv6/udp.c
95348 @@ -52,6 +52,10 @@
95349 #include <trace/events/skb.h>
95350 #include "udp_impl.h"
95351
95352 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95353 +extern int grsec_enable_blackhole;
95354 +#endif
95355 +
95356 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
95357 {
95358 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
95359 @@ -419,7 +423,7 @@ try_again:
95360 if (unlikely(err)) {
95361 trace_kfree_skb(skb, udpv6_recvmsg);
95362 if (!peeked) {
95363 - atomic_inc(&sk->sk_drops);
95364 + atomic_inc_unchecked(&sk->sk_drops);
95365 if (is_udp4)
95366 UDP_INC_STATS_USER(sock_net(sk),
95367 UDP_MIB_INERRORS,
95368 @@ -665,7 +669,7 @@ csum_error:
95369 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
95370 drop:
95371 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
95372 - atomic_inc(&sk->sk_drops);
95373 + atomic_inc_unchecked(&sk->sk_drops);
95374 kfree_skb(skb);
95375 return -1;
95376 }
95377 @@ -723,7 +727,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
95378 if (likely(skb1 == NULL))
95379 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
95380 if (!skb1) {
95381 - atomic_inc(&sk->sk_drops);
95382 + atomic_inc_unchecked(&sk->sk_drops);
95383 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
95384 IS_UDPLITE(sk));
95385 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
95386 @@ -860,6 +864,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
95387 goto csum_error;
95388
95389 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
95390 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95391 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
95392 +#endif
95393 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
95394
95395 kfree_skb(skb);
95396 @@ -1392,7 +1399,7 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
95397 0,
95398 sock_i_ino(sp),
95399 atomic_read(&sp->sk_refcnt), sp,
95400 - atomic_read(&sp->sk_drops));
95401 + atomic_read_unchecked(&sp->sk_drops));
95402 }
95403
95404 int udp6_seq_show(struct seq_file *seq, void *v)
95405 diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
95406 index 23ed03d..465a71d 100644
95407 --- a/net/ipv6/xfrm6_policy.c
95408 +++ b/net/ipv6/xfrm6_policy.c
95409 @@ -324,19 +324,19 @@ static struct ctl_table xfrm6_policy_table[] = {
95410
95411 static int __net_init xfrm6_net_init(struct net *net)
95412 {
95413 - struct ctl_table *table;
95414 + ctl_table_no_const *table = NULL;
95415 struct ctl_table_header *hdr;
95416
95417 - table = xfrm6_policy_table;
95418 if (!net_eq(net, &init_net)) {
95419 - table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
95420 + table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
95421 if (!table)
95422 goto err_alloc;
95423
95424 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
95425 - }
95426 + hdr = register_net_sysctl(net, "net/ipv6", table);
95427 + } else
95428 + hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
95429
95430 - hdr = register_net_sysctl(net, "net/ipv6", table);
95431 if (!hdr)
95432 goto err_reg;
95433
95434 @@ -344,8 +344,7 @@ static int __net_init xfrm6_net_init(struct net *net)
95435 return 0;
95436
95437 err_reg:
95438 - if (!net_eq(net, &init_net))
95439 - kfree(table);
95440 + kfree(table);
95441 err_alloc:
95442 return -ENOMEM;
95443 }
95444 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
95445 index 41ac7938..75e3bb1 100644
95446 --- a/net/irda/ircomm/ircomm_tty.c
95447 +++ b/net/irda/ircomm/ircomm_tty.c
95448 @@ -319,11 +319,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
95449 add_wait_queue(&port->open_wait, &wait);
95450
95451 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
95452 - __FILE__, __LINE__, tty->driver->name, port->count);
95453 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
95454
95455 spin_lock_irqsave(&port->lock, flags);
95456 if (!tty_hung_up_p(filp))
95457 - port->count--;
95458 + atomic_dec(&port->count);
95459 port->blocked_open++;
95460 spin_unlock_irqrestore(&port->lock, flags);
95461
95462 @@ -358,7 +358,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
95463 }
95464
95465 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
95466 - __FILE__, __LINE__, tty->driver->name, port->count);
95467 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
95468
95469 schedule();
95470 }
95471 @@ -368,12 +368,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
95472
95473 spin_lock_irqsave(&port->lock, flags);
95474 if (!tty_hung_up_p(filp))
95475 - port->count++;
95476 + atomic_inc(&port->count);
95477 port->blocked_open--;
95478 spin_unlock_irqrestore(&port->lock, flags);
95479
95480 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
95481 - __FILE__, __LINE__, tty->driver->name, port->count);
95482 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
95483
95484 if (!retval)
95485 port->flags |= ASYNC_NORMAL_ACTIVE;
95486 @@ -447,12 +447,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
95487
95488 /* ++ is not atomic, so this should be protected - Jean II */
95489 spin_lock_irqsave(&self->port.lock, flags);
95490 - self->port.count++;
95491 + atomic_inc(&self->port.count);
95492 spin_unlock_irqrestore(&self->port.lock, flags);
95493 tty_port_tty_set(&self->port, tty);
95494
95495 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
95496 - self->line, self->port.count);
95497 + self->line, atomic_read(&self->port.count));
95498
95499 /* Not really used by us, but lets do it anyway */
95500 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
95501 @@ -989,7 +989,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
95502 tty_kref_put(port->tty);
95503 }
95504 port->tty = NULL;
95505 - port->count = 0;
95506 + atomic_set(&port->count, 0);
95507 spin_unlock_irqrestore(&port->lock, flags);
95508
95509 wake_up_interruptible(&port->open_wait);
95510 @@ -1346,7 +1346,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
95511 seq_putc(m, '\n');
95512
95513 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
95514 - seq_printf(m, "Open count: %d\n", self->port.count);
95515 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
95516 seq_printf(m, "Max data size: %d\n", self->max_data_size);
95517 seq_printf(m, "Max header size: %d\n", self->max_header_size);
95518
95519 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
95520 index ae69165..c8b82d8 100644
95521 --- a/net/iucv/af_iucv.c
95522 +++ b/net/iucv/af_iucv.c
95523 @@ -773,10 +773,10 @@ static int iucv_sock_autobind(struct sock *sk)
95524
95525 write_lock_bh(&iucv_sk_list.lock);
95526
95527 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
95528 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
95529 while (__iucv_get_sock_by_name(name)) {
95530 sprintf(name, "%08x",
95531 - atomic_inc_return(&iucv_sk_list.autobind_name));
95532 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
95533 }
95534
95535 write_unlock_bh(&iucv_sk_list.lock);
95536 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
95537 index 4fe76ff..426a904 100644
95538 --- a/net/iucv/iucv.c
95539 +++ b/net/iucv/iucv.c
95540 @@ -690,7 +690,7 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
95541 return NOTIFY_OK;
95542 }
95543
95544 -static struct notifier_block __refdata iucv_cpu_notifier = {
95545 +static struct notifier_block iucv_cpu_notifier = {
95546 .notifier_call = iucv_cpu_notify,
95547 };
95548
95549 diff --git a/net/key/af_key.c b/net/key/af_key.c
95550 index ab8bd2c..cd2d641 100644
95551 --- a/net/key/af_key.c
95552 +++ b/net/key/af_key.c
95553 @@ -3048,10 +3048,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
95554 static u32 get_acqseq(void)
95555 {
95556 u32 res;
95557 - static atomic_t acqseq;
95558 + static atomic_unchecked_t acqseq;
95559
95560 do {
95561 - res = atomic_inc_return(&acqseq);
95562 + res = atomic_inc_return_unchecked(&acqseq);
95563 } while (!res);
95564 return res;
95565 }
95566 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
95567 index ae36f8e..09d42ac 100644
95568 --- a/net/mac80211/cfg.c
95569 +++ b/net/mac80211/cfg.c
95570 @@ -806,7 +806,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
95571 ret = ieee80211_vif_use_channel(sdata, chandef,
95572 IEEE80211_CHANCTX_EXCLUSIVE);
95573 }
95574 - } else if (local->open_count == local->monitors) {
95575 + } else if (local_read(&local->open_count) == local->monitors) {
95576 local->_oper_chandef = *chandef;
95577 ieee80211_hw_config(local, 0);
95578 }
95579 @@ -2922,7 +2922,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
95580 else
95581 local->probe_req_reg--;
95582
95583 - if (!local->open_count)
95584 + if (!local_read(&local->open_count))
95585 break;
95586
95587 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
95588 @@ -3385,8 +3385,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
95589 if (chanctx_conf) {
95590 *chandef = chanctx_conf->def;
95591 ret = 0;
95592 - } else if (local->open_count > 0 &&
95593 - local->open_count == local->monitors &&
95594 + } else if (local_read(&local->open_count) > 0 &&
95595 + local_read(&local->open_count) == local->monitors &&
95596 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
95597 if (local->use_chanctx)
95598 *chandef = local->monitor_chandef;
95599 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
95600 index 9ca8e32..48e4a9b 100644
95601 --- a/net/mac80211/ieee80211_i.h
95602 +++ b/net/mac80211/ieee80211_i.h
95603 @@ -28,6 +28,7 @@
95604 #include <net/ieee80211_radiotap.h>
95605 #include <net/cfg80211.h>
95606 #include <net/mac80211.h>
95607 +#include <asm/local.h>
95608 #include "key.h"
95609 #include "sta_info.h"
95610 #include "debug.h"
95611 @@ -891,7 +892,7 @@ struct ieee80211_local {
95612 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
95613 spinlock_t queue_stop_reason_lock;
95614
95615 - int open_count;
95616 + local_t open_count;
95617 int monitors, cooked_mntrs;
95618 /* number of interfaces with corresponding FIF_ flags */
95619 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
95620 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
95621 index 514e90f..56f22bf 100644
95622 --- a/net/mac80211/iface.c
95623 +++ b/net/mac80211/iface.c
95624 @@ -502,7 +502,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
95625 break;
95626 }
95627
95628 - if (local->open_count == 0) {
95629 + if (local_read(&local->open_count) == 0) {
95630 res = drv_start(local);
95631 if (res)
95632 goto err_del_bss;
95633 @@ -545,7 +545,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
95634 break;
95635 }
95636
95637 - if (local->monitors == 0 && local->open_count == 0) {
95638 + if (local->monitors == 0 && local_read(&local->open_count) == 0) {
95639 res = ieee80211_add_virtual_monitor(local);
95640 if (res)
95641 goto err_stop;
95642 @@ -653,7 +653,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
95643 atomic_inc(&local->iff_promiscs);
95644
95645 if (coming_up)
95646 - local->open_count++;
95647 + local_inc(&local->open_count);
95648
95649 if (hw_reconf_flags)
95650 ieee80211_hw_config(local, hw_reconf_flags);
95651 @@ -691,7 +691,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
95652 err_del_interface:
95653 drv_remove_interface(local, sdata);
95654 err_stop:
95655 - if (!local->open_count)
95656 + if (!local_read(&local->open_count))
95657 drv_stop(local);
95658 err_del_bss:
95659 sdata->bss = NULL;
95660 @@ -828,7 +828,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
95661 }
95662
95663 if (going_down)
95664 - local->open_count--;
95665 + local_dec(&local->open_count);
95666
95667 switch (sdata->vif.type) {
95668 case NL80211_IFTYPE_AP_VLAN:
95669 @@ -895,7 +895,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
95670 }
95671 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
95672
95673 - if (local->open_count == 0)
95674 + if (local_read(&local->open_count) == 0)
95675 ieee80211_clear_tx_pending(local);
95676
95677 /*
95678 @@ -931,7 +931,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
95679
95680 ieee80211_recalc_ps(local, -1);
95681
95682 - if (local->open_count == 0) {
95683 + if (local_read(&local->open_count) == 0) {
95684 ieee80211_stop_device(local);
95685
95686 /* no reconfiguring after stop! */
95687 @@ -942,7 +942,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
95688 ieee80211_configure_filter(local);
95689 ieee80211_hw_config(local, hw_reconf_flags);
95690
95691 - if (local->monitors == local->open_count)
95692 + if (local->monitors == local_read(&local->open_count))
95693 ieee80211_add_virtual_monitor(local);
95694 }
95695
95696 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
95697 index 8a7bfc4..be07e86 100644
95698 --- a/net/mac80211/main.c
95699 +++ b/net/mac80211/main.c
95700 @@ -181,7 +181,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
95701 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
95702 IEEE80211_CONF_CHANGE_POWER);
95703
95704 - if (changed && local->open_count) {
95705 + if (changed && local_read(&local->open_count)) {
95706 ret = drv_config(local, changed);
95707 /*
95708 * Goal:
95709 @@ -921,7 +921,7 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
95710 hw->queues = IEEE80211_MAX_QUEUES;
95711
95712 local->workqueue =
95713 - alloc_ordered_workqueue(wiphy_name(local->hw.wiphy), 0);
95714 + alloc_ordered_workqueue("%s", 0, wiphy_name(local->hw.wiphy));
95715 if (!local->workqueue) {
95716 result = -ENOMEM;
95717 goto fail_workqueue;
95718 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
95719 index 3401262..d5cd68d 100644
95720 --- a/net/mac80211/pm.c
95721 +++ b/net/mac80211/pm.c
95722 @@ -12,7 +12,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
95723 struct ieee80211_sub_if_data *sdata;
95724 struct sta_info *sta;
95725
95726 - if (!local->open_count)
95727 + if (!local_read(&local->open_count))
95728 goto suspend;
95729
95730 ieee80211_scan_cancel(local);
95731 @@ -59,7 +59,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
95732 cancel_work_sync(&local->dynamic_ps_enable_work);
95733 del_timer_sync(&local->dynamic_ps_timer);
95734
95735 - local->wowlan = wowlan && local->open_count;
95736 + local->wowlan = wowlan && local_read(&local->open_count);
95737 if (local->wowlan) {
95738 int err = drv_suspend(local, wowlan);
95739 if (err < 0) {
95740 @@ -116,7 +116,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
95741 WARN_ON(!list_empty(&local->chanctx_list));
95742
95743 /* stop hardware - this must stop RX */
95744 - if (local->open_count)
95745 + if (local_read(&local->open_count))
95746 ieee80211_stop_device(local);
95747
95748 suspend:
95749 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
95750 index a02bef3..f2f38dd 100644
95751 --- a/net/mac80211/rate.c
95752 +++ b/net/mac80211/rate.c
95753 @@ -712,7 +712,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
95754
95755 ASSERT_RTNL();
95756
95757 - if (local->open_count)
95758 + if (local_read(&local->open_count))
95759 return -EBUSY;
95760
95761 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
95762 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
95763 index c97a065..ff61928 100644
95764 --- a/net/mac80211/rc80211_pid_debugfs.c
95765 +++ b/net/mac80211/rc80211_pid_debugfs.c
95766 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
95767
95768 spin_unlock_irqrestore(&events->lock, status);
95769
95770 - if (copy_to_user(buf, pb, p))
95771 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
95772 return -EFAULT;
95773
95774 return p;
95775 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
95776 index 72e6292..e6319eb 100644
95777 --- a/net/mac80211/util.c
95778 +++ b/net/mac80211/util.c
95779 @@ -1472,7 +1472,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
95780 }
95781 #endif
95782 /* everything else happens only if HW was up & running */
95783 - if (!local->open_count)
95784 + if (!local_read(&local->open_count))
95785 goto wake_up;
95786
95787 /*
95788 @@ -1696,7 +1696,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
95789 local->in_reconfig = false;
95790 barrier();
95791
95792 - if (local->monitors == local->open_count && local->monitors > 0)
95793 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
95794 ieee80211_add_virtual_monitor(local);
95795
95796 /*
95797 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
95798 index 56d22ca..87c778f 100644
95799 --- a/net/netfilter/Kconfig
95800 +++ b/net/netfilter/Kconfig
95801 @@ -958,6 +958,16 @@ config NETFILTER_XT_MATCH_ESP
95802
95803 To compile it as a module, choose M here. If unsure, say N.
95804
95805 +config NETFILTER_XT_MATCH_GRADM
95806 + tristate '"gradm" match support'
95807 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
95808 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
95809 + ---help---
95810 + The gradm match allows to match on grsecurity RBAC being enabled.
95811 + It is useful when iptables rules are applied early on bootup to
95812 + prevent connections to the machine (except from a trusted host)
95813 + while the RBAC system is disabled.
95814 +
95815 config NETFILTER_XT_MATCH_HASHLIMIT
95816 tristate '"hashlimit" match support'
95817 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
95818 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
95819 index a1abf87..dbcb7ee 100644
95820 --- a/net/netfilter/Makefile
95821 +++ b/net/netfilter/Makefile
95822 @@ -112,6 +112,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
95823 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
95824 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
95825 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
95826 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
95827 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
95828 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
95829 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
95830 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
95831 index f771390..145b765 100644
95832 --- a/net/netfilter/ipset/ip_set_core.c
95833 +++ b/net/netfilter/ipset/ip_set_core.c
95834 @@ -1820,7 +1820,7 @@ done:
95835 return ret;
95836 }
95837
95838 -static struct nf_sockopt_ops so_set __read_mostly = {
95839 +static struct nf_sockopt_ops so_set = {
95840 .pf = PF_INET,
95841 .get_optmin = SO_IP_SET,
95842 .get_optmax = SO_IP_SET + 1,
95843 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
95844 index a083bda..da661c3 100644
95845 --- a/net/netfilter/ipvs/ip_vs_conn.c
95846 +++ b/net/netfilter/ipvs/ip_vs_conn.c
95847 @@ -556,7 +556,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
95848 /* Increase the refcnt counter of the dest */
95849 ip_vs_dest_hold(dest);
95850
95851 - conn_flags = atomic_read(&dest->conn_flags);
95852 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
95853 if (cp->protocol != IPPROTO_UDP)
95854 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
95855 flags = cp->flags;
95856 @@ -900,7 +900,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
95857
95858 cp->control = NULL;
95859 atomic_set(&cp->n_control, 0);
95860 - atomic_set(&cp->in_pkts, 0);
95861 + atomic_set_unchecked(&cp->in_pkts, 0);
95862
95863 cp->packet_xmit = NULL;
95864 cp->app = NULL;
95865 @@ -1190,7 +1190,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
95866
95867 /* Don't drop the entry if its number of incoming packets is not
95868 located in [0, 8] */
95869 - i = atomic_read(&cp->in_pkts);
95870 + i = atomic_read_unchecked(&cp->in_pkts);
95871 if (i > 8 || i < 0) return 0;
95872
95873 if (!todrop_rate[i]) return 0;
95874 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
95875 index 23b8eb5..48a8959 100644
95876 --- a/net/netfilter/ipvs/ip_vs_core.c
95877 +++ b/net/netfilter/ipvs/ip_vs_core.c
95878 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
95879 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
95880 /* do not touch skb anymore */
95881
95882 - atomic_inc(&cp->in_pkts);
95883 + atomic_inc_unchecked(&cp->in_pkts);
95884 ip_vs_conn_put(cp);
95885 return ret;
95886 }
95887 @@ -1711,7 +1711,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
95888 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
95889 pkts = sysctl_sync_threshold(ipvs);
95890 else
95891 - pkts = atomic_add_return(1, &cp->in_pkts);
95892 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
95893
95894 if (ipvs->sync_state & IP_VS_STATE_MASTER)
95895 ip_vs_sync_conn(net, cp, pkts);
95896 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
95897 index 9e6c2a0..28552e2 100644
95898 --- a/net/netfilter/ipvs/ip_vs_ctl.c
95899 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
95900 @@ -789,7 +789,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
95901 */
95902 ip_vs_rs_hash(ipvs, dest);
95903 }
95904 - atomic_set(&dest->conn_flags, conn_flags);
95905 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
95906
95907 /* bind the service */
95908 if (!dest->svc) {
95909 @@ -1657,7 +1657,7 @@ proc_do_sync_ports(ctl_table *table, int write,
95910 * align with netns init in ip_vs_control_net_init()
95911 */
95912
95913 -static struct ctl_table vs_vars[] = {
95914 +static ctl_table_no_const vs_vars[] __read_only = {
95915 {
95916 .procname = "amemthresh",
95917 .maxlen = sizeof(int),
95918 @@ -2060,7 +2060,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
95919 " %-7s %-6d %-10d %-10d\n",
95920 &dest->addr.in6,
95921 ntohs(dest->port),
95922 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
95923 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
95924 atomic_read(&dest->weight),
95925 atomic_read(&dest->activeconns),
95926 atomic_read(&dest->inactconns));
95927 @@ -2071,7 +2071,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
95928 "%-7s %-6d %-10d %-10d\n",
95929 ntohl(dest->addr.ip),
95930 ntohs(dest->port),
95931 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
95932 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
95933 atomic_read(&dest->weight),
95934 atomic_read(&dest->activeconns),
95935 atomic_read(&dest->inactconns));
95936 @@ -2549,7 +2549,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
95937
95938 entry.addr = dest->addr.ip;
95939 entry.port = dest->port;
95940 - entry.conn_flags = atomic_read(&dest->conn_flags);
95941 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
95942 entry.weight = atomic_read(&dest->weight);
95943 entry.u_threshold = dest->u_threshold;
95944 entry.l_threshold = dest->l_threshold;
95945 @@ -3092,7 +3092,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
95946 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
95947 nla_put_be16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
95948 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
95949 - (atomic_read(&dest->conn_flags) &
95950 + (atomic_read_unchecked(&dest->conn_flags) &
95951 IP_VS_CONN_F_FWD_MASK)) ||
95952 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
95953 atomic_read(&dest->weight)) ||
95954 @@ -3682,7 +3682,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
95955 {
95956 int idx;
95957 struct netns_ipvs *ipvs = net_ipvs(net);
95958 - struct ctl_table *tbl;
95959 + ctl_table_no_const *tbl;
95960
95961 atomic_set(&ipvs->dropentry, 0);
95962 spin_lock_init(&ipvs->dropentry_lock);
95963 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
95964 index 5ea26bd..c9bc65f 100644
95965 --- a/net/netfilter/ipvs/ip_vs_lblc.c
95966 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
95967 @@ -118,7 +118,7 @@ struct ip_vs_lblc_table {
95968 * IPVS LBLC sysctl table
95969 */
95970 #ifdef CONFIG_SYSCTL
95971 -static ctl_table vs_vars_table[] = {
95972 +static ctl_table_no_const vs_vars_table[] __read_only = {
95973 {
95974 .procname = "lblc_expiration",
95975 .data = NULL,
95976 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
95977 index 50123c2..067c773 100644
95978 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
95979 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
95980 @@ -299,7 +299,7 @@ struct ip_vs_lblcr_table {
95981 * IPVS LBLCR sysctl table
95982 */
95983
95984 -static ctl_table vs_vars_table[] = {
95985 +static ctl_table_no_const vs_vars_table[] __read_only = {
95986 {
95987 .procname = "lblcr_expiration",
95988 .data = NULL,
95989 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
95990 index f6046d9..4f10cfd 100644
95991 --- a/net/netfilter/ipvs/ip_vs_sync.c
95992 +++ b/net/netfilter/ipvs/ip_vs_sync.c
95993 @@ -596,7 +596,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
95994 cp = cp->control;
95995 if (cp) {
95996 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
95997 - pkts = atomic_add_return(1, &cp->in_pkts);
95998 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
95999 else
96000 pkts = sysctl_sync_threshold(ipvs);
96001 ip_vs_sync_conn(net, cp->control, pkts);
96002 @@ -758,7 +758,7 @@ control:
96003 if (!cp)
96004 return;
96005 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
96006 - pkts = atomic_add_return(1, &cp->in_pkts);
96007 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
96008 else
96009 pkts = sysctl_sync_threshold(ipvs);
96010 goto sloop;
96011 @@ -882,7 +882,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
96012
96013 if (opt)
96014 memcpy(&cp->in_seq, opt, sizeof(*opt));
96015 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
96016 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
96017 cp->state = state;
96018 cp->old_state = cp->state;
96019 /*
96020 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
96021 index b75ff64..0c51bbe 100644
96022 --- a/net/netfilter/ipvs/ip_vs_xmit.c
96023 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
96024 @@ -1102,7 +1102,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
96025 else
96026 rc = NF_ACCEPT;
96027 /* do not touch skb anymore */
96028 - atomic_inc(&cp->in_pkts);
96029 + atomic_inc_unchecked(&cp->in_pkts);
96030 goto out;
96031 }
96032
96033 @@ -1194,7 +1194,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
96034 else
96035 rc = NF_ACCEPT;
96036 /* do not touch skb anymore */
96037 - atomic_inc(&cp->in_pkts);
96038 + atomic_inc_unchecked(&cp->in_pkts);
96039 goto out;
96040 }
96041
96042 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
96043 index 2d3030a..7ba1c0a 100644
96044 --- a/net/netfilter/nf_conntrack_acct.c
96045 +++ b/net/netfilter/nf_conntrack_acct.c
96046 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
96047 #ifdef CONFIG_SYSCTL
96048 static int nf_conntrack_acct_init_sysctl(struct net *net)
96049 {
96050 - struct ctl_table *table;
96051 + ctl_table_no_const *table;
96052
96053 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
96054 GFP_KERNEL);
96055 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
96056 index 0283bae..5febcb0 100644
96057 --- a/net/netfilter/nf_conntrack_core.c
96058 +++ b/net/netfilter/nf_conntrack_core.c
96059 @@ -1614,6 +1614,10 @@ void nf_conntrack_init_end(void)
96060 #define DYING_NULLS_VAL ((1<<30)+1)
96061 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
96062
96063 +#ifdef CONFIG_GRKERNSEC_HIDESYM
96064 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
96065 +#endif
96066 +
96067 int nf_conntrack_init_net(struct net *net)
96068 {
96069 int ret;
96070 @@ -1628,7 +1632,11 @@ int nf_conntrack_init_net(struct net *net)
96071 goto err_stat;
96072 }
96073
96074 +#ifdef CONFIG_GRKERNSEC_HIDESYM
96075 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
96076 +#else
96077 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
96078 +#endif
96079 if (!net->ct.slabname) {
96080 ret = -ENOMEM;
96081 goto err_slabname;
96082 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
96083 index 1df1761..ce8b88a 100644
96084 --- a/net/netfilter/nf_conntrack_ecache.c
96085 +++ b/net/netfilter/nf_conntrack_ecache.c
96086 @@ -188,7 +188,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
96087 #ifdef CONFIG_SYSCTL
96088 static int nf_conntrack_event_init_sysctl(struct net *net)
96089 {
96090 - struct ctl_table *table;
96091 + ctl_table_no_const *table;
96092
96093 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
96094 GFP_KERNEL);
96095 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
96096 index 974a2a4..52cc6ff 100644
96097 --- a/net/netfilter/nf_conntrack_helper.c
96098 +++ b/net/netfilter/nf_conntrack_helper.c
96099 @@ -57,7 +57,7 @@ static struct ctl_table helper_sysctl_table[] = {
96100
96101 static int nf_conntrack_helper_init_sysctl(struct net *net)
96102 {
96103 - struct ctl_table *table;
96104 + ctl_table_no_const *table;
96105
96106 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
96107 GFP_KERNEL);
96108 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
96109 index 0ab9636..cea3c6a 100644
96110 --- a/net/netfilter/nf_conntrack_proto.c
96111 +++ b/net/netfilter/nf_conntrack_proto.c
96112 @@ -52,7 +52,7 @@ nf_ct_register_sysctl(struct net *net,
96113
96114 static void
96115 nf_ct_unregister_sysctl(struct ctl_table_header **header,
96116 - struct ctl_table **table,
96117 + ctl_table_no_const **table,
96118 unsigned int users)
96119 {
96120 if (users > 0)
96121 diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
96122 index a99b6c3..cb372f9 100644
96123 --- a/net/netfilter/nf_conntrack_proto_dccp.c
96124 +++ b/net/netfilter/nf_conntrack_proto_dccp.c
96125 @@ -428,7 +428,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
96126 const char *msg;
96127 u_int8_t state;
96128
96129 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
96130 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
96131 BUG_ON(dh == NULL);
96132
96133 state = dccp_state_table[CT_DCCP_ROLE_CLIENT][dh->dccph_type][CT_DCCP_NONE];
96134 @@ -457,7 +457,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
96135 out_invalid:
96136 if (LOG_INVALID(net, IPPROTO_DCCP))
96137 nf_log_packet(net, nf_ct_l3num(ct), 0, skb, NULL, NULL,
96138 - NULL, msg);
96139 + NULL, "%s", msg);
96140 return false;
96141 }
96142
96143 @@ -486,7 +486,7 @@ static int dccp_packet(struct nf_conn *ct, const struct sk_buff *skb,
96144 u_int8_t type, old_state, new_state;
96145 enum ct_dccp_roles role;
96146
96147 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
96148 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
96149 BUG_ON(dh == NULL);
96150 type = dh->dccph_type;
96151
96152 @@ -577,7 +577,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
96153 unsigned int cscov;
96154 const char *msg;
96155
96156 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
96157 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
96158 if (dh == NULL) {
96159 msg = "nf_ct_dccp: short packet ";
96160 goto out_invalid;
96161 @@ -614,7 +614,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
96162
96163 out_invalid:
96164 if (LOG_INVALID(net, IPPROTO_DCCP))
96165 - nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, msg);
96166 + nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, "%s", msg);
96167 return -NF_ACCEPT;
96168 }
96169
96170 diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
96171 index 4d4d8f1..e0f9a32 100644
96172 --- a/net/netfilter/nf_conntrack_proto_tcp.c
96173 +++ b/net/netfilter/nf_conntrack_proto_tcp.c
96174 @@ -526,7 +526,7 @@ static bool tcp_in_window(const struct nf_conn *ct,
96175 const struct nf_conntrack_tuple *tuple = &ct->tuplehash[dir].tuple;
96176 __u32 seq, ack, sack, end, win, swin;
96177 s16 receiver_offset;
96178 - bool res;
96179 + bool res, in_recv_win;
96180
96181 /*
96182 * Get the required data from the packet.
96183 @@ -649,14 +649,18 @@ static bool tcp_in_window(const struct nf_conn *ct,
96184 receiver->td_end, receiver->td_maxend, receiver->td_maxwin,
96185 receiver->td_scale);
96186
96187 + /* Is the ending sequence in the receive window (if available)? */
96188 + in_recv_win = !receiver->td_maxwin ||
96189 + after(end, sender->td_end - receiver->td_maxwin - 1);
96190 +
96191 pr_debug("tcp_in_window: I=%i II=%i III=%i IV=%i\n",
96192 before(seq, sender->td_maxend + 1),
96193 - after(end, sender->td_end - receiver->td_maxwin - 1),
96194 + (in_recv_win ? 1 : 0),
96195 before(sack, receiver->td_end + 1),
96196 after(sack, receiver->td_end - MAXACKWINDOW(sender) - 1));
96197
96198 if (before(seq, sender->td_maxend + 1) &&
96199 - after(end, sender->td_end - receiver->td_maxwin - 1) &&
96200 + in_recv_win &&
96201 before(sack, receiver->td_end + 1) &&
96202 after(sack, receiver->td_end - MAXACKWINDOW(sender) - 1)) {
96203 /*
96204 @@ -725,7 +729,7 @@ static bool tcp_in_window(const struct nf_conn *ct,
96205 nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL,
96206 "nf_ct_tcp: %s ",
96207 before(seq, sender->td_maxend + 1) ?
96208 - after(end, sender->td_end - receiver->td_maxwin - 1) ?
96209 + in_recv_win ?
96210 before(sack, receiver->td_end + 1) ?
96211 after(sack, receiver->td_end - MAXACKWINDOW(sender) - 1) ? "BUG"
96212 : "ACK is under the lower bound (possible overly delayed ACK)"
96213 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
96214 index bd700b4..4a3dc61 100644
96215 --- a/net/netfilter/nf_conntrack_standalone.c
96216 +++ b/net/netfilter/nf_conntrack_standalone.c
96217 @@ -471,7 +471,7 @@ static ctl_table nf_ct_netfilter_table[] = {
96218
96219 static int nf_conntrack_standalone_init_sysctl(struct net *net)
96220 {
96221 - struct ctl_table *table;
96222 + ctl_table_no_const *table;
96223
96224 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
96225 GFP_KERNEL);
96226 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
96227 index 902fb0a..87f7fdb 100644
96228 --- a/net/netfilter/nf_conntrack_timestamp.c
96229 +++ b/net/netfilter/nf_conntrack_timestamp.c
96230 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
96231 #ifdef CONFIG_SYSCTL
96232 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
96233 {
96234 - struct ctl_table *table;
96235 + ctl_table_no_const *table;
96236
96237 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
96238 GFP_KERNEL);
96239 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
96240 index 3b18dd1..f79e0ca 100644
96241 --- a/net/netfilter/nf_log.c
96242 +++ b/net/netfilter/nf_log.c
96243 @@ -243,7 +243,7 @@ static const struct file_operations nflog_file_ops = {
96244
96245 #ifdef CONFIG_SYSCTL
96246 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
96247 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
96248 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
96249
96250 static int nf_log_proc_dostring(ctl_table *table, int write,
96251 void __user *buffer, size_t *lenp, loff_t *ppos)
96252 @@ -274,14 +274,16 @@ static int nf_log_proc_dostring(ctl_table *table, int write,
96253 rcu_assign_pointer(net->nf.nf_loggers[tindex], logger);
96254 mutex_unlock(&nf_log_mutex);
96255 } else {
96256 + ctl_table_no_const nf_log_table = *table;
96257 +
96258 mutex_lock(&nf_log_mutex);
96259 logger = rcu_dereference_protected(net->nf.nf_loggers[tindex],
96260 lockdep_is_held(&nf_log_mutex));
96261 if (!logger)
96262 - table->data = "NONE";
96263 + nf_log_table.data = "NONE";
96264 else
96265 - table->data = logger->name;
96266 - r = proc_dostring(table, write, buffer, lenp, ppos);
96267 + nf_log_table.data = logger->name;
96268 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
96269 mutex_unlock(&nf_log_mutex);
96270 }
96271
96272 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
96273 index f042ae5..30ea486 100644
96274 --- a/net/netfilter/nf_sockopt.c
96275 +++ b/net/netfilter/nf_sockopt.c
96276 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
96277 }
96278 }
96279
96280 - list_add(&reg->list, &nf_sockopts);
96281 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
96282 out:
96283 mutex_unlock(&nf_sockopt_mutex);
96284 return ret;
96285 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
96286 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
96287 {
96288 mutex_lock(&nf_sockopt_mutex);
96289 - list_del(&reg->list);
96290 + pax_list_del((struct list_head *)&reg->list);
96291 mutex_unlock(&nf_sockopt_mutex);
96292 }
96293 EXPORT_SYMBOL(nf_unregister_sockopt);
96294 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
96295 index 962e979..e46f350 100644
96296 --- a/net/netfilter/nfnetlink_log.c
96297 +++ b/net/netfilter/nfnetlink_log.c
96298 @@ -82,7 +82,7 @@ static int nfnl_log_net_id __read_mostly;
96299 struct nfnl_log_net {
96300 spinlock_t instances_lock;
96301 struct hlist_head instance_table[INSTANCE_BUCKETS];
96302 - atomic_t global_seq;
96303 + atomic_unchecked_t global_seq;
96304 };
96305
96306 static struct nfnl_log_net *nfnl_log_pernet(struct net *net)
96307 @@ -419,6 +419,7 @@ __build_packet_message(struct nfnl_log_net *log,
96308 nfmsg->version = NFNETLINK_V0;
96309 nfmsg->res_id = htons(inst->group_num);
96310
96311 + memset(&pmsg, 0, sizeof(pmsg));
96312 pmsg.hw_protocol = skb->protocol;
96313 pmsg.hook = hooknum;
96314
96315 @@ -498,7 +499,10 @@ __build_packet_message(struct nfnl_log_net *log,
96316 if (indev && skb->dev &&
96317 skb->mac_header != skb->network_header) {
96318 struct nfulnl_msg_packet_hw phw;
96319 - int len = dev_parse_header(skb, phw.hw_addr);
96320 + int len;
96321 +
96322 + memset(&phw, 0, sizeof(phw));
96323 + len = dev_parse_header(skb, phw.hw_addr);
96324 if (len > 0) {
96325 phw.hw_addrlen = htons(len);
96326 if (nla_put(inst->skb, NFULA_HWADDR, sizeof(phw), &phw))
96327 @@ -559,7 +563,7 @@ __build_packet_message(struct nfnl_log_net *log,
96328 /* global sequence number */
96329 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
96330 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
96331 - htonl(atomic_inc_return(&log->global_seq))))
96332 + htonl(atomic_inc_return_unchecked(&log->global_seq))))
96333 goto nla_put_failure;
96334
96335 if (data_len) {
96336 diff --git a/net/netfilter/nfnetlink_queue_core.c b/net/netfilter/nfnetlink_queue_core.c
96337 index 5352b2d..e0083ce 100644
96338 --- a/net/netfilter/nfnetlink_queue_core.c
96339 +++ b/net/netfilter/nfnetlink_queue_core.c
96340 @@ -444,7 +444,10 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue,
96341 if (indev && entskb->dev &&
96342 entskb->mac_header != entskb->network_header) {
96343 struct nfqnl_msg_packet_hw phw;
96344 - int len = dev_parse_header(entskb, phw.hw_addr);
96345 + int len;
96346 +
96347 + memset(&phw, 0, sizeof(phw));
96348 + len = dev_parse_header(entskb, phw.hw_addr);
96349 if (len) {
96350 phw.hw_addrlen = htons(len);
96351 if (nla_put(skb, NFQA_HWADDR, sizeof(phw), &phw))
96352 diff --git a/net/netfilter/xt_TCPMSS.c b/net/netfilter/xt_TCPMSS.c
96353 index 7011c71..6113cc7 100644
96354 --- a/net/netfilter/xt_TCPMSS.c
96355 +++ b/net/netfilter/xt_TCPMSS.c
96356 @@ -52,7 +52,8 @@ tcpmss_mangle_packet(struct sk_buff *skb,
96357 {
96358 const struct xt_tcpmss_info *info = par->targinfo;
96359 struct tcphdr *tcph;
96360 - unsigned int tcplen, i;
96361 + int len, tcp_hdrlen;
96362 + unsigned int i;
96363 __be16 oldval;
96364 u16 newmss;
96365 u8 *opt;
96366 @@ -64,11 +65,14 @@ tcpmss_mangle_packet(struct sk_buff *skb,
96367 if (!skb_make_writable(skb, skb->len))
96368 return -1;
96369
96370 - tcplen = skb->len - tcphoff;
96371 + len = skb->len - tcphoff;
96372 + if (len < (int)sizeof(struct tcphdr))
96373 + return -1;
96374 +
96375 tcph = (struct tcphdr *)(skb_network_header(skb) + tcphoff);
96376 + tcp_hdrlen = tcph->doff * 4;
96377
96378 - /* Header cannot be larger than the packet */
96379 - if (tcplen < tcph->doff*4)
96380 + if (len < tcp_hdrlen)
96381 return -1;
96382
96383 if (info->mss == XT_TCPMSS_CLAMP_PMTU) {
96384 @@ -87,9 +91,8 @@ tcpmss_mangle_packet(struct sk_buff *skb,
96385 newmss = info->mss;
96386
96387 opt = (u_int8_t *)tcph;
96388 - for (i = sizeof(struct tcphdr); i < tcph->doff*4; i += optlen(opt, i)) {
96389 - if (opt[i] == TCPOPT_MSS && tcph->doff*4 - i >= TCPOLEN_MSS &&
96390 - opt[i+1] == TCPOLEN_MSS) {
96391 + for (i = sizeof(struct tcphdr); i <= tcp_hdrlen - TCPOLEN_MSS; i += optlen(opt, i)) {
96392 + if (opt[i] == TCPOPT_MSS && opt[i+1] == TCPOLEN_MSS) {
96393 u_int16_t oldmss;
96394
96395 oldmss = (opt[i+2] << 8) | opt[i+3];
96396 @@ -112,9 +115,10 @@ tcpmss_mangle_packet(struct sk_buff *skb,
96397 }
96398
96399 /* There is data after the header so the option can't be added
96400 - without moving it, and doing so may make the SYN packet
96401 - itself too large. Accept the packet unmodified instead. */
96402 - if (tcplen > tcph->doff*4)
96403 + * without moving it, and doing so may make the SYN packet
96404 + * itself too large. Accept the packet unmodified instead.
96405 + */
96406 + if (len > tcp_hdrlen)
96407 return 0;
96408
96409 /*
96410 @@ -143,10 +147,10 @@ tcpmss_mangle_packet(struct sk_buff *skb,
96411 newmss = min(newmss, (u16)1220);
96412
96413 opt = (u_int8_t *)tcph + sizeof(struct tcphdr);
96414 - memmove(opt + TCPOLEN_MSS, opt, tcplen - sizeof(struct tcphdr));
96415 + memmove(opt + TCPOLEN_MSS, opt, len - sizeof(struct tcphdr));
96416
96417 inet_proto_csum_replace2(&tcph->check, skb,
96418 - htons(tcplen), htons(tcplen + TCPOLEN_MSS), 1);
96419 + htons(len), htons(len + TCPOLEN_MSS), 1);
96420 opt[0] = TCPOPT_MSS;
96421 opt[1] = TCPOLEN_MSS;
96422 opt[2] = (newmss & 0xff00) >> 8;
96423 diff --git a/net/netfilter/xt_TCPOPTSTRIP.c b/net/netfilter/xt_TCPOPTSTRIP.c
96424 index b68fa19..625fa1d 100644
96425 --- a/net/netfilter/xt_TCPOPTSTRIP.c
96426 +++ b/net/netfilter/xt_TCPOPTSTRIP.c
96427 @@ -38,7 +38,7 @@ tcpoptstrip_mangle_packet(struct sk_buff *skb,
96428 struct tcphdr *tcph;
96429 u_int16_t n, o;
96430 u_int8_t *opt;
96431 - int len;
96432 + int len, tcp_hdrlen;
96433
96434 /* This is a fragment, no TCP header is available */
96435 if (par->fragoff != 0)
96436 @@ -52,7 +52,9 @@ tcpoptstrip_mangle_packet(struct sk_buff *skb,
96437 return NF_DROP;
96438
96439 tcph = (struct tcphdr *)(skb_network_header(skb) + tcphoff);
96440 - if (tcph->doff * 4 > len)
96441 + tcp_hdrlen = tcph->doff * 4;
96442 +
96443 + if (len < tcp_hdrlen)
96444 return NF_DROP;
96445
96446 opt = (u_int8_t *)tcph;
96447 @@ -61,10 +63,10 @@ tcpoptstrip_mangle_packet(struct sk_buff *skb,
96448 * Walk through all TCP options - if we find some option to remove,
96449 * set all octets to %TCPOPT_NOP and adjust checksum.
96450 */
96451 - for (i = sizeof(struct tcphdr); i < tcp_hdrlen(skb); i += optl) {
96452 + for (i = sizeof(struct tcphdr); i < tcp_hdrlen - 1; i += optl) {
96453 optl = optlen(opt, i);
96454
96455 - if (i + optl > tcp_hdrlen(skb))
96456 + if (i + optl > tcp_hdrlen)
96457 break;
96458
96459 if (!tcpoptstrip_test_bit(info->strip_bmap, opt[i]))
96460 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
96461 new file mode 100644
96462 index 0000000..c566332
96463 --- /dev/null
96464 +++ b/net/netfilter/xt_gradm.c
96465 @@ -0,0 +1,51 @@
96466 +/*
96467 + * gradm match for netfilter
96468 + * Copyright © Zbigniew Krzystolik, 2010
96469 + *
96470 + * This program is free software; you can redistribute it and/or modify
96471 + * it under the terms of the GNU General Public License; either version
96472 + * 2 or 3 as published by the Free Software Foundation.
96473 + */
96474 +#include <linux/module.h>
96475 +#include <linux/moduleparam.h>
96476 +#include <linux/skbuff.h>
96477 +#include <linux/netfilter/x_tables.h>
96478 +#include <linux/grsecurity.h>
96479 +#include <linux/netfilter/xt_gradm.h>
96480 +
96481 +static bool
96482 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
96483 +{
96484 + const struct xt_gradm_mtinfo *info = par->matchinfo;
96485 + bool retval = false;
96486 + if (gr_acl_is_enabled())
96487 + retval = true;
96488 + return retval ^ info->invflags;
96489 +}
96490 +
96491 +static struct xt_match gradm_mt_reg __read_mostly = {
96492 + .name = "gradm",
96493 + .revision = 0,
96494 + .family = NFPROTO_UNSPEC,
96495 + .match = gradm_mt,
96496 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
96497 + .me = THIS_MODULE,
96498 +};
96499 +
96500 +static int __init gradm_mt_init(void)
96501 +{
96502 + return xt_register_match(&gradm_mt_reg);
96503 +}
96504 +
96505 +static void __exit gradm_mt_exit(void)
96506 +{
96507 + xt_unregister_match(&gradm_mt_reg);
96508 +}
96509 +
96510 +module_init(gradm_mt_init);
96511 +module_exit(gradm_mt_exit);
96512 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
96513 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
96514 +MODULE_LICENSE("GPL");
96515 +MODULE_ALIAS("ipt_gradm");
96516 +MODULE_ALIAS("ip6t_gradm");
96517 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
96518 index 4fe4fb4..87a89e5 100644
96519 --- a/net/netfilter/xt_statistic.c
96520 +++ b/net/netfilter/xt_statistic.c
96521 @@ -19,7 +19,7 @@
96522 #include <linux/module.h>
96523
96524 struct xt_statistic_priv {
96525 - atomic_t count;
96526 + atomic_unchecked_t count;
96527 } ____cacheline_aligned_in_smp;
96528
96529 MODULE_LICENSE("GPL");
96530 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
96531 break;
96532 case XT_STATISTIC_MODE_NTH:
96533 do {
96534 - oval = atomic_read(&info->master->count);
96535 + oval = atomic_read_unchecked(&info->master->count);
96536 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
96537 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
96538 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
96539 if (nval == 0)
96540 ret = !ret;
96541 break;
96542 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
96543 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
96544 if (info->master == NULL)
96545 return -ENOMEM;
96546 - atomic_set(&info->master->count, info->u.nth.count);
96547 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
96548
96549 return 0;
96550 }
96551 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
96552 index 57ee84d..8b99cf5 100644
96553 --- a/net/netlink/af_netlink.c
96554 +++ b/net/netlink/af_netlink.c
96555 @@ -121,7 +121,7 @@ static void netlink_overrun(struct sock *sk)
96556 sk->sk_error_report(sk);
96557 }
96558 }
96559 - atomic_inc(&sk->sk_drops);
96560 + atomic_inc_unchecked(&sk->sk_drops);
96561 }
96562
96563 static void netlink_rcv_wake(struct sock *sk)
96564 @@ -2771,7 +2771,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
96565 sk_wmem_alloc_get(s),
96566 nlk->cb,
96567 atomic_read(&s->sk_refcnt),
96568 - atomic_read(&s->sk_drops),
96569 + atomic_read_unchecked(&s->sk_drops),
96570 sock_i_ino(s)
96571 );
96572
96573 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
96574 index 1076fe1..f190285 100644
96575 --- a/net/netlink/genetlink.c
96576 +++ b/net/netlink/genetlink.c
96577 @@ -310,18 +310,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
96578 goto errout;
96579 }
96580
96581 + pax_open_kernel();
96582 if (ops->dumpit)
96583 - ops->flags |= GENL_CMD_CAP_DUMP;
96584 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
96585 if (ops->doit)
96586 - ops->flags |= GENL_CMD_CAP_DO;
96587 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
96588 if (ops->policy)
96589 - ops->flags |= GENL_CMD_CAP_HASPOL;
96590 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
96591 + pax_close_kernel();
96592
96593 genl_lock_all();
96594 - list_add_tail(&ops->ops_list, &family->ops_list);
96595 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
96596 genl_unlock_all();
96597
96598 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
96599 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
96600 err = 0;
96601 errout:
96602 return err;
96603 @@ -351,9 +353,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
96604 genl_lock_all();
96605 list_for_each_entry(rc, &family->ops_list, ops_list) {
96606 if (rc == ops) {
96607 - list_del(&ops->ops_list);
96608 + pax_list_del((struct list_head *)&ops->ops_list);
96609 genl_unlock_all();
96610 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
96611 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
96612 return 0;
96613 }
96614 }
96615 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
96616 index ec0c80f..41e1830 100644
96617 --- a/net/netrom/af_netrom.c
96618 +++ b/net/netrom/af_netrom.c
96619 @@ -850,7 +850,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
96620 *uaddr_len = sizeof(struct full_sockaddr_ax25);
96621 } else {
96622 sax->fsa_ax25.sax25_family = AF_NETROM;
96623 - sax->fsa_ax25.sax25_ndigis = 0;
96624 sax->fsa_ax25.sax25_call = nr->source_addr;
96625 *uaddr_len = sizeof(struct sockaddr_ax25);
96626 }
96627 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
96628 index 20a1bd0..bb8f1c1 100644
96629 --- a/net/packet/af_packet.c
96630 +++ b/net/packet/af_packet.c
96631 @@ -1681,7 +1681,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
96632
96633 spin_lock(&sk->sk_receive_queue.lock);
96634 po->stats.stats1.tp_packets++;
96635 - skb->dropcount = atomic_read(&sk->sk_drops);
96636 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
96637 __skb_queue_tail(&sk->sk_receive_queue, skb);
96638 spin_unlock(&sk->sk_receive_queue.lock);
96639 sk->sk_data_ready(sk, skb->len);
96640 @@ -1690,7 +1690,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
96641 drop_n_acct:
96642 spin_lock(&sk->sk_receive_queue.lock);
96643 po->stats.stats1.tp_drops++;
96644 - atomic_inc(&sk->sk_drops);
96645 + atomic_inc_unchecked(&sk->sk_drops);
96646 spin_unlock(&sk->sk_receive_queue.lock);
96647
96648 drop_n_restore:
96649 @@ -2640,6 +2640,7 @@ out:
96650
96651 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
96652 {
96653 + struct sock_extended_err ee;
96654 struct sock_exterr_skb *serr;
96655 struct sk_buff *skb, *skb2;
96656 int copied, err;
96657 @@ -2661,8 +2662,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
96658 sock_recv_timestamp(msg, sk, skb);
96659
96660 serr = SKB_EXT_ERR(skb);
96661 + ee = serr->ee;
96662 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
96663 - sizeof(serr->ee), &serr->ee);
96664 + sizeof ee, &ee);
96665
96666 msg->msg_flags |= MSG_ERRQUEUE;
96667 err = copied;
96668 @@ -3281,7 +3283,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
96669 case PACKET_HDRLEN:
96670 if (len > sizeof(int))
96671 len = sizeof(int);
96672 - if (copy_from_user(&val, optval, len))
96673 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
96674 return -EFAULT;
96675 switch (val) {
96676 case TPACKET_V1:
96677 @@ -3324,7 +3326,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
96678 len = lv;
96679 if (put_user(len, optlen))
96680 return -EFAULT;
96681 - if (copy_to_user(optval, data, len))
96682 + if (len > sizeof(st) || copy_to_user(optval, data, len))
96683 return -EFAULT;
96684 return 0;
96685 }
96686 diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
96687 index 5a940db..d6a502d 100644
96688 --- a/net/phonet/af_phonet.c
96689 +++ b/net/phonet/af_phonet.c
96690 @@ -469,7 +469,7 @@ int __init_or_module phonet_proto_register(unsigned int protocol,
96691 {
96692 int err = 0;
96693
96694 - if (protocol >= PHONET_NPROTO)
96695 + if (protocol < 0 || protocol >= PHONET_NPROTO)
96696 return -EINVAL;
96697
96698 err = proto_register(pp->prot, 1);
96699 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
96700 index e774117..900b8b7 100644
96701 --- a/net/phonet/pep.c
96702 +++ b/net/phonet/pep.c
96703 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
96704
96705 case PNS_PEP_CTRL_REQ:
96706 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
96707 - atomic_inc(&sk->sk_drops);
96708 + atomic_inc_unchecked(&sk->sk_drops);
96709 break;
96710 }
96711 __skb_pull(skb, 4);
96712 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
96713 }
96714
96715 if (pn->rx_credits == 0) {
96716 - atomic_inc(&sk->sk_drops);
96717 + atomic_inc_unchecked(&sk->sk_drops);
96718 err = -ENOBUFS;
96719 break;
96720 }
96721 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
96722 }
96723
96724 if (pn->rx_credits == 0) {
96725 - atomic_inc(&sk->sk_drops);
96726 + atomic_inc_unchecked(&sk->sk_drops);
96727 err = NET_RX_DROP;
96728 break;
96729 }
96730 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
96731 index 1afd138..0b42453 100644
96732 --- a/net/phonet/socket.c
96733 +++ b/net/phonet/socket.c
96734 @@ -612,7 +612,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
96735 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
96736 sock_i_ino(sk),
96737 atomic_read(&sk->sk_refcnt), sk,
96738 - atomic_read(&sk->sk_drops), &len);
96739 + atomic_read_unchecked(&sk->sk_drops), &len);
96740 }
96741 seq_printf(seq, "%*s\n", 127 - len, "");
96742 return 0;
96743 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
96744 index d6bbbbd..61561e4 100644
96745 --- a/net/phonet/sysctl.c
96746 +++ b/net/phonet/sysctl.c
96747 @@ -67,7 +67,7 @@ static int proc_local_port_range(ctl_table *table, int write,
96748 {
96749 int ret;
96750 int range[2] = {local_port_range[0], local_port_range[1]};
96751 - ctl_table tmp = {
96752 + ctl_table_no_const tmp = {
96753 .data = &range,
96754 .maxlen = sizeof(range),
96755 .mode = table->mode,
96756 diff --git a/net/rds/cong.c b/net/rds/cong.c
96757 index e5b65ac..f3b6fb7 100644
96758 --- a/net/rds/cong.c
96759 +++ b/net/rds/cong.c
96760 @@ -78,7 +78,7 @@
96761 * finds that the saved generation number is smaller than the global generation
96762 * number, it wakes up the process.
96763 */
96764 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
96765 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
96766
96767 /*
96768 * Congestion monitoring
96769 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
96770 rdsdebug("waking map %p for %pI4\n",
96771 map, &map->m_addr);
96772 rds_stats_inc(s_cong_update_received);
96773 - atomic_inc(&rds_cong_generation);
96774 + atomic_inc_unchecked(&rds_cong_generation);
96775 if (waitqueue_active(&map->m_waitq))
96776 wake_up(&map->m_waitq);
96777 if (waitqueue_active(&rds_poll_waitq))
96778 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
96779
96780 int rds_cong_updated_since(unsigned long *recent)
96781 {
96782 - unsigned long gen = atomic_read(&rds_cong_generation);
96783 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
96784
96785 if (likely(*recent == gen))
96786 return 0;
96787 diff --git a/net/rds/ib.h b/net/rds/ib.h
96788 index 7280ab8..e04f4ea 100644
96789 --- a/net/rds/ib.h
96790 +++ b/net/rds/ib.h
96791 @@ -128,7 +128,7 @@ struct rds_ib_connection {
96792 /* sending acks */
96793 unsigned long i_ack_flags;
96794 #ifdef KERNEL_HAS_ATOMIC64
96795 - atomic64_t i_ack_next; /* next ACK to send */
96796 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
96797 #else
96798 spinlock_t i_ack_lock; /* protect i_ack_next */
96799 u64 i_ack_next; /* next ACK to send */
96800 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
96801 index 31b74f5..dc1fbfa 100644
96802 --- a/net/rds/ib_cm.c
96803 +++ b/net/rds/ib_cm.c
96804 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
96805 /* Clear the ACK state */
96806 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
96807 #ifdef KERNEL_HAS_ATOMIC64
96808 - atomic64_set(&ic->i_ack_next, 0);
96809 + atomic64_set_unchecked(&ic->i_ack_next, 0);
96810 #else
96811 ic->i_ack_next = 0;
96812 #endif
96813 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
96814 index 8eb9501..0c386ff 100644
96815 --- a/net/rds/ib_recv.c
96816 +++ b/net/rds/ib_recv.c
96817 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
96818 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
96819 int ack_required)
96820 {
96821 - atomic64_set(&ic->i_ack_next, seq);
96822 + atomic64_set_unchecked(&ic->i_ack_next, seq);
96823 if (ack_required) {
96824 smp_mb__before_clear_bit();
96825 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
96826 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
96827 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
96828 smp_mb__after_clear_bit();
96829
96830 - return atomic64_read(&ic->i_ack_next);
96831 + return atomic64_read_unchecked(&ic->i_ack_next);
96832 }
96833 #endif
96834
96835 diff --git a/net/rds/iw.h b/net/rds/iw.h
96836 index 04ce3b1..48119a6 100644
96837 --- a/net/rds/iw.h
96838 +++ b/net/rds/iw.h
96839 @@ -134,7 +134,7 @@ struct rds_iw_connection {
96840 /* sending acks */
96841 unsigned long i_ack_flags;
96842 #ifdef KERNEL_HAS_ATOMIC64
96843 - atomic64_t i_ack_next; /* next ACK to send */
96844 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
96845 #else
96846 spinlock_t i_ack_lock; /* protect i_ack_next */
96847 u64 i_ack_next; /* next ACK to send */
96848 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
96849 index a91e1db..cf3053f 100644
96850 --- a/net/rds/iw_cm.c
96851 +++ b/net/rds/iw_cm.c
96852 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
96853 /* Clear the ACK state */
96854 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
96855 #ifdef KERNEL_HAS_ATOMIC64
96856 - atomic64_set(&ic->i_ack_next, 0);
96857 + atomic64_set_unchecked(&ic->i_ack_next, 0);
96858 #else
96859 ic->i_ack_next = 0;
96860 #endif
96861 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
96862 index 4503335..db566b4 100644
96863 --- a/net/rds/iw_recv.c
96864 +++ b/net/rds/iw_recv.c
96865 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
96866 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
96867 int ack_required)
96868 {
96869 - atomic64_set(&ic->i_ack_next, seq);
96870 + atomic64_set_unchecked(&ic->i_ack_next, seq);
96871 if (ack_required) {
96872 smp_mb__before_clear_bit();
96873 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
96874 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
96875 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
96876 smp_mb__after_clear_bit();
96877
96878 - return atomic64_read(&ic->i_ack_next);
96879 + return atomic64_read_unchecked(&ic->i_ack_next);
96880 }
96881 #endif
96882
96883 diff --git a/net/rds/rds.h b/net/rds/rds.h
96884 index ec1d731..90a3a8d 100644
96885 --- a/net/rds/rds.h
96886 +++ b/net/rds/rds.h
96887 @@ -449,7 +449,7 @@ struct rds_transport {
96888 void (*sync_mr)(void *trans_private, int direction);
96889 void (*free_mr)(void *trans_private, int invalidate);
96890 void (*flush_mrs)(void);
96891 -};
96892 +} __do_const;
96893
96894 struct rds_sock {
96895 struct sock rs_sk;
96896 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
96897 index edac9ef..16bcb98 100644
96898 --- a/net/rds/tcp.c
96899 +++ b/net/rds/tcp.c
96900 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
96901 int val = 1;
96902
96903 set_fs(KERNEL_DS);
96904 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
96905 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
96906 sizeof(val));
96907 set_fs(oldfs);
96908 }
96909 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
96910 index 81cf5a4..b5826ff 100644
96911 --- a/net/rds/tcp_send.c
96912 +++ b/net/rds/tcp_send.c
96913 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
96914
96915 oldfs = get_fs();
96916 set_fs(KERNEL_DS);
96917 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
96918 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
96919 sizeof(val));
96920 set_fs(oldfs);
96921 }
96922 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
96923 index e61aa60..f07cc89 100644
96924 --- a/net/rxrpc/af_rxrpc.c
96925 +++ b/net/rxrpc/af_rxrpc.c
96926 @@ -40,7 +40,7 @@ static const struct proto_ops rxrpc_rpc_ops;
96927 __be32 rxrpc_epoch;
96928
96929 /* current debugging ID */
96930 -atomic_t rxrpc_debug_id;
96931 +atomic_unchecked_t rxrpc_debug_id;
96932
96933 /* count of skbs currently in use */
96934 atomic_t rxrpc_n_skbs;
96935 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
96936 index e4d9cbc..b229649 100644
96937 --- a/net/rxrpc/ar-ack.c
96938 +++ b/net/rxrpc/ar-ack.c
96939 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
96940
96941 _enter("{%d,%d,%d,%d},",
96942 call->acks_hard, call->acks_unacked,
96943 - atomic_read(&call->sequence),
96944 + atomic_read_unchecked(&call->sequence),
96945 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
96946
96947 stop = 0;
96948 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
96949
96950 /* each Tx packet has a new serial number */
96951 sp->hdr.serial =
96952 - htonl(atomic_inc_return(&call->conn->serial));
96953 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
96954
96955 hdr = (struct rxrpc_header *) txb->head;
96956 hdr->serial = sp->hdr.serial;
96957 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
96958 */
96959 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
96960 {
96961 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
96962 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
96963 }
96964
96965 /*
96966 @@ -629,7 +629,7 @@ process_further:
96967
96968 latest = ntohl(sp->hdr.serial);
96969 hard = ntohl(ack.firstPacket);
96970 - tx = atomic_read(&call->sequence);
96971 + tx = atomic_read_unchecked(&call->sequence);
96972
96973 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
96974 latest,
96975 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
96976 goto maybe_reschedule;
96977
96978 send_ACK_with_skew:
96979 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
96980 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
96981 ntohl(ack.serial));
96982 send_ACK:
96983 mtu = call->conn->trans->peer->if_mtu;
96984 @@ -1173,7 +1173,7 @@ send_ACK:
96985 ackinfo.rxMTU = htonl(5692);
96986 ackinfo.jumbo_max = htonl(4);
96987
96988 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
96989 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
96990 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
96991 ntohl(hdr.serial),
96992 ntohs(ack.maxSkew),
96993 @@ -1191,7 +1191,7 @@ send_ACK:
96994 send_message:
96995 _debug("send message");
96996
96997 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
96998 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
96999 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
97000 send_message_2:
97001
97002 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
97003 index a3bbb36..3341fb9 100644
97004 --- a/net/rxrpc/ar-call.c
97005 +++ b/net/rxrpc/ar-call.c
97006 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
97007 spin_lock_init(&call->lock);
97008 rwlock_init(&call->state_lock);
97009 atomic_set(&call->usage, 1);
97010 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
97011 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
97012 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
97013
97014 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
97015 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
97016 index 4106ca9..a338d7a 100644
97017 --- a/net/rxrpc/ar-connection.c
97018 +++ b/net/rxrpc/ar-connection.c
97019 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
97020 rwlock_init(&conn->lock);
97021 spin_lock_init(&conn->state_lock);
97022 atomic_set(&conn->usage, 1);
97023 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
97024 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
97025 conn->avail_calls = RXRPC_MAXCALLS;
97026 conn->size_align = 4;
97027 conn->header_size = sizeof(struct rxrpc_header);
97028 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
97029 index e7ed43a..6afa140 100644
97030 --- a/net/rxrpc/ar-connevent.c
97031 +++ b/net/rxrpc/ar-connevent.c
97032 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
97033
97034 len = iov[0].iov_len + iov[1].iov_len;
97035
97036 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
97037 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
97038 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
97039
97040 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
97041 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
97042 index 529572f..c758ca7 100644
97043 --- a/net/rxrpc/ar-input.c
97044 +++ b/net/rxrpc/ar-input.c
97045 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
97046 /* track the latest serial number on this connection for ACK packet
97047 * information */
97048 serial = ntohl(sp->hdr.serial);
97049 - hi_serial = atomic_read(&call->conn->hi_serial);
97050 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
97051 while (serial > hi_serial)
97052 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
97053 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
97054 serial);
97055
97056 /* request ACK generation for any ACK or DATA packet that requests
97057 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
97058 index a693aca..81e7293 100644
97059 --- a/net/rxrpc/ar-internal.h
97060 +++ b/net/rxrpc/ar-internal.h
97061 @@ -272,8 +272,8 @@ struct rxrpc_connection {
97062 int error; /* error code for local abort */
97063 int debug_id; /* debug ID for printks */
97064 unsigned int call_counter; /* call ID counter */
97065 - atomic_t serial; /* packet serial number counter */
97066 - atomic_t hi_serial; /* highest serial number received */
97067 + atomic_unchecked_t serial; /* packet serial number counter */
97068 + atomic_unchecked_t hi_serial; /* highest serial number received */
97069 u8 avail_calls; /* number of calls available */
97070 u8 size_align; /* data size alignment (for security) */
97071 u8 header_size; /* rxrpc + security header size */
97072 @@ -346,7 +346,7 @@ struct rxrpc_call {
97073 spinlock_t lock;
97074 rwlock_t state_lock; /* lock for state transition */
97075 atomic_t usage;
97076 - atomic_t sequence; /* Tx data packet sequence counter */
97077 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
97078 u32 abort_code; /* local/remote abort code */
97079 enum { /* current state of call */
97080 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
97081 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
97082 */
97083 extern atomic_t rxrpc_n_skbs;
97084 extern __be32 rxrpc_epoch;
97085 -extern atomic_t rxrpc_debug_id;
97086 +extern atomic_unchecked_t rxrpc_debug_id;
97087 extern struct workqueue_struct *rxrpc_workqueue;
97088
97089 /*
97090 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
97091 index 87f7135..74d3703 100644
97092 --- a/net/rxrpc/ar-local.c
97093 +++ b/net/rxrpc/ar-local.c
97094 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
97095 spin_lock_init(&local->lock);
97096 rwlock_init(&local->services_lock);
97097 atomic_set(&local->usage, 1);
97098 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
97099 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
97100 memcpy(&local->srx, srx, sizeof(*srx));
97101 }
97102
97103 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
97104 index e1ac183..b43e10e 100644
97105 --- a/net/rxrpc/ar-output.c
97106 +++ b/net/rxrpc/ar-output.c
97107 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
97108 sp->hdr.cid = call->cid;
97109 sp->hdr.callNumber = call->call_id;
97110 sp->hdr.seq =
97111 - htonl(atomic_inc_return(&call->sequence));
97112 + htonl(atomic_inc_return_unchecked(&call->sequence));
97113 sp->hdr.serial =
97114 - htonl(atomic_inc_return(&conn->serial));
97115 + htonl(atomic_inc_return_unchecked(&conn->serial));
97116 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
97117 sp->hdr.userStatus = 0;
97118 sp->hdr.securityIndex = conn->security_ix;
97119 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
97120 index bebaa43..2644591 100644
97121 --- a/net/rxrpc/ar-peer.c
97122 +++ b/net/rxrpc/ar-peer.c
97123 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
97124 INIT_LIST_HEAD(&peer->error_targets);
97125 spin_lock_init(&peer->lock);
97126 atomic_set(&peer->usage, 1);
97127 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
97128 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
97129 memcpy(&peer->srx, srx, sizeof(*srx));
97130
97131 rxrpc_assess_MTU_size(peer);
97132 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
97133 index 38047f7..9f48511 100644
97134 --- a/net/rxrpc/ar-proc.c
97135 +++ b/net/rxrpc/ar-proc.c
97136 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
97137 atomic_read(&conn->usage),
97138 rxrpc_conn_states[conn->state],
97139 key_serial(conn->key),
97140 - atomic_read(&conn->serial),
97141 - atomic_read(&conn->hi_serial));
97142 + atomic_read_unchecked(&conn->serial),
97143 + atomic_read_unchecked(&conn->hi_serial));
97144
97145 return 0;
97146 }
97147 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
97148 index 92df566..87ec1bf 100644
97149 --- a/net/rxrpc/ar-transport.c
97150 +++ b/net/rxrpc/ar-transport.c
97151 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
97152 spin_lock_init(&trans->client_lock);
97153 rwlock_init(&trans->conn_lock);
97154 atomic_set(&trans->usage, 1);
97155 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
97156 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
97157
97158 if (peer->srx.transport.family == AF_INET) {
97159 switch (peer->srx.transport_type) {
97160 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
97161 index f226709..0e735a8 100644
97162 --- a/net/rxrpc/rxkad.c
97163 +++ b/net/rxrpc/rxkad.c
97164 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
97165
97166 len = iov[0].iov_len + iov[1].iov_len;
97167
97168 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
97169 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
97170 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
97171
97172 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
97173 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
97174
97175 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
97176
97177 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
97178 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
97179 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
97180
97181 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
97182 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
97183 index 391a245..296b3d7 100644
97184 --- a/net/sctp/ipv6.c
97185 +++ b/net/sctp/ipv6.c
97186 @@ -981,7 +981,7 @@ static const struct inet6_protocol sctpv6_protocol = {
97187 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
97188 };
97189
97190 -static struct sctp_af sctp_af_inet6 = {
97191 +static struct sctp_af sctp_af_inet6 __read_only = {
97192 .sa_family = AF_INET6,
97193 .sctp_xmit = sctp_v6_xmit,
97194 .setsockopt = ipv6_setsockopt,
97195 @@ -1013,7 +1013,7 @@ static struct sctp_af sctp_af_inet6 = {
97196 #endif
97197 };
97198
97199 -static struct sctp_pf sctp_pf_inet6 = {
97200 +static struct sctp_pf sctp_pf_inet6 __read_only = {
97201 .event_msgname = sctp_inet6_event_msgname,
97202 .skb_msgname = sctp_inet6_skb_msgname,
97203 .af_supported = sctp_inet6_af_supported,
97204 @@ -1038,7 +1038,7 @@ void sctp_v6_pf_init(void)
97205
97206 void sctp_v6_pf_exit(void)
97207 {
97208 - list_del(&sctp_af_inet6.list);
97209 + pax_list_del(&sctp_af_inet6.list);
97210 }
97211
97212 /* Initialize IPv6 support and register with socket layer. */
97213 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
97214 index 4e45ee3..e66a031 100644
97215 --- a/net/sctp/proc.c
97216 +++ b/net/sctp/proc.c
97217 @@ -337,7 +337,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
97218 seq_printf(seq,
97219 "%8pK %8pK %-3d %-3d %-2d %-4d "
97220 "%4d %8d %8d %7d %5lu %-5d %5d ",
97221 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
97222 + assoc, sk,
97223 + sctp_sk(sk)->type, sk->sk_state,
97224 assoc->state, hash,
97225 assoc->assoc_id,
97226 assoc->sndbuf_used,
97227 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
97228 index eaee00c..97c0afd 100644
97229 --- a/net/sctp/protocol.c
97230 +++ b/net/sctp/protocol.c
97231 @@ -834,8 +834,10 @@ int sctp_register_af(struct sctp_af *af)
97232 return 0;
97233 }
97234
97235 + pax_open_kernel();
97236 INIT_LIST_HEAD(&af->list);
97237 - list_add_tail(&af->list, &sctp_address_families);
97238 + pax_close_kernel();
97239 + pax_list_add_tail(&af->list, &sctp_address_families);
97240 return 1;
97241 }
97242
97243 @@ -966,7 +968,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
97244
97245 static struct sctp_af sctp_af_inet;
97246
97247 -static struct sctp_pf sctp_pf_inet = {
97248 +static struct sctp_pf sctp_pf_inet __read_only = {
97249 .event_msgname = sctp_inet_event_msgname,
97250 .skb_msgname = sctp_inet_skb_msgname,
97251 .af_supported = sctp_inet_af_supported,
97252 @@ -1037,7 +1039,7 @@ static const struct net_protocol sctp_protocol = {
97253 };
97254
97255 /* IPv4 address related functions. */
97256 -static struct sctp_af sctp_af_inet = {
97257 +static struct sctp_af sctp_af_inet __read_only = {
97258 .sa_family = AF_INET,
97259 .sctp_xmit = sctp_v4_xmit,
97260 .setsockopt = ip_setsockopt,
97261 @@ -1122,7 +1124,7 @@ static void sctp_v4_pf_init(void)
97262
97263 static void sctp_v4_pf_exit(void)
97264 {
97265 - list_del(&sctp_af_inet.list);
97266 + pax_list_del(&sctp_af_inet.list);
97267 }
97268
97269 static int sctp_v4_protosw_init(void)
97270 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
97271 index 8aab894..f6b7e7d 100644
97272 --- a/net/sctp/sm_sideeffect.c
97273 +++ b/net/sctp/sm_sideeffect.c
97274 @@ -447,7 +447,7 @@ static void sctp_generate_sack_event(unsigned long data)
97275 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
97276 }
97277
97278 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
97279 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
97280 NULL,
97281 sctp_generate_t1_cookie_event,
97282 sctp_generate_t1_init_event,
97283 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
97284 index 6abb1ca..1678f8b 100644
97285 --- a/net/sctp/socket.c
97286 +++ b/net/sctp/socket.c
97287 @@ -2167,11 +2167,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
97288 {
97289 struct sctp_association *asoc;
97290 struct sctp_ulpevent *event;
97291 + struct sctp_event_subscribe subscribe;
97292
97293 if (optlen > sizeof(struct sctp_event_subscribe))
97294 return -EINVAL;
97295 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
97296 + if (copy_from_user(&subscribe, optval, optlen))
97297 return -EFAULT;
97298 + sctp_sk(sk)->subscribe = subscribe;
97299
97300 /*
97301 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
97302 @@ -4222,13 +4224,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
97303 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
97304 int __user *optlen)
97305 {
97306 + struct sctp_event_subscribe subscribe;
97307 +
97308 if (len <= 0)
97309 return -EINVAL;
97310 if (len > sizeof(struct sctp_event_subscribe))
97311 len = sizeof(struct sctp_event_subscribe);
97312 if (put_user(len, optlen))
97313 return -EFAULT;
97314 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
97315 + subscribe = sctp_sk(sk)->subscribe;
97316 + if (copy_to_user(optval, &subscribe, len))
97317 return -EFAULT;
97318 return 0;
97319 }
97320 @@ -4246,6 +4251,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
97321 */
97322 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
97323 {
97324 + __u32 autoclose;
97325 +
97326 /* Applicable to UDP-style socket only */
97327 if (sctp_style(sk, TCP))
97328 return -EOPNOTSUPP;
97329 @@ -4254,7 +4261,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
97330 len = sizeof(int);
97331 if (put_user(len, optlen))
97332 return -EFAULT;
97333 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
97334 + autoclose = sctp_sk(sk)->autoclose;
97335 + if (copy_to_user(optval, &autoclose, sizeof(int)))
97336 return -EFAULT;
97337 return 0;
97338 }
97339 @@ -4626,12 +4634,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
97340 */
97341 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
97342 {
97343 + struct sctp_initmsg initmsg;
97344 +
97345 if (len < sizeof(struct sctp_initmsg))
97346 return -EINVAL;
97347 len = sizeof(struct sctp_initmsg);
97348 if (put_user(len, optlen))
97349 return -EFAULT;
97350 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
97351 + initmsg = sctp_sk(sk)->initmsg;
97352 + if (copy_to_user(optval, &initmsg, len))
97353 return -EFAULT;
97354 return 0;
97355 }
97356 @@ -4672,6 +4683,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
97357 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
97358 if (space_left < addrlen)
97359 return -ENOMEM;
97360 + if (addrlen > sizeof(temp) || addrlen < 0)
97361 + return -EFAULT;
97362 if (copy_to_user(to, &temp, addrlen))
97363 return -EFAULT;
97364 to += addrlen;
97365 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
97366 index bf3c6e8..376d8d0 100644
97367 --- a/net/sctp/sysctl.c
97368 +++ b/net/sctp/sysctl.c
97369 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
97370 {
97371 struct net *net = current->nsproxy->net_ns;
97372 char tmp[8];
97373 - ctl_table tbl;
97374 + ctl_table_no_const tbl;
97375 int ret;
97376 int changed = 0;
97377 char *none = "none";
97378 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
97379
97380 int sctp_sysctl_net_register(struct net *net)
97381 {
97382 - struct ctl_table *table;
97383 + ctl_table_no_const *table;
97384 int i;
97385
97386 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
97387 diff --git a/net/sctp/transport.c b/net/sctp/transport.c
97388 index 098f1d5f..60da2f7 100644
97389 --- a/net/sctp/transport.c
97390 +++ b/net/sctp/transport.c
97391 @@ -178,12 +178,12 @@ static void sctp_transport_destroy(struct sctp_transport *transport)
97392 {
97393 SCTP_ASSERT(transport->dead, "Transport is not dead", return);
97394
97395 - call_rcu(&transport->rcu, sctp_transport_destroy_rcu);
97396 -
97397 sctp_packet_free(&transport->packet);
97398
97399 if (transport->asoc)
97400 sctp_association_put(transport->asoc);
97401 +
97402 + call_rcu(&transport->rcu, sctp_transport_destroy_rcu);
97403 }
97404
97405 /* Start T3_rtx timer if it is not already running and update the heartbeat
97406 diff --git a/net/socket.c b/net/socket.c
97407 index 4ca1526..df83e47 100644
97408 --- a/net/socket.c
97409 +++ b/net/socket.c
97410 @@ -88,6 +88,7 @@
97411 #include <linux/magic.h>
97412 #include <linux/slab.h>
97413 #include <linux/xattr.h>
97414 +#include <linux/in.h>
97415
97416 #include <asm/uaccess.h>
97417 #include <asm/unistd.h>
97418 @@ -105,6 +106,8 @@
97419 #include <linux/sockios.h>
97420 #include <linux/atalk.h>
97421
97422 +#include <linux/grsock.h>
97423 +
97424 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
97425 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
97426 unsigned long nr_segs, loff_t pos);
97427 @@ -321,7 +324,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
97428 &sockfs_dentry_operations, SOCKFS_MAGIC);
97429 }
97430
97431 -static struct vfsmount *sock_mnt __read_mostly;
97432 +struct vfsmount *sock_mnt __read_mostly;
97433
97434 static struct file_system_type sock_fs_type = {
97435 .name = "sockfs",
97436 @@ -1246,6 +1249,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
97437 return -EAFNOSUPPORT;
97438 if (type < 0 || type >= SOCK_MAX)
97439 return -EINVAL;
97440 + if (protocol < 0)
97441 + return -EINVAL;
97442
97443 /* Compatibility.
97444
97445 @@ -1377,6 +1382,16 @@ SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
97446 if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
97447 flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
97448
97449 + if(!gr_search_socket(family, type, protocol)) {
97450 + retval = -EACCES;
97451 + goto out;
97452 + }
97453 +
97454 + if (gr_handle_sock_all(family, type, protocol)) {
97455 + retval = -EACCES;
97456 + goto out;
97457 + }
97458 +
97459 retval = sock_create(family, type, protocol, &sock);
97460 if (retval < 0)
97461 goto out;
97462 @@ -1504,6 +1519,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
97463 if (sock) {
97464 err = move_addr_to_kernel(umyaddr, addrlen, &address);
97465 if (err >= 0) {
97466 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
97467 + err = -EACCES;
97468 + goto error;
97469 + }
97470 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
97471 + if (err)
97472 + goto error;
97473 +
97474 err = security_socket_bind(sock,
97475 (struct sockaddr *)&address,
97476 addrlen);
97477 @@ -1512,6 +1535,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
97478 (struct sockaddr *)
97479 &address, addrlen);
97480 }
97481 +error:
97482 fput_light(sock->file, fput_needed);
97483 }
97484 return err;
97485 @@ -1535,10 +1559,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
97486 if ((unsigned int)backlog > somaxconn)
97487 backlog = somaxconn;
97488
97489 + if (gr_handle_sock_server_other(sock->sk)) {
97490 + err = -EPERM;
97491 + goto error;
97492 + }
97493 +
97494 + err = gr_search_listen(sock);
97495 + if (err)
97496 + goto error;
97497 +
97498 err = security_socket_listen(sock, backlog);
97499 if (!err)
97500 err = sock->ops->listen(sock, backlog);
97501
97502 +error:
97503 fput_light(sock->file, fput_needed);
97504 }
97505 return err;
97506 @@ -1582,6 +1616,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
97507 newsock->type = sock->type;
97508 newsock->ops = sock->ops;
97509
97510 + if (gr_handle_sock_server_other(sock->sk)) {
97511 + err = -EPERM;
97512 + sock_release(newsock);
97513 + goto out_put;
97514 + }
97515 +
97516 + err = gr_search_accept(sock);
97517 + if (err) {
97518 + sock_release(newsock);
97519 + goto out_put;
97520 + }
97521 +
97522 /*
97523 * We don't need try_module_get here, as the listening socket (sock)
97524 * has the protocol module (sock->ops->owner) held.
97525 @@ -1627,6 +1673,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
97526 fd_install(newfd, newfile);
97527 err = newfd;
97528
97529 + gr_attach_curr_ip(newsock->sk);
97530 +
97531 out_put:
97532 fput_light(sock->file, fput_needed);
97533 out:
97534 @@ -1659,6 +1707,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
97535 int, addrlen)
97536 {
97537 struct socket *sock;
97538 + struct sockaddr *sck;
97539 struct sockaddr_storage address;
97540 int err, fput_needed;
97541
97542 @@ -1669,6 +1718,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
97543 if (err < 0)
97544 goto out_put;
97545
97546 + sck = (struct sockaddr *)&address;
97547 +
97548 + if (gr_handle_sock_client(sck)) {
97549 + err = -EACCES;
97550 + goto out_put;
97551 + }
97552 +
97553 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
97554 + if (err)
97555 + goto out_put;
97556 +
97557 err =
97558 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
97559 if (err)
97560 @@ -1750,6 +1810,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
97561 * the protocol.
97562 */
97563
97564 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
97565 +
97566 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
97567 unsigned int, flags, struct sockaddr __user *, addr,
97568 int, addr_len)
97569 @@ -1816,7 +1878,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
97570 struct socket *sock;
97571 struct iovec iov;
97572 struct msghdr msg;
97573 - struct sockaddr_storage address;
97574 + struct sockaddr_storage address = { };
97575 int err, err2;
97576 int fput_needed;
97577
97578 @@ -2023,7 +2085,7 @@ static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
97579 * checking falls down on this.
97580 */
97581 if (copy_from_user(ctl_buf,
97582 - (void __user __force *)msg_sys->msg_control,
97583 + (void __force_user *)msg_sys->msg_control,
97584 ctl_len))
97585 goto out_freectl;
97586 msg_sys->msg_control = ctl_buf;
97587 @@ -2174,7 +2236,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
97588 int err, total_len, len;
97589
97590 /* kernel mode address */
97591 - struct sockaddr_storage addr;
97592 + struct sockaddr_storage addr = { };
97593
97594 /* user mode address pointers */
97595 struct sockaddr __user *uaddr;
97596 @@ -2202,7 +2264,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
97597 * kernel msghdr to use the kernel address space)
97598 */
97599
97600 - uaddr = (__force void __user *)msg_sys->msg_name;
97601 + uaddr = (void __force_user *)msg_sys->msg_name;
97602 uaddr_len = COMPAT_NAMELEN(msg);
97603 if (MSG_CMSG_COMPAT & flags) {
97604 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
97605 @@ -2955,7 +3017,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
97606 old_fs = get_fs();
97607 set_fs(KERNEL_DS);
97608 err = dev_ioctl(net, cmd,
97609 - (struct ifreq __user __force *) &kifr);
97610 + (struct ifreq __force_user *) &kifr);
97611 set_fs(old_fs);
97612
97613 return err;
97614 @@ -3064,7 +3126,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
97615
97616 old_fs = get_fs();
97617 set_fs(KERNEL_DS);
97618 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
97619 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
97620 set_fs(old_fs);
97621
97622 if (cmd == SIOCGIFMAP && !err) {
97623 @@ -3169,7 +3231,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
97624 ret |= __get_user(rtdev, &(ur4->rt_dev));
97625 if (rtdev) {
97626 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
97627 - r4.rt_dev = (char __user __force *)devname;
97628 + r4.rt_dev = (char __force_user *)devname;
97629 devname[15] = 0;
97630 } else
97631 r4.rt_dev = NULL;
97632 @@ -3395,8 +3457,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
97633 int __user *uoptlen;
97634 int err;
97635
97636 - uoptval = (char __user __force *) optval;
97637 - uoptlen = (int __user __force *) optlen;
97638 + uoptval = (char __force_user *) optval;
97639 + uoptlen = (int __force_user *) optlen;
97640
97641 set_fs(KERNEL_DS);
97642 if (level == SOL_SOCKET)
97643 @@ -3416,7 +3478,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
97644 char __user *uoptval;
97645 int err;
97646
97647 - uoptval = (char __user __force *) optval;
97648 + uoptval = (char __force_user *) optval;
97649
97650 set_fs(KERNEL_DS);
97651 if (level == SOL_SOCKET)
97652 diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
97653 index 29b4ba9..f648ae7 100644
97654 --- a/net/sunrpc/auth_gss/svcauth_gss.c
97655 +++ b/net/sunrpc/auth_gss/svcauth_gss.c
97656 @@ -1144,7 +1144,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
97657 uint64_t *handle)
97658 {
97659 struct rsc rsci, *rscp = NULL;
97660 - static atomic64_t ctxhctr;
97661 + static atomic64_unchecked_t ctxhctr = ATOMIC64_INIT(0);
97662 long long ctxh;
97663 struct gss_api_mech *gm = NULL;
97664 time_t expiry;
97665 @@ -1155,7 +1155,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
97666 status = -ENOMEM;
97667 /* the handle needs to be just a unique id,
97668 * use a static counter */
97669 - ctxh = atomic64_inc_return(&ctxhctr);
97670 + ctxh = atomic64_inc_return_unchecked(&ctxhctr);
97671
97672 /* make a copy for the caller */
97673 *handle = ctxh;
97674 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
97675 index 426f8fc..1ef9c32 100644
97676 --- a/net/sunrpc/clnt.c
97677 +++ b/net/sunrpc/clnt.c
97678 @@ -1288,7 +1288,9 @@ call_start(struct rpc_task *task)
97679 (RPC_IS_ASYNC(task) ? "async" : "sync"));
97680
97681 /* Increment call count */
97682 - task->tk_msg.rpc_proc->p_count++;
97683 + pax_open_kernel();
97684 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
97685 + pax_close_kernel();
97686 clnt->cl_stats->rpccnt++;
97687 task->tk_action = call_reserve;
97688 }
97689 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
97690 index 5356b12..c0f4c29 100644
97691 --- a/net/sunrpc/sched.c
97692 +++ b/net/sunrpc/sched.c
97693 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
97694 #ifdef RPC_DEBUG
97695 static void rpc_task_set_debuginfo(struct rpc_task *task)
97696 {
97697 - static atomic_t rpc_pid;
97698 + static atomic_unchecked_t rpc_pid;
97699
97700 - task->tk_pid = atomic_inc_return(&rpc_pid);
97701 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
97702 }
97703 #else
97704 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
97705 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
97706 index 89a588b..678ed90 100644
97707 --- a/net/sunrpc/svc.c
97708 +++ b/net/sunrpc/svc.c
97709 @@ -740,7 +740,7 @@ svc_set_num_threads(struct svc_serv *serv, struct svc_pool *pool, int nrservs)
97710
97711 __module_get(serv->sv_module);
97712 task = kthread_create_on_node(serv->sv_function, rqstp,
97713 - node, serv->sv_name);
97714 + node, "%s", serv->sv_name);
97715 if (IS_ERR(task)) {
97716 error = PTR_ERR(task);
97717 module_put(serv->sv_module);
97718 @@ -1160,7 +1160,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
97719 svc_putnl(resv, RPC_SUCCESS);
97720
97721 /* Bump per-procedure stats counter */
97722 - procp->pc_count++;
97723 + pax_open_kernel();
97724 + (*(unsigned int *)&procp->pc_count)++;
97725 + pax_close_kernel();
97726
97727 /* Initialize storage for argp and resp */
97728 memset(rqstp->rq_argp, 0, procp->pc_argsize);
97729 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
97730 index 8343737..677025e 100644
97731 --- a/net/sunrpc/xprtrdma/svc_rdma.c
97732 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
97733 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
97734 static unsigned int min_max_inline = 4096;
97735 static unsigned int max_max_inline = 65536;
97736
97737 -atomic_t rdma_stat_recv;
97738 -atomic_t rdma_stat_read;
97739 -atomic_t rdma_stat_write;
97740 -atomic_t rdma_stat_sq_starve;
97741 -atomic_t rdma_stat_rq_starve;
97742 -atomic_t rdma_stat_rq_poll;
97743 -atomic_t rdma_stat_rq_prod;
97744 -atomic_t rdma_stat_sq_poll;
97745 -atomic_t rdma_stat_sq_prod;
97746 +atomic_unchecked_t rdma_stat_recv;
97747 +atomic_unchecked_t rdma_stat_read;
97748 +atomic_unchecked_t rdma_stat_write;
97749 +atomic_unchecked_t rdma_stat_sq_starve;
97750 +atomic_unchecked_t rdma_stat_rq_starve;
97751 +atomic_unchecked_t rdma_stat_rq_poll;
97752 +atomic_unchecked_t rdma_stat_rq_prod;
97753 +atomic_unchecked_t rdma_stat_sq_poll;
97754 +atomic_unchecked_t rdma_stat_sq_prod;
97755
97756 /* Temporary NFS request map and context caches */
97757 struct kmem_cache *svc_rdma_map_cachep;
97758 @@ -110,7 +110,7 @@ static int read_reset_stat(ctl_table *table, int write,
97759 len -= *ppos;
97760 if (len > *lenp)
97761 len = *lenp;
97762 - if (len && copy_to_user(buffer, str_buf, len))
97763 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
97764 return -EFAULT;
97765 *lenp = len;
97766 *ppos += len;
97767 @@ -151,63 +151,63 @@ static ctl_table svcrdma_parm_table[] = {
97768 {
97769 .procname = "rdma_stat_read",
97770 .data = &rdma_stat_read,
97771 - .maxlen = sizeof(atomic_t),
97772 + .maxlen = sizeof(atomic_unchecked_t),
97773 .mode = 0644,
97774 .proc_handler = read_reset_stat,
97775 },
97776 {
97777 .procname = "rdma_stat_recv",
97778 .data = &rdma_stat_recv,
97779 - .maxlen = sizeof(atomic_t),
97780 + .maxlen = sizeof(atomic_unchecked_t),
97781 .mode = 0644,
97782 .proc_handler = read_reset_stat,
97783 },
97784 {
97785 .procname = "rdma_stat_write",
97786 .data = &rdma_stat_write,
97787 - .maxlen = sizeof(atomic_t),
97788 + .maxlen = sizeof(atomic_unchecked_t),
97789 .mode = 0644,
97790 .proc_handler = read_reset_stat,
97791 },
97792 {
97793 .procname = "rdma_stat_sq_starve",
97794 .data = &rdma_stat_sq_starve,
97795 - .maxlen = sizeof(atomic_t),
97796 + .maxlen = sizeof(atomic_unchecked_t),
97797 .mode = 0644,
97798 .proc_handler = read_reset_stat,
97799 },
97800 {
97801 .procname = "rdma_stat_rq_starve",
97802 .data = &rdma_stat_rq_starve,
97803 - .maxlen = sizeof(atomic_t),
97804 + .maxlen = sizeof(atomic_unchecked_t),
97805 .mode = 0644,
97806 .proc_handler = read_reset_stat,
97807 },
97808 {
97809 .procname = "rdma_stat_rq_poll",
97810 .data = &rdma_stat_rq_poll,
97811 - .maxlen = sizeof(atomic_t),
97812 + .maxlen = sizeof(atomic_unchecked_t),
97813 .mode = 0644,
97814 .proc_handler = read_reset_stat,
97815 },
97816 {
97817 .procname = "rdma_stat_rq_prod",
97818 .data = &rdma_stat_rq_prod,
97819 - .maxlen = sizeof(atomic_t),
97820 + .maxlen = sizeof(atomic_unchecked_t),
97821 .mode = 0644,
97822 .proc_handler = read_reset_stat,
97823 },
97824 {
97825 .procname = "rdma_stat_sq_poll",
97826 .data = &rdma_stat_sq_poll,
97827 - .maxlen = sizeof(atomic_t),
97828 + .maxlen = sizeof(atomic_unchecked_t),
97829 .mode = 0644,
97830 .proc_handler = read_reset_stat,
97831 },
97832 {
97833 .procname = "rdma_stat_sq_prod",
97834 .data = &rdma_stat_sq_prod,
97835 - .maxlen = sizeof(atomic_t),
97836 + .maxlen = sizeof(atomic_unchecked_t),
97837 .mode = 0644,
97838 .proc_handler = read_reset_stat,
97839 },
97840 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
97841 index 0ce7552..d074459 100644
97842 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
97843 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
97844 @@ -501,7 +501,7 @@ next_sge:
97845 svc_rdma_put_context(ctxt, 0);
97846 goto out;
97847 }
97848 - atomic_inc(&rdma_stat_read);
97849 + atomic_inc_unchecked(&rdma_stat_read);
97850
97851 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
97852 chl_map->ch[ch_no].count -= read_wr.num_sge;
97853 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
97854 dto_q);
97855 list_del_init(&ctxt->dto_q);
97856 } else {
97857 - atomic_inc(&rdma_stat_rq_starve);
97858 + atomic_inc_unchecked(&rdma_stat_rq_starve);
97859 clear_bit(XPT_DATA, &xprt->xpt_flags);
97860 ctxt = NULL;
97861 }
97862 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
97863 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
97864 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
97865 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
97866 - atomic_inc(&rdma_stat_recv);
97867 + atomic_inc_unchecked(&rdma_stat_recv);
97868
97869 /* Build up the XDR from the receive buffers. */
97870 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
97871 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
97872 index c1d124d..acfc59e 100644
97873 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
97874 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
97875 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
97876 write_wr.wr.rdma.remote_addr = to;
97877
97878 /* Post It */
97879 - atomic_inc(&rdma_stat_write);
97880 + atomic_inc_unchecked(&rdma_stat_write);
97881 if (svc_rdma_send(xprt, &write_wr))
97882 goto err;
97883 return 0;
97884 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
97885 index 62e4f9b..dd3f2d7 100644
97886 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
97887 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
97888 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
97889 return;
97890
97891 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
97892 - atomic_inc(&rdma_stat_rq_poll);
97893 + atomic_inc_unchecked(&rdma_stat_rq_poll);
97894
97895 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
97896 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
97897 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
97898 }
97899
97900 if (ctxt)
97901 - atomic_inc(&rdma_stat_rq_prod);
97902 + atomic_inc_unchecked(&rdma_stat_rq_prod);
97903
97904 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
97905 /*
97906 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
97907 return;
97908
97909 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
97910 - atomic_inc(&rdma_stat_sq_poll);
97911 + atomic_inc_unchecked(&rdma_stat_sq_poll);
97912 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
97913 if (wc.status != IB_WC_SUCCESS)
97914 /* Close the transport */
97915 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
97916 }
97917
97918 if (ctxt)
97919 - atomic_inc(&rdma_stat_sq_prod);
97920 + atomic_inc_unchecked(&rdma_stat_sq_prod);
97921 }
97922
97923 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
97924 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
97925 spin_lock_bh(&xprt->sc_lock);
97926 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
97927 spin_unlock_bh(&xprt->sc_lock);
97928 - atomic_inc(&rdma_stat_sq_starve);
97929 + atomic_inc_unchecked(&rdma_stat_sq_starve);
97930
97931 /* See if we can opportunistically reap SQ WR to make room */
97932 sq_cq_reap(xprt);
97933 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
97934 index 9bc6db0..47ac8c0 100644
97935 --- a/net/sysctl_net.c
97936 +++ b/net/sysctl_net.c
97937 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
97938 kgid_t root_gid = make_kgid(net->user_ns, 0);
97939
97940 /* Allow network administrator to have same access as root. */
97941 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
97942 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
97943 uid_eq(root_uid, current_uid())) {
97944 int mode = (table->mode >> 6) & 7;
97945 return (mode << 6) | (mode << 3) | mode;
97946 diff --git a/net/tipc/link.c b/net/tipc/link.c
97947 index a80feee..2bbbe70 100644
97948 --- a/net/tipc/link.c
97949 +++ b/net/tipc/link.c
97950 @@ -1201,7 +1201,7 @@ static int link_send_sections_long(struct tipc_port *sender,
97951 struct tipc_msg fragm_hdr;
97952 struct sk_buff *buf, *buf_chain, *prev;
97953 u32 fragm_crs, fragm_rest, hsz, sect_rest;
97954 - const unchar *sect_crs;
97955 + const unchar __user *sect_crs;
97956 int curr_sect;
97957 u32 fragm_no;
97958
97959 @@ -1242,7 +1242,7 @@ again:
97960
97961 if (!sect_rest) {
97962 sect_rest = msg_sect[++curr_sect].iov_len;
97963 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
97964 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
97965 }
97966
97967 if (sect_rest < fragm_rest)
97968 @@ -1261,7 +1261,7 @@ error:
97969 }
97970 } else
97971 skb_copy_to_linear_data_offset(buf, fragm_crs,
97972 - sect_crs, sz);
97973 + (const void __force_kernel *)sect_crs, sz);
97974 sect_crs += sz;
97975 sect_rest -= sz;
97976 fragm_crs += sz;
97977 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
97978 index f2db8a8..9245aa4 100644
97979 --- a/net/tipc/msg.c
97980 +++ b/net/tipc/msg.c
97981 @@ -98,7 +98,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
97982 msg_sect[cnt].iov_len);
97983 else
97984 skb_copy_to_linear_data_offset(*buf, pos,
97985 - msg_sect[cnt].iov_base,
97986 + (const void __force_kernel *)msg_sect[cnt].iov_base,
97987 msg_sect[cnt].iov_len);
97988 pos += msg_sect[cnt].iov_len;
97989 }
97990 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
97991 index 6b42d47..2ac24d5 100644
97992 --- a/net/tipc/subscr.c
97993 +++ b/net/tipc/subscr.c
97994 @@ -96,7 +96,7 @@ static void subscr_send_event(struct tipc_subscription *sub,
97995 {
97996 struct iovec msg_sect;
97997
97998 - msg_sect.iov_base = (void *)&sub->evt;
97999 + msg_sect.iov_base = (void __force_user *)&sub->evt;
98000 msg_sect.iov_len = sizeof(struct tipc_event);
98001
98002 sub->evt.event = htohl(event, sub->swap);
98003 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
98004 index 826e099..4fa8c93 100644
98005 --- a/net/unix/af_unix.c
98006 +++ b/net/unix/af_unix.c
98007 @@ -783,6 +783,12 @@ static struct sock *unix_find_other(struct net *net,
98008 err = -ECONNREFUSED;
98009 if (!S_ISSOCK(inode->i_mode))
98010 goto put_fail;
98011 +
98012 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
98013 + err = -EACCES;
98014 + goto put_fail;
98015 + }
98016 +
98017 u = unix_find_socket_byinode(inode);
98018 if (!u)
98019 goto put_fail;
98020 @@ -803,6 +809,13 @@ static struct sock *unix_find_other(struct net *net,
98021 if (u) {
98022 struct dentry *dentry;
98023 dentry = unix_sk(u)->path.dentry;
98024 +
98025 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
98026 + err = -EPERM;
98027 + sock_put(u);
98028 + goto fail;
98029 + }
98030 +
98031 if (dentry)
98032 touch_atime(&unix_sk(u)->path);
98033 } else
98034 @@ -836,12 +849,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
98035 */
98036 err = security_path_mknod(&path, dentry, mode, 0);
98037 if (!err) {
98038 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
98039 + err = -EACCES;
98040 + goto out;
98041 + }
98042 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
98043 if (!err) {
98044 res->mnt = mntget(path.mnt);
98045 res->dentry = dget(dentry);
98046 + gr_handle_create(dentry, path.mnt);
98047 }
98048 }
98049 +out:
98050 done_path_create(&path, dentry);
98051 return err;
98052 }
98053 @@ -2324,9 +2343,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
98054 seq_puts(seq, "Num RefCount Protocol Flags Type St "
98055 "Inode Path\n");
98056 else {
98057 - struct sock *s = v;
98058 + struct sock *s = v, *peer;
98059 struct unix_sock *u = unix_sk(s);
98060 unix_state_lock(s);
98061 + peer = unix_peer(s);
98062 + unix_state_unlock(s);
98063 +
98064 + unix_state_double_lock(s, peer);
98065
98066 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
98067 s,
98068 @@ -2353,8 +2376,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
98069 }
98070 for ( ; i < len; i++)
98071 seq_putc(seq, u->addr->name->sun_path[i]);
98072 - }
98073 - unix_state_unlock(s);
98074 + } else if (peer)
98075 + seq_printf(seq, " P%lu", sock_i_ino(peer));
98076 +
98077 + unix_state_double_unlock(s, peer);
98078 seq_putc(seq, '\n');
98079 }
98080
98081 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
98082 index 8800604..0526440 100644
98083 --- a/net/unix/sysctl_net_unix.c
98084 +++ b/net/unix/sysctl_net_unix.c
98085 @@ -28,7 +28,7 @@ static ctl_table unix_table[] = {
98086
98087 int __net_init unix_sysctl_register(struct net *net)
98088 {
98089 - struct ctl_table *table;
98090 + ctl_table_no_const *table;
98091
98092 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
98093 if (table == NULL)
98094 diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
98095 index 3f77f42..662d89b 100644
98096 --- a/net/vmw_vsock/af_vsock.c
98097 +++ b/net/vmw_vsock/af_vsock.c
98098 @@ -335,7 +335,7 @@ void vsock_for_each_connected_socket(void (*fn)(struct sock *sk))
98099 for (i = 0; i < ARRAY_SIZE(vsock_connected_table); i++) {
98100 struct vsock_sock *vsk;
98101 list_for_each_entry(vsk, &vsock_connected_table[i],
98102 - connected_table);
98103 + connected_table)
98104 fn(sk_vsock(vsk));
98105 }
98106
98107 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
98108 index c8717c1..08539f5 100644
98109 --- a/net/wireless/wext-core.c
98110 +++ b/net/wireless/wext-core.c
98111 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
98112 */
98113
98114 /* Support for very large requests */
98115 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
98116 - (user_length > descr->max_tokens)) {
98117 + if (user_length > descr->max_tokens) {
98118 /* Allow userspace to GET more than max so
98119 * we can support any size GET requests.
98120 * There is still a limit : -ENOMEM.
98121 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
98122 }
98123 }
98124
98125 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
98126 - /*
98127 - * If this is a GET, but not NOMAX, it means that the extra
98128 - * data is not bounded by userspace, but by max_tokens. Thus
98129 - * set the length to max_tokens. This matches the extra data
98130 - * allocation.
98131 - * The driver should fill it with the number of tokens it
98132 - * provided, and it may check iwp->length rather than having
98133 - * knowledge of max_tokens. If the driver doesn't change the
98134 - * iwp->length, this ioctl just copies back max_token tokens
98135 - * filled with zeroes. Hopefully the driver isn't claiming
98136 - * them to be valid data.
98137 - */
98138 - iwp->length = descr->max_tokens;
98139 - }
98140 -
98141 err = handler(dev, info, (union iwreq_data *) iwp, extra);
98142
98143 iwp->length += essid_compat;
98144 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
98145 index ea970b8..c68edb9f 100644
98146 --- a/net/xfrm/xfrm_policy.c
98147 +++ b/net/xfrm/xfrm_policy.c
98148 @@ -334,7 +334,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
98149 {
98150 policy->walk.dead = 1;
98151
98152 - atomic_inc(&policy->genid);
98153 + atomic_inc_unchecked(&policy->genid);
98154
98155 del_timer(&policy->polq.hold_timer);
98156 xfrm_queue_purge(&policy->polq.hold_queue);
98157 @@ -659,7 +659,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
98158 hlist_add_head(&policy->bydst, chain);
98159 xfrm_pol_hold(policy);
98160 net->xfrm.policy_count[dir]++;
98161 - atomic_inc(&flow_cache_genid);
98162 + atomic_inc_unchecked(&flow_cache_genid);
98163 rt_genid_bump(net);
98164 if (delpol) {
98165 xfrm_policy_requeue(delpol, policy);
98166 @@ -1629,7 +1629,7 @@ free_dst:
98167 goto out;
98168 }
98169
98170 -static int inline
98171 +static inline int
98172 xfrm_dst_alloc_copy(void **target, const void *src, int size)
98173 {
98174 if (!*target) {
98175 @@ -1641,7 +1641,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
98176 return 0;
98177 }
98178
98179 -static int inline
98180 +static inline int
98181 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
98182 {
98183 #ifdef CONFIG_XFRM_SUB_POLICY
98184 @@ -1653,7 +1653,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
98185 #endif
98186 }
98187
98188 -static int inline
98189 +static inline int
98190 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
98191 {
98192 #ifdef CONFIG_XFRM_SUB_POLICY
98193 @@ -1747,7 +1747,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
98194
98195 xdst->num_pols = num_pols;
98196 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
98197 - xdst->policy_genid = atomic_read(&pols[0]->genid);
98198 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
98199
98200 return xdst;
98201 }
98202 @@ -2618,7 +2618,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
98203 if (xdst->xfrm_genid != dst->xfrm->genid)
98204 return 0;
98205 if (xdst->num_pols > 0 &&
98206 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
98207 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
98208 return 0;
98209
98210 mtu = dst_mtu(dst->child);
98211 @@ -2706,8 +2706,11 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
98212 dst_ops->link_failure = xfrm_link_failure;
98213 if (likely(dst_ops->neigh_lookup == NULL))
98214 dst_ops->neigh_lookup = xfrm_neigh_lookup;
98215 - if (likely(afinfo->garbage_collect == NULL))
98216 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
98217 + if (likely(afinfo->garbage_collect == NULL)) {
98218 + pax_open_kernel();
98219 + *(void **)&afinfo->garbage_collect = xfrm_garbage_collect_deferred;
98220 + pax_close_kernel();
98221 + }
98222 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
98223 }
98224 spin_unlock(&xfrm_policy_afinfo_lock);
98225 @@ -2761,7 +2764,9 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
98226 dst_ops->check = NULL;
98227 dst_ops->negative_advice = NULL;
98228 dst_ops->link_failure = NULL;
98229 - afinfo->garbage_collect = NULL;
98230 + pax_open_kernel();
98231 + *(void **)&afinfo->garbage_collect = NULL;
98232 + pax_close_kernel();
98233 }
98234 return err;
98235 }
98236 @@ -3144,7 +3149,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
98237 sizeof(pol->xfrm_vec[i].saddr));
98238 pol->xfrm_vec[i].encap_family = mp->new_family;
98239 /* flush bundles */
98240 - atomic_inc(&pol->genid);
98241 + atomic_inc_unchecked(&pol->genid);
98242 }
98243 }
98244
98245 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
98246 index 78f66fa..b93d547 100644
98247 --- a/net/xfrm/xfrm_state.c
98248 +++ b/net/xfrm/xfrm_state.c
98249 @@ -177,12 +177,14 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
98250
98251 if (unlikely(afinfo == NULL))
98252 return -EAFNOSUPPORT;
98253 - typemap = afinfo->type_map;
98254 + typemap = (const struct xfrm_type **)afinfo->type_map;
98255 spin_lock_bh(&xfrm_type_lock);
98256
98257 - if (likely(typemap[type->proto] == NULL))
98258 + if (likely(typemap[type->proto] == NULL)) {
98259 + pax_open_kernel();
98260 typemap[type->proto] = type;
98261 - else
98262 + pax_close_kernel();
98263 + } else
98264 err = -EEXIST;
98265 spin_unlock_bh(&xfrm_type_lock);
98266 xfrm_state_put_afinfo(afinfo);
98267 @@ -198,13 +200,16 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
98268
98269 if (unlikely(afinfo == NULL))
98270 return -EAFNOSUPPORT;
98271 - typemap = afinfo->type_map;
98272 + typemap = (const struct xfrm_type **)afinfo->type_map;
98273 spin_lock_bh(&xfrm_type_lock);
98274
98275 if (unlikely(typemap[type->proto] != type))
98276 err = -ENOENT;
98277 - else
98278 + else {
98279 + pax_open_kernel();
98280 typemap[type->proto] = NULL;
98281 + pax_close_kernel();
98282 + }
98283 spin_unlock_bh(&xfrm_type_lock);
98284 xfrm_state_put_afinfo(afinfo);
98285 return err;
98286 @@ -214,7 +219,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
98287 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
98288 {
98289 struct xfrm_state_afinfo *afinfo;
98290 - const struct xfrm_type **typemap;
98291 const struct xfrm_type *type;
98292 int modload_attempted = 0;
98293
98294 @@ -222,9 +226,8 @@ retry:
98295 afinfo = xfrm_state_get_afinfo(family);
98296 if (unlikely(afinfo == NULL))
98297 return NULL;
98298 - typemap = afinfo->type_map;
98299
98300 - type = typemap[proto];
98301 + type = afinfo->type_map[proto];
98302 if (unlikely(type && !try_module_get(type->owner)))
98303 type = NULL;
98304 if (!type && !modload_attempted) {
98305 @@ -258,7 +261,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
98306 return -EAFNOSUPPORT;
98307
98308 err = -EEXIST;
98309 - modemap = afinfo->mode_map;
98310 + modemap = (struct xfrm_mode **)afinfo->mode_map;
98311 spin_lock_bh(&xfrm_mode_lock);
98312 if (modemap[mode->encap])
98313 goto out;
98314 @@ -267,8 +270,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
98315 if (!try_module_get(afinfo->owner))
98316 goto out;
98317
98318 - mode->afinfo = afinfo;
98319 + pax_open_kernel();
98320 + *(const void **)&mode->afinfo = afinfo;
98321 modemap[mode->encap] = mode;
98322 + pax_close_kernel();
98323 err = 0;
98324
98325 out:
98326 @@ -292,10 +297,12 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
98327 return -EAFNOSUPPORT;
98328
98329 err = -ENOENT;
98330 - modemap = afinfo->mode_map;
98331 + modemap = (struct xfrm_mode **)afinfo->mode_map;
98332 spin_lock_bh(&xfrm_mode_lock);
98333 if (likely(modemap[mode->encap] == mode)) {
98334 + pax_open_kernel();
98335 modemap[mode->encap] = NULL;
98336 + pax_close_kernel();
98337 module_put(mode->afinfo->owner);
98338 err = 0;
98339 }
98340 @@ -1486,10 +1493,10 @@ EXPORT_SYMBOL(xfrm_find_acq_byseq);
98341 u32 xfrm_get_acqseq(void)
98342 {
98343 u32 res;
98344 - static atomic_t acqseq;
98345 + static atomic_unchecked_t acqseq;
98346
98347 do {
98348 - res = atomic_inc_return(&acqseq);
98349 + res = atomic_inc_return_unchecked(&acqseq);
98350 } while (!res);
98351
98352 return res;
98353 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
98354 index 05a6e3d..6716ec9 100644
98355 --- a/net/xfrm/xfrm_sysctl.c
98356 +++ b/net/xfrm/xfrm_sysctl.c
98357 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
98358
98359 int __net_init xfrm_sysctl_init(struct net *net)
98360 {
98361 - struct ctl_table *table;
98362 + ctl_table_no_const *table;
98363
98364 __xfrm_sysctl_init(net);
98365
98366 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
98367 index d5d859c..781cbcb 100644
98368 --- a/scripts/Makefile.build
98369 +++ b/scripts/Makefile.build
98370 @@ -111,7 +111,7 @@ endif
98371 endif
98372
98373 # Do not include host rules unless needed
98374 -ifneq ($(hostprogs-y)$(hostprogs-m),)
98375 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
98376 include scripts/Makefile.host
98377 endif
98378
98379 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
98380 index 686cb0d..9d653bf 100644
98381 --- a/scripts/Makefile.clean
98382 +++ b/scripts/Makefile.clean
98383 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
98384 __clean-files := $(extra-y) $(always) \
98385 $(targets) $(clean-files) \
98386 $(host-progs) \
98387 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
98388 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
98389 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
98390
98391 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
98392
98393 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
98394 index 1ac414f..38575f7 100644
98395 --- a/scripts/Makefile.host
98396 +++ b/scripts/Makefile.host
98397 @@ -31,6 +31,8 @@
98398 # Note: Shared libraries consisting of C++ files are not supported
98399
98400 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
98401 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
98402 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
98403
98404 # C code
98405 # Executables compiled from a single .c file
98406 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
98407 # Shared libaries (only .c supported)
98408 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
98409 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
98410 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
98411 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
98412 # Remove .so files from "xxx-objs"
98413 host-cobjs := $(filter-out %.so,$(host-cobjs))
98414 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
98415
98416 -#Object (.o) files used by the shared libaries
98417 +# Object (.o) files used by the shared libaries
98418 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
98419 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
98420
98421 # output directory for programs/.o files
98422 # hostprogs-y := tools/build may have been specified. Retrieve directory
98423 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
98424 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
98425 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
98426 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
98427 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
98428 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
98429 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
98430 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
98431
98432 obj-dirs += $(host-objdirs)
98433 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
98434 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
98435 $(call if_changed_dep,host-cshobjs)
98436
98437 +# Compile .c file, create position independent .o file
98438 +# host-cxxshobjs -> .o
98439 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
98440 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
98441 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
98442 + $(call if_changed_dep,host-cxxshobjs)
98443 +
98444 # Link a shared library, based on position independent .o files
98445 # *.o -> .so shared library (host-cshlib)
98446 quiet_cmd_host-cshlib = HOSTLLD -shared $@
98447 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
98448 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
98449 $(call if_changed,host-cshlib)
98450
98451 +# Link a shared library, based on position independent .o files
98452 +# *.o -> .so shared library (host-cxxshlib)
98453 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
98454 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
98455 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
98456 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
98457 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
98458 + $(call if_changed,host-cxxshlib)
98459 +
98460 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
98461 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
98462 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
98463
98464 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
98465 index 078fe1d..fbdb363 100644
98466 --- a/scripts/basic/fixdep.c
98467 +++ b/scripts/basic/fixdep.c
98468 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
98469 /*
98470 * Lookup a value in the configuration string.
98471 */
98472 -static int is_defined_config(const char *name, int len, unsigned int hash)
98473 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
98474 {
98475 struct item *aux;
98476
98477 @@ -211,10 +211,10 @@ static void clear_config(void)
98478 /*
98479 * Record the use of a CONFIG_* word.
98480 */
98481 -static void use_config(const char *m, int slen)
98482 +static void use_config(const char *m, unsigned int slen)
98483 {
98484 unsigned int hash = strhash(m, slen);
98485 - int c, i;
98486 + unsigned int c, i;
98487
98488 if (is_defined_config(m, slen, hash))
98489 return;
98490 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
98491
98492 static void parse_config_file(const char *map, size_t len)
98493 {
98494 - const int *end = (const int *) (map + len);
98495 + const unsigned int *end = (const unsigned int *) (map + len);
98496 /* start at +1, so that p can never be < map */
98497 - const int *m = (const int *) map + 1;
98498 + const unsigned int *m = (const unsigned int *) map + 1;
98499 const char *p, *q;
98500
98501 for (; m < end; m++) {
98502 @@ -435,7 +435,7 @@ static void print_deps(void)
98503 static void traps(void)
98504 {
98505 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
98506 - int *p = (int *)test;
98507 + unsigned int *p = (unsigned int *)test;
98508
98509 if (*p != INT_CONF) {
98510 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
98511 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
98512 new file mode 100644
98513 index 0000000..5e0222d
98514 --- /dev/null
98515 +++ b/scripts/gcc-plugin.sh
98516 @@ -0,0 +1,17 @@
98517 +#!/bin/bash
98518 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
98519 +#include "gcc-plugin.h"
98520 +#include "tree.h"
98521 +#include "tm.h"
98522 +#include "rtl.h"
98523 +#ifdef ENABLE_BUILD_WITH_CXX
98524 +#warning $2
98525 +#else
98526 +#warning $1
98527 +#endif
98528 +EOF`
98529 +if [ $? -eq 0 ]
98530 +then
98531 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
98532 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
98533 +fi
98534 diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
98535 index 643764f..6cc0137 100644
98536 --- a/scripts/headers_install.sh
98537 +++ b/scripts/headers_install.sh
98538 @@ -29,6 +29,7 @@ do
98539 FILE="$(basename "$i")"
98540 sed -r \
98541 -e 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g' \
98542 + -e 's/__intentional_overflow\([- \t,0-9]*\)//g' \
98543 -e 's/__attribute_const__([ \t]|$)/\1/g' \
98544 -e 's@^#include <linux/compiler.h>@@' \
98545 -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
98546 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
98547 index 0149949..d482a0d 100644
98548 --- a/scripts/link-vmlinux.sh
98549 +++ b/scripts/link-vmlinux.sh
98550 @@ -158,7 +158,7 @@ else
98551 fi;
98552
98553 # final build of init/
98554 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
98555 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
98556
98557 kallsymso=""
98558 kallsyms_vmlinux=""
98559 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
98560 index 45f9a33..e4194b3 100644
98561 --- a/scripts/mod/file2alias.c
98562 +++ b/scripts/mod/file2alias.c
98563 @@ -140,7 +140,7 @@ static void device_id_check(const char *modname, const char *device_id,
98564 unsigned long size, unsigned long id_size,
98565 void *symval)
98566 {
98567 - int i;
98568 + unsigned int i;
98569
98570 if (size % id_size || size < id_size) {
98571 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
98572 @@ -168,7 +168,7 @@ static void device_id_check(const char *modname, const char *device_id,
98573 /* USB is special because the bcdDevice can be matched against a numeric range */
98574 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
98575 static void do_usb_entry(void *symval,
98576 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
98577 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
98578 unsigned char range_lo, unsigned char range_hi,
98579 unsigned char max, struct module *mod)
98580 {
98581 @@ -278,7 +278,7 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
98582 {
98583 unsigned int devlo, devhi;
98584 unsigned char chi, clo, max;
98585 - int ndigits;
98586 + unsigned int ndigits;
98587
98588 DEF_FIELD(symval, usb_device_id, match_flags);
98589 DEF_FIELD(symval, usb_device_id, idVendor);
98590 @@ -531,7 +531,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
98591 for (i = 0; i < count; i++) {
98592 DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id);
98593 char acpi_id[sizeof(*id)];
98594 - int j;
98595 + unsigned int j;
98596
98597 buf_printf(&mod->dev_table_buf,
98598 "MODULE_ALIAS(\"pnp:d%s*\");\n", *id);
98599 @@ -560,7 +560,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
98600
98601 for (j = 0; j < PNP_MAX_DEVICES; j++) {
98602 const char *id = (char *)(*devs)[j].id;
98603 - int i2, j2;
98604 + unsigned int i2, j2;
98605 int dup = 0;
98606
98607 if (!id[0])
98608 @@ -586,7 +586,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
98609 /* add an individual alias for every device entry */
98610 if (!dup) {
98611 char acpi_id[PNP_ID_LEN];
98612 - int k;
98613 + unsigned int k;
98614
98615 buf_printf(&mod->dev_table_buf,
98616 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
98617 @@ -938,7 +938,7 @@ static void dmi_ascii_filter(char *d, const char *s)
98618 static int do_dmi_entry(const char *filename, void *symval,
98619 char *alias)
98620 {
98621 - int i, j;
98622 + unsigned int i, j;
98623 DEF_FIELD_ADDR(symval, dmi_system_id, matches);
98624 sprintf(alias, "dmi*");
98625
98626 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
98627 index a4be8e1..6e8a5fb 100644
98628 --- a/scripts/mod/modpost.c
98629 +++ b/scripts/mod/modpost.c
98630 @@ -933,6 +933,7 @@ enum mismatch {
98631 ANY_INIT_TO_ANY_EXIT,
98632 ANY_EXIT_TO_ANY_INIT,
98633 EXPORT_TO_INIT_EXIT,
98634 + DATA_TO_TEXT
98635 };
98636
98637 struct sectioncheck {
98638 @@ -1047,6 +1048,12 @@ const struct sectioncheck sectioncheck[] = {
98639 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
98640 .mismatch = EXPORT_TO_INIT_EXIT,
98641 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
98642 +},
98643 +/* Do not reference code from writable data */
98644 +{
98645 + .fromsec = { DATA_SECTIONS, NULL },
98646 + .tosec = { TEXT_SECTIONS, NULL },
98647 + .mismatch = DATA_TO_TEXT
98648 }
98649 };
98650
98651 @@ -1169,10 +1176,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
98652 continue;
98653 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
98654 continue;
98655 - if (sym->st_value == addr)
98656 - return sym;
98657 /* Find a symbol nearby - addr are maybe negative */
98658 d = sym->st_value - addr;
98659 + if (d == 0)
98660 + return sym;
98661 if (d < 0)
98662 d = addr - sym->st_value;
98663 if (d < distance) {
98664 @@ -1451,6 +1458,14 @@ static void report_sec_mismatch(const char *modname,
98665 tosym, prl_to, prl_to, tosym);
98666 free(prl_to);
98667 break;
98668 + case DATA_TO_TEXT:
98669 +#if 0
98670 + fprintf(stderr,
98671 + "The %s %s:%s references\n"
98672 + "the %s %s:%s%s\n",
98673 + from, fromsec, fromsym, to, tosec, tosym, to_p);
98674 +#endif
98675 + break;
98676 }
98677 fprintf(stderr, "\n");
98678 }
98679 @@ -1685,7 +1700,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
98680 static void check_sec_ref(struct module *mod, const char *modname,
98681 struct elf_info *elf)
98682 {
98683 - int i;
98684 + unsigned int i;
98685 Elf_Shdr *sechdrs = elf->sechdrs;
98686
98687 /* Walk through all sections */
98688 @@ -1804,7 +1819,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
98689 va_end(ap);
98690 }
98691
98692 -void buf_write(struct buffer *buf, const char *s, int len)
98693 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
98694 {
98695 if (buf->size - buf->pos < len) {
98696 buf->size += len + SZ;
98697 @@ -2023,7 +2038,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
98698 if (fstat(fileno(file), &st) < 0)
98699 goto close_write;
98700
98701 - if (st.st_size != b->pos)
98702 + if (st.st_size != (off_t)b->pos)
98703 goto close_write;
98704
98705 tmp = NOFAIL(malloc(b->pos));
98706 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
98707 index 51207e4..f7d603d 100644
98708 --- a/scripts/mod/modpost.h
98709 +++ b/scripts/mod/modpost.h
98710 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
98711
98712 struct buffer {
98713 char *p;
98714 - int pos;
98715 - int size;
98716 + unsigned int pos;
98717 + unsigned int size;
98718 };
98719
98720 void __attribute__((format(printf, 2, 3)))
98721 buf_printf(struct buffer *buf, const char *fmt, ...);
98722
98723 void
98724 -buf_write(struct buffer *buf, const char *s, int len);
98725 +buf_write(struct buffer *buf, const char *s, unsigned int len);
98726
98727 struct module {
98728 struct module *next;
98729 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
98730 index 9dfcd6d..099068e 100644
98731 --- a/scripts/mod/sumversion.c
98732 +++ b/scripts/mod/sumversion.c
98733 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
98734 goto out;
98735 }
98736
98737 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
98738 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
98739 warn("writing sum in %s failed: %s\n",
98740 filename, strerror(errno));
98741 goto out;
98742 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
98743 index acb8650..b8c5f02 100644
98744 --- a/scripts/package/builddeb
98745 +++ b/scripts/package/builddeb
98746 @@ -246,6 +246,7 @@ fi
98747 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
98748 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
98749 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
98750 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
98751 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
98752 mkdir -p "$destdir"
98753 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
98754 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
98755 index 68bb4ef..2f419e1 100644
98756 --- a/scripts/pnmtologo.c
98757 +++ b/scripts/pnmtologo.c
98758 @@ -244,14 +244,14 @@ static void write_header(void)
98759 fprintf(out, " * Linux logo %s\n", logoname);
98760 fputs(" */\n\n", out);
98761 fputs("#include <linux/linux_logo.h>\n\n", out);
98762 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
98763 + fprintf(out, "static unsigned char %s_data[] = {\n",
98764 logoname);
98765 }
98766
98767 static void write_footer(void)
98768 {
98769 fputs("\n};\n\n", out);
98770 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
98771 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
98772 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
98773 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
98774 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
98775 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
98776 fputs("\n};\n\n", out);
98777
98778 /* write logo clut */
98779 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
98780 + fprintf(out, "static unsigned char %s_clut[] = {\n",
98781 logoname);
98782 write_hex_cnt = 0;
98783 for (i = 0; i < logo_clutsize; i++) {
98784 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
98785 index f5eb43d..1814de8 100644
98786 --- a/scripts/sortextable.h
98787 +++ b/scripts/sortextable.h
98788 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
98789 const char *secstrtab;
98790 const char *strtab;
98791 char *extab_image;
98792 - int extab_index = 0;
98793 - int i;
98794 - int idx;
98795 + unsigned int extab_index = 0;
98796 + unsigned int i;
98797 + unsigned int idx;
98798
98799 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
98800 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
98801 diff --git a/security/Kconfig b/security/Kconfig
98802 index e9c6ac7..c5d45c8 100644
98803 --- a/security/Kconfig
98804 +++ b/security/Kconfig
98805 @@ -4,6 +4,959 @@
98806
98807 menu "Security options"
98808
98809 +menu "Grsecurity"
98810 +
98811 + config ARCH_TRACK_EXEC_LIMIT
98812 + bool
98813 +
98814 + config PAX_KERNEXEC_PLUGIN
98815 + bool
98816 +
98817 + config PAX_PER_CPU_PGD
98818 + bool
98819 +
98820 + config TASK_SIZE_MAX_SHIFT
98821 + int
98822 + depends on X86_64
98823 + default 47 if !PAX_PER_CPU_PGD
98824 + default 42 if PAX_PER_CPU_PGD
98825 +
98826 + config PAX_ENABLE_PAE
98827 + bool
98828 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
98829 +
98830 + config PAX_USERCOPY_SLABS
98831 + bool
98832 +
98833 +config GRKERNSEC
98834 + bool "Grsecurity"
98835 + select CRYPTO
98836 + select CRYPTO_SHA256
98837 + select PROC_FS
98838 + select STOP_MACHINE
98839 + select TTY
98840 + help
98841 + If you say Y here, you will be able to configure many features
98842 + that will enhance the security of your system. It is highly
98843 + recommended that you say Y here and read through the help
98844 + for each option so that you fully understand the features and
98845 + can evaluate their usefulness for your machine.
98846 +
98847 +choice
98848 + prompt "Configuration Method"
98849 + depends on GRKERNSEC
98850 + default GRKERNSEC_CONFIG_CUSTOM
98851 + help
98852 +
98853 +config GRKERNSEC_CONFIG_AUTO
98854 + bool "Automatic"
98855 + help
98856 + If you choose this configuration method, you'll be able to answer a small
98857 + number of simple questions about how you plan to use this kernel.
98858 + The settings of grsecurity and PaX will be automatically configured for
98859 + the highest commonly-used settings within the provided constraints.
98860 +
98861 + If you require additional configuration, custom changes can still be made
98862 + from the "custom configuration" menu.
98863 +
98864 +config GRKERNSEC_CONFIG_CUSTOM
98865 + bool "Custom"
98866 + help
98867 + If you choose this configuration method, you'll be able to configure all
98868 + grsecurity and PaX settings manually. Via this method, no options are
98869 + automatically enabled.
98870 +
98871 +endchoice
98872 +
98873 +choice
98874 + prompt "Usage Type"
98875 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
98876 + default GRKERNSEC_CONFIG_SERVER
98877 + help
98878 +
98879 +config GRKERNSEC_CONFIG_SERVER
98880 + bool "Server"
98881 + help
98882 + Choose this option if you plan to use this kernel on a server.
98883 +
98884 +config GRKERNSEC_CONFIG_DESKTOP
98885 + bool "Desktop"
98886 + help
98887 + Choose this option if you plan to use this kernel on a desktop.
98888 +
98889 +endchoice
98890 +
98891 +choice
98892 + prompt "Virtualization Type"
98893 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
98894 + default GRKERNSEC_CONFIG_VIRT_NONE
98895 + help
98896 +
98897 +config GRKERNSEC_CONFIG_VIRT_NONE
98898 + bool "None"
98899 + help
98900 + Choose this option if this kernel will be run on bare metal.
98901 +
98902 +config GRKERNSEC_CONFIG_VIRT_GUEST
98903 + bool "Guest"
98904 + help
98905 + Choose this option if this kernel will be run as a VM guest.
98906 +
98907 +config GRKERNSEC_CONFIG_VIRT_HOST
98908 + bool "Host"
98909 + help
98910 + Choose this option if this kernel will be run as a VM host.
98911 +
98912 +endchoice
98913 +
98914 +choice
98915 + prompt "Virtualization Hardware"
98916 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
98917 + help
98918 +
98919 +config GRKERNSEC_CONFIG_VIRT_EPT
98920 + bool "EPT/RVI Processor Support"
98921 + depends on X86
98922 + help
98923 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
98924 + hardware virtualization. This allows for additional kernel hardening protections
98925 + to operate without additional performance impact.
98926 +
98927 + To see if your Intel processor supports EPT, see:
98928 + http://ark.intel.com/Products/VirtualizationTechnology
98929 + (Most Core i3/5/7 support EPT)
98930 +
98931 + To see if your AMD processor supports RVI, see:
98932 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
98933 +
98934 +config GRKERNSEC_CONFIG_VIRT_SOFT
98935 + bool "First-gen/No Hardware Virtualization"
98936 + help
98937 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
98938 + support hardware virtualization or doesn't support the EPT/RVI extensions.
98939 +
98940 +endchoice
98941 +
98942 +choice
98943 + prompt "Virtualization Software"
98944 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
98945 + help
98946 +
98947 +config GRKERNSEC_CONFIG_VIRT_XEN
98948 + bool "Xen"
98949 + help
98950 + Choose this option if this kernel is running as a Xen guest or host.
98951 +
98952 +config GRKERNSEC_CONFIG_VIRT_VMWARE
98953 + bool "VMWare"
98954 + help
98955 + Choose this option if this kernel is running as a VMWare guest or host.
98956 +
98957 +config GRKERNSEC_CONFIG_VIRT_KVM
98958 + bool "KVM"
98959 + help
98960 + Choose this option if this kernel is running as a KVM guest or host.
98961 +
98962 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
98963 + bool "VirtualBox"
98964 + help
98965 + Choose this option if this kernel is running as a VirtualBox guest or host.
98966 +
98967 +endchoice
98968 +
98969 +choice
98970 + prompt "Required Priorities"
98971 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
98972 + default GRKERNSEC_CONFIG_PRIORITY_PERF
98973 + help
98974 +
98975 +config GRKERNSEC_CONFIG_PRIORITY_PERF
98976 + bool "Performance"
98977 + help
98978 + Choose this option if performance is of highest priority for this deployment
98979 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
98980 + clearing of structures intended for userland, and freed memory sanitizing will
98981 + be disabled.
98982 +
98983 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
98984 + bool "Security"
98985 + help
98986 + Choose this option if security is of highest priority for this deployment of
98987 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
98988 + for userland, and freed memory sanitizing will be enabled for this kernel.
98989 + In a worst-case scenario, these features can introduce a 20% performance hit
98990 + (UDEREF on x64 contributing half of this hit).
98991 +
98992 +endchoice
98993 +
98994 +menu "Default Special Groups"
98995 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
98996 +
98997 +config GRKERNSEC_PROC_GID
98998 + int "GID exempted from /proc restrictions"
98999 + default 1001
99000 + help
99001 + Setting this GID determines which group will be exempted from
99002 + grsecurity's /proc restrictions, allowing users of the specified
99003 + group to view network statistics and the existence of other users'
99004 + processes on the system. This GID may also be chosen at boot time
99005 + via "grsec_proc_gid=" on the kernel commandline.
99006 +
99007 +config GRKERNSEC_TPE_UNTRUSTED_GID
99008 + int "GID for TPE-untrusted users"
99009 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
99010 + default 1005
99011 + help
99012 + Setting this GID determines which group untrusted users should
99013 + be added to. These users will be placed under grsecurity's Trusted Path
99014 + Execution mechanism, preventing them from executing their own binaries.
99015 + The users will only be able to execute binaries in directories owned and
99016 + writable only by the root user. If the sysctl option is enabled, a sysctl
99017 + option with name "tpe_gid" is created.
99018 +
99019 +config GRKERNSEC_TPE_TRUSTED_GID
99020 + int "GID for TPE-trusted users"
99021 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
99022 + default 1005
99023 + help
99024 + Setting this GID determines what group TPE restrictions will be
99025 + *disabled* for. If the sysctl option is enabled, a sysctl option
99026 + with name "tpe_gid" is created.
99027 +
99028 +config GRKERNSEC_SYMLINKOWN_GID
99029 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
99030 + depends on GRKERNSEC_CONFIG_SERVER
99031 + default 1006
99032 + help
99033 + Setting this GID determines what group kernel-enforced
99034 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
99035 + is enabled, a sysctl option with name "symlinkown_gid" is created.
99036 +
99037 +
99038 +endmenu
99039 +
99040 +menu "Customize Configuration"
99041 +depends on GRKERNSEC
99042 +
99043 +menu "PaX"
99044 +
99045 +config PAX
99046 + bool "Enable various PaX features"
99047 + default y if GRKERNSEC_CONFIG_AUTO
99048 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
99049 + help
99050 + This allows you to enable various PaX features. PaX adds
99051 + intrusion prevention mechanisms to the kernel that reduce
99052 + the risks posed by exploitable memory corruption bugs.
99053 +
99054 +menu "PaX Control"
99055 + depends on PAX
99056 +
99057 +config PAX_SOFTMODE
99058 + bool 'Support soft mode'
99059 + help
99060 + Enabling this option will allow you to run PaX in soft mode, that
99061 + is, PaX features will not be enforced by default, only on executables
99062 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
99063 + support as they are the only way to mark executables for soft mode use.
99064 +
99065 + Soft mode can be activated by using the "pax_softmode=1" kernel command
99066 + line option on boot. Furthermore you can control various PaX features
99067 + at runtime via the entries in /proc/sys/kernel/pax.
99068 +
99069 +config PAX_EI_PAX
99070 + bool 'Use legacy ELF header marking'
99071 + default y if GRKERNSEC_CONFIG_AUTO
99072 + help
99073 + Enabling this option will allow you to control PaX features on
99074 + a per executable basis via the 'chpax' utility available at
99075 + http://pax.grsecurity.net/. The control flags will be read from
99076 + an otherwise reserved part of the ELF header. This marking has
99077 + numerous drawbacks (no support for soft-mode, toolchain does not
99078 + know about the non-standard use of the ELF header) therefore it
99079 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
99080 + support.
99081 +
99082 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
99083 + support as well, they will override the legacy EI_PAX marks.
99084 +
99085 + If you enable none of the marking options then all applications
99086 + will run with PaX enabled on them by default.
99087 +
99088 +config PAX_PT_PAX_FLAGS
99089 + bool 'Use ELF program header marking'
99090 + default y if GRKERNSEC_CONFIG_AUTO
99091 + help
99092 + Enabling this option will allow you to control PaX features on
99093 + a per executable basis via the 'paxctl' utility available at
99094 + http://pax.grsecurity.net/. The control flags will be read from
99095 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
99096 + has the benefits of supporting both soft mode and being fully
99097 + integrated into the toolchain (the binutils patch is available
99098 + from http://pax.grsecurity.net).
99099 +
99100 + Note that if you enable the legacy EI_PAX marking support as well,
99101 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
99102 +
99103 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
99104 + must make sure that the marks are the same if a binary has both marks.
99105 +
99106 + If you enable none of the marking options then all applications
99107 + will run with PaX enabled on them by default.
99108 +
99109 +config PAX_XATTR_PAX_FLAGS
99110 + bool 'Use filesystem extended attributes marking'
99111 + default y if GRKERNSEC_CONFIG_AUTO
99112 + select CIFS_XATTR if CIFS
99113 + select EXT2_FS_XATTR if EXT2_FS
99114 + select EXT3_FS_XATTR if EXT3_FS
99115 + select EXT4_FS_XATTR if EXT4_FS
99116 + select JFFS2_FS_XATTR if JFFS2_FS
99117 + select REISERFS_FS_XATTR if REISERFS_FS
99118 + select SQUASHFS_XATTR if SQUASHFS
99119 + select TMPFS_XATTR if TMPFS
99120 + select UBIFS_FS_XATTR if UBIFS_FS
99121 + help
99122 + Enabling this option will allow you to control PaX features on
99123 + a per executable basis via the 'setfattr' utility. The control
99124 + flags will be read from the user.pax.flags extended attribute of
99125 + the file. This marking has the benefit of supporting binary-only
99126 + applications that self-check themselves (e.g., skype) and would
99127 + not tolerate chpax/paxctl changes. The main drawback is that
99128 + extended attributes are not supported by some filesystems (e.g.,
99129 + isofs, udf, vfat) so copying files through such filesystems will
99130 + lose the extended attributes and these PaX markings.
99131 +
99132 + Note that if you enable the legacy EI_PAX marking support as well,
99133 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
99134 +
99135 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
99136 + must make sure that the marks are the same if a binary has both marks.
99137 +
99138 + If you enable none of the marking options then all applications
99139 + will run with PaX enabled on them by default.
99140 +
99141 +choice
99142 + prompt 'MAC system integration'
99143 + default PAX_HAVE_ACL_FLAGS
99144 + help
99145 + Mandatory Access Control systems have the option of controlling
99146 + PaX flags on a per executable basis, choose the method supported
99147 + by your particular system.
99148 +
99149 + - "none": if your MAC system does not interact with PaX,
99150 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
99151 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
99152 +
99153 + NOTE: this option is for developers/integrators only.
99154 +
99155 + config PAX_NO_ACL_FLAGS
99156 + bool 'none'
99157 +
99158 + config PAX_HAVE_ACL_FLAGS
99159 + bool 'direct'
99160 +
99161 + config PAX_HOOK_ACL_FLAGS
99162 + bool 'hook'
99163 +endchoice
99164 +
99165 +endmenu
99166 +
99167 +menu "Non-executable pages"
99168 + depends on PAX
99169 +
99170 +config PAX_NOEXEC
99171 + bool "Enforce non-executable pages"
99172 + default y if GRKERNSEC_CONFIG_AUTO
99173 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
99174 + help
99175 + By design some architectures do not allow for protecting memory
99176 + pages against execution or even if they do, Linux does not make
99177 + use of this feature. In practice this means that if a page is
99178 + readable (such as the stack or heap) it is also executable.
99179 +
99180 + There is a well known exploit technique that makes use of this
99181 + fact and a common programming mistake where an attacker can
99182 + introduce code of his choice somewhere in the attacked program's
99183 + memory (typically the stack or the heap) and then execute it.
99184 +
99185 + If the attacked program was running with different (typically
99186 + higher) privileges than that of the attacker, then he can elevate
99187 + his own privilege level (e.g. get a root shell, write to files for
99188 + which he does not have write access to, etc).
99189 +
99190 + Enabling this option will let you choose from various features
99191 + that prevent the injection and execution of 'foreign' code in
99192 + a program.
99193 +
99194 + This will also break programs that rely on the old behaviour and
99195 + expect that dynamically allocated memory via the malloc() family
99196 + of functions is executable (which it is not). Notable examples
99197 + are the XFree86 4.x server, the java runtime and wine.
99198 +
99199 +config PAX_PAGEEXEC
99200 + bool "Paging based non-executable pages"
99201 + default y if GRKERNSEC_CONFIG_AUTO
99202 + 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)
99203 + select ARCH_TRACK_EXEC_LIMIT if X86_32
99204 + help
99205 + This implementation is based on the paging feature of the CPU.
99206 + On i386 without hardware non-executable bit support there is a
99207 + variable but usually low performance impact, however on Intel's
99208 + P4 core based CPUs it is very high so you should not enable this
99209 + for kernels meant to be used on such CPUs.
99210 +
99211 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
99212 + with hardware non-executable bit support there is no performance
99213 + impact, on ppc the impact is negligible.
99214 +
99215 + Note that several architectures require various emulations due to
99216 + badly designed userland ABIs, this will cause a performance impact
99217 + but will disappear as soon as userland is fixed. For example, ppc
99218 + userland MUST have been built with secure-plt by a recent toolchain.
99219 +
99220 +config PAX_SEGMEXEC
99221 + bool "Segmentation based non-executable pages"
99222 + default y if GRKERNSEC_CONFIG_AUTO
99223 + depends on PAX_NOEXEC && X86_32
99224 + help
99225 + This implementation is based on the segmentation feature of the
99226 + CPU and has a very small performance impact, however applications
99227 + will be limited to a 1.5 GB address space instead of the normal
99228 + 3 GB.
99229 +
99230 +config PAX_EMUTRAMP
99231 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
99232 + default y if PARISC
99233 + help
99234 + There are some programs and libraries that for one reason or
99235 + another attempt to execute special small code snippets from
99236 + non-executable memory pages. Most notable examples are the
99237 + signal handler return code generated by the kernel itself and
99238 + the GCC trampolines.
99239 +
99240 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
99241 + such programs will no longer work under your kernel.
99242 +
99243 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
99244 + utilities to enable trampoline emulation for the affected programs
99245 + yet still have the protection provided by the non-executable pages.
99246 +
99247 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
99248 + your system will not even boot.
99249 +
99250 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
99251 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
99252 + for the affected files.
99253 +
99254 + NOTE: enabling this feature *may* open up a loophole in the
99255 + protection provided by non-executable pages that an attacker
99256 + could abuse. Therefore the best solution is to not have any
99257 + files on your system that would require this option. This can
99258 + be achieved by not using libc5 (which relies on the kernel
99259 + signal handler return code) and not using or rewriting programs
99260 + that make use of the nested function implementation of GCC.
99261 + Skilled users can just fix GCC itself so that it implements
99262 + nested function calls in a way that does not interfere with PaX.
99263 +
99264 +config PAX_EMUSIGRT
99265 + bool "Automatically emulate sigreturn trampolines"
99266 + depends on PAX_EMUTRAMP && PARISC
99267 + default y
99268 + help
99269 + Enabling this option will have the kernel automatically detect
99270 + and emulate signal return trampolines executing on the stack
99271 + that would otherwise lead to task termination.
99272 +
99273 + This solution is intended as a temporary one for users with
99274 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
99275 + Modula-3 runtime, etc) or executables linked to such, basically
99276 + everything that does not specify its own SA_RESTORER function in
99277 + normal executable memory like glibc 2.1+ does.
99278 +
99279 + On parisc you MUST enable this option, otherwise your system will
99280 + not even boot.
99281 +
99282 + NOTE: this feature cannot be disabled on a per executable basis
99283 + and since it *does* open up a loophole in the protection provided
99284 + by non-executable pages, the best solution is to not have any
99285 + files on your system that would require this option.
99286 +
99287 +config PAX_MPROTECT
99288 + bool "Restrict mprotect()"
99289 + default y if GRKERNSEC_CONFIG_AUTO
99290 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
99291 + help
99292 + Enabling this option will prevent programs from
99293 + - changing the executable status of memory pages that were
99294 + not originally created as executable,
99295 + - making read-only executable pages writable again,
99296 + - creating executable pages from anonymous memory,
99297 + - making read-only-after-relocations (RELRO) data pages writable again.
99298 +
99299 + You should say Y here to complete the protection provided by
99300 + the enforcement of non-executable pages.
99301 +
99302 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
99303 + this feature on a per file basis.
99304 +
99305 +config PAX_MPROTECT_COMPAT
99306 + bool "Use legacy/compat protection demoting (read help)"
99307 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
99308 + depends on PAX_MPROTECT
99309 + help
99310 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
99311 + by sending the proper error code to the application. For some broken
99312 + userland, this can cause problems with Python or other applications. The
99313 + current implementation however allows for applications like clamav to
99314 + detect if JIT compilation/execution is allowed and to fall back gracefully
99315 + to an interpreter-based mode if it does not. While we encourage everyone
99316 + to use the current implementation as-is and push upstream to fix broken
99317 + userland (note that the RWX logging option can assist with this), in some
99318 + environments this may not be possible. Having to disable MPROTECT
99319 + completely on certain binaries reduces the security benefit of PaX,
99320 + so this option is provided for those environments to revert to the old
99321 + behavior.
99322 +
99323 +config PAX_ELFRELOCS
99324 + bool "Allow ELF text relocations (read help)"
99325 + depends on PAX_MPROTECT
99326 + default n
99327 + help
99328 + Non-executable pages and mprotect() restrictions are effective
99329 + in preventing the introduction of new executable code into an
99330 + attacked task's address space. There remain only two venues
99331 + for this kind of attack: if the attacker can execute already
99332 + existing code in the attacked task then he can either have it
99333 + create and mmap() a file containing his code or have it mmap()
99334 + an already existing ELF library that does not have position
99335 + independent code in it and use mprotect() on it to make it
99336 + writable and copy his code there. While protecting against
99337 + the former approach is beyond PaX, the latter can be prevented
99338 + by having only PIC ELF libraries on one's system (which do not
99339 + need to relocate their code). If you are sure this is your case,
99340 + as is the case with all modern Linux distributions, then leave
99341 + this option disabled. You should say 'n' here.
99342 +
99343 +config PAX_ETEXECRELOCS
99344 + bool "Allow ELF ET_EXEC text relocations"
99345 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
99346 + select PAX_ELFRELOCS
99347 + default y
99348 + help
99349 + On some architectures there are incorrectly created applications
99350 + that require text relocations and would not work without enabling
99351 + this option. If you are an alpha, ia64 or parisc user, you should
99352 + enable this option and disable it once you have made sure that
99353 + none of your applications need it.
99354 +
99355 +config PAX_EMUPLT
99356 + bool "Automatically emulate ELF PLT"
99357 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
99358 + default y
99359 + help
99360 + Enabling this option will have the kernel automatically detect
99361 + and emulate the Procedure Linkage Table entries in ELF files.
99362 + On some architectures such entries are in writable memory, and
99363 + become non-executable leading to task termination. Therefore
99364 + it is mandatory that you enable this option on alpha, parisc,
99365 + sparc and sparc64, otherwise your system would not even boot.
99366 +
99367 + NOTE: this feature *does* open up a loophole in the protection
99368 + provided by the non-executable pages, therefore the proper
99369 + solution is to modify the toolchain to produce a PLT that does
99370 + not need to be writable.
99371 +
99372 +config PAX_DLRESOLVE
99373 + bool 'Emulate old glibc resolver stub'
99374 + depends on PAX_EMUPLT && SPARC
99375 + default n
99376 + help
99377 + This option is needed if userland has an old glibc (before 2.4)
99378 + that puts a 'save' instruction into the runtime generated resolver
99379 + stub that needs special emulation.
99380 +
99381 +config PAX_KERNEXEC
99382 + bool "Enforce non-executable kernel pages"
99383 + 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))
99384 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
99385 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
99386 + select PAX_KERNEXEC_PLUGIN if X86_64
99387 + help
99388 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
99389 + that is, enabling this option will make it harder to inject
99390 + and execute 'foreign' code in kernel memory itself.
99391 +
99392 +choice
99393 + prompt "Return Address Instrumentation Method"
99394 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
99395 + depends on PAX_KERNEXEC_PLUGIN
99396 + help
99397 + Select the method used to instrument function pointer dereferences.
99398 + Note that binary modules cannot be instrumented by this approach.
99399 +
99400 + Note that the implementation requires a gcc with plugin support,
99401 + i.e., gcc 4.5 or newer. You may need to install the supporting
99402 + headers explicitly in addition to the normal gcc package.
99403 +
99404 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
99405 + bool "bts"
99406 + help
99407 + This method is compatible with binary only modules but has
99408 + a higher runtime overhead.
99409 +
99410 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
99411 + bool "or"
99412 + depends on !PARAVIRT
99413 + help
99414 + This method is incompatible with binary only modules but has
99415 + a lower runtime overhead.
99416 +endchoice
99417 +
99418 +config PAX_KERNEXEC_PLUGIN_METHOD
99419 + string
99420 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
99421 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
99422 + default ""
99423 +
99424 +config PAX_KERNEXEC_MODULE_TEXT
99425 + int "Minimum amount of memory reserved for module code"
99426 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
99427 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
99428 + depends on PAX_KERNEXEC && X86_32
99429 + help
99430 + Due to implementation details the kernel must reserve a fixed
99431 + amount of memory for runtime allocated code (such as modules)
99432 + at compile time that cannot be changed at runtime. Here you
99433 + can specify the minimum amount in MB that will be reserved.
99434 + Due to the same implementation details this size will always
99435 + be rounded up to the next 2/4 MB boundary (depends on PAE) so
99436 + the actually available memory for runtime allocated code will
99437 + usually be more than this minimum.
99438 +
99439 + The default 4 MB should be enough for most users but if you have
99440 + an excessive number of modules (e.g., most distribution configs
99441 + compile many drivers as modules) or use huge modules such as
99442 + nvidia's kernel driver, you will need to adjust this amount.
99443 + A good rule of thumb is to look at your currently loaded kernel
99444 + modules and add up their sizes.
99445 +
99446 +endmenu
99447 +
99448 +menu "Address Space Layout Randomization"
99449 + depends on PAX
99450 +
99451 +config PAX_ASLR
99452 + bool "Address Space Layout Randomization"
99453 + default y if GRKERNSEC_CONFIG_AUTO
99454 + help
99455 + Many if not most exploit techniques rely on the knowledge of
99456 + certain addresses in the attacked program. The following options
99457 + will allow the kernel to apply a certain amount of randomization
99458 + to specific parts of the program thereby forcing an attacker to
99459 + guess them in most cases. Any failed guess will most likely crash
99460 + the attacked program which allows the kernel to detect such attempts
99461 + and react on them. PaX itself provides no reaction mechanisms,
99462 + instead it is strongly encouraged that you make use of Nergal's
99463 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
99464 + (http://www.grsecurity.net/) built-in crash detection features or
99465 + develop one yourself.
99466 +
99467 + By saying Y here you can choose to randomize the following areas:
99468 + - top of the task's kernel stack
99469 + - top of the task's userland stack
99470 + - base address for mmap() requests that do not specify one
99471 + (this includes all libraries)
99472 + - base address of the main executable
99473 +
99474 + It is strongly recommended to say Y here as address space layout
99475 + randomization has negligible impact on performance yet it provides
99476 + a very effective protection.
99477 +
99478 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
99479 + this feature on a per file basis.
99480 +
99481 +config PAX_RANDKSTACK
99482 + bool "Randomize kernel stack base"
99483 + default y if GRKERNSEC_CONFIG_AUTO && !(GRKERNSEC_CONFIG_VIRT_HOST && GRKERNSEC_CONFIG_VIRT_VIRTUALBOX)
99484 + depends on X86_TSC && X86
99485 + help
99486 + By saying Y here the kernel will randomize every task's kernel
99487 + stack on every system call. This will not only force an attacker
99488 + to guess it but also prevent him from making use of possible
99489 + leaked information about it.
99490 +
99491 + Since the kernel stack is a rather scarce resource, randomization
99492 + may cause unexpected stack overflows, therefore you should very
99493 + carefully test your system. Note that once enabled in the kernel
99494 + configuration, this feature cannot be disabled on a per file basis.
99495 +
99496 +config PAX_RANDUSTACK
99497 + bool "Randomize user stack base"
99498 + default y if GRKERNSEC_CONFIG_AUTO
99499 + depends on PAX_ASLR
99500 + help
99501 + By saying Y here the kernel will randomize every task's userland
99502 + stack. The randomization is done in two steps where the second
99503 + one may apply a big amount of shift to the top of the stack and
99504 + cause problems for programs that want to use lots of memory (more
99505 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
99506 + For this reason the second step can be controlled by 'chpax' or
99507 + 'paxctl' on a per file basis.
99508 +
99509 +config PAX_RANDMMAP
99510 + bool "Randomize mmap() base"
99511 + default y if GRKERNSEC_CONFIG_AUTO
99512 + depends on PAX_ASLR
99513 + help
99514 + By saying Y here the kernel will use a randomized base address for
99515 + mmap() requests that do not specify one themselves. As a result
99516 + all dynamically loaded libraries will appear at random addresses
99517 + and therefore be harder to exploit by a technique where an attacker
99518 + attempts to execute library code for his purposes (e.g. spawn a
99519 + shell from an exploited program that is running at an elevated
99520 + privilege level).
99521 +
99522 + Furthermore, if a program is relinked as a dynamic ELF file, its
99523 + base address will be randomized as well, completing the full
99524 + randomization of the address space layout. Attacking such programs
99525 + becomes a guess game. You can find an example of doing this at
99526 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
99527 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
99528 +
99529 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
99530 + feature on a per file basis.
99531 +
99532 +endmenu
99533 +
99534 +menu "Miscellaneous hardening features"
99535 +
99536 +config PAX_MEMORY_SANITIZE
99537 + bool "Sanitize all freed memory"
99538 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
99539 + depends on !HIBERNATION
99540 + help
99541 + By saying Y here the kernel will erase memory pages and slab objects
99542 + as soon as they are freed. This in turn reduces the lifetime of data
99543 + stored in them, making it less likely that sensitive information such
99544 + as passwords, cryptographic secrets, etc stay in memory for too long.
99545 +
99546 + This is especially useful for programs whose runtime is short, long
99547 + lived processes and the kernel itself benefit from this as long as
99548 + they ensure timely freeing of memory that may hold sensitive
99549 + information.
99550 +
99551 + A nice side effect of the sanitization of slab objects is the
99552 + reduction of possible info leaks caused by padding bytes within the
99553 + leaky structures. Use-after-free bugs for structures containing
99554 + pointers can also be detected as dereferencing the sanitized pointer
99555 + will generate an access violation.
99556 +
99557 + The tradeoff is performance impact, on a single CPU system kernel
99558 + compilation sees a 3% slowdown, other systems and workloads may vary
99559 + and you are advised to test this feature on your expected workload
99560 + before deploying it.
99561 +
99562 + To reduce the performance penalty by sanitizing pages only, albeit
99563 + limiting the effectiveness of this feature at the same time, slab
99564 + sanitization can be disabled with the kernel commandline parameter
99565 + "pax_sanitize_slab=0".
99566 +
99567 + Note that this feature does not protect data stored in live pages,
99568 + e.g., process memory swapped to disk may stay there for a long time.
99569 +
99570 +config PAX_MEMORY_STACKLEAK
99571 + bool "Sanitize kernel stack"
99572 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
99573 + depends on X86
99574 + help
99575 + By saying Y here the kernel will erase the kernel stack before it
99576 + returns from a system call. This in turn reduces the information
99577 + that a kernel stack leak bug can reveal.
99578 +
99579 + Note that such a bug can still leak information that was put on
99580 + the stack by the current system call (the one eventually triggering
99581 + the bug) but traces of earlier system calls on the kernel stack
99582 + cannot leak anymore.
99583 +
99584 + The tradeoff is performance impact: on a single CPU system kernel
99585 + compilation sees a 1% slowdown, other systems and workloads may vary
99586 + and you are advised to test this feature on your expected workload
99587 + before deploying it.
99588 +
99589 + Note that the full feature requires a gcc with plugin support,
99590 + i.e., gcc 4.5 or newer. You may need to install the supporting
99591 + headers explicitly in addition to the normal gcc package. Using
99592 + older gcc versions means that functions with large enough stack
99593 + frames may leave uninitialized memory behind that may be exposed
99594 + to a later syscall leaking the stack.
99595 +
99596 +config PAX_MEMORY_STRUCTLEAK
99597 + bool "Forcibly initialize local variables copied to userland"
99598 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
99599 + help
99600 + By saying Y here the kernel will zero initialize some local
99601 + variables that are going to be copied to userland. This in
99602 + turn prevents unintended information leakage from the kernel
99603 + stack should later code forget to explicitly set all parts of
99604 + the copied variable.
99605 +
99606 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
99607 + at a much smaller coverage.
99608 +
99609 + Note that the implementation requires a gcc with plugin support,
99610 + i.e., gcc 4.5 or newer. You may need to install the supporting
99611 + headers explicitly in addition to the normal gcc package.
99612 +
99613 +config PAX_MEMORY_UDEREF
99614 + bool "Prevent invalid userland pointer dereference"
99615 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
99616 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
99617 + select PAX_PER_CPU_PGD if X86_64
99618 + help
99619 + By saying Y here the kernel will be prevented from dereferencing
99620 + userland pointers in contexts where the kernel expects only kernel
99621 + pointers. This is both a useful runtime debugging feature and a
99622 + security measure that prevents exploiting a class of kernel bugs.
99623 +
99624 + The tradeoff is that some virtualization solutions may experience
99625 + a huge slowdown and therefore you should not enable this feature
99626 + for kernels meant to run in such environments. Whether a given VM
99627 + solution is affected or not is best determined by simply trying it
99628 + out, the performance impact will be obvious right on boot as this
99629 + mechanism engages from very early on. A good rule of thumb is that
99630 + VMs running on CPUs without hardware virtualization support (i.e.,
99631 + the majority of IA-32 CPUs) will likely experience the slowdown.
99632 +
99633 + On X86_64 the kernel will make use of PCID support when available
99634 + (Intel's Westmere, Sandy Bridge, etc) for better security (default)
99635 + or performance impact. Pass pax_weakuderef on the kernel command
99636 + line to choose the latter.
99637 +
99638 +config PAX_REFCOUNT
99639 + bool "Prevent various kernel object reference counter overflows"
99640 + default y if GRKERNSEC_CONFIG_AUTO
99641 + depends on GRKERNSEC && ((ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || MIPS || SPARC64 || X86)
99642 + help
99643 + By saying Y here the kernel will detect and prevent overflowing
99644 + various (but not all) kinds of object reference counters. Such
99645 + overflows can normally occur due to bugs only and are often, if
99646 + not always, exploitable.
99647 +
99648 + The tradeoff is that data structures protected by an overflowed
99649 + refcount will never be freed and therefore will leak memory. Note
99650 + that this leak also happens even without this protection but in
99651 + that case the overflow can eventually trigger the freeing of the
99652 + data structure while it is still being used elsewhere, resulting
99653 + in the exploitable situation that this feature prevents.
99654 +
99655 + Since this has a negligible performance impact, you should enable
99656 + this feature.
99657 +
99658 +config PAX_CONSTIFY_PLUGIN
99659 + bool "Automatically constify eligible structures"
99660 + default y
99661 + depends on !UML && PAX_KERNEXEC
99662 + help
99663 + By saying Y here the compiler will automatically constify a class
99664 + of types that contain only function pointers. This reduces the
99665 + kernel's attack surface and also produces a better memory layout.
99666 +
99667 + Note that the implementation requires a gcc with plugin support,
99668 + i.e., gcc 4.5 or newer. You may need to install the supporting
99669 + headers explicitly in addition to the normal gcc package.
99670 +
99671 + Note that if some code really has to modify constified variables
99672 + then the source code will have to be patched to allow it. Examples
99673 + can be found in PaX itself (the no_const attribute) and for some
99674 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
99675 +
99676 +config PAX_USERCOPY
99677 + bool "Harden heap object copies between kernel and userland"
99678 + default y if GRKERNSEC_CONFIG_AUTO
99679 + depends on ARM || IA64 || PPC || SPARC || X86
99680 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
99681 + select PAX_USERCOPY_SLABS
99682 + help
99683 + By saying Y here the kernel will enforce the size of heap objects
99684 + when they are copied in either direction between the kernel and
99685 + userland, even if only a part of the heap object is copied.
99686 +
99687 + Specifically, this checking prevents information leaking from the
99688 + kernel heap during kernel to userland copies (if the kernel heap
99689 + object is otherwise fully initialized) and prevents kernel heap
99690 + overflows during userland to kernel copies.
99691 +
99692 + Note that the current implementation provides the strictest bounds
99693 + checks for the SLUB allocator.
99694 +
99695 + Enabling this option also enables per-slab cache protection against
99696 + data in a given cache being copied into/out of via userland
99697 + accessors. Though the whitelist of regions will be reduced over
99698 + time, it notably protects important data structures like task structs.
99699 +
99700 + If frame pointers are enabled on x86, this option will also restrict
99701 + copies into and out of the kernel stack to local variables within a
99702 + single frame.
99703 +
99704 + Since this has a negligible performance impact, you should enable
99705 + this feature.
99706 +
99707 +config PAX_USERCOPY_DEBUG
99708 + bool
99709 + depends on X86 && PAX_USERCOPY
99710 + default n
99711 +
99712 +config PAX_SIZE_OVERFLOW
99713 + bool "Prevent various integer overflows in function size parameters"
99714 + default y if GRKERNSEC_CONFIG_AUTO
99715 + depends on X86
99716 + help
99717 + By saying Y here the kernel recomputes expressions of function
99718 + arguments marked by a size_overflow attribute with double integer
99719 + precision (DImode/TImode for 32/64 bit integer types).
99720 +
99721 + The recomputed argument is checked against TYPE_MAX and an event
99722 + is logged on overflow and the triggering process is killed.
99723 +
99724 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
99725 +
99726 + Note that the implementation requires a gcc with plugin support,
99727 + i.e., gcc 4.5 or newer. You may need to install the supporting
99728 + headers explicitly in addition to the normal gcc package.
99729 +
99730 +config PAX_LATENT_ENTROPY
99731 + bool "Generate some entropy during boot"
99732 + default y if GRKERNSEC_CONFIG_AUTO
99733 + help
99734 + By saying Y here the kernel will instrument early boot code to
99735 + extract some entropy from both original and artificially created
99736 + program state. This will help especially embedded systems where
99737 + there is little 'natural' source of entropy normally. The cost
99738 + is some slowdown of the boot process.
99739 +
99740 + When pax_extra_latent_entropy is passed on the kernel command line,
99741 + entropy will be extracted from up to the first 4GB of RAM while the
99742 + runtime memory allocator is being initialized. This costs even more
99743 + slowdown of the boot process.
99744 +
99745 + Note that the implementation requires a gcc with plugin support,
99746 + i.e., gcc 4.5 or newer. You may need to install the supporting
99747 + headers explicitly in addition to the normal gcc package.
99748 +
99749 + Note that entropy extracted this way is not cryptographically
99750 + secure!
99751 +
99752 +endmenu
99753 +
99754 +endmenu
99755 +
99756 +source grsecurity/Kconfig
99757 +
99758 +endmenu
99759 +
99760 +endmenu
99761 +
99762 source security/keys/Kconfig
99763
99764 config SECURITY_DMESG_RESTRICT
99765 @@ -103,7 +1056,7 @@ config INTEL_TXT
99766 config LSM_MMAP_MIN_ADDR
99767 int "Low address space for LSM to protect from user allocation"
99768 depends on SECURITY && SECURITY_SELINUX
99769 - default 32768 if ARM
99770 + default 32768 if ALPHA || ARM || PARISC || SPARC32
99771 default 65536
99772 help
99773 This is the portion of low virtual memory which should be protected
99774 diff --git a/security/apparmor/Kconfig b/security/apparmor/Kconfig
99775 index 9b9013b..51ebf96 100644
99776 --- a/security/apparmor/Kconfig
99777 +++ b/security/apparmor/Kconfig
99778 @@ -29,3 +29,12 @@ config SECURITY_APPARMOR_BOOTPARAM_VALUE
99779 boot.
99780
99781 If you are unsure how to answer this question, answer 1.
99782 +
99783 +config SECURITY_APPARMOR_COMPAT_24
99784 + bool "Enable AppArmor 2.4 compatability"
99785 + depends on SECURITY_APPARMOR
99786 + default y
99787 + help
99788 + This option enables compatability with AppArmor 2.4. It is
99789 + recommended if compatability with older versions of AppArmor
99790 + is desired.
99791 diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
99792 index 16c15ec..42b7c9f 100644
99793 --- a/security/apparmor/apparmorfs.c
99794 +++ b/security/apparmor/apparmorfs.c
99795 @@ -182,6 +182,234 @@ const struct file_operations aa_fs_seq_file_ops = {
99796 .release = single_release,
99797 };
99798
99799 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
99800 +/**
99801 + * __next_namespace - find the next namespace to list
99802 + * @root: root namespace to stop search at (NOT NULL)
99803 + * @ns: current ns position (NOT NULL)
99804 + *
99805 + * Find the next namespace from @ns under @root and handle all locking needed
99806 + * while switching current namespace.
99807 + *
99808 + * Returns: next namespace or NULL if at last namespace under @root
99809 + * NOTE: will not unlock root->lock
99810 + */
99811 +static struct aa_namespace *__next_namespace(struct aa_namespace *root,
99812 + struct aa_namespace *ns)
99813 +{
99814 + struct aa_namespace *parent;
99815 +
99816 + /* is next namespace a child */
99817 + if (!list_empty(&ns->sub_ns)) {
99818 + struct aa_namespace *next;
99819 + next = list_first_entry(&ns->sub_ns, typeof(*ns), base.list);
99820 + read_lock(&next->lock);
99821 + return next;
99822 + }
99823 +
99824 + /* check if the next ns is a sibling, parent, gp, .. */
99825 + parent = ns->parent;
99826 + while (parent) {
99827 + read_unlock(&ns->lock);
99828 + list_for_each_entry_continue(ns, &parent->sub_ns, base.list) {
99829 + read_lock(&ns->lock);
99830 + return ns;
99831 + }
99832 + if (parent == root)
99833 + return NULL;
99834 + ns = parent;
99835 + parent = parent->parent;
99836 + }
99837 +
99838 + return NULL;
99839 +}
99840 +
99841 +/**
99842 + * __first_profile - find the first profile in a namespace
99843 + * @root: namespace that is root of profiles being displayed (NOT NULL)
99844 + * @ns: namespace to start in (NOT NULL)
99845 + *
99846 + * Returns: unrefcounted profile or NULL if no profile
99847 + */
99848 +static struct aa_profile *__first_profile(struct aa_namespace *root,
99849 + struct aa_namespace *ns)
99850 +{
99851 + for ( ; ns; ns = __next_namespace(root, ns)) {
99852 + if (!list_empty(&ns->base.profiles))
99853 + return list_first_entry(&ns->base.profiles,
99854 + struct aa_profile, base.list);
99855 + }
99856 + return NULL;
99857 +}
99858 +
99859 +/**
99860 + * __next_profile - step to the next profile in a profile tree
99861 + * @profile: current profile in tree (NOT NULL)
99862 + *
99863 + * Perform a depth first taversal on the profile tree in a namespace
99864 + *
99865 + * Returns: next profile or NULL if done
99866 + * Requires: profile->ns.lock to be held
99867 + */
99868 +static struct aa_profile *__next_profile(struct aa_profile *p)
99869 +{
99870 + struct aa_profile *parent;
99871 + struct aa_namespace *ns = p->ns;
99872 +
99873 + /* is next profile a child */
99874 + if (!list_empty(&p->base.profiles))
99875 + return list_first_entry(&p->base.profiles, typeof(*p),
99876 + base.list);
99877 +
99878 + /* is next profile a sibling, parent sibling, gp, subling, .. */
99879 + parent = p->parent;
99880 + while (parent) {
99881 + list_for_each_entry_continue(p, &parent->base.profiles,
99882 + base.list)
99883 + return p;
99884 + p = parent;
99885 + parent = parent->parent;
99886 + }
99887 +
99888 + /* is next another profile in the namespace */
99889 + list_for_each_entry_continue(p, &ns->base.profiles, base.list)
99890 + return p;
99891 +
99892 + return NULL;
99893 +}
99894 +
99895 +/**
99896 + * next_profile - step to the next profile in where ever it may be
99897 + * @root: root namespace (NOT NULL)
99898 + * @profile: current profile (NOT NULL)
99899 + *
99900 + * Returns: next profile or NULL if there isn't one
99901 + */
99902 +static struct aa_profile *next_profile(struct aa_namespace *root,
99903 + struct aa_profile *profile)
99904 +{
99905 + struct aa_profile *next = __next_profile(profile);
99906 + if (next)
99907 + return next;
99908 +
99909 + /* finished all profiles in namespace move to next namespace */
99910 + return __first_profile(root, __next_namespace(root, profile->ns));
99911 +}
99912 +
99913 +/**
99914 + * p_start - start a depth first traversal of profile tree
99915 + * @f: seq_file to fill
99916 + * @pos: current position
99917 + *
99918 + * Returns: first profile under current namespace or NULL if none found
99919 + *
99920 + * acquires first ns->lock
99921 + */
99922 +static void *p_start(struct seq_file *f, loff_t *pos)
99923 + __acquires(root->lock)
99924 +{
99925 + struct aa_profile *profile = NULL;
99926 + struct aa_namespace *root = aa_current_profile()->ns;
99927 + loff_t l = *pos;
99928 + f->private = aa_get_namespace(root);
99929 +
99930 +
99931 + /* find the first profile */
99932 + read_lock(&root->lock);
99933 + profile = __first_profile(root, root);
99934 +
99935 + /* skip to position */
99936 + for (; profile && l > 0; l--)
99937 + profile = next_profile(root, profile);
99938 +
99939 + return profile;
99940 +}
99941 +
99942 +/**
99943 + * p_next - read the next profile entry
99944 + * @f: seq_file to fill
99945 + * @p: profile previously returned
99946 + * @pos: current position
99947 + *
99948 + * Returns: next profile after @p or NULL if none
99949 + *
99950 + * may acquire/release locks in namespace tree as necessary
99951 + */
99952 +static void *p_next(struct seq_file *f, void *p, loff_t *pos)
99953 +{
99954 + struct aa_profile *profile = p;
99955 + struct aa_namespace *root = f->private;
99956 + (*pos)++;
99957 +
99958 + return next_profile(root, profile);
99959 +}
99960 +
99961 +/**
99962 + * p_stop - stop depth first traversal
99963 + * @f: seq_file we are filling
99964 + * @p: the last profile writen
99965 + *
99966 + * Release all locking done by p_start/p_next on namespace tree
99967 + */
99968 +static void p_stop(struct seq_file *f, void *p)
99969 + __releases(root->lock)
99970 +{
99971 + struct aa_profile *profile = p;
99972 + struct aa_namespace *root = f->private, *ns;
99973 +
99974 + if (profile) {
99975 + for (ns = profile->ns; ns && ns != root; ns = ns->parent)
99976 + read_unlock(&ns->lock);
99977 + }
99978 + read_unlock(&root->lock);
99979 + aa_put_namespace(root);
99980 +}
99981 +
99982 +/**
99983 + * seq_show_profile - show a profile entry
99984 + * @f: seq_file to file
99985 + * @p: current position (profile) (NOT NULL)
99986 + *
99987 + * Returns: error on failure
99988 + */
99989 +static int seq_show_profile(struct seq_file *f, void *p)
99990 +{
99991 + struct aa_profile *profile = (struct aa_profile *)p;
99992 + struct aa_namespace *root = f->private;
99993 +
99994 + if (profile->ns != root)
99995 + seq_printf(f, ":%s://", aa_ns_name(root, profile->ns));
99996 + seq_printf(f, "%s (%s)\n", profile->base.hname,
99997 + COMPLAIN_MODE(profile) ? "complain" : "enforce");
99998 +
99999 + return 0;
100000 +}
100001 +
100002 +static const struct seq_operations aa_fs_profiles_op = {
100003 + .start = p_start,
100004 + .next = p_next,
100005 + .stop = p_stop,
100006 + .show = seq_show_profile,
100007 +};
100008 +
100009 +static int profiles_open(struct inode *inode, struct file *file)
100010 +{
100011 + return seq_open(file, &aa_fs_profiles_op);
100012 +}
100013 +
100014 +static int profiles_release(struct inode *inode, struct file *file)
100015 +{
100016 + return seq_release(inode, file);
100017 +}
100018 +
100019 +const struct file_operations aa_fs_profiles_fops = {
100020 + .open = profiles_open,
100021 + .read = seq_read,
100022 + .llseek = seq_lseek,
100023 + .release = profiles_release,
100024 +};
100025 +#endif /* CONFIG_SECURITY_APPARMOR_COMPAT_24 */
100026 +
100027 /** Base file system setup **/
100028
100029 static struct aa_fs_entry aa_fs_entry_file[] = {
100030 @@ -210,6 +438,9 @@ static struct aa_fs_entry aa_fs_entry_apparmor[] = {
100031 AA_FS_FILE_FOPS(".load", 0640, &aa_fs_profile_load),
100032 AA_FS_FILE_FOPS(".replace", 0640, &aa_fs_profile_replace),
100033 AA_FS_FILE_FOPS(".remove", 0640, &aa_fs_profile_remove),
100034 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
100035 + AA_FS_FILE_FOPS("profiles", 0640, &aa_fs_profiles_fops),
100036 +#endif
100037 AA_FS_DIR("features", aa_fs_entry_features),
100038 { }
100039 };
100040 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
100041 index b21830e..a7d1a17 100644
100042 --- a/security/apparmor/lsm.c
100043 +++ b/security/apparmor/lsm.c
100044 @@ -614,7 +614,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
100045 return error;
100046 }
100047
100048 -static struct security_operations apparmor_ops = {
100049 +static struct security_operations apparmor_ops __read_only = {
100050 .name = "apparmor",
100051
100052 .ptrace_access_check = apparmor_ptrace_access_check,
100053 diff --git a/security/commoncap.c b/security/commoncap.c
100054 index c44b6fe..932df30 100644
100055 --- a/security/commoncap.c
100056 +++ b/security/commoncap.c
100057 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
100058 return 0;
100059 }
100060
100061 +/* returns:
100062 + 1 for suid privilege
100063 + 2 for sgid privilege
100064 + 3 for fscap privilege
100065 +*/
100066 +int is_privileged_binary(const struct dentry *dentry)
100067 +{
100068 + struct cpu_vfs_cap_data capdata;
100069 + struct inode *inode = dentry->d_inode;
100070 +
100071 + if (!inode || S_ISDIR(inode->i_mode))
100072 + return 0;
100073 +
100074 + if (inode->i_mode & S_ISUID)
100075 + return 1;
100076 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
100077 + return 2;
100078 +
100079 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
100080 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
100081 + return 3;
100082 + }
100083 +
100084 + return 0;
100085 +}
100086 +
100087 /*
100088 * Attempt to get the on-exec apply capability sets for an executable file from
100089 * its xattrs and, if present, apply them to the proposed credentials being
100090 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
100091 const struct cred *cred = current_cred();
100092 kuid_t root_uid = make_kuid(cred->user_ns, 0);
100093
100094 + if (gr_acl_enable_at_secure())
100095 + return 1;
100096 +
100097 if (!uid_eq(cred->uid, root_uid)) {
100098 if (bprm->cap_effective)
100099 return 1;
100100 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
100101 index a41c9c1..83da6dd 100644
100102 --- a/security/integrity/ima/ima.h
100103 +++ b/security/integrity/ima/ima.h
100104 @@ -97,8 +97,8 @@ int ima_init_crypto(void);
100105 extern spinlock_t ima_queue_lock;
100106
100107 struct ima_h_table {
100108 - atomic_long_t len; /* number of stored measurements in the list */
100109 - atomic_long_t violations;
100110 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
100111 + atomic_long_unchecked_t violations;
100112 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
100113 };
100114 extern struct ima_h_table ima_htable;
100115 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
100116 index 1c03e8f1..398a941 100644
100117 --- a/security/integrity/ima/ima_api.c
100118 +++ b/security/integrity/ima/ima_api.c
100119 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
100120 int result;
100121
100122 /* can overflow, only indicator */
100123 - atomic_long_inc(&ima_htable.violations);
100124 + atomic_long_inc_unchecked(&ima_htable.violations);
100125
100126 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
100127 if (!entry) {
100128 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
100129 index 38477c9..87a60c7 100644
100130 --- a/security/integrity/ima/ima_fs.c
100131 +++ b/security/integrity/ima/ima_fs.c
100132 @@ -28,12 +28,12 @@
100133 static int valid_policy = 1;
100134 #define TMPBUFLEN 12
100135 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
100136 - loff_t *ppos, atomic_long_t *val)
100137 + loff_t *ppos, atomic_long_unchecked_t *val)
100138 {
100139 char tmpbuf[TMPBUFLEN];
100140 ssize_t len;
100141
100142 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
100143 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
100144 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
100145 }
100146
100147 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
100148 index ff63fe0..809cd96 100644
100149 --- a/security/integrity/ima/ima_queue.c
100150 +++ b/security/integrity/ima/ima_queue.c
100151 @@ -80,7 +80,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
100152 INIT_LIST_HEAD(&qe->later);
100153 list_add_tail_rcu(&qe->later, &ima_measurements);
100154
100155 - atomic_long_inc(&ima_htable.len);
100156 + atomic_long_inc_unchecked(&ima_htable.len);
100157 key = ima_hash_key(entry->digest);
100158 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
100159 return 0;
100160 diff --git a/security/keys/compat.c b/security/keys/compat.c
100161 index d65fa7f..cbfe366 100644
100162 --- a/security/keys/compat.c
100163 +++ b/security/keys/compat.c
100164 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
100165 if (ret == 0)
100166 goto no_payload_free;
100167
100168 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
100169 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
100170 err:
100171 if (iov != iovstack)
100172 kfree(iov);
100173 diff --git a/security/keys/internal.h b/security/keys/internal.h
100174 index d4f1468..cc52f92 100644
100175 --- a/security/keys/internal.h
100176 +++ b/security/keys/internal.h
100177 @@ -242,7 +242,7 @@ extern long keyctl_instantiate_key_iov(key_serial_t,
100178 extern long keyctl_invalidate_key(key_serial_t);
100179
100180 extern long keyctl_instantiate_key_common(key_serial_t,
100181 - const struct iovec *,
100182 + const struct iovec __user *,
100183 unsigned, size_t, key_serial_t);
100184
100185 /*
100186 diff --git a/security/keys/key.c b/security/keys/key.c
100187 index 8fb7c7b..ba3610d 100644
100188 --- a/security/keys/key.c
100189 +++ b/security/keys/key.c
100190 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
100191
100192 atomic_set(&key->usage, 1);
100193 init_rwsem(&key->sem);
100194 - lockdep_set_class(&key->sem, &type->lock_class);
100195 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
100196 key->type = type;
100197 key->user = user;
100198 key->quotalen = quotalen;
100199 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
100200 struct key_type *p;
100201 int ret;
100202
100203 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
100204 + pax_open_kernel();
100205 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
100206 + pax_close_kernel();
100207
100208 ret = -EEXIST;
100209 down_write(&key_types_sem);
100210 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
100211 }
100212
100213 /* store the type */
100214 - list_add(&ktype->link, &key_types_list);
100215 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
100216
100217 pr_notice("Key type %s registered\n", ktype->name);
100218 ret = 0;
100219 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
100220 void unregister_key_type(struct key_type *ktype)
100221 {
100222 down_write(&key_types_sem);
100223 - list_del_init(&ktype->link);
100224 + pax_list_del_init((struct list_head *)&ktype->link);
100225 downgrade_write(&key_types_sem);
100226 key_gc_keytype(ktype);
100227 pr_notice("Key type %s unregistered\n", ktype->name);
100228 @@ -1084,10 +1086,10 @@ void __init key_init(void)
100229 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
100230
100231 /* add the special key types */
100232 - list_add_tail(&key_type_keyring.link, &key_types_list);
100233 - list_add_tail(&key_type_dead.link, &key_types_list);
100234 - list_add_tail(&key_type_user.link, &key_types_list);
100235 - list_add_tail(&key_type_logon.link, &key_types_list);
100236 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
100237 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
100238 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
100239 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
100240
100241 /* record the root user tracking */
100242 rb_link_node(&root_key_user.node,
100243 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
100244 index 33cfd27..842fc5a 100644
100245 --- a/security/keys/keyctl.c
100246 +++ b/security/keys/keyctl.c
100247 @@ -987,7 +987,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
100248 /*
100249 * Copy the iovec data from userspace
100250 */
100251 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
100252 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
100253 unsigned ioc)
100254 {
100255 for (; ioc > 0; ioc--) {
100256 @@ -1009,7 +1009,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
100257 * If successful, 0 will be returned.
100258 */
100259 long keyctl_instantiate_key_common(key_serial_t id,
100260 - const struct iovec *payload_iov,
100261 + const struct iovec __user *payload_iov,
100262 unsigned ioc,
100263 size_t plen,
100264 key_serial_t ringid)
100265 @@ -1104,7 +1104,7 @@ long keyctl_instantiate_key(key_serial_t id,
100266 [0].iov_len = plen
100267 };
100268
100269 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
100270 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
100271 }
100272
100273 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
100274 @@ -1137,7 +1137,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
100275 if (ret == 0)
100276 goto no_payload_free;
100277
100278 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
100279 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
100280 err:
100281 if (iov != iovstack)
100282 kfree(iov);
100283 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
100284 index 6ece7f2..ecdb55c 100644
100285 --- a/security/keys/keyring.c
100286 +++ b/security/keys/keyring.c
100287 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
100288 ret = -EFAULT;
100289
100290 for (loop = 0; loop < klist->nkeys; loop++) {
100291 + key_serial_t serial;
100292 key = rcu_deref_link_locked(klist, loop,
100293 keyring);
100294 + serial = key->serial;
100295
100296 tmp = sizeof(key_serial_t);
100297 if (tmp > buflen)
100298 tmp = buflen;
100299
100300 - if (copy_to_user(buffer,
100301 - &key->serial,
100302 - tmp) != 0)
100303 + if (copy_to_user(buffer, &serial, tmp))
100304 goto error;
100305
100306 buflen -= tmp;
100307 diff --git a/security/min_addr.c b/security/min_addr.c
100308 index f728728..6457a0c 100644
100309 --- a/security/min_addr.c
100310 +++ b/security/min_addr.c
100311 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
100312 */
100313 static void update_mmap_min_addr(void)
100314 {
100315 +#ifndef SPARC
100316 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
100317 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
100318 mmap_min_addr = dac_mmap_min_addr;
100319 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
100320 #else
100321 mmap_min_addr = dac_mmap_min_addr;
100322 #endif
100323 +#endif
100324 }
100325
100326 /*
100327 diff --git a/security/security.c b/security/security.c
100328 index a3dce87..9ca1435 100644
100329 --- a/security/security.c
100330 +++ b/security/security.c
100331 @@ -20,6 +20,7 @@
100332 #include <linux/ima.h>
100333 #include <linux/evm.h>
100334 #include <linux/fsnotify.h>
100335 +#include <linux/mm.h>
100336 #include <linux/mman.h>
100337 #include <linux/mount.h>
100338 #include <linux/personality.h>
100339 @@ -32,8 +33,8 @@
100340 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
100341 CONFIG_DEFAULT_SECURITY;
100342
100343 -static struct security_operations *security_ops;
100344 -static struct security_operations default_security_ops = {
100345 +static struct security_operations *security_ops __read_only;
100346 +static struct security_operations default_security_ops __read_only = {
100347 .name = "default",
100348 };
100349
100350 @@ -74,7 +75,9 @@ int __init security_init(void)
100351
100352 void reset_security_ops(void)
100353 {
100354 + pax_open_kernel();
100355 security_ops = &default_security_ops;
100356 + pax_close_kernel();
100357 }
100358
100359 /* Save user chosen LSM */
100360 diff --git a/security/selinux/avc.c b/security/selinux/avc.c
100361 index dad36a6..7e5ffbf 100644
100362 --- a/security/selinux/avc.c
100363 +++ b/security/selinux/avc.c
100364 @@ -59,7 +59,7 @@ struct avc_node {
100365 struct avc_cache {
100366 struct hlist_head slots[AVC_CACHE_SLOTS]; /* head for avc_node->list */
100367 spinlock_t slots_lock[AVC_CACHE_SLOTS]; /* lock for writes */
100368 - atomic_t lru_hint; /* LRU hint for reclaim scan */
100369 + atomic_unchecked_t lru_hint; /* LRU hint for reclaim scan */
100370 atomic_t active_nodes;
100371 u32 latest_notif; /* latest revocation notification */
100372 };
100373 @@ -167,7 +167,7 @@ void __init avc_init(void)
100374 spin_lock_init(&avc_cache.slots_lock[i]);
100375 }
100376 atomic_set(&avc_cache.active_nodes, 0);
100377 - atomic_set(&avc_cache.lru_hint, 0);
100378 + atomic_set_unchecked(&avc_cache.lru_hint, 0);
100379
100380 avc_node_cachep = kmem_cache_create("avc_node", sizeof(struct avc_node),
100381 0, SLAB_PANIC, NULL);
100382 @@ -242,7 +242,7 @@ static inline int avc_reclaim_node(void)
100383 spinlock_t *lock;
100384
100385 for (try = 0, ecx = 0; try < AVC_CACHE_SLOTS; try++) {
100386 - hvalue = atomic_inc_return(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
100387 + hvalue = atomic_inc_return_unchecked(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
100388 head = &avc_cache.slots[hvalue];
100389 lock = &avc_cache.slots_lock[hvalue];
100390
100391 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
100392 index 5c6f2cd..b4f945c 100644
100393 --- a/security/selinux/hooks.c
100394 +++ b/security/selinux/hooks.c
100395 @@ -96,8 +96,6 @@
100396
100397 #define NUM_SEL_MNT_OPTS 5
100398
100399 -extern struct security_operations *security_ops;
100400 -
100401 /* SECMARK reference count */
100402 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
100403
100404 @@ -5529,7 +5527,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
100405
100406 #endif
100407
100408 -static struct security_operations selinux_ops = {
100409 +static struct security_operations selinux_ops __read_only = {
100410 .name = "selinux",
100411
100412 .ptrace_access_check = selinux_ptrace_access_check,
100413 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
100414 index 65f67cb..3f141ef 100644
100415 --- a/security/selinux/include/xfrm.h
100416 +++ b/security/selinux/include/xfrm.h
100417 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
100418
100419 static inline void selinux_xfrm_notify_policyload(void)
100420 {
100421 - atomic_inc(&flow_cache_genid);
100422 + atomic_inc_unchecked(&flow_cache_genid);
100423 rt_genid_bump(&init_net);
100424 }
100425 #else
100426 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
100427 index d52c780..6431349 100644
100428 --- a/security/smack/smack_lsm.c
100429 +++ b/security/smack/smack_lsm.c
100430 @@ -3392,7 +3392,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
100431 return 0;
100432 }
100433
100434 -struct security_operations smack_ops = {
100435 +struct security_operations smack_ops __read_only = {
100436 .name = "smack",
100437
100438 .ptrace_access_check = smack_ptrace_access_check,
100439 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
100440 index 390c646..f2f8db3 100644
100441 --- a/security/tomoyo/mount.c
100442 +++ b/security/tomoyo/mount.c
100443 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
100444 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
100445 need_dev = -1; /* dev_name is a directory */
100446 } else {
100447 + if (!capable(CAP_SYS_ADMIN)) {
100448 + error = -EPERM;
100449 + goto out;
100450 + }
100451 fstype = get_fs_type(type);
100452 if (!fstype) {
100453 error = -ENODEV;
100454 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
100455 index f0b756e..b129202 100644
100456 --- a/security/tomoyo/tomoyo.c
100457 +++ b/security/tomoyo/tomoyo.c
100458 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
100459 * tomoyo_security_ops is a "struct security_operations" which is used for
100460 * registering TOMOYO.
100461 */
100462 -static struct security_operations tomoyo_security_ops = {
100463 +static struct security_operations tomoyo_security_ops __read_only = {
100464 .name = "tomoyo",
100465 .cred_alloc_blank = tomoyo_cred_alloc_blank,
100466 .cred_prepare = tomoyo_cred_prepare,
100467 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
100468 index 20ef514..4182bed 100644
100469 --- a/security/yama/Kconfig
100470 +++ b/security/yama/Kconfig
100471 @@ -1,6 +1,6 @@
100472 config SECURITY_YAMA
100473 bool "Yama support"
100474 - depends on SECURITY
100475 + depends on SECURITY && !GRKERNSEC
100476 select SECURITYFS
100477 select SECURITY_PATH
100478 default n
100479 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
100480 index 13c88fbc..f8c115e 100644
100481 --- a/security/yama/yama_lsm.c
100482 +++ b/security/yama/yama_lsm.c
100483 @@ -365,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
100484 }
100485
100486 #ifndef CONFIG_SECURITY_YAMA_STACKED
100487 -static struct security_operations yama_ops = {
100488 +static struct security_operations yama_ops __read_only = {
100489 .name = "yama",
100490
100491 .ptrace_access_check = yama_ptrace_access_check,
100492 @@ -376,28 +376,24 @@ static struct security_operations yama_ops = {
100493 #endif
100494
100495 #ifdef CONFIG_SYSCTL
100496 +static int zero __read_only;
100497 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
100498 +
100499 static int yama_dointvec_minmax(struct ctl_table *table, int write,
100500 void __user *buffer, size_t *lenp, loff_t *ppos)
100501 {
100502 - int rc;
100503 + ctl_table_no_const yama_table;
100504
100505 if (write && !capable(CAP_SYS_PTRACE))
100506 return -EPERM;
100507
100508 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
100509 - if (rc)
100510 - return rc;
100511 -
100512 + yama_table = *table;
100513 /* Lock the max value if it ever gets set. */
100514 - if (write && *(int *)table->data == *(int *)table->extra2)
100515 - table->extra1 = table->extra2;
100516 -
100517 - return rc;
100518 + if (ptrace_scope == max_scope)
100519 + yama_table.extra1 = &max_scope;
100520 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
100521 }
100522
100523 -static int zero;
100524 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
100525 -
100526 struct ctl_path yama_sysctl_path[] = {
100527 { .procname = "kernel", },
100528 { .procname = "yama", },
100529 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
100530 index 4cedc69..e59d8a3 100644
100531 --- a/sound/aoa/codecs/onyx.c
100532 +++ b/sound/aoa/codecs/onyx.c
100533 @@ -54,7 +54,7 @@ struct onyx {
100534 spdif_locked:1,
100535 analog_locked:1,
100536 original_mute:2;
100537 - int open_count;
100538 + local_t open_count;
100539 struct codec_info *codec_info;
100540
100541 /* mutex serializes concurrent access to the device
100542 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
100543 struct onyx *onyx = cii->codec_data;
100544
100545 mutex_lock(&onyx->mutex);
100546 - onyx->open_count++;
100547 + local_inc(&onyx->open_count);
100548 mutex_unlock(&onyx->mutex);
100549
100550 return 0;
100551 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
100552 struct onyx *onyx = cii->codec_data;
100553
100554 mutex_lock(&onyx->mutex);
100555 - onyx->open_count--;
100556 - if (!onyx->open_count)
100557 + if (local_dec_and_test(&onyx->open_count))
100558 onyx->spdif_locked = onyx->analog_locked = 0;
100559 mutex_unlock(&onyx->mutex);
100560
100561 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
100562 index ffd2025..df062c9 100644
100563 --- a/sound/aoa/codecs/onyx.h
100564 +++ b/sound/aoa/codecs/onyx.h
100565 @@ -11,6 +11,7 @@
100566 #include <linux/i2c.h>
100567 #include <asm/pmac_low_i2c.h>
100568 #include <asm/prom.h>
100569 +#include <asm/local.h>
100570
100571 /* PCM3052 register definitions */
100572
100573 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
100574 index 4c1cc51..16040040 100644
100575 --- a/sound/core/oss/pcm_oss.c
100576 +++ b/sound/core/oss/pcm_oss.c
100577 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
100578 if (in_kernel) {
100579 mm_segment_t fs;
100580 fs = snd_enter_user();
100581 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
100582 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
100583 snd_leave_user(fs);
100584 } else {
100585 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
100586 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
100587 }
100588 if (ret != -EPIPE && ret != -ESTRPIPE)
100589 break;
100590 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
100591 if (in_kernel) {
100592 mm_segment_t fs;
100593 fs = snd_enter_user();
100594 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
100595 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
100596 snd_leave_user(fs);
100597 } else {
100598 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
100599 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
100600 }
100601 if (ret == -EPIPE) {
100602 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
100603 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
100604 struct snd_pcm_plugin_channel *channels;
100605 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
100606 if (!in_kernel) {
100607 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
100608 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
100609 return -EFAULT;
100610 buf = runtime->oss.buffer;
100611 }
100612 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
100613 }
100614 } else {
100615 tmp = snd_pcm_oss_write2(substream,
100616 - (const char __force *)buf,
100617 + (const char __force_kernel *)buf,
100618 runtime->oss.period_bytes, 0);
100619 if (tmp <= 0)
100620 goto err;
100621 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
100622 struct snd_pcm_runtime *runtime = substream->runtime;
100623 snd_pcm_sframes_t frames, frames1;
100624 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
100625 - char __user *final_dst = (char __force __user *)buf;
100626 + char __user *final_dst = (char __force_user *)buf;
100627 if (runtime->oss.plugin_first) {
100628 struct snd_pcm_plugin_channel *channels;
100629 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
100630 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
100631 xfer += tmp;
100632 runtime->oss.buffer_used -= tmp;
100633 } else {
100634 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
100635 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
100636 runtime->oss.period_bytes, 0);
100637 if (tmp <= 0)
100638 goto err;
100639 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
100640 size1);
100641 size1 /= runtime->channels; /* frames */
100642 fs = snd_enter_user();
100643 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
100644 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
100645 snd_leave_user(fs);
100646 }
100647 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
100648 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
100649 index af49721..e85058e 100644
100650 --- a/sound/core/pcm_compat.c
100651 +++ b/sound/core/pcm_compat.c
100652 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
100653 int err;
100654
100655 fs = snd_enter_user();
100656 - err = snd_pcm_delay(substream, &delay);
100657 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
100658 snd_leave_user(fs);
100659 if (err < 0)
100660 return err;
100661 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
100662 index f928181..33fb83d 100644
100663 --- a/sound/core/pcm_native.c
100664 +++ b/sound/core/pcm_native.c
100665 @@ -2819,11 +2819,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
100666 switch (substream->stream) {
100667 case SNDRV_PCM_STREAM_PLAYBACK:
100668 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
100669 - (void __user *)arg);
100670 + (void __force_user *)arg);
100671 break;
100672 case SNDRV_PCM_STREAM_CAPTURE:
100673 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
100674 - (void __user *)arg);
100675 + (void __force_user *)arg);
100676 break;
100677 default:
100678 result = -EINVAL;
100679 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
100680 index 040c60e..989a19a 100644
100681 --- a/sound/core/seq/seq_device.c
100682 +++ b/sound/core/seq/seq_device.c
100683 @@ -64,7 +64,7 @@ struct ops_list {
100684 int argsize; /* argument size */
100685
100686 /* operators */
100687 - struct snd_seq_dev_ops ops;
100688 + struct snd_seq_dev_ops *ops;
100689
100690 /* registered devices */
100691 struct list_head dev_list; /* list of devices */
100692 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
100693
100694 mutex_lock(&ops->reg_mutex);
100695 /* copy driver operators */
100696 - ops->ops = *entry;
100697 + ops->ops = entry;
100698 ops->driver |= DRIVER_LOADED;
100699 ops->argsize = argsize;
100700
100701 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
100702 dev->name, ops->id, ops->argsize, dev->argsize);
100703 return -EINVAL;
100704 }
100705 - if (ops->ops.init_device(dev) >= 0) {
100706 + if (ops->ops->init_device(dev) >= 0) {
100707 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
100708 ops->num_init_devices++;
100709 } else {
100710 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
100711 dev->name, ops->id, ops->argsize, dev->argsize);
100712 return -EINVAL;
100713 }
100714 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
100715 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
100716 dev->status = SNDRV_SEQ_DEVICE_FREE;
100717 dev->driver_data = NULL;
100718 ops->num_init_devices--;
100719 diff --git a/sound/core/sound.c b/sound/core/sound.c
100720 index f002bd9..c462985 100644
100721 --- a/sound/core/sound.c
100722 +++ b/sound/core/sound.c
100723 @@ -86,7 +86,7 @@ static void snd_request_other(int minor)
100724 case SNDRV_MINOR_TIMER: str = "snd-timer"; break;
100725 default: return;
100726 }
100727 - request_module(str);
100728 + request_module("%s", str);
100729 }
100730
100731 #endif /* modular kernel */
100732 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
100733 index 4e0dd22..7a1f32c 100644
100734 --- a/sound/drivers/mts64.c
100735 +++ b/sound/drivers/mts64.c
100736 @@ -29,6 +29,7 @@
100737 #include <sound/initval.h>
100738 #include <sound/rawmidi.h>
100739 #include <sound/control.h>
100740 +#include <asm/local.h>
100741
100742 #define CARD_NAME "Miditerminal 4140"
100743 #define DRIVER_NAME "MTS64"
100744 @@ -67,7 +68,7 @@ struct mts64 {
100745 struct pardevice *pardev;
100746 int pardev_claimed;
100747
100748 - int open_count;
100749 + local_t open_count;
100750 int current_midi_output_port;
100751 int current_midi_input_port;
100752 u8 mode[MTS64_NUM_INPUT_PORTS];
100753 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
100754 {
100755 struct mts64 *mts = substream->rmidi->private_data;
100756
100757 - if (mts->open_count == 0) {
100758 + if (local_read(&mts->open_count) == 0) {
100759 /* We don't need a spinlock here, because this is just called
100760 if the device has not been opened before.
100761 So there aren't any IRQs from the device */
100762 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
100763
100764 msleep(50);
100765 }
100766 - ++(mts->open_count);
100767 + local_inc(&mts->open_count);
100768
100769 return 0;
100770 }
100771 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
100772 struct mts64 *mts = substream->rmidi->private_data;
100773 unsigned long flags;
100774
100775 - --(mts->open_count);
100776 - if (mts->open_count == 0) {
100777 + if (local_dec_return(&mts->open_count) == 0) {
100778 /* We need the spinlock_irqsave here because we can still
100779 have IRQs at this point */
100780 spin_lock_irqsave(&mts->lock, flags);
100781 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
100782
100783 msleep(500);
100784
100785 - } else if (mts->open_count < 0)
100786 - mts->open_count = 0;
100787 + } else if (local_read(&mts->open_count) < 0)
100788 + local_set(&mts->open_count, 0);
100789
100790 return 0;
100791 }
100792 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
100793 index b953fb4..1999c01 100644
100794 --- a/sound/drivers/opl4/opl4_lib.c
100795 +++ b/sound/drivers/opl4/opl4_lib.c
100796 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
100797 MODULE_DESCRIPTION("OPL4 driver");
100798 MODULE_LICENSE("GPL");
100799
100800 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
100801 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
100802 {
100803 int timeout = 10;
100804 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
100805 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
100806 index 991018d..8984740 100644
100807 --- a/sound/drivers/portman2x4.c
100808 +++ b/sound/drivers/portman2x4.c
100809 @@ -48,6 +48,7 @@
100810 #include <sound/initval.h>
100811 #include <sound/rawmidi.h>
100812 #include <sound/control.h>
100813 +#include <asm/local.h>
100814
100815 #define CARD_NAME "Portman 2x4"
100816 #define DRIVER_NAME "portman"
100817 @@ -85,7 +86,7 @@ struct portman {
100818 struct pardevice *pardev;
100819 int pardev_claimed;
100820
100821 - int open_count;
100822 + local_t open_count;
100823 int mode[PORTMAN_NUM_INPUT_PORTS];
100824 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
100825 };
100826 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
100827 index ea995af..f1bfa37 100644
100828 --- a/sound/firewire/amdtp.c
100829 +++ b/sound/firewire/amdtp.c
100830 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
100831 ptr = s->pcm_buffer_pointer + data_blocks;
100832 if (ptr >= pcm->runtime->buffer_size)
100833 ptr -= pcm->runtime->buffer_size;
100834 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
100835 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
100836
100837 s->pcm_period_pointer += data_blocks;
100838 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
100839 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
100840 */
100841 void amdtp_out_stream_update(struct amdtp_out_stream *s)
100842 {
100843 - ACCESS_ONCE(s->source_node_id_field) =
100844 + ACCESS_ONCE_RW(s->source_node_id_field) =
100845 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
100846 }
100847 EXPORT_SYMBOL(amdtp_out_stream_update);
100848 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
100849 index b680c5e..061b7a0 100644
100850 --- a/sound/firewire/amdtp.h
100851 +++ b/sound/firewire/amdtp.h
100852 @@ -139,7 +139,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
100853 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
100854 struct snd_pcm_substream *pcm)
100855 {
100856 - ACCESS_ONCE(s->pcm) = pcm;
100857 + ACCESS_ONCE_RW(s->pcm) = pcm;
100858 }
100859
100860 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
100861 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
100862 index d428ffe..751ef78 100644
100863 --- a/sound/firewire/isight.c
100864 +++ b/sound/firewire/isight.c
100865 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
100866 ptr += count;
100867 if (ptr >= runtime->buffer_size)
100868 ptr -= runtime->buffer_size;
100869 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
100870 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
100871
100872 isight->period_counter += count;
100873 if (isight->period_counter >= runtime->period_size) {
100874 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
100875 if (err < 0)
100876 return err;
100877
100878 - ACCESS_ONCE(isight->pcm_active) = true;
100879 + ACCESS_ONCE_RW(isight->pcm_active) = true;
100880
100881 return 0;
100882 }
100883 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
100884 {
100885 struct isight *isight = substream->private_data;
100886
100887 - ACCESS_ONCE(isight->pcm_active) = false;
100888 + ACCESS_ONCE_RW(isight->pcm_active) = false;
100889
100890 mutex_lock(&isight->mutex);
100891 isight_stop_streaming(isight);
100892 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
100893
100894 switch (cmd) {
100895 case SNDRV_PCM_TRIGGER_START:
100896 - ACCESS_ONCE(isight->pcm_running) = true;
100897 + ACCESS_ONCE_RW(isight->pcm_running) = true;
100898 break;
100899 case SNDRV_PCM_TRIGGER_STOP:
100900 - ACCESS_ONCE(isight->pcm_running) = false;
100901 + ACCESS_ONCE_RW(isight->pcm_running) = false;
100902 break;
100903 default:
100904 return -EINVAL;
100905 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
100906 index 844a555..985ab83 100644
100907 --- a/sound/firewire/scs1x.c
100908 +++ b/sound/firewire/scs1x.c
100909 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
100910 {
100911 struct scs *scs = stream->rmidi->private_data;
100912
100913 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
100914 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
100915 if (up) {
100916 scs->output_idle = false;
100917 tasklet_schedule(&scs->tasklet);
100918 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
100919 {
100920 struct scs *scs = stream->rmidi->private_data;
100921
100922 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
100923 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
100924 }
100925
100926 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
100927 @@ -457,8 +457,8 @@ static int scs_remove(struct device *dev)
100928
100929 snd_card_disconnect(scs->card);
100930
100931 - ACCESS_ONCE(scs->output) = NULL;
100932 - ACCESS_ONCE(scs->input) = NULL;
100933 + ACCESS_ONCE_RW(scs->output) = NULL;
100934 + ACCESS_ONCE_RW(scs->input) = NULL;
100935
100936 wait_event(scs->idle_wait, scs->output_idle);
100937
100938 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
100939 index 048439a..3be9f6f 100644
100940 --- a/sound/oss/sb_audio.c
100941 +++ b/sound/oss/sb_audio.c
100942 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
100943 buf16 = (signed short *)(localbuf + localoffs);
100944 while (c)
100945 {
100946 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
100947 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
100948 if (copy_from_user(lbuf8,
100949 userbuf+useroffs + p,
100950 locallen))
100951 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
100952 index 7d8803a..559f8d0 100644
100953 --- a/sound/oss/swarm_cs4297a.c
100954 +++ b/sound/oss/swarm_cs4297a.c
100955 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
100956 {
100957 struct cs4297a_state *s;
100958 u32 pwr, id;
100959 - mm_segment_t fs;
100960 int rval;
100961 #ifndef CONFIG_BCM_CS4297A_CSWARM
100962 u64 cfg;
100963 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
100964 if (!rval) {
100965 char *sb1250_duart_present;
100966
100967 +#if 0
100968 + mm_segment_t fs;
100969 fs = get_fs();
100970 set_fs(KERNEL_DS);
100971 -#if 0
100972 val = SOUND_MASK_LINE;
100973 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
100974 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
100975 val = initvol[i].vol;
100976 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
100977 }
100978 + set_fs(fs);
100979 // cs4297a_write_ac97(s, 0x18, 0x0808);
100980 #else
100981 // cs4297a_write_ac97(s, 0x5e, 0x180);
100982 cs4297a_write_ac97(s, 0x02, 0x0808);
100983 cs4297a_write_ac97(s, 0x18, 0x0808);
100984 #endif
100985 - set_fs(fs);
100986
100987 list_add(&s->list, &cs4297a_devs);
100988
100989 diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
100990 index 55108b5..d973e11 100644
100991 --- a/sound/pci/hda/hda_codec.c
100992 +++ b/sound/pci/hda/hda_codec.c
100993 @@ -916,14 +916,10 @@ find_codec_preset(struct hda_codec *codec)
100994 mutex_unlock(&preset_mutex);
100995
100996 if (mod_requested < HDA_MODREQ_MAX_COUNT) {
100997 - char name[32];
100998 if (!mod_requested)
100999 - snprintf(name, sizeof(name), "snd-hda-codec-id:%08x",
101000 - codec->vendor_id);
101001 + request_module("snd-hda-codec-id:%08x", codec->vendor_id);
101002 else
101003 - snprintf(name, sizeof(name), "snd-hda-codec-id:%04x*",
101004 - (codec->vendor_id >> 16) & 0xffff);
101005 - request_module(name);
101006 + request_module("snd-hda-codec-id:%04x*", (codec->vendor_id >> 16) & 0xffff);
101007 mod_requested++;
101008 goto again;
101009 }
101010 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
101011 index 4631a23..001ae57 100644
101012 --- a/sound/pci/ymfpci/ymfpci.h
101013 +++ b/sound/pci/ymfpci/ymfpci.h
101014 @@ -358,7 +358,7 @@ struct snd_ymfpci {
101015 spinlock_t reg_lock;
101016 spinlock_t voice_lock;
101017 wait_queue_head_t interrupt_sleep;
101018 - atomic_t interrupt_sleep_count;
101019 + atomic_unchecked_t interrupt_sleep_count;
101020 struct snd_info_entry *proc_entry;
101021 const struct firmware *dsp_microcode;
101022 const struct firmware *controller_microcode;
101023 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
101024 index 22056c5..25d3244 100644
101025 --- a/sound/pci/ymfpci/ymfpci_main.c
101026 +++ b/sound/pci/ymfpci/ymfpci_main.c
101027 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
101028 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
101029 break;
101030 }
101031 - if (atomic_read(&chip->interrupt_sleep_count)) {
101032 - atomic_set(&chip->interrupt_sleep_count, 0);
101033 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
101034 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
101035 wake_up(&chip->interrupt_sleep);
101036 }
101037 __end:
101038 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
101039 continue;
101040 init_waitqueue_entry(&wait, current);
101041 add_wait_queue(&chip->interrupt_sleep, &wait);
101042 - atomic_inc(&chip->interrupt_sleep_count);
101043 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
101044 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
101045 remove_wait_queue(&chip->interrupt_sleep, &wait);
101046 }
101047 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
101048 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
101049 spin_unlock(&chip->reg_lock);
101050
101051 - if (atomic_read(&chip->interrupt_sleep_count)) {
101052 - atomic_set(&chip->interrupt_sleep_count, 0);
101053 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
101054 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
101055 wake_up(&chip->interrupt_sleep);
101056 }
101057 }
101058 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
101059 spin_lock_init(&chip->reg_lock);
101060 spin_lock_init(&chip->voice_lock);
101061 init_waitqueue_head(&chip->interrupt_sleep);
101062 - atomic_set(&chip->interrupt_sleep_count, 0);
101063 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
101064 chip->card = card;
101065 chip->pci = pci;
101066 chip->irq = -1;
101067 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
101068 index 0f0bed6..c161e28 100644
101069 --- a/sound/soc/fsl/fsl_ssi.c
101070 +++ b/sound/soc/fsl/fsl_ssi.c
101071 @@ -657,7 +657,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
101072 {
101073 struct fsl_ssi_private *ssi_private;
101074 int ret = 0;
101075 - struct device_attribute *dev_attr = NULL;
101076 + device_attribute_no_const *dev_attr = NULL;
101077 struct device_node *np = pdev->dev.of_node;
101078 const char *p, *sprop;
101079 const uint32_t *iprop;
101080 diff --git a/sound/sound_core.c b/sound/sound_core.c
101081 index 359753f..45759f4 100644
101082 --- a/sound/sound_core.c
101083 +++ b/sound/sound_core.c
101084 @@ -292,7 +292,7 @@ retry:
101085 }
101086
101087 device_create(sound_class, dev, MKDEV(SOUND_MAJOR, s->unit_minor),
101088 - NULL, s->name+6);
101089 + NULL, "%s", s->name+6);
101090 return s->unit_minor;
101091
101092 fail:
101093 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
101094 new file mode 100644
101095 index 0000000..50f2f2f
101096 --- /dev/null
101097 +++ b/tools/gcc/.gitignore
101098 @@ -0,0 +1 @@
101099 +size_overflow_hash.h
101100 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
101101 new file mode 100644
101102 index 0000000..144dbee
101103 --- /dev/null
101104 +++ b/tools/gcc/Makefile
101105 @@ -0,0 +1,45 @@
101106 +#CC := gcc
101107 +#PLUGIN_SOURCE_FILES := pax_plugin.c
101108 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
101109 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
101110 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
101111 +
101112 +ifeq ($(PLUGINCC),$(HOSTCC))
101113 +HOSTLIBS := hostlibs
101114 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
101115 +else
101116 +HOSTLIBS := hostcxxlibs
101117 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
101118 +endif
101119 +
101120 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
101121 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
101122 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
101123 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
101124 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
101125 +$(HOSTLIBS)-y += colorize_plugin.so
101126 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
101127 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
101128 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
101129 +
101130 +always := $($(HOSTLIBS)-y)
101131 +
101132 +constify_plugin-objs := constify_plugin.o
101133 +stackleak_plugin-objs := stackleak_plugin.o
101134 +kallocstat_plugin-objs := kallocstat_plugin.o
101135 +kernexec_plugin-objs := kernexec_plugin.o
101136 +checker_plugin-objs := checker_plugin.o
101137 +colorize_plugin-objs := colorize_plugin.o
101138 +size_overflow_plugin-objs := size_overflow_plugin.o
101139 +latent_entropy_plugin-objs := latent_entropy_plugin.o
101140 +structleak_plugin-objs := structleak_plugin.o
101141 +
101142 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
101143 +
101144 +quiet_cmd_build_size_overflow_hash = GENHASH $@
101145 + cmd_build_size_overflow_hash = \
101146 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
101147 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
101148 + $(call if_changed,build_size_overflow_hash)
101149 +
101150 +targets += size_overflow_hash.h
101151 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
101152 new file mode 100644
101153 index 0000000..22f03c0
101154 --- /dev/null
101155 +++ b/tools/gcc/checker_plugin.c
101156 @@ -0,0 +1,172 @@
101157 +/*
101158 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
101159 + * Licensed under the GPL v2
101160 + *
101161 + * Note: the choice of the license means that the compilation process is
101162 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
101163 + * but for the kernel it doesn't matter since it doesn't link against
101164 + * any of the gcc libraries
101165 + *
101166 + * gcc plugin to implement various sparse (source code checker) features
101167 + *
101168 + * TODO:
101169 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
101170 + *
101171 + * BUGS:
101172 + * - none known
101173 + */
101174 +#include "gcc-plugin.h"
101175 +#include "config.h"
101176 +#include "system.h"
101177 +#include "coretypes.h"
101178 +#include "tree.h"
101179 +#include "tree-pass.h"
101180 +#include "flags.h"
101181 +#include "intl.h"
101182 +#include "toplev.h"
101183 +#include "plugin.h"
101184 +//#include "expr.h" where are you...
101185 +#include "diagnostic.h"
101186 +#include "plugin-version.h"
101187 +#include "tm.h"
101188 +#include "function.h"
101189 +#include "basic-block.h"
101190 +#include "gimple.h"
101191 +#include "rtl.h"
101192 +#include "emit-rtl.h"
101193 +#include "tree-flow.h"
101194 +#include "target.h"
101195 +
101196 +extern void c_register_addr_space (const char *str, addr_space_t as);
101197 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
101198 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
101199 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
101200 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
101201 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
101202 +
101203 +extern void print_gimple_stmt(FILE *, gimple, int, int);
101204 +extern rtx emit_move_insn(rtx x, rtx y);
101205 +
101206 +int plugin_is_GPL_compatible;
101207 +
101208 +static struct plugin_info checker_plugin_info = {
101209 + .version = "201111150100",
101210 + .help = NULL,
101211 +};
101212 +
101213 +#define ADDR_SPACE_KERNEL 0
101214 +#define ADDR_SPACE_FORCE_KERNEL 1
101215 +#define ADDR_SPACE_USER 2
101216 +#define ADDR_SPACE_FORCE_USER 3
101217 +#define ADDR_SPACE_IOMEM 0
101218 +#define ADDR_SPACE_FORCE_IOMEM 0
101219 +#define ADDR_SPACE_PERCPU 0
101220 +#define ADDR_SPACE_FORCE_PERCPU 0
101221 +#define ADDR_SPACE_RCU 0
101222 +#define ADDR_SPACE_FORCE_RCU 0
101223 +
101224 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
101225 +{
101226 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
101227 +}
101228 +
101229 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
101230 +{
101231 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
101232 +}
101233 +
101234 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
101235 +{
101236 + return default_addr_space_valid_pointer_mode(mode, as);
101237 +}
101238 +
101239 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
101240 +{
101241 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
101242 +}
101243 +
101244 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
101245 +{
101246 + return default_addr_space_legitimize_address(x, oldx, mode, as);
101247 +}
101248 +
101249 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
101250 +{
101251 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
101252 + return true;
101253 +
101254 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
101255 + return true;
101256 +
101257 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
101258 + return true;
101259 +
101260 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
101261 + return true;
101262 +
101263 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
101264 + return true;
101265 +
101266 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
101267 + return true;
101268 +
101269 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
101270 + return true;
101271 +
101272 + return subset == superset;
101273 +}
101274 +
101275 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
101276 +{
101277 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
101278 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
101279 +
101280 + return op;
101281 +}
101282 +
101283 +static void register_checker_address_spaces(void *event_data, void *data)
101284 +{
101285 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
101286 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
101287 + c_register_addr_space("__user", ADDR_SPACE_USER);
101288 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
101289 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
101290 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
101291 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
101292 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
101293 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
101294 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
101295 +
101296 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
101297 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
101298 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
101299 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
101300 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
101301 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
101302 + targetm.addr_space.convert = checker_addr_space_convert;
101303 +}
101304 +
101305 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101306 +{
101307 + const char * const plugin_name = plugin_info->base_name;
101308 + const int argc = plugin_info->argc;
101309 + const struct plugin_argument * const argv = plugin_info->argv;
101310 + int i;
101311 +
101312 + if (!plugin_default_version_check(version, &gcc_version)) {
101313 + error(G_("incompatible gcc/plugin versions"));
101314 + return 1;
101315 + }
101316 +
101317 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
101318 +
101319 + for (i = 0; i < argc; ++i)
101320 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
101321 +
101322 + if (TARGET_64BIT == 0)
101323 + return 0;
101324 +
101325 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
101326 +
101327 + return 0;
101328 +}
101329 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
101330 new file mode 100644
101331 index 0000000..414fe5e
101332 --- /dev/null
101333 +++ b/tools/gcc/colorize_plugin.c
101334 @@ -0,0 +1,151 @@
101335 +/*
101336 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
101337 + * Licensed under the GPL v2
101338 + *
101339 + * Note: the choice of the license means that the compilation process is
101340 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
101341 + * but for the kernel it doesn't matter since it doesn't link against
101342 + * any of the gcc libraries
101343 + *
101344 + * gcc plugin to colorize diagnostic output
101345 + *
101346 + */
101347 +
101348 +#include "gcc-plugin.h"
101349 +#include "config.h"
101350 +#include "system.h"
101351 +#include "coretypes.h"
101352 +#include "tree.h"
101353 +#include "tree-pass.h"
101354 +#include "flags.h"
101355 +#include "intl.h"
101356 +#include "toplev.h"
101357 +#include "plugin.h"
101358 +#include "diagnostic.h"
101359 +#include "plugin-version.h"
101360 +#include "tm.h"
101361 +
101362 +int plugin_is_GPL_compatible;
101363 +
101364 +static struct plugin_info colorize_plugin_info = {
101365 + .version = "201302112000",
101366 + .help = NULL,
101367 +};
101368 +
101369 +#define GREEN "\033[32m\033[2m"
101370 +#define LIGHTGREEN "\033[32m\033[1m"
101371 +#define YELLOW "\033[33m\033[2m"
101372 +#define LIGHTYELLOW "\033[33m\033[1m"
101373 +#define RED "\033[31m\033[2m"
101374 +#define LIGHTRED "\033[31m\033[1m"
101375 +#define BLUE "\033[34m\033[2m"
101376 +#define LIGHTBLUE "\033[34m\033[1m"
101377 +#define BRIGHT "\033[m\033[1m"
101378 +#define NORMAL "\033[m"
101379 +
101380 +static diagnostic_starter_fn old_starter;
101381 +static diagnostic_finalizer_fn old_finalizer;
101382 +
101383 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
101384 +{
101385 + const char *color;
101386 + char *newprefix;
101387 +
101388 + switch (diagnostic->kind) {
101389 + case DK_NOTE:
101390 + color = LIGHTBLUE;
101391 + break;
101392 +
101393 + case DK_PEDWARN:
101394 + case DK_WARNING:
101395 + color = LIGHTYELLOW;
101396 + break;
101397 +
101398 + case DK_ERROR:
101399 + case DK_FATAL:
101400 + case DK_ICE:
101401 + case DK_PERMERROR:
101402 + case DK_SORRY:
101403 + color = LIGHTRED;
101404 + break;
101405 +
101406 + default:
101407 + color = NORMAL;
101408 + }
101409 +
101410 + old_starter(context, diagnostic);
101411 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
101412 + return;
101413 + pp_destroy_prefix(context->printer);
101414 + pp_set_prefix(context->printer, newprefix);
101415 +}
101416 +
101417 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
101418 +{
101419 + old_finalizer(context, diagnostic);
101420 +}
101421 +
101422 +static void colorize_arm(void)
101423 +{
101424 + old_starter = diagnostic_starter(global_dc);
101425 + old_finalizer = diagnostic_finalizer(global_dc);
101426 +
101427 + diagnostic_starter(global_dc) = start_colorize;
101428 + diagnostic_finalizer(global_dc) = finalize_colorize;
101429 +}
101430 +
101431 +static unsigned int execute_colorize_rearm(void)
101432 +{
101433 + if (diagnostic_starter(global_dc) == start_colorize)
101434 + return 0;
101435 +
101436 + colorize_arm();
101437 + return 0;
101438 +}
101439 +
101440 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
101441 + .pass = {
101442 + .type = SIMPLE_IPA_PASS,
101443 + .name = "colorize_rearm",
101444 +#if BUILDING_GCC_VERSION >= 4008
101445 + .optinfo_flags = OPTGROUP_NONE,
101446 +#endif
101447 + .gate = NULL,
101448 + .execute = execute_colorize_rearm,
101449 + .sub = NULL,
101450 + .next = NULL,
101451 + .static_pass_number = 0,
101452 + .tv_id = TV_NONE,
101453 + .properties_required = 0,
101454 + .properties_provided = 0,
101455 + .properties_destroyed = 0,
101456 + .todo_flags_start = 0,
101457 + .todo_flags_finish = 0
101458 + }
101459 +};
101460 +
101461 +static void colorize_start_unit(void *gcc_data, void *user_data)
101462 +{
101463 + colorize_arm();
101464 +}
101465 +
101466 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101467 +{
101468 + const char * const plugin_name = plugin_info->base_name;
101469 + struct register_pass_info colorize_rearm_pass_info = {
101470 + .pass = &pass_ipa_colorize_rearm.pass,
101471 + .reference_pass_name = "*free_lang_data",
101472 + .ref_pass_instance_number = 1,
101473 + .pos_op = PASS_POS_INSERT_AFTER
101474 + };
101475 +
101476 + if (!plugin_default_version_check(version, &gcc_version)) {
101477 + error(G_("incompatible gcc/plugin versions"));
101478 + return 1;
101479 + }
101480 +
101481 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
101482 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
101483 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
101484 + return 0;
101485 +}
101486 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
101487 new file mode 100644
101488 index 0000000..c17312d
101489 --- /dev/null
101490 +++ b/tools/gcc/constify_plugin.c
101491 @@ -0,0 +1,560 @@
101492 +/*
101493 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
101494 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
101495 + * Licensed under the GPL v2, or (at your option) v3
101496 + *
101497 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
101498 + *
101499 + * Homepage:
101500 + * http://www.grsecurity.net/~ephox/const_plugin/
101501 + *
101502 + * Usage:
101503 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
101504 + * $ gcc -fplugin=constify_plugin.so test.c -O2
101505 + */
101506 +
101507 +#include "gcc-plugin.h"
101508 +#include "config.h"
101509 +#include "system.h"
101510 +#include "coretypes.h"
101511 +#include "tree.h"
101512 +#include "tree-pass.h"
101513 +#include "flags.h"
101514 +#include "intl.h"
101515 +#include "toplev.h"
101516 +#include "plugin.h"
101517 +#include "diagnostic.h"
101518 +#include "plugin-version.h"
101519 +#include "tm.h"
101520 +#include "function.h"
101521 +#include "basic-block.h"
101522 +#include "gimple.h"
101523 +#include "rtl.h"
101524 +#include "emit-rtl.h"
101525 +#include "tree-flow.h"
101526 +#include "target.h"
101527 +#include "langhooks.h"
101528 +
101529 +// should come from c-tree.h if only it were installed for gcc 4.5...
101530 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
101531 +
101532 +// unused type flag in all versions 4.5-4.8
101533 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
101534 +
101535 +int plugin_is_GPL_compatible;
101536 +
101537 +static struct plugin_info const_plugin_info = {
101538 + .version = "201305231310",
101539 + .help = "no-constify\tturn off constification\n",
101540 +};
101541 +
101542 +typedef struct {
101543 + bool has_fptr_field;
101544 + bool has_writable_field;
101545 + bool has_do_const_field;
101546 + bool has_no_const_field;
101547 +} constify_info;
101548 +
101549 +static const_tree get_field_type(const_tree field)
101550 +{
101551 + return strip_array_types(TREE_TYPE(field));
101552 +}
101553 +
101554 +static bool is_fptr(const_tree field)
101555 +{
101556 + const_tree ptr = get_field_type(field);
101557 +
101558 + if (TREE_CODE(ptr) != POINTER_TYPE)
101559 + return false;
101560 +
101561 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
101562 +}
101563 +
101564 +/*
101565 + * determine whether the given structure type meets the requirements for automatic constification,
101566 + * including the constification attributes on nested structure types
101567 + */
101568 +static void constifiable(const_tree node, constify_info *cinfo)
101569 +{
101570 + const_tree field;
101571 +
101572 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
101573 +
101574 + // e.g., pointer to structure fields while still constructing the structure type
101575 + if (TYPE_FIELDS(node) == NULL_TREE)
101576 + return;
101577 +
101578 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
101579 + const_tree type = get_field_type(field);
101580 + enum tree_code code = TREE_CODE(type);
101581 +
101582 + if (node == type)
101583 + continue;
101584 +
101585 + if (is_fptr(field))
101586 + cinfo->has_fptr_field = true;
101587 + else if (!TREE_READONLY(field))
101588 + cinfo->has_writable_field = true;
101589 +
101590 + if (code == RECORD_TYPE || code == UNION_TYPE) {
101591 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
101592 + cinfo->has_do_const_field = true;
101593 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
101594 + cinfo->has_no_const_field = true;
101595 + else
101596 + constifiable(type, cinfo);
101597 + }
101598 + }
101599 +}
101600 +
101601 +static bool constified(const_tree node)
101602 +{
101603 + constify_info cinfo = {
101604 + .has_fptr_field = false,
101605 + .has_writable_field = false,
101606 + .has_do_const_field = false,
101607 + .has_no_const_field = false
101608 + };
101609 +
101610 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
101611 +
101612 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
101613 + gcc_assert(!TYPE_READONLY(node));
101614 + return false;
101615 + }
101616 +
101617 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
101618 + gcc_assert(TYPE_READONLY(node));
101619 + return true;
101620 + }
101621 +
101622 + constifiable(node, &cinfo);
101623 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
101624 + return false;
101625 +
101626 + return TYPE_READONLY(node);
101627 +}
101628 +
101629 +static void deconstify_tree(tree node);
101630 +
101631 +static void deconstify_type(tree type)
101632 +{
101633 + tree field;
101634 +
101635 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
101636 +
101637 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
101638 + const_tree fieldtype = get_field_type(field);
101639 +
101640 + // special case handling of simple ptr-to-same-array-type members
101641 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
101642 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
101643 +
101644 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
101645 + continue;
101646 + if (TREE_TYPE(TREE_TYPE(field)) == type)
101647 + continue;
101648 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
101649 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
101650 + TREE_TYPE(TREE_TYPE(field)) = type;
101651 + }
101652 + continue;
101653 + }
101654 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
101655 + continue;
101656 + if (!constified(fieldtype))
101657 + continue;
101658 +
101659 + deconstify_tree(field);
101660 + TREE_READONLY(field) = 0;
101661 + }
101662 + TYPE_READONLY(type) = 0;
101663 + C_TYPE_FIELDS_READONLY(type) = 0;
101664 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
101665 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
101666 +}
101667 +
101668 +static void deconstify_tree(tree node)
101669 +{
101670 + tree old_type, new_type, field;
101671 +
101672 + old_type = TREE_TYPE(node);
101673 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
101674 + node = TREE_TYPE(node) = copy_node(old_type);
101675 + old_type = TREE_TYPE(old_type);
101676 + }
101677 +
101678 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
101679 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
101680 +
101681 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
101682 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
101683 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
101684 + DECL_FIELD_CONTEXT(field) = new_type;
101685 +
101686 + deconstify_type(new_type);
101687 +
101688 + TREE_TYPE(node) = new_type;
101689 +}
101690 +
101691 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
101692 +{
101693 + tree type;
101694 + constify_info cinfo = {
101695 + .has_fptr_field = false,
101696 + .has_writable_field = false,
101697 + .has_do_const_field = false,
101698 + .has_no_const_field = false
101699 + };
101700 +
101701 + *no_add_attrs = true;
101702 + if (TREE_CODE(*node) == FUNCTION_DECL) {
101703 + error("%qE attribute does not apply to functions", name);
101704 + return NULL_TREE;
101705 + }
101706 +
101707 + if (TREE_CODE(*node) == PARM_DECL) {
101708 + error("%qE attribute does not apply to function parameters", name);
101709 + return NULL_TREE;
101710 + }
101711 +
101712 + if (TREE_CODE(*node) == VAR_DECL) {
101713 + error("%qE attribute does not apply to variables", name);
101714 + return NULL_TREE;
101715 + }
101716 +
101717 + if (TYPE_P(*node)) {
101718 + *no_add_attrs = false;
101719 + type = *node;
101720 + } else {
101721 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
101722 + type = TREE_TYPE(*node);
101723 + }
101724 +
101725 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
101726 + error("%qE attribute applies to struct and union types only", name);
101727 + return NULL_TREE;
101728 + }
101729 +
101730 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
101731 + error("%qE attribute is already applied to the type", name);
101732 + return NULL_TREE;
101733 + }
101734 +
101735 + if (TYPE_P(*node)) {
101736 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
101737 + error("%qE attribute is incompatible with 'do_const'", name);
101738 + return NULL_TREE;
101739 + }
101740 +
101741 + constifiable(type, &cinfo);
101742 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
101743 + deconstify_tree(*node);
101744 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
101745 + return NULL_TREE;
101746 + }
101747 +
101748 + error("%qE attribute used on type that is not constified", name);
101749 + return NULL_TREE;
101750 +}
101751 +
101752 +static void constify_type(tree type)
101753 +{
101754 + TYPE_READONLY(type) = 1;
101755 + C_TYPE_FIELDS_READONLY(type) = 1;
101756 + TYPE_CONSTIFY_VISITED(type) = 1;
101757 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
101758 +}
101759 +
101760 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
101761 +{
101762 + *no_add_attrs = true;
101763 + if (!TYPE_P(*node)) {
101764 + error("%qE attribute applies to types only", name);
101765 + return NULL_TREE;
101766 + }
101767 +
101768 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
101769 + error("%qE attribute applies to struct and union types only", name);
101770 + return NULL_TREE;
101771 + }
101772 +
101773 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
101774 + error("%qE attribute is already applied to the type", name);
101775 + return NULL_TREE;
101776 + }
101777 +
101778 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
101779 + error("%qE attribute is incompatible with 'no_const'", name);
101780 + return NULL_TREE;
101781 + }
101782 +
101783 + *no_add_attrs = false;
101784 + return NULL_TREE;
101785 +}
101786 +
101787 +static struct attribute_spec no_const_attr = {
101788 + .name = "no_const",
101789 + .min_length = 0,
101790 + .max_length = 0,
101791 + .decl_required = false,
101792 + .type_required = false,
101793 + .function_type_required = false,
101794 + .handler = handle_no_const_attribute,
101795 +#if BUILDING_GCC_VERSION >= 4007
101796 + .affects_type_identity = true
101797 +#endif
101798 +};
101799 +
101800 +static struct attribute_spec do_const_attr = {
101801 + .name = "do_const",
101802 + .min_length = 0,
101803 + .max_length = 0,
101804 + .decl_required = false,
101805 + .type_required = false,
101806 + .function_type_required = false,
101807 + .handler = handle_do_const_attribute,
101808 +#if BUILDING_GCC_VERSION >= 4007
101809 + .affects_type_identity = true
101810 +#endif
101811 +};
101812 +
101813 +static void register_attributes(void *event_data, void *data)
101814 +{
101815 + register_attribute(&no_const_attr);
101816 + register_attribute(&do_const_attr);
101817 +}
101818 +
101819 +static void finish_type(void *event_data, void *data)
101820 +{
101821 + tree type = (tree)event_data;
101822 + constify_info cinfo = {
101823 + .has_fptr_field = false,
101824 + .has_writable_field = false,
101825 + .has_do_const_field = false,
101826 + .has_no_const_field = false
101827 + };
101828 +
101829 + if (type == NULL_TREE || type == error_mark_node)
101830 + return;
101831 +
101832 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
101833 + return;
101834 +
101835 + constifiable(type, &cinfo);
101836 +
101837 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
101838 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
101839 + return;
101840 + if (cinfo.has_writable_field)
101841 + return;
101842 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
101843 + return;
101844 + }
101845 +
101846 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
101847 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
101848 + deconstify_type(type);
101849 + TYPE_CONSTIFY_VISITED(type) = 1;
101850 + } else
101851 + error("'no_const' attribute used on type that is not constified");
101852 + return;
101853 + }
101854 +
101855 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
101856 + constify_type(type);
101857 + return;
101858 + }
101859 +
101860 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
101861 + constify_type(type);
101862 + return;
101863 + }
101864 +
101865 + deconstify_type(type);
101866 + TYPE_CONSTIFY_VISITED(type) = 1;
101867 +}
101868 +
101869 +static void check_global_variables(void)
101870 +{
101871 + struct varpool_node *node;
101872 +
101873 +#if BUILDING_GCC_VERSION <= 4007
101874 + for (node = varpool_nodes; node; node = node->next) {
101875 + tree var = node->decl;
101876 +#else
101877 + FOR_EACH_VARIABLE(node) {
101878 + tree var = node->symbol.decl;
101879 +#endif
101880 + tree type = TREE_TYPE(var);
101881 +
101882 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
101883 + continue;
101884 +
101885 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
101886 + continue;
101887 +
101888 + if (!TYPE_CONSTIFY_VISITED(type))
101889 + continue;
101890 +
101891 + if (DECL_EXTERNAL(var))
101892 + continue;
101893 +
101894 + if (DECL_INITIAL(var))
101895 + continue;
101896 +
101897 + // this works around a gcc bug/feature where uninitialized globals
101898 + // are moved into the .bss section regardless of any constification
101899 + DECL_INITIAL(var) = build_constructor(type, NULL);
101900 +// inform(DECL_SOURCE_LOCATION(var), "constified variable %qE moved into .rodata", var);
101901 + }
101902 +}
101903 +
101904 +static unsigned int check_local_variables(void)
101905 +{
101906 + unsigned int ret = 0;
101907 + tree var;
101908 +
101909 +#if BUILDING_GCC_VERSION == 4005
101910 + tree vars;
101911 +#else
101912 + unsigned int i;
101913 +#endif
101914 +
101915 +#if BUILDING_GCC_VERSION == 4005
101916 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
101917 + var = TREE_VALUE(vars);
101918 +#else
101919 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
101920 +#endif
101921 + tree type = TREE_TYPE(var);
101922 +
101923 + gcc_assert(DECL_P(var));
101924 + if (is_global_var(var))
101925 + continue;
101926 +
101927 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
101928 + continue;
101929 +
101930 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
101931 + continue;
101932 +
101933 + if (!TYPE_CONSTIFY_VISITED(type))
101934 + continue;
101935 +
101936 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
101937 + ret = 1;
101938 + }
101939 + return ret;
101940 +}
101941 +
101942 +static unsigned int check_variables(void)
101943 +{
101944 + check_global_variables();
101945 + return check_local_variables();
101946 +}
101947 +
101948 + unsigned int ret = 0;
101949 +static struct gimple_opt_pass pass_local_variable = {
101950 + {
101951 + .type = GIMPLE_PASS,
101952 + .name = "check_variables",
101953 +#if BUILDING_GCC_VERSION >= 4008
101954 + .optinfo_flags = OPTGROUP_NONE,
101955 +#endif
101956 + .gate = NULL,
101957 + .execute = check_variables,
101958 + .sub = NULL,
101959 + .next = NULL,
101960 + .static_pass_number = 0,
101961 + .tv_id = TV_NONE,
101962 + .properties_required = 0,
101963 + .properties_provided = 0,
101964 + .properties_destroyed = 0,
101965 + .todo_flags_start = 0,
101966 + .todo_flags_finish = 0
101967 + }
101968 +};
101969 +
101970 +static struct {
101971 + const char *name;
101972 + const char *asm_op;
101973 +} sections[] = {
101974 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
101975 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
101976 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
101977 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
101978 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
101979 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
101980 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
101981 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
101982 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
101983 +};
101984 +
101985 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
101986 +
101987 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
101988 +{
101989 + size_t i;
101990 +
101991 + for (i = 0; i < ARRAY_SIZE(sections); i++)
101992 + if (!strcmp(sections[i].name, name))
101993 + return 0;
101994 + return old_section_type_flags(decl, name, reloc);
101995 +}
101996 +
101997 +static void constify_start_unit(void *gcc_data, void *user_data)
101998 +{
101999 +// size_t i;
102000 +
102001 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
102002 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
102003 +// sections[i].section = get_section(sections[i].name, 0, NULL);
102004 +
102005 + old_section_type_flags = targetm.section_type_flags;
102006 + targetm.section_type_flags = constify_section_type_flags;
102007 +}
102008 +
102009 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
102010 +{
102011 + const char * const plugin_name = plugin_info->base_name;
102012 + const int argc = plugin_info->argc;
102013 + const struct plugin_argument * const argv = plugin_info->argv;
102014 + int i;
102015 + bool constify = true;
102016 +
102017 + struct register_pass_info local_variable_pass_info = {
102018 + .pass = &pass_local_variable.pass,
102019 + .reference_pass_name = "ssa",
102020 + .ref_pass_instance_number = 1,
102021 + .pos_op = PASS_POS_INSERT_BEFORE
102022 + };
102023 +
102024 + if (!plugin_default_version_check(version, &gcc_version)) {
102025 + error(G_("incompatible gcc/plugin versions"));
102026 + return 1;
102027 + }
102028 +
102029 + for (i = 0; i < argc; ++i) {
102030 + if (!(strcmp(argv[i].key, "no-constify"))) {
102031 + constify = false;
102032 + continue;
102033 + }
102034 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102035 + }
102036 +
102037 + if (strcmp(lang_hooks.name, "GNU C")) {
102038 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
102039 + constify = false;
102040 + }
102041 +
102042 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
102043 + if (constify) {
102044 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
102045 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
102046 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
102047 + }
102048 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
102049 +
102050 + return 0;
102051 +}
102052 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
102053 new file mode 100644
102054 index 0000000..e518932
102055 --- /dev/null
102056 +++ b/tools/gcc/generate_size_overflow_hash.sh
102057 @@ -0,0 +1,94 @@
102058 +#!/bin/bash
102059 +
102060 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
102061 +
102062 +header1="size_overflow_hash.h"
102063 +database="size_overflow_hash.data"
102064 +n=65536
102065 +
102066 +usage() {
102067 +cat <<EOF
102068 +usage: $0 options
102069 +OPTIONS:
102070 + -h|--help help
102071 + -o header file
102072 + -d database file
102073 + -n hash array size
102074 +EOF
102075 + return 0
102076 +}
102077 +
102078 +while true
102079 +do
102080 + case "$1" in
102081 + -h|--help) usage && exit 0;;
102082 + -n) n=$2; shift 2;;
102083 + -o) header1="$2"; shift 2;;
102084 + -d) database="$2"; shift 2;;
102085 + --) shift 1; break ;;
102086 + *) break ;;
102087 + esac
102088 +done
102089 +
102090 +create_defines() {
102091 + for i in `seq 0 31`
102092 + do
102093 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
102094 + done
102095 + echo >> "$header1"
102096 +}
102097 +
102098 +create_structs() {
102099 + rm -f "$header1"
102100 +
102101 + create_defines
102102 +
102103 + cat "$database" | while read data
102104 + do
102105 + data_array=($data)
102106 + struct_hash_name="${data_array[0]}"
102107 + funcn="${data_array[1]}"
102108 + params="${data_array[2]}"
102109 + next="${data_array[4]}"
102110 +
102111 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
102112 +
102113 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
102114 + echo -en "\t.param\t= " >> "$header1"
102115 + line=
102116 + for param_num in ${params//-/ };
102117 + do
102118 + line="${line}PARAM"$param_num"|"
102119 + done
102120 +
102121 + echo -e "${line%?},\n};\n" >> "$header1"
102122 + done
102123 +}
102124 +
102125 +create_headers() {
102126 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
102127 +}
102128 +
102129 +create_array_elements() {
102130 + index=0
102131 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
102132 + do
102133 + data_array=($data)
102134 + i="${data_array[3]}"
102135 + hash="${data_array[0]}"
102136 + while [[ $index -lt $i ]]
102137 + do
102138 + echo -e "\t["$index"]\t= NULL," >> "$header1"
102139 + index=$(($index + 1))
102140 + done
102141 + index=$(($index + 1))
102142 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
102143 + done
102144 + echo '};' >> $header1
102145 +}
102146 +
102147 +create_structs
102148 +create_headers
102149 +create_array_elements
102150 +
102151 +exit 0
102152 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
102153 new file mode 100644
102154 index 0000000..568b360
102155 --- /dev/null
102156 +++ b/tools/gcc/kallocstat_plugin.c
102157 @@ -0,0 +1,170 @@
102158 +/*
102159 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
102160 + * Licensed under the GPL v2
102161 + *
102162 + * Note: the choice of the license means that the compilation process is
102163 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
102164 + * but for the kernel it doesn't matter since it doesn't link against
102165 + * any of the gcc libraries
102166 + *
102167 + * gcc plugin to find the distribution of k*alloc sizes
102168 + *
102169 + * TODO:
102170 + *
102171 + * BUGS:
102172 + * - none known
102173 + */
102174 +#include "gcc-plugin.h"
102175 +#include "config.h"
102176 +#include "system.h"
102177 +#include "coretypes.h"
102178 +#include "tree.h"
102179 +#include "tree-pass.h"
102180 +#include "flags.h"
102181 +#include "intl.h"
102182 +#include "toplev.h"
102183 +#include "plugin.h"
102184 +//#include "expr.h" where are you...
102185 +#include "diagnostic.h"
102186 +#include "plugin-version.h"
102187 +#include "tm.h"
102188 +#include "function.h"
102189 +#include "basic-block.h"
102190 +#include "gimple.h"
102191 +#include "rtl.h"
102192 +#include "emit-rtl.h"
102193 +
102194 +extern void print_gimple_stmt(FILE *, gimple, int, int);
102195 +
102196 +int plugin_is_GPL_compatible;
102197 +
102198 +static const char * const kalloc_functions[] = {
102199 + "__kmalloc",
102200 + "kmalloc",
102201 + "kmalloc_large",
102202 + "kmalloc_node",
102203 + "kmalloc_order",
102204 + "kmalloc_order_trace",
102205 + "kmalloc_slab",
102206 + "kzalloc",
102207 + "kzalloc_node",
102208 +};
102209 +
102210 +static struct plugin_info kallocstat_plugin_info = {
102211 + .version = "201302112000",
102212 +};
102213 +
102214 +static unsigned int execute_kallocstat(void);
102215 +
102216 +static struct gimple_opt_pass kallocstat_pass = {
102217 + .pass = {
102218 + .type = GIMPLE_PASS,
102219 + .name = "kallocstat",
102220 +#if BUILDING_GCC_VERSION >= 4008
102221 + .optinfo_flags = OPTGROUP_NONE,
102222 +#endif
102223 + .gate = NULL,
102224 + .execute = execute_kallocstat,
102225 + .sub = NULL,
102226 + .next = NULL,
102227 + .static_pass_number = 0,
102228 + .tv_id = TV_NONE,
102229 + .properties_required = 0,
102230 + .properties_provided = 0,
102231 + .properties_destroyed = 0,
102232 + .todo_flags_start = 0,
102233 + .todo_flags_finish = 0
102234 + }
102235 +};
102236 +
102237 +static bool is_kalloc(const char *fnname)
102238 +{
102239 + size_t i;
102240 +
102241 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
102242 + if (!strcmp(fnname, kalloc_functions[i]))
102243 + return true;
102244 + return false;
102245 +}
102246 +
102247 +static unsigned int execute_kallocstat(void)
102248 +{
102249 + basic_block bb;
102250 +
102251 + // 1. loop through BBs and GIMPLE statements
102252 + FOR_EACH_BB(bb) {
102253 + gimple_stmt_iterator gsi;
102254 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
102255 + // gimple match:
102256 + tree fndecl, size;
102257 + gimple call_stmt;
102258 + const char *fnname;
102259 +
102260 + // is it a call
102261 + call_stmt = gsi_stmt(gsi);
102262 + if (!is_gimple_call(call_stmt))
102263 + continue;
102264 + fndecl = gimple_call_fndecl(call_stmt);
102265 + if (fndecl == NULL_TREE)
102266 + continue;
102267 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
102268 + continue;
102269 +
102270 + // is it a call to k*alloc
102271 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
102272 + if (!is_kalloc(fnname))
102273 + continue;
102274 +
102275 + // is the size arg the result of a simple const assignment
102276 + size = gimple_call_arg(call_stmt, 0);
102277 + while (true) {
102278 + gimple def_stmt;
102279 + expanded_location xloc;
102280 + size_t size_val;
102281 +
102282 + if (TREE_CODE(size) != SSA_NAME)
102283 + break;
102284 + def_stmt = SSA_NAME_DEF_STMT(size);
102285 + if (!def_stmt || !is_gimple_assign(def_stmt))
102286 + break;
102287 + if (gimple_num_ops(def_stmt) != 2)
102288 + break;
102289 + size = gimple_assign_rhs1(def_stmt);
102290 + if (!TREE_CONSTANT(size))
102291 + continue;
102292 + xloc = expand_location(gimple_location(def_stmt));
102293 + if (!xloc.file)
102294 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
102295 + size_val = TREE_INT_CST_LOW(size);
102296 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
102297 + break;
102298 + }
102299 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
102300 +//debug_tree(gimple_call_fn(call_stmt));
102301 +//print_node(stderr, "pax", fndecl, 4);
102302 + }
102303 + }
102304 +
102305 + return 0;
102306 +}
102307 +
102308 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
102309 +{
102310 + const char * const plugin_name = plugin_info->base_name;
102311 + struct register_pass_info kallocstat_pass_info = {
102312 + .pass = &kallocstat_pass.pass,
102313 + .reference_pass_name = "ssa",
102314 + .ref_pass_instance_number = 1,
102315 + .pos_op = PASS_POS_INSERT_AFTER
102316 + };
102317 +
102318 + if (!plugin_default_version_check(version, &gcc_version)) {
102319 + error(G_("incompatible gcc/plugin versions"));
102320 + return 1;
102321 + }
102322 +
102323 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
102324 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
102325 +
102326 + return 0;
102327 +}
102328 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
102329 new file mode 100644
102330 index 0000000..257529f
102331 --- /dev/null
102332 +++ b/tools/gcc/kernexec_plugin.c
102333 @@ -0,0 +1,471 @@
102334 +/*
102335 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
102336 + * Licensed under the GPL v2
102337 + *
102338 + * Note: the choice of the license means that the compilation process is
102339 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
102340 + * but for the kernel it doesn't matter since it doesn't link against
102341 + * any of the gcc libraries
102342 + *
102343 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
102344 + *
102345 + * TODO:
102346 + *
102347 + * BUGS:
102348 + * - none known
102349 + */
102350 +#include "gcc-plugin.h"
102351 +#include "config.h"
102352 +#include "system.h"
102353 +#include "coretypes.h"
102354 +#include "tree.h"
102355 +#include "tree-pass.h"
102356 +#include "flags.h"
102357 +#include "intl.h"
102358 +#include "toplev.h"
102359 +#include "plugin.h"
102360 +//#include "expr.h" where are you...
102361 +#include "diagnostic.h"
102362 +#include "plugin-version.h"
102363 +#include "tm.h"
102364 +#include "function.h"
102365 +#include "basic-block.h"
102366 +#include "gimple.h"
102367 +#include "rtl.h"
102368 +#include "emit-rtl.h"
102369 +#include "tree-flow.h"
102370 +
102371 +extern void print_gimple_stmt(FILE *, gimple, int, int);
102372 +extern rtx emit_move_insn(rtx x, rtx y);
102373 +
102374 +#if BUILDING_GCC_VERSION <= 4006
102375 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
102376 +#endif
102377 +
102378 +#if BUILDING_GCC_VERSION >= 4008
102379 +#define TODO_dump_func 0
102380 +#endif
102381 +
102382 +int plugin_is_GPL_compatible;
102383 +
102384 +static struct plugin_info kernexec_plugin_info = {
102385 + .version = "201308230150",
102386 + .help = "method=[bts|or]\tinstrumentation method\n"
102387 +};
102388 +
102389 +static unsigned int execute_kernexec_reload(void);
102390 +static unsigned int execute_kernexec_fptr(void);
102391 +static unsigned int execute_kernexec_retaddr(void);
102392 +static bool kernexec_cmodel_check(void);
102393 +
102394 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
102395 +static void (*kernexec_instrument_retaddr)(rtx);
102396 +
102397 +static struct gimple_opt_pass kernexec_reload_pass = {
102398 + .pass = {
102399 + .type = GIMPLE_PASS,
102400 + .name = "kernexec_reload",
102401 +#if BUILDING_GCC_VERSION >= 4008
102402 + .optinfo_flags = OPTGROUP_NONE,
102403 +#endif
102404 + .gate = kernexec_cmodel_check,
102405 + .execute = execute_kernexec_reload,
102406 + .sub = NULL,
102407 + .next = NULL,
102408 + .static_pass_number = 0,
102409 + .tv_id = TV_NONE,
102410 + .properties_required = 0,
102411 + .properties_provided = 0,
102412 + .properties_destroyed = 0,
102413 + .todo_flags_start = 0,
102414 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
102415 + }
102416 +};
102417 +
102418 +static struct gimple_opt_pass kernexec_fptr_pass = {
102419 + .pass = {
102420 + .type = GIMPLE_PASS,
102421 + .name = "kernexec_fptr",
102422 +#if BUILDING_GCC_VERSION >= 4008
102423 + .optinfo_flags = OPTGROUP_NONE,
102424 +#endif
102425 + .gate = kernexec_cmodel_check,
102426 + .execute = execute_kernexec_fptr,
102427 + .sub = NULL,
102428 + .next = NULL,
102429 + .static_pass_number = 0,
102430 + .tv_id = TV_NONE,
102431 + .properties_required = 0,
102432 + .properties_provided = 0,
102433 + .properties_destroyed = 0,
102434 + .todo_flags_start = 0,
102435 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
102436 + }
102437 +};
102438 +
102439 +static struct rtl_opt_pass kernexec_retaddr_pass = {
102440 + .pass = {
102441 + .type = RTL_PASS,
102442 + .name = "kernexec_retaddr",
102443 +#if BUILDING_GCC_VERSION >= 4008
102444 + .optinfo_flags = OPTGROUP_NONE,
102445 +#endif
102446 + .gate = kernexec_cmodel_check,
102447 + .execute = execute_kernexec_retaddr,
102448 + .sub = NULL,
102449 + .next = NULL,
102450 + .static_pass_number = 0,
102451 + .tv_id = TV_NONE,
102452 + .properties_required = 0,
102453 + .properties_provided = 0,
102454 + .properties_destroyed = 0,
102455 + .todo_flags_start = 0,
102456 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
102457 + }
102458 +};
102459 +
102460 +static bool kernexec_cmodel_check(void)
102461 +{
102462 + tree section;
102463 +
102464 + if (ix86_cmodel != CM_KERNEL)
102465 + return false;
102466 +
102467 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
102468 + if (!section || !TREE_VALUE(section))
102469 + return true;
102470 +
102471 + section = TREE_VALUE(TREE_VALUE(section));
102472 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
102473 + return true;
102474 +
102475 + return false;
102476 +}
102477 +
102478 +/*
102479 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
102480 + */
102481 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
102482 +{
102483 + gimple asm_movabs_stmt;
102484 +
102485 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
102486 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
102487 + gimple_asm_set_volatile(asm_movabs_stmt, true);
102488 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
102489 + update_stmt(asm_movabs_stmt);
102490 +}
102491 +
102492 +/*
102493 + * find all asm() stmts that clobber r10 and add a reload of r10
102494 + */
102495 +static unsigned int execute_kernexec_reload(void)
102496 +{
102497 + basic_block bb;
102498 +
102499 + // 1. loop through BBs and GIMPLE statements
102500 + FOR_EACH_BB(bb) {
102501 + gimple_stmt_iterator gsi;
102502 +
102503 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
102504 + // gimple match: __asm__ ("" : : : "r10");
102505 + gimple asm_stmt;
102506 + size_t nclobbers;
102507 +
102508 + // is it an asm ...
102509 + asm_stmt = gsi_stmt(gsi);
102510 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
102511 + continue;
102512 +
102513 + // ... clobbering r10
102514 + nclobbers = gimple_asm_nclobbers(asm_stmt);
102515 + while (nclobbers--) {
102516 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
102517 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
102518 + continue;
102519 + kernexec_reload_fptr_mask(&gsi);
102520 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
102521 + break;
102522 + }
102523 + }
102524 + }
102525 +
102526 + return 0;
102527 +}
102528 +
102529 +/*
102530 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
102531 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
102532 + */
102533 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
102534 +{
102535 + gimple assign_intptr, assign_new_fptr, call_stmt;
102536 + tree intptr, orptr, old_fptr, new_fptr, kernexec_mask;
102537 +
102538 + call_stmt = gsi_stmt(*gsi);
102539 + old_fptr = gimple_call_fn(call_stmt);
102540 +
102541 + // create temporary unsigned long variable used for bitops and cast fptr to it
102542 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
102543 +#if BUILDING_GCC_VERSION <= 4007
102544 + add_referenced_var(intptr);
102545 +#endif
102546 + intptr = make_ssa_name(intptr, NULL);
102547 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
102548 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
102549 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
102550 + update_stmt(assign_intptr);
102551 +
102552 + // apply logical or to temporary unsigned long and bitmask
102553 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
102554 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
102555 + orptr = fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask);
102556 + intptr = make_ssa_name(SSA_NAME_VAR(intptr), NULL);
102557 + assign_intptr = gimple_build_assign(intptr, orptr);
102558 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
102559 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
102560 + update_stmt(assign_intptr);
102561 +
102562 + // cast temporary unsigned long back to a temporary fptr variable
102563 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
102564 +#if BUILDING_GCC_VERSION <= 4007
102565 + add_referenced_var(new_fptr);
102566 +#endif
102567 + new_fptr = make_ssa_name(new_fptr, NULL);
102568 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
102569 + SSA_NAME_DEF_STMT(new_fptr) = assign_new_fptr;
102570 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
102571 + update_stmt(assign_new_fptr);
102572 +
102573 + // replace call stmt fn with the new fptr
102574 + gimple_call_set_fn(call_stmt, new_fptr);
102575 + update_stmt(call_stmt);
102576 +}
102577 +
102578 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
102579 +{
102580 + gimple asm_or_stmt, call_stmt;
102581 + tree old_fptr, new_fptr, input, output;
102582 +#if BUILDING_GCC_VERSION <= 4007
102583 + VEC(tree, gc) *inputs = NULL;
102584 + VEC(tree, gc) *outputs = NULL;
102585 +#else
102586 + vec<tree, va_gc> *inputs = NULL;
102587 + vec<tree, va_gc> *outputs = NULL;
102588 +#endif
102589 +
102590 + call_stmt = gsi_stmt(*gsi);
102591 + old_fptr = gimple_call_fn(call_stmt);
102592 +
102593 + // create temporary fptr variable
102594 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
102595 +#if BUILDING_GCC_VERSION <= 4007
102596 + add_referenced_var(new_fptr);
102597 +#endif
102598 + new_fptr = make_ssa_name(new_fptr, NULL);
102599 +
102600 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
102601 + input = build_tree_list(NULL_TREE, build_string(2, "0"));
102602 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
102603 + output = build_tree_list(NULL_TREE, build_string(3, "=r"));
102604 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
102605 +#if BUILDING_GCC_VERSION <= 4007
102606 + VEC_safe_push(tree, gc, inputs, input);
102607 + VEC_safe_push(tree, gc, outputs, output);
102608 +#else
102609 + vec_safe_push(inputs, input);
102610 + vec_safe_push(outputs, output);
102611 +#endif
102612 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
102613 + SSA_NAME_DEF_STMT(new_fptr) = asm_or_stmt;
102614 + gimple_asm_set_volatile(asm_or_stmt, true);
102615 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
102616 + update_stmt(asm_or_stmt);
102617 +
102618 + // replace call stmt fn with the new fptr
102619 + gimple_call_set_fn(call_stmt, new_fptr);
102620 + update_stmt(call_stmt);
102621 +}
102622 +
102623 +/*
102624 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
102625 + */
102626 +static unsigned int execute_kernexec_fptr(void)
102627 +{
102628 + basic_block bb;
102629 +
102630 + // 1. loop through BBs and GIMPLE statements
102631 + FOR_EACH_BB(bb) {
102632 + gimple_stmt_iterator gsi;
102633 +
102634 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
102635 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
102636 + tree fn;
102637 + gimple call_stmt;
102638 +
102639 + // is it a call ...
102640 + call_stmt = gsi_stmt(gsi);
102641 + if (!is_gimple_call(call_stmt))
102642 + continue;
102643 + fn = gimple_call_fn(call_stmt);
102644 + if (TREE_CODE(fn) == ADDR_EXPR)
102645 + continue;
102646 + if (TREE_CODE(fn) != SSA_NAME)
102647 + gcc_unreachable();
102648 +
102649 + // ... through a function pointer
102650 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
102651 + fn = SSA_NAME_VAR(fn);
102652 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
102653 + debug_tree(fn);
102654 + gcc_unreachable();
102655 + }
102656 + }
102657 + fn = TREE_TYPE(fn);
102658 + if (TREE_CODE(fn) != POINTER_TYPE)
102659 + continue;
102660 + fn = TREE_TYPE(fn);
102661 + if (TREE_CODE(fn) != FUNCTION_TYPE)
102662 + continue;
102663 +
102664 + kernexec_instrument_fptr(&gsi);
102665 +
102666 +//debug_tree(gimple_call_fn(call_stmt));
102667 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
102668 + }
102669 + }
102670 +
102671 + return 0;
102672 +}
102673 +
102674 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
102675 +static void kernexec_instrument_retaddr_bts(rtx insn)
102676 +{
102677 + rtx btsq;
102678 + rtvec argvec, constraintvec, labelvec;
102679 + int line;
102680 +
102681 + // create asm volatile("btsq $63,(%%rsp)":::)
102682 + argvec = rtvec_alloc(0);
102683 + constraintvec = rtvec_alloc(0);
102684 + labelvec = rtvec_alloc(0);
102685 + line = expand_location(RTL_LOCATION(insn)).line;
102686 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
102687 + MEM_VOLATILE_P(btsq) = 1;
102688 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
102689 + emit_insn_before(btsq, insn);
102690 +}
102691 +
102692 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
102693 +static void kernexec_instrument_retaddr_or(rtx insn)
102694 +{
102695 + rtx orq;
102696 + rtvec argvec, constraintvec, labelvec;
102697 + int line;
102698 +
102699 + // create asm volatile("orq %%r10,(%%rsp)":::)
102700 + argvec = rtvec_alloc(0);
102701 + constraintvec = rtvec_alloc(0);
102702 + labelvec = rtvec_alloc(0);
102703 + line = expand_location(RTL_LOCATION(insn)).line;
102704 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
102705 + MEM_VOLATILE_P(orq) = 1;
102706 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
102707 + emit_insn_before(orq, insn);
102708 +}
102709 +
102710 +/*
102711 + * find all asm level function returns and forcibly set the highest bit of the return address
102712 + */
102713 +static unsigned int execute_kernexec_retaddr(void)
102714 +{
102715 + rtx insn;
102716 +
102717 + // 1. find function returns
102718 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
102719 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
102720 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
102721 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
102722 + rtx body;
102723 +
102724 + // is it a retn
102725 + if (!JUMP_P(insn))
102726 + continue;
102727 + body = PATTERN(insn);
102728 + if (GET_CODE(body) == PARALLEL)
102729 + body = XVECEXP(body, 0, 0);
102730 + if (!ANY_RETURN_P(body))
102731 + continue;
102732 + kernexec_instrument_retaddr(insn);
102733 + }
102734 +
102735 +// print_simple_rtl(stderr, get_insns());
102736 +// print_rtl(stderr, get_insns());
102737 +
102738 + return 0;
102739 +}
102740 +
102741 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
102742 +{
102743 + const char * const plugin_name = plugin_info->base_name;
102744 + const int argc = plugin_info->argc;
102745 + const struct plugin_argument * const argv = plugin_info->argv;
102746 + int i;
102747 + struct register_pass_info kernexec_reload_pass_info = {
102748 + .pass = &kernexec_reload_pass.pass,
102749 + .reference_pass_name = "ssa",
102750 + .ref_pass_instance_number = 1,
102751 + .pos_op = PASS_POS_INSERT_AFTER
102752 + };
102753 + struct register_pass_info kernexec_fptr_pass_info = {
102754 + .pass = &kernexec_fptr_pass.pass,
102755 + .reference_pass_name = "ssa",
102756 + .ref_pass_instance_number = 1,
102757 + .pos_op = PASS_POS_INSERT_AFTER
102758 + };
102759 + struct register_pass_info kernexec_retaddr_pass_info = {
102760 + .pass = &kernexec_retaddr_pass.pass,
102761 + .reference_pass_name = "pro_and_epilogue",
102762 + .ref_pass_instance_number = 1,
102763 + .pos_op = PASS_POS_INSERT_AFTER
102764 + };
102765 +
102766 + if (!plugin_default_version_check(version, &gcc_version)) {
102767 + error(G_("incompatible gcc/plugin versions"));
102768 + return 1;
102769 + }
102770 +
102771 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
102772 +
102773 + if (TARGET_64BIT == 0)
102774 + return 0;
102775 +
102776 + for (i = 0; i < argc; ++i) {
102777 + if (!strcmp(argv[i].key, "method")) {
102778 + if (!argv[i].value) {
102779 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102780 + continue;
102781 + }
102782 + if (!strcmp(argv[i].value, "bts")) {
102783 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
102784 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
102785 + } else if (!strcmp(argv[i].value, "or")) {
102786 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
102787 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
102788 + fix_register("r10", 1, 1);
102789 + } else
102790 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
102791 + continue;
102792 + }
102793 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102794 + }
102795 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
102796 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
102797 +
102798 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
102799 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
102800 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
102801 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
102802 +
102803 + return 0;
102804 +}
102805 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
102806 new file mode 100644
102807 index 0000000..2ef6fd9
102808 --- /dev/null
102809 +++ b/tools/gcc/latent_entropy_plugin.c
102810 @@ -0,0 +1,321 @@
102811 +/*
102812 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
102813 + * Licensed under the GPL v2
102814 + *
102815 + * Note: the choice of the license means that the compilation process is
102816 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
102817 + * but for the kernel it doesn't matter since it doesn't link against
102818 + * any of the gcc libraries
102819 + *
102820 + * gcc plugin to help generate a little bit of entropy from program state,
102821 + * used during boot in the kernel
102822 + *
102823 + * TODO:
102824 + * - add ipa pass to identify not explicitly marked candidate functions
102825 + * - mix in more program state (function arguments/return values, loop variables, etc)
102826 + * - more instrumentation control via attribute parameters
102827 + *
102828 + * BUGS:
102829 + * - LTO needs -flto-partition=none for now
102830 + */
102831 +#include "gcc-plugin.h"
102832 +#include "config.h"
102833 +#include "system.h"
102834 +#include "coretypes.h"
102835 +#include "tree.h"
102836 +#include "tree-pass.h"
102837 +#include "flags.h"
102838 +#include "intl.h"
102839 +#include "toplev.h"
102840 +#include "plugin.h"
102841 +//#include "expr.h" where are you...
102842 +#include "diagnostic.h"
102843 +#include "plugin-version.h"
102844 +#include "tm.h"
102845 +#include "function.h"
102846 +#include "basic-block.h"
102847 +#include "gimple.h"
102848 +#include "rtl.h"
102849 +#include "emit-rtl.h"
102850 +#include "tree-flow.h"
102851 +#include "langhooks.h"
102852 +
102853 +#if BUILDING_GCC_VERSION >= 4008
102854 +#define TODO_dump_func 0
102855 +#endif
102856 +
102857 +int plugin_is_GPL_compatible;
102858 +
102859 +static tree latent_entropy_decl;
102860 +
102861 +static struct plugin_info latent_entropy_plugin_info = {
102862 + .version = "201308230230",
102863 + .help = NULL
102864 +};
102865 +
102866 +static unsigned int execute_latent_entropy(void);
102867 +static bool gate_latent_entropy(void);
102868 +
102869 +static struct gimple_opt_pass latent_entropy_pass = {
102870 + .pass = {
102871 + .type = GIMPLE_PASS,
102872 + .name = "latent_entropy",
102873 +#if BUILDING_GCC_VERSION >= 4008
102874 + .optinfo_flags = OPTGROUP_NONE,
102875 +#endif
102876 + .gate = gate_latent_entropy,
102877 + .execute = execute_latent_entropy,
102878 + .sub = NULL,
102879 + .next = NULL,
102880 + .static_pass_number = 0,
102881 + .tv_id = TV_NONE,
102882 + .properties_required = PROP_gimple_leh | PROP_cfg,
102883 + .properties_provided = 0,
102884 + .properties_destroyed = 0,
102885 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
102886 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
102887 + }
102888 +};
102889 +
102890 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
102891 +{
102892 + if (TREE_CODE(*node) != FUNCTION_DECL) {
102893 + *no_add_attrs = true;
102894 + error("%qE attribute only applies to functions", name);
102895 + }
102896 + return NULL_TREE;
102897 +}
102898 +
102899 +static struct attribute_spec latent_entropy_attr = {
102900 + .name = "latent_entropy",
102901 + .min_length = 0,
102902 + .max_length = 0,
102903 + .decl_required = true,
102904 + .type_required = false,
102905 + .function_type_required = false,
102906 + .handler = handle_latent_entropy_attribute,
102907 +#if BUILDING_GCC_VERSION >= 4007
102908 + .affects_type_identity = false
102909 +#endif
102910 +};
102911 +
102912 +static void register_attributes(void *event_data, void *data)
102913 +{
102914 + register_attribute(&latent_entropy_attr);
102915 +}
102916 +
102917 +static bool gate_latent_entropy(void)
102918 +{
102919 + tree latent_entropy_attr;
102920 +
102921 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
102922 + return latent_entropy_attr != NULL_TREE;
102923 +}
102924 +
102925 +static unsigned HOST_WIDE_INT seed;
102926 +static unsigned HOST_WIDE_INT get_random_const(void)
102927 +{
102928 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
102929 + return seed;
102930 +}
102931 +
102932 +static enum tree_code get_op(tree *rhs)
102933 +{
102934 + static enum tree_code op;
102935 + unsigned HOST_WIDE_INT random_const;
102936 +
102937 + random_const = get_random_const();
102938 +
102939 + switch (op) {
102940 + case BIT_XOR_EXPR:
102941 + op = PLUS_EXPR;
102942 + break;
102943 +
102944 + case PLUS_EXPR:
102945 + if (rhs) {
102946 + op = LROTATE_EXPR;
102947 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
102948 + break;
102949 + }
102950 +
102951 + case LROTATE_EXPR:
102952 + default:
102953 + op = BIT_XOR_EXPR;
102954 + break;
102955 + }
102956 + if (rhs)
102957 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
102958 + return op;
102959 +}
102960 +
102961 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
102962 +{
102963 + gimple_stmt_iterator gsi;
102964 + gimple assign;
102965 + tree addxorrol, rhs;
102966 + enum tree_code op;
102967 +
102968 + op = get_op(&rhs);
102969 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
102970 + assign = gimple_build_assign(local_entropy, addxorrol);
102971 + gsi = gsi_after_labels(bb);
102972 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
102973 + update_stmt(assign);
102974 +//debug_bb(bb);
102975 +}
102976 +
102977 +static void perturb_latent_entropy(basic_block bb, tree rhs)
102978 +{
102979 + gimple_stmt_iterator gsi;
102980 + gimple assign;
102981 + tree addxorrol, temp;
102982 +
102983 + // 1. create temporary copy of latent_entropy
102984 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
102985 +#if BUILDING_GCC_VERSION <= 4007
102986 + add_referenced_var(temp);
102987 +#endif
102988 +
102989 + // 2. read...
102990 + temp = make_ssa_name(temp, NULL);
102991 + assign = gimple_build_assign(temp, latent_entropy_decl);
102992 + SSA_NAME_DEF_STMT(temp) = assign;
102993 +#if BUILDING_GCC_VERSION <= 4007
102994 + add_referenced_var(latent_entropy_decl);
102995 +#endif
102996 + gsi = gsi_after_labels(bb);
102997 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
102998 + update_stmt(assign);
102999 +
103000 + // 3. ...modify...
103001 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
103002 + temp = make_ssa_name(SSA_NAME_VAR(temp), NULL);
103003 + assign = gimple_build_assign(temp, addxorrol);
103004 + SSA_NAME_DEF_STMT(temp) = assign;
103005 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
103006 + update_stmt(assign);
103007 +
103008 + // 4. ...write latent_entropy
103009 + assign = gimple_build_assign(latent_entropy_decl, temp);
103010 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
103011 + update_stmt(assign);
103012 +}
103013 +
103014 +static unsigned int execute_latent_entropy(void)
103015 +{
103016 + basic_block bb;
103017 + gimple assign;
103018 + gimple_stmt_iterator gsi;
103019 + tree local_entropy;
103020 +
103021 + if (!latent_entropy_decl) {
103022 + struct varpool_node *node;
103023 +
103024 +#if BUILDING_GCC_VERSION <= 4007
103025 + for (node = varpool_nodes; node; node = node->next) {
103026 + tree var = node->decl;
103027 +#else
103028 + FOR_EACH_VARIABLE(node) {
103029 + tree var = node->symbol.decl;
103030 +#endif
103031 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
103032 + continue;
103033 + latent_entropy_decl = var;
103034 +// debug_tree(var);
103035 + break;
103036 + }
103037 + if (!latent_entropy_decl) {
103038 +// debug_tree(current_function_decl);
103039 + return 0;
103040 + }
103041 + }
103042 +
103043 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
103044 +
103045 + // 1. create local entropy variable
103046 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
103047 +#if BUILDING_GCC_VERSION <= 4007
103048 + add_referenced_var(local_entropy);
103049 + mark_sym_for_renaming(local_entropy);
103050 +#endif
103051 +
103052 + // 2. initialize local entropy variable
103053 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
103054 + if (dom_info_available_p(CDI_DOMINATORS))
103055 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
103056 + gsi = gsi_start_bb(bb);
103057 +
103058 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
103059 +// gimple_set_location(assign, loc);
103060 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
103061 + update_stmt(assign);
103062 +//debug_bb(bb);
103063 + bb = bb->next_bb;
103064 +
103065 + // 3. instrument each BB with an operation on the local entropy variable
103066 + while (bb != EXIT_BLOCK_PTR) {
103067 + perturb_local_entropy(bb, local_entropy);
103068 +//debug_bb(bb);
103069 + bb = bb->next_bb;
103070 + };
103071 +
103072 + // 4. mix local entropy into the global entropy variable
103073 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
103074 +//debug_bb(EXIT_BLOCK_PTR->prev_bb);
103075 + return 0;
103076 +}
103077 +
103078 +static void start_unit_callback(void *gcc_data, void *user_data)
103079 +{
103080 + tree latent_entropy_type;
103081 +
103082 +#if BUILDING_GCC_VERSION >= 4007
103083 + seed = get_random_seed(false);
103084 +#else
103085 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
103086 + seed *= seed;
103087 +#endif
103088 +
103089 + if (in_lto_p)
103090 + return;
103091 +
103092 + // extern volatile u64 latent_entropy
103093 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
103094 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
103095 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
103096 +
103097 + TREE_STATIC(latent_entropy_decl) = 1;
103098 + TREE_PUBLIC(latent_entropy_decl) = 1;
103099 + TREE_USED(latent_entropy_decl) = 1;
103100 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
103101 + DECL_EXTERNAL(latent_entropy_decl) = 1;
103102 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
103103 + DECL_INITIAL(latent_entropy_decl) = NULL;
103104 + lang_hooks.decls.pushdecl(latent_entropy_decl);
103105 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
103106 +// varpool_finalize_decl(latent_entropy_decl);
103107 +// varpool_mark_needed_node(latent_entropy_decl);
103108 +}
103109 +
103110 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103111 +{
103112 + const char * const plugin_name = plugin_info->base_name;
103113 + struct register_pass_info latent_entropy_pass_info = {
103114 + .pass = &latent_entropy_pass.pass,
103115 + .reference_pass_name = "optimized",
103116 + .ref_pass_instance_number = 1,
103117 + .pos_op = PASS_POS_INSERT_BEFORE
103118 + };
103119 +
103120 + if (!plugin_default_version_check(version, &gcc_version)) {
103121 + error(G_("incompatible gcc/plugin versions"));
103122 + return 1;
103123 + }
103124 +
103125 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
103126 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
103127 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
103128 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
103129 +
103130 + return 0;
103131 +}
103132 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
103133 new file mode 100644
103134 index 0000000..b04803b
103135 --- /dev/null
103136 +++ b/tools/gcc/size_overflow_hash.data
103137 @@ -0,0 +1,6350 @@
103138 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
103139 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
103140 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
103141 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
103142 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
103143 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
103144 +padzero_55 padzero 1 55 &sel_read_policyvers_55
103145 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
103146 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
103147 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 NULL
103148 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
103149 +load_msg_95 load_msg 2 95 NULL
103150 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
103151 +init_q_132 init_q 4 132 NULL
103152 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
103153 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
103154 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
103155 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
103156 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
103157 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
103158 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
103159 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
103160 +br_port_info_size_268 br_port_info_size 0 268 NULL
103161 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
103162 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
103163 +SYSC_connect_304 SYSC_connect 3 304 NULL
103164 +syslog_print_307 syslog_print 2 307 NULL
103165 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
103166 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
103167 +next_node_allowed_318 next_node_allowed 1 318 NULL
103168 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
103169 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
103170 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
103171 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
103172 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
103173 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
103174 +nvme_trans_modesel_data_488 nvme_trans_modesel_data 4 488 NULL
103175 +pidlist_resize_496 pidlist_resize 2 496 NULL
103176 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
103177 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
103178 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
103179 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0 537 NULL
103180 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
103181 +dle_count_543 dle_count 0 543 NULL
103182 +devres_alloc_551 devres_alloc 2 551 NULL
103183 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
103184 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
103185 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
103186 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
103187 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
103188 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
103189 +fuse_request_alloc_nofs_617 fuse_request_alloc_nofs 1 617 NULL
103190 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
103191 +isp1760_register_628 isp1760_register 1-2 628 NULL
103192 +clone_split_bio_633 clone_split_bio 6 633 NULL
103193 +ceph_osdc_new_request_635 ceph_osdc_new_request 6 635 NULL
103194 +remap_to_cache_640 remap_to_cache 3 640 NULL
103195 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
103196 +unlink_queued_645 unlink_queued 3-4 645 NULL
103197 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
103198 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
103199 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
103200 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
103201 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
103202 +disk_max_parts_719 disk_max_parts 0 719 NULL
103203 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
103204 +dvb_video_write_754 dvb_video_write 3 754 NULL
103205 +if_writecmd_815 if_writecmd 2 815 NULL
103206 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
103207 +read_fifo_826 read_fifo 3 826 NULL
103208 +um_idi_read_850 um_idi_read 3 850 NULL
103209 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
103210 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
103211 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
103212 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
103213 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
103214 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
103215 +get_ramdisk_size_954 get_ramdisk_size 0 954 NULL
103216 +__nodes_weight_956 __nodes_weight 2-0 956 NULL
103217 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
103218 +pte_prefetch_gfn_to_pfn_997 pte_prefetch_gfn_to_pfn 2 997 NULL nohasharray
103219 +hdlcdev_rx_997 hdlcdev_rx 3 997 &pte_prefetch_gfn_to_pfn_997
103220 +dm_cache_set_dirty_1016 dm_cache_set_dirty 2 1016 NULL
103221 +_do_truncate_1019 _do_truncate 2 1019 NULL
103222 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
103223 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
103224 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
103225 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
103226 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
103227 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
103228 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
103229 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
103230 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
103231 +sys_mremap_1107 sys_mremap 5-1-2 1107 NULL
103232 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
103233 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
103234 +dec_zcache_eph_zpages_1138 dec_zcache_eph_zpages 1 1138 NULL
103235 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
103236 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
103237 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
103238 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
103239 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
103240 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
103241 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
103242 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
103243 +nested_get_page_1252 nested_get_page 2 1252 NULL
103244 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
103245 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
103246 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
103247 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
103248 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
103249 +wm_adsp_buf_alloc_1317 wm_adsp_buf_alloc 2 1317 NULL
103250 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
103251 +ffs_1322 ffs 0 1322 NULL
103252 +qlcnic_pci_sriov_configure_1327 qlcnic_pci_sriov_configure 2 1327 NULL
103253 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
103254 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
103255 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
103256 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
103257 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
103258 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
103259 +iov_num_pages_1364 iov_num_pages 0 1364 NULL
103260 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
103261 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
103262 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
103263 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
103264 +zone_page_state_1393 zone_page_state 0 1393 NULL
103265 +file_read_actor_1401 file_read_actor 4 1401 NULL
103266 +vb2_dc_get_user_pages_1442 vb2_dc_get_user_pages 1-3 1442 NULL
103267 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
103268 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
103269 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
103270 +SYSC_syslog_1477 SYSC_syslog 3 1477 NULL
103271 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
103272 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
103273 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
103274 +__vfio_dma_map_1523 __vfio_dma_map 3 1523 NULL
103275 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
103276 +ath6kl_init_get_fwcaps_1557 ath6kl_init_get_fwcaps 3 1557 NULL
103277 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
103278 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
103279 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
103280 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
103281 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
103282 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
103283 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
103284 +mei_cl_recv_1665 mei_cl_recv 3 1665 NULL
103285 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
103286 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
103287 +rmap_add_1677 rmap_add 3 1677 NULL
103288 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
103289 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
103290 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
103291 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
103292 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
103293 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
103294 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
103295 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
103296 +cosa_write_1774 cosa_write 3 1774 NULL
103297 +update_macheader_1775 update_macheader 7 1775 NULL
103298 +dec_zcache_pers_zbytes_1779 dec_zcache_pers_zbytes 1 1779 NULL
103299 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
103300 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
103301 +alloc_pages_exact_1892 alloc_pages_exact 1 1892 NULL
103302 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
103303 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
103304 +SyS_add_key_1900 SyS_add_key 4 1900 NULL
103305 +isku_sysfs_write_keys_media_1910 isku_sysfs_write_keys_media 6 1910 NULL
103306 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
103307 +memblock_alloc_base_1938 memblock_alloc_base 1-2 1938 NULL
103308 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
103309 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
103310 +read_swap_header_1957 read_swap_header 0 1957 NULL
103311 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
103312 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
103313 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2-3 1992 NULL
103314 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
103315 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
103316 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
103317 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
103318 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
103319 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
103320 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
103321 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
103322 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
103323 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
103324 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
103325 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
103326 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
103327 +audit_expand_2098 audit_expand 2 2098 NULL
103328 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
103329 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
103330 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
103331 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
103332 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
103333 +pcf50633_write_block_2124 pcf50633_write_block 2-3 2124 NULL
103334 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
103335 +lp_gpio_irq_map_2149 lp_gpio_irq_map 2 2149 NULL
103336 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL
103337 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
103338 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
103339 +bio_integrity_alloc_2194 bio_integrity_alloc 3 2194 NULL
103340 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
103341 +mei_dbgfs_read_meclients_2219 mei_dbgfs_read_meclients 3 2219 NULL nohasharray
103342 +u32_array_read_2219 u32_array_read 3 2219 &mei_dbgfs_read_meclients_2219
103343 +vhci_write_2224 vhci_write 3 2224 NULL
103344 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
103345 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
103346 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
103347 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
103348 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
103349 +do_update_counters_2259 do_update_counters 4 2259 NULL
103350 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
103351 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
103352 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4-2 2308 NULL
103353 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
103354 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
103355 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
103356 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
103357 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
103358 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
103359 +SyS_mremap_2367 SyS_mremap 1-2-5 2367 NULL
103360 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
103361 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
103362 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
103363 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
103364 +SYSC_mlock_2415 SYSC_mlock 1 2415 NULL
103365 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
103366 +raid1_size_2419 raid1_size 0-2 2419 NULL
103367 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
103368 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
103369 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
103370 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
103371 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 NULL
103372 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
103373 +update_pmkid_2481 update_pmkid 4 2481 NULL
103374 +wiphy_new_2482 wiphy_new 2 2482 NULL
103375 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
103376 +lookup_cache_entry_2494 lookup_cache_entry 2 2494 NULL
103377 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
103378 +dm_write_2513 dm_write 3 2513 NULL
103379 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
103380 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
103381 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
103382 +i915_next_seqno_write_2572 i915_next_seqno_write 3 2572 NULL
103383 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
103384 +slot_bytes_2609 slot_bytes 0 2609 NULL
103385 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
103386 +kvm_gfn_to_hva_cache_init_2636 kvm_gfn_to_hva_cache_init 3 2636 NULL
103387 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
103388 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
103389 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
103390 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
103391 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
103392 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL nohasharray
103393 +bictcp_update_2771 bictcp_update 2 2771 &mon_bin_ioctl_2771
103394 +__next_cpu_2782 __next_cpu 1 2782 NULL
103395 +set_msr_hyperv_pw_2785 set_msr_hyperv_pw 3 2785 NULL
103396 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
103397 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL
103398 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
103399 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
103400 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
103401 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
103402 +mq_map_2871 mq_map 2 2871 NULL
103403 +nla_padlen_2883 nla_padlen 1 2883 NULL
103404 +cmm_write_2896 cmm_write 3 2896 NULL
103405 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
103406 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
103407 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
103408 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
103409 +set_fast_connectable_2952 set_fast_connectable 4 2952 NULL
103410 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
103411 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
103412 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
103413 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
103414 +depth_write_3021 depth_write 3 3021 NULL
103415 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
103416 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
103417 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
103418 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
103419 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
103420 +qp_alloc_ppn_set_3068 qp_alloc_ppn_set 2-4 3068 NULL
103421 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
103422 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
103423 +free_coherent_3082 free_coherent 4-2 3082 NULL
103424 +clone_bio_3100 clone_bio 6 3100 NULL nohasharray
103425 +ttusb2_msg_3100 ttusb2_msg 4 3100 &clone_bio_3100
103426 +rb_alloc_3102 rb_alloc 1 3102 NULL
103427 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
103428 +print_time_3132 print_time 0 3132 NULL
103429 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
103430 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
103431 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
103432 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
103433 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
103434 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
103435 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
103436 +alloc_context_3194 alloc_context 1 3194 NULL
103437 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
103438 +SyS_sendto_3219 SyS_sendto 6 3219 NULL
103439 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
103440 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
103441 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
103442 +key_key_read_3241 key_key_read 3 3241 NULL
103443 +number_3243 number 0 3243 NULL
103444 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
103445 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
103446 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
103447 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
103448 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
103449 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
103450 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
103451 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
103452 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
103453 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
103454 +scnprintf_3360 scnprintf 0-2 3360 NULL
103455 +x86_emulate_instruction_3389 x86_emulate_instruction 2 3389 NULL
103456 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
103457 +send_stream_3397 send_stream 4 3397 NULL
103458 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
103459 +msix_map_region_3411 msix_map_region 3 3411 NULL
103460 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
103461 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
103462 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
103463 +SyS_msgsnd_3436 SyS_msgsnd 3 3436 NULL
103464 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
103465 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
103466 +map_single_3449 map_single 0-2 3449 NULL
103467 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
103468 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
103469 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
103470 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
103471 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
103472 +kvm_handle_bad_page_3503 kvm_handle_bad_page 2 3503 NULL
103473 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
103474 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
103475 +SyS_readv_3539 SyS_readv 3 3539 NULL
103476 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
103477 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
103478 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
103479 +evtchn_read_3569 evtchn_read 3 3569 NULL
103480 +vc_resize_3585 vc_resize 2-3 3585 NULL
103481 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
103482 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
103483 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
103484 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
103485 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
103486 +x86_swiotlb_alloc_coherent_3649 x86_swiotlb_alloc_coherent 2 3649 NULL nohasharray
103487 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 &x86_swiotlb_alloc_coherent_3649
103488 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
103489 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
103490 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 NULL nohasharray
103491 +create_irq_3703 create_irq 0 3703 &snd_m3_assp_read_3703 nohasharray
103492 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703
103493 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
103494 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
103495 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
103496 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
103497 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
103498 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
103499 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
103500 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
103501 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
103502 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
103503 +get_fd_set_3866 get_fd_set 1 3866 NULL
103504 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
103505 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
103506 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
103507 +nvram_write_3894 nvram_write 3 3894 NULL
103508 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
103509 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
103510 +vcs_write_3910 vcs_write 3 3910 NULL
103511 +brcmf_debugfs_fws_stats_read_3947 brcmf_debugfs_fws_stats_read 3 3947 NULL
103512 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
103513 +do_add_counters_3992 do_add_counters 3 3992 NULL
103514 +userspace_status_4004 userspace_status 4 4004 NULL
103515 +mei_write_4005 mei_write 3 4005 NULL nohasharray
103516 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
103517 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
103518 +mm_populate_4016 mm_populate 1 4016 NULL
103519 +blk_end_request_4024 blk_end_request 3 4024 NULL
103520 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
103521 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
103522 +read_file_queues_4078 read_file_queues 3 4078 NULL
103523 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
103524 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
103525 +C_SYSC_rt_sigpending_4114 C_SYSC_rt_sigpending 2 4114 NULL
103526 +ntb_netdev_change_mtu_4147 ntb_netdev_change_mtu 2 4147 NULL
103527 +tm6000_read_4151 tm6000_read 3 4151 NULL
103528 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
103529 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
103530 +get_alua_req_4166 get_alua_req 3 4166 NULL
103531 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
103532 +read_file_bool_4180 read_file_bool 3 4180 NULL
103533 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
103534 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
103535 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
103536 +goldfish_audio_write_4284 goldfish_audio_write 3 4284 NULL
103537 +paging32_page_fault_4288 paging32_page_fault 2 4288 NULL
103538 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
103539 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
103540 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 3-2-5 4303 NULL
103541 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
103542 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
103543 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
103544 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
103545 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
103546 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
103547 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
103548 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
103549 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
103550 +memparse_4444 memparse 0 4444 NULL
103551 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
103552 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
103553 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
103554 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
103555 +set_link_security_4502 set_link_security 4 4502 NULL
103556 +dm_cache_remove_mapping_4513 dm_cache_remove_mapping 2 4513 NULL
103557 +__gfn_to_pfn_memslot_4530 __gfn_to_pfn_memslot 2 4530 NULL
103558 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
103559 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
103560 +tty_register_device_4544 tty_register_device 2 4544 NULL
103561 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
103562 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
103563 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
103564 +bch_alloc_4593 bch_alloc 1 4593 NULL
103565 +__wb_force_remove_mapping_4622 __wb_force_remove_mapping 2 4622 NULL
103566 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
103567 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
103568 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
103569 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
103570 +kone_receive_4690 kone_receive 4 4690 NULL
103571 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
103572 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
103573 +konepure_sysfs_read_4709 konepure_sysfs_read 6 4709 NULL
103574 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
103575 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
103576 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
103577 +__find_free_cblock_4741 __find_free_cblock 2 4741 NULL
103578 +memblock_find_in_range_4759 memblock_find_in_range 3-4 4759 NULL
103579 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
103580 +create_subvol_4791 create_subvol 4 4791 NULL
103581 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
103582 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
103583 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
103584 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
103585 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
103586 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
103587 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
103588 +sys_ipc_4889 sys_ipc 3 4889 NULL
103589 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
103590 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
103591 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
103592 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
103593 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
103594 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
103595 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
103596 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
103597 +compat_SyS_ipc_5000 compat_SyS_ipc 3-4-5-6 5000 NULL
103598 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
103599 +do_mincore_5018 do_mincore 0-1 5018 NULL
103600 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
103601 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
103602 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
103603 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
103604 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
103605 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
103606 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
103607 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
103608 +sound_write_5102 sound_write 3 5102 NULL
103609 +clear_dirty_5105 clear_dirty 3 5105 NULL
103610 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
103611 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
103612 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
103613 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
103614 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
103615 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
103616 +skb_network_header_5203 skb_network_header 0 5203 NULL
103617 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
103618 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
103619 +dwc2_hcd_urb_alloc_5217 dwc2_hcd_urb_alloc 2 5217 NULL
103620 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
103621 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL nohasharray
103622 +konepure_sysfs_write_5228 konepure_sysfs_write 6 5228 &ssb_ioremap_5228
103623 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
103624 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
103625 +gfn_to_hva_memslot_5265 gfn_to_hva_memslot 2 5265 NULL
103626 +alloc_cache_blocks_with_hash_5285 alloc_cache_blocks_with_hash 2 5285 NULL
103627 +__gfn_to_hva_memslot_5304 __gfn_to_hva_memslot 0-2 5304 NULL
103628 +sbc_get_write_same_sectors_5317 sbc_get_write_same_sectors 0 5317 NULL
103629 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
103630 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
103631 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
103632 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
103633 +kvm_pin_pages_5369 kvm_pin_pages 2 5369 NULL
103634 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
103635 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
103636 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
103637 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
103638 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
103639 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
103640 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
103641 +tty_write_5494 tty_write 3 5494 NULL
103642 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
103643 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
103644 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
103645 +spidev_message_5518 spidev_message 3 5518 NULL
103646 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
103647 +get_entry_msg_len_5552 get_entry_msg_len 0 5552 NULL
103648 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
103649 +le_readq_5557 le_readq 0 5557 NULL
103650 +inw_5558 inw 0 5558 NULL
103651 +fir16_create_5574 fir16_create 3 5574 NULL
103652 +bioset_create_5580 bioset_create 1 5580 NULL
103653 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
103654 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
103655 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
103656 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
103657 +SYSC_fsetxattr_5639 SYSC_fsetxattr 4 5639 NULL
103658 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
103659 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
103660 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
103661 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
103662 +wb_clear_dirty_5684 wb_clear_dirty 2 5684 NULL
103663 +get_arg_5694 get_arg 3 5694 NULL
103664 +subbuf_read_actor_5708 subbuf_read_actor 3 5708 NULL
103665 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
103666 +reexecute_instruction_5733 reexecute_instruction 2 5733 NULL
103667 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
103668 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
103669 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL nohasharray
103670 +qlcnic_83xx_sysfs_flash_read_handler_5775 qlcnic_83xx_sysfs_flash_read_handler 6 5775 &sctp_setsockopt_autoclose_5775
103671 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
103672 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
103673 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
103674 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
103675 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
103676 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
103677 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
103678 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
103679 +setup_req_5848 setup_req 3 5848 NULL
103680 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
103681 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
103682 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
103683 +paging64_walk_addr_5887 paging64_walk_addr 3 5887 NULL
103684 +port_show_regs_5904 port_show_regs 3 5904 NULL
103685 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
103686 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
103687 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
103688 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
103689 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
103690 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
103691 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
103692 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
103693 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
103694 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
103695 +native_pte_val_5978 native_pte_val 0 5978 NULL
103696 +SyS_semop_5980 SyS_semop 3 5980 NULL
103697 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
103698 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
103699 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
103700 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
103701 +md_trim_bio_6078 md_trim_bio 2 6078 NULL
103702 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
103703 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
103704 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
103705 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
103706 +ieee80211_if_fmt_beacon_timeout_6153 ieee80211_if_fmt_beacon_timeout 3 6153 NULL
103707 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
103708 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
103709 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
103710 +paging64_walk_addr_generic_6180 paging64_walk_addr_generic 4 6180 NULL
103711 +qp_host_get_user_memory_6189 qp_host_get_user_memory 1-2 6189 NULL
103712 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
103713 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
103714 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
103715 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
103716 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
103717 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
103718 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
103719 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 3 6282 NULL nohasharray
103720 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
103721 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
103722 +paging64_gva_to_gpa_nested_6287 paging64_gva_to_gpa_nested 2 6287 NULL
103723 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
103724 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
103725 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
103726 +qlcnic_sriov_alloc_bc_msg_6309 qlcnic_sriov_alloc_bc_msg 2 6309 NULL
103727 +SyS_mincore_6329 SyS_mincore 1 6329 NULL
103728 +fuse_get_req_for_background_6337 fuse_get_req_for_background 2 6337 NULL
103729 +ucs2_strnlen_6342 ucs2_strnlen 0 6342 NULL
103730 +mei_dbgfs_read_devstate_6352 mei_dbgfs_read_devstate 3 6352 NULL
103731 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
103732 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
103733 +isku_sysfs_write_light_6406 isku_sysfs_write_light 6 6406 NULL
103734 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
103735 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
103736 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2-3 6432 NULL
103737 +paging32_gva_to_gpa_nested_6442 paging32_gva_to_gpa_nested 2 6442 NULL
103738 +mlx4_ib_reg_user_mr_6471 mlx4_ib_reg_user_mr 2-3 6471 NULL nohasharray
103739 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 &mlx4_ib_reg_user_mr_6471
103740 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
103741 +qp_memcpy_from_queue_6479 qp_memcpy_from_queue 4-5 6479 NULL
103742 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
103743 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
103744 +mei_read_6507 mei_read 3 6507 NULL
103745 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
103746 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
103747 +wdm_read_6549 wdm_read 3 6549 NULL
103748 +isku_sysfs_write_keys_easyzone_6553 isku_sysfs_write_keys_easyzone 6 6553 NULL
103749 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
103750 +SyS_semtimedop_6563 SyS_semtimedop 3 6563 NULL
103751 +SyS_fcntl64_6582 SyS_fcntl64 3 6582 NULL
103752 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
103753 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
103754 +compat_SyS_shmat_6642 compat_SyS_shmat 2 6642 NULL
103755 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
103756 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
103757 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
103758 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
103759 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
103760 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
103761 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
103762 +mpeg_read_6708 mpeg_read 3 6708 NULL
103763 +set_orig_insn_6712 set_orig_insn 3 6712 NULL
103764 +video_proc_write_6724 video_proc_write 3 6724 NULL
103765 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
103766 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
103767 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
103768 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
103769 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
103770 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
103771 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
103772 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
103773 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
103774 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
103775 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
103776 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
103777 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
103778 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
103779 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
103780 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
103781 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
103782 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
103783 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
103784 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
103785 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
103786 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
103787 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
103788 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
103789 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
103790 +request_key_async_6990 request_key_async 4 6990 NULL
103791 +tpl_write_6998 tpl_write 3 6998 NULL
103792 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
103793 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
103794 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
103795 +wimax_msg_7030 wimax_msg 4 7030 NULL
103796 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
103797 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
103798 +event_enable_read_7074 event_enable_read 3 7074 NULL
103799 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
103800 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
103801 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
103802 +check_header_7108 check_header 0 7108 NULL
103803 +qlcnic_enable_msix_7144 qlcnic_enable_msix 2 7144 NULL
103804 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 NULL
103805 +batadv_check_unicast_ttvn_7206 batadv_check_unicast_ttvn 3 7206 NULL
103806 +sys32_ipc_7238 sys32_ipc 3-5-6 7238 NULL
103807 +get_param_h_7247 get_param_h 0 7247 NULL
103808 +af_alg_make_sg_7254 af_alg_make_sg 3 7254 NULL
103809 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
103810 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
103811 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
103812 +isku_sysfs_write_macro_7293 isku_sysfs_write_macro 6 7293 NULL
103813 +wb_remove_mapping_7307 wb_remove_mapping 2 7307 NULL
103814 +mgmt_control_7349 mgmt_control 3 7349 NULL
103815 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
103816 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
103817 +hweight_long_7388 hweight_long 0-1 7388 NULL
103818 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
103819 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
103820 +readb_7401 readb 0 7401 NULL
103821 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
103822 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
103823 +SYSC_setgroups_7454 SYSC_setgroups 1 7454 NULL
103824 +numa_emulation_7466 numa_emulation 2 7466 NULL
103825 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL
103826 +garp_request_join_7471 garp_request_join 4 7471 NULL
103827 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
103828 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
103829 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
103830 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
103831 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
103832 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
103833 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
103834 +btrfs_block_rsv_add_7579 btrfs_block_rsv_add 3 7579 NULL
103835 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
103836 +groups_alloc_7614 groups_alloc 1 7614 NULL
103837 +sg_virt_7616 sg_virt 0 7616 NULL
103838 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
103839 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
103840 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
103841 +dev_write_7708 dev_write 3 7708 NULL
103842 +unmap_region_7709 unmap_region 1 7709 NULL
103843 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL
103844 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
103845 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
103846 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
103847 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
103848 +ioread32be_7773 ioread32be 0 7773 NULL
103849 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
103850 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
103851 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
103852 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
103853 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
103854 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
103855 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
103856 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
103857 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
103858 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
103859 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
103860 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
103861 +hash_netiface6_expire_7944 hash_netiface6_expire 3 7944 NULL
103862 +integrity_digsig_verify_7956 integrity_digsig_verify 3 7956 NULL
103863 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
103864 +sys_mbind_7990 sys_mbind 5 7990 NULL
103865 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
103866 +vcs_read_8017 vcs_read 3 8017 NULL
103867 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
103868 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
103869 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
103870 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
103871 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
103872 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
103873 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
103874 +venus_lookup_8121 venus_lookup 4 8121 NULL
103875 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
103876 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
103877 +ore_truncate_8181 ore_truncate 3 8181 NULL
103878 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
103879 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
103880 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
103881 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
103882 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
103883 +play_iframe_8219 play_iframe 3 8219 NULL
103884 +create_log_8225 create_log 2 8225 NULL nohasharray
103885 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
103886 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
103887 +ceph_sync_write_8233 ceph_sync_write 4 8233 NULL
103888 +bnx2x_iov_get_max_queue_count_8235 bnx2x_iov_get_max_queue_count 0 8235 NULL
103889 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
103890 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
103891 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
103892 +init_cdev_8274 init_cdev 1 8274 NULL
103893 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
103894 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
103895 +construct_key_and_link_8321 construct_key_and_link 4 8321 NULL
103896 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
103897 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
103898 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
103899 +isku_sysfs_write_talk_8360 isku_sysfs_write_talk 6 8360 NULL nohasharray
103900 +ping_getfrag_8360 ping_getfrag 4-3 8360 &isku_sysfs_write_talk_8360
103901 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
103902 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
103903 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
103904 +smk_write_change_rule_8411 smk_write_change_rule 3 8411 NULL nohasharray
103905 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 &smk_write_change_rule_8411
103906 +pca953x_gpio_to_irq_8424 pca953x_gpio_to_irq 2 8424 NULL
103907 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
103908 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
103909 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
103910 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
103911 +dev_config_8506 dev_config 3 8506 NULL
103912 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
103913 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
103914 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
103915 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
103916 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
103917 +user_on_off_8552 user_on_off 2 8552 NULL
103918 +profile_remove_8556 profile_remove 3 8556 NULL
103919 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
103920 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
103921 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
103922 +tower_write_8580 tower_write 3 8580 NULL
103923 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
103924 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
103925 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
103926 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
103927 +fuse_send_write_pages_8636 fuse_send_write_pages 0-5 8636 NULL
103928 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
103929 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
103930 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
103931 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
103932 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
103933 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
103934 +arcfb_write_8702 arcfb_write 3 8702 NULL
103935 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
103936 +init_header_8703 init_header 0 8703 &i_size_read_8703
103937 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
103938 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL
103939 +f_dupfd_8730 f_dupfd 1 8730 NULL
103940 +__create_irqs_8733 __create_irqs 2-1 8733 NULL
103941 +pca953x_gpio_irq_map_8737 pca953x_gpio_irq_map 2 8737 NULL
103942 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
103943 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
103944 +sys_prctl_8766 sys_prctl 4 8766 NULL
103945 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
103946 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
103947 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
103948 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
103949 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
103950 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
103951 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
103952 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
103953 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
103954 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
103955 +clear_bitset_8840 clear_bitset 2 8840 NULL
103956 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
103957 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
103958 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
103959 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
103960 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
103961 +layout_commit_8926 layout_commit 3 8926 NULL
103962 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
103963 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
103964 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
103965 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
103966 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
103967 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
103968 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
103969 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
103970 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
103971 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
103972 +btrfs_alloc_free_block_8986 btrfs_alloc_free_block 3 8986 NULL
103973 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
103974 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
103975 +nla_put_9042 nla_put 3 9042 NULL
103976 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
103977 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
103978 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
103979 +string_9080 string 0 9080 NULL
103980 +create_queues_9088 create_queues 2-3 9088 NULL
103981 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
103982 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
103983 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
103984 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
103985 +isku_sysfs_write_keys_macro_9120 isku_sysfs_write_keys_macro 6 9120 NULL
103986 +mq_remove_mapping_9124 mq_remove_mapping 2 9124 NULL
103987 +mlx4_alloc_resize_umem_9132 mlx4_alloc_resize_umem 3 9132 NULL
103988 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
103989 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
103990 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
103991 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
103992 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
103993 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
103994 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
103995 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
103996 +get_pfn_9207 get_pfn 1 9207 NULL
103997 +virtqueue_add_9217 virtqueue_add 5-4 9217 NULL
103998 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
103999 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
104000 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
104001 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
104002 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
104003 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
104004 +flakey_status_9274 flakey_status 5 9274 NULL
104005 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
104006 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
104007 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
104008 +memblock_find_in_range_node_9328 memblock_find_in_range_node 0-3-4 9328 NULL
104009 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
104010 +nvme_trans_fmt_get_parm_header_9340 nvme_trans_fmt_get_parm_header 2 9340 NULL
104011 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
104012 +sta_beacon_loss_count_read_9370 sta_beacon_loss_count_read 3 9370 NULL
104013 +virtqueue_add_outbuf_9395 virtqueue_add_outbuf 3 9395 NULL
104014 +read_9397 read 3 9397 NULL
104015 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
104016 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
104017 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
104018 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
104019 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
104020 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
104021 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
104022 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
104023 +__alloc_preds_9492 __alloc_preds 2 9492 NULL nohasharray
104024 +crypt_status_9492 crypt_status 5 9492 &__alloc_preds_9492
104025 +lp_write_9511 lp_write 3 9511 NULL
104026 +xen_remap_exchanged_ptes_9513 xen_remap_exchanged_ptes 1 9513 NULL
104027 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
104028 +read_file_dma_9530 read_file_dma 3 9530 NULL
104029 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
104030 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
104031 +fw_node_create_9559 fw_node_create 2 9559 NULL
104032 +ipath_get_user_pages_9561 ipath_get_user_pages 1-2 9561 NULL
104033 +kobj_map_9566 kobj_map 2-3 9566 NULL
104034 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
104035 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
104036 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
104037 +use_block_rsv_9597 use_block_rsv 3 9597 NULL
104038 +do_sync_9604 do_sync 1 9604 NULL
104039 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
104040 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
104041 +ceph_copy_user_to_page_vector_9635 ceph_copy_user_to_page_vector 4-3 9635 NULL
104042 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
104043 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
104044 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
104045 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
104046 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
104047 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
104048 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
104049 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
104050 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
104051 +is_hole_9694 is_hole 2 9694 NULL nohasharray
104052 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 &is_hole_9694
104053 +fnb_9703 fnb 2-3 9703 NULL
104054 +fuse_iter_npages_9705 fuse_iter_npages 0 9705 NULL nohasharray
104055 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 &fuse_iter_npages_9705
104056 +nla_get_u8_9736 nla_get_u8 0 9736 NULL
104057 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
104058 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
104059 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
104060 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
104061 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
104062 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
104063 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
104064 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
104065 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
104066 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
104067 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
104068 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
104069 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
104070 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
104071 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
104072 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
104073 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
104074 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
104075 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
104076 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
104077 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
104078 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
104079 +gen6_get_total_gtt_size_9913 gen6_get_total_gtt_size 0-1 9913 NULL
104080 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
104081 +read_file_misc_9948 read_file_misc 3 9948 NULL
104082 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
104083 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
104084 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
104085 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
104086 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
104087 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
104088 +SYSC_move_pages_9986 SYSC_move_pages 2 9986 NULL
104089 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
104090 +handle_request_10024 handle_request 9 10024 NULL
104091 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
104092 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
104093 +xen_destroy_contiguous_region_10054 xen_destroy_contiguous_region 1 10054 NULL
104094 +vfio_pci_write_10063 vfio_pci_write 3 10063 NULL
104095 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
104096 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
104097 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
104098 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
104099 +jbd_alloc_10112 jbd_alloc 0 10112 NULL nohasharray
104100 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 &jbd_alloc_10112
104101 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
104102 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
104103 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
104104 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
104105 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
104106 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
104107 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
104108 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
104109 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
104110 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
104111 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
104112 +__qlcnic_pci_sriov_enable_10281 __qlcnic_pci_sriov_enable 2 10281 NULL
104113 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
104114 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
104115 +read_emulate_10310 read_emulate 2-4 10310 NULL
104116 +read_file_spectral_count_10320 read_file_spectral_count 3 10320 NULL
104117 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
104118 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
104119 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
104120 +get_dump_page_10338 get_dump_page 1 10338 NULL
104121 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
104122 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
104123 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
104124 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
104125 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
104126 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
104127 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
104128 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
104129 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
104130 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
104131 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
104132 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
104133 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
104134 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
104135 +qlcnic_pci_sriov_enable_10519 qlcnic_pci_sriov_enable 2 10519 NULL nohasharray
104136 +hash_netiface4_expire_10519 hash_netiface4_expire 3 10519 &qlcnic_pci_sriov_enable_10519
104137 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
104138 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
104139 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
104140 +ieee80211_send_probe_req_10539 ieee80211_send_probe_req 4-6 10539 NULL
104141 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
104142 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
104143 +otp_read_10594 otp_read 2-4-5 10594 NULL
104144 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
104145 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
104146 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
104147 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
104148 +dtf_read_device_10663 dtf_read_device 3 10663 NULL
104149 +parport_write_10669 parport_write 0 10669 NULL
104150 +inl_10708 inl 0 10708 NULL nohasharray
104151 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
104152 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
104153 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
104154 +spi_sync_10731 spi_sync 0 10731 NULL
104155 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
104156 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
104157 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
104158 +sys_syslog_10746 sys_syslog 3 10746 NULL
104159 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
104160 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
104161 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4-2 10765 NULL
104162 +wb_set_dirty_10778 wb_set_dirty 2 10778 NULL
104163 +__qp_memcpy_to_queue_10779 __qp_memcpy_to_queue 2-4 10779 NULL
104164 +sys_bind_10799 sys_bind 3 10799 NULL
104165 +compat_put_int_10828 compat_put_int 1 10828 NULL
104166 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
104167 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
104168 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
104169 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
104170 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
104171 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
104172 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
104173 +get_scq_10897 get_scq 2 10897 NULL
104174 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
104175 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
104176 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
104177 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
104178 +ci_port_test_write_10962 ci_port_test_write 3 10962 NULL
104179 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
104180 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
104181 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
104182 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
104183 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
104184 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
104185 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
104186 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
104187 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
104188 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
104189 +count_argc_11083 count_argc 0 11083 NULL
104190 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
104191 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
104192 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
104193 +page_offset_11120 page_offset 0 11120 NULL
104194 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL nohasharray
104195 +cea_db_payload_len_11124 cea_db_payload_len 0 11124 &tracing_buffers_read_11124
104196 +alloc_alien_cache_11127 alloc_alien_cache 2 11127 NULL
104197 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
104198 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
104199 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
104200 +__swab16p_11220 __swab16p 0 11220 NULL
104201 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
104202 +mmap_region_11247 mmap_region 0-2 11247 NULL
104203 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
104204 +dm_cache_discard_bitset_resize_11262 dm_cache_discard_bitset_resize 3 11262 NULL
104205 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
104206 +cru_detect_11272 cru_detect 1 11272 NULL
104207 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
104208 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
104209 +construct_key_11329 construct_key 3 11329 NULL nohasharray
104210 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
104211 +next_segment_11330 next_segment 0-2-1 11330 NULL
104212 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
104213 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
104214 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
104215 +sel_write_create_11353 sel_write_create 3 11353 NULL
104216 +handle_unit_11355 handle_unit 0-1 11355 NULL
104217 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
104218 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
104219 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
104220 +isku_sysfs_read_keys_capslock_11392 isku_sysfs_read_keys_capslock 6 11392 NULL
104221 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
104222 +___alloc_bootmem_11410 ___alloc_bootmem 1-2 11410 NULL
104223 +str_to_user_11411 str_to_user 2 11411 NULL
104224 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
104225 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
104226 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
104227 +trace_options_read_11419 trace_options_read 3 11419 NULL
104228 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
104229 +prepare_image_11424 prepare_image 0 11424 NULL
104230 +vring_size_11426 vring_size 0-1-2 11426 NULL
104231 +bttv_read_11432 bttv_read 3 11432 NULL
104232 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
104233 +swp_offset_11475 swp_offset 0 11475 NULL
104234 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
104235 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
104236 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
104237 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
104238 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
104239 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
104240 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
104241 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
104242 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
104243 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
104244 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
104245 +SYSC_mq_timedsend_11607 SYSC_mq_timedsend 3 11607 NULL
104246 +add_new_bitmap_11644 add_new_bitmap 3 11644 NULL
104247 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
104248 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
104249 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
104250 +compat_SyS_msgsnd_11675 compat_SyS_msgsnd 2-3 11675 NULL
104251 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
104252 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
104253 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
104254 +split_11691 split 2 11691 NULL
104255 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
104256 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
104257 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
104258 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
104259 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
104260 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
104261 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
104262 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
104263 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
104264 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2-3 11818 NULL
104265 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
104266 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
104267 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
104268 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
104269 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
104270 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
104271 +ieee80211_rx_bss_info_11887 ieee80211_rx_bss_info 3 11887 NULL
104272 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
104273 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
104274 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
104275 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
104276 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
104277 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
104278 +atmel_read16_11981 atmel_read16 0 11981 NULL
104279 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
104280 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
104281 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
104282 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
104283 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
104284 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
104285 +pse36_gfn_delta_12087 pse36_gfn_delta 0-1 12087 NULL
104286 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
104287 +set_powered_12129 set_powered 4 12129 NULL
104288 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
104289 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
104290 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
104291 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
104292 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
104293 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
104294 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
104295 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
104296 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
104297 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
104298 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
104299 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
104300 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
104301 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
104302 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
104303 +scaled_div_12201 scaled_div 1-2 12201 NULL
104304 +free_initrd_mem_12203 free_initrd_mem 1 12203 NULL
104305 +receive_copy_12216 receive_copy 3 12216 NULL
104306 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
104307 +fuse_get_req_12221 fuse_get_req 2 12221 NULL nohasharray
104308 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 &fuse_get_req_12221
104309 +__alloc_bootmem_low_nopanic_12235 __alloc_bootmem_low_nopanic 1-2 12235 NULL
104310 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
104311 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
104312 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
104313 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
104314 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
104315 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
104316 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
104317 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
104318 +wrap_min_12303 wrap_min 0-1-2 12303 NULL
104319 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
104320 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
104321 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
104322 +paging32_walk_addr_12359 paging32_walk_addr 3 12359 NULL
104323 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
104324 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
104325 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
104326 +hbucket_elem_add_12416 hbucket_elem_add 3 12416 NULL
104327 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
104328 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
104329 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
104330 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
104331 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
104332 +fnic_trace_ctrl_read_12497 fnic_trace_ctrl_read 3 12497 NULL
104333 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
104334 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
104335 +kvm_setup_async_pf_12555 kvm_setup_async_pf 3 12555 NULL
104336 +ib_umem_get_12557 ib_umem_get 2-3 12557 NULL
104337 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
104338 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
104339 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
104340 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
104341 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
104342 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
104343 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
104344 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
104345 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
104346 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
104347 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
104348 +wb_create_12651 wb_create 1 12651 NULL
104349 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
104350 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
104351 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
104352 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
104353 +ivtv_write_12721 ivtv_write 3 12721 NULL
104354 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
104355 +__mei_cl_async_send_12737 __mei_cl_async_send 3 12737 NULL
104356 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
104357 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
104358 +listxattr_12769 listxattr 3 12769 NULL
104359 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
104360 +ieee80211_rx_mgmt_beacon_12780 ieee80211_rx_mgmt_beacon 3 12780 NULL
104361 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
104362 +btrfs_remove_free_space_12793 btrfs_remove_free_space 2 12793 NULL
104363 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
104364 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
104365 +readq_12825 readq 0 12825 NULL
104366 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
104367 +spidev_sync_12842 spidev_sync 0 12842 NULL nohasharray
104368 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 &spidev_sync_12842
104369 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
104370 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
104371 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
104372 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
104373 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
104374 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
104375 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
104376 +bm_status_write_12964 bm_status_write 3 12964 NULL
104377 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
104378 +raid56_parity_recover_12987 raid56_parity_recover 5 12987 NULL
104379 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
104380 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
104381 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
104382 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
104383 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
104384 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
104385 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
104386 +biovec_create_pool_13079 biovec_create_pool 2 13079 NULL
104387 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
104388 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
104389 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
104390 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
104391 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
104392 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
104393 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
104394 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
104395 +blk_update_request_13146 blk_update_request 3 13146 NULL
104396 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
104397 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
104398 +ucs2_strlen_13178 ucs2_strlen 0 13178 NULL
104399 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
104400 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
104401 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
104402 +__cmpxchg64_13187 __cmpxchg64 0 13187 NULL
104403 +comedi_read_13199 comedi_read 3 13199 NULL
104404 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
104405 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
104406 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
104407 +fnic_trace_ctrl_write_13229 fnic_trace_ctrl_write 3 13229 NULL
104408 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
104409 +fw_download_code_13249 fw_download_code 3 13249 NULL nohasharray
104410 +kvm_lapic_enable_pv_eoi_13249 kvm_lapic_enable_pv_eoi 2 13249 &fw_download_code_13249
104411 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
104412 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
104413 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
104414 +c4iw_reg_user_mr_13269 c4iw_reg_user_mr 2-3 13269 NULL
104415 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
104416 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
104417 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
104418 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
104419 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
104420 +i915_drop_caches_write_13308 i915_drop_caches_write 3 13308 NULL
104421 +reexecute_instruction_13321 reexecute_instruction 2 13321 NULL
104422 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
104423 +__clone_and_map_data_bio_13334 __clone_and_map_data_bio 4-8 13334 NULL
104424 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5-2 13337 NULL
104425 +cache_ctr_13364 cache_ctr 2 13364 NULL
104426 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
104427 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
104428 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
104429 +dis_bypass_write_13388 dis_bypass_write 3 13388 NULL
104430 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
104431 +sky2_receive_13407 sky2_receive 2 13407 NULL
104432 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
104433 +keyring_read_13438 keyring_read 3 13438 NULL
104434 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
104435 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
104436 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 8-9-7 13443 NULL
104437 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
104438 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
104439 +core_status_13515 core_status 4 13515 NULL
104440 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
104441 +bm_init_13529 bm_init 2 13529 NULL
104442 +non_atomic_pte_lookup_13540 non_atomic_pte_lookup 2 13540 NULL nohasharray
104443 +SYSC_remap_file_pages_13540 SYSC_remap_file_pages 1 13540 &non_atomic_pte_lookup_13540
104444 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
104445 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
104446 +sys_madvise_13569 sys_madvise 1 13569 NULL
104447 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
104448 +cache_write_13589 cache_write 3 13589 NULL
104449 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
104450 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
104451 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
104452 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
104453 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
104454 +wm8994_bulk_write_13615 wm8994_bulk_write 2-3 13615 NULL
104455 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
104456 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
104457 +packet_snd_13634 packet_snd 3 13634 NULL
104458 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
104459 +cache_downcall_13666 cache_downcall 3 13666 NULL
104460 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
104461 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
104462 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
104463 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
104464 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
104465 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
104466 +random_read_13815 random_read 3 13815 NULL
104467 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
104468 +___mei_cl_send_13821 ___mei_cl_send 3 13821 NULL
104469 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
104470 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
104471 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
104472 +qp_memcpy_to_queue_13886 qp_memcpy_to_queue 2-5 13886 NULL
104473 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
104474 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
104475 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
104476 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
104477 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
104478 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
104479 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
104480 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
104481 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
104482 +com90xx_found_13974 com90xx_found 3 13974 NULL
104483 +qcam_read_13977 qcam_read 3 13977 NULL
104484 +dsp_read_13980 dsp_read 2 13980 NULL
104485 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
104486 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
104487 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
104488 +dmi_format_ids_14018 dmi_format_ids 2 14018 NULL
104489 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
104490 +iscsi_create_flashnode_conn_14022 iscsi_create_flashnode_conn 4 14022 NULL
104491 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
104492 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
104493 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
104494 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
104495 +i915_drop_caches_read_14060 i915_drop_caches_read 3 14060 NULL
104496 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
104497 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
104498 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
104499 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
104500 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
104501 +isku_sysfs_read_light_14140 isku_sysfs_read_light 6 14140 NULL
104502 +em_canid_change_14150 em_canid_change 3 14150 NULL
104503 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
104504 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
104505 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
104506 +alloc_async_14208 alloc_async 1 14208 NULL
104507 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
104508 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
104509 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
104510 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 2-4 14245 NULL
104511 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
104512 +ath6kl_connect_event_14267 ath6kl_connect_event 8-9-7 14267 NULL
104513 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
104514 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
104515 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
104516 +rr_status_14293 rr_status 5 14293 NULL
104517 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
104518 +oo_objects_14319 oo_objects 0 14319 NULL
104519 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
104520 +scsi2int_14358 scsi2int 0 14358 NULL
104521 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
104522 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
104523 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
104524 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
104525 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
104526 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
104527 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
104528 +block_size_14443 block_size 0 14443 NULL
104529 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
104530 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
104531 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
104532 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
104533 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
104534 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 NULL nohasharray
104535 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
104536 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
104537 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
104538 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
104539 +qp_host_alloc_queue_14566 qp_host_alloc_queue 1 14566 NULL
104540 +SyS_setdomainname_14569 SyS_setdomainname 2 14569 NULL
104541 +remap_to_origin_then_cache_14583 remap_to_origin_then_cache 3 14583 NULL
104542 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
104543 +ceph_osdc_alloc_request_14597 ceph_osdc_alloc_request 3 14597 NULL
104544 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
104545 +dbJoin_14644 dbJoin 0 14644 NULL
104546 +profile_replace_14652 profile_replace 3 14652 NULL
104547 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
104548 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
104549 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
104550 +SyS_fsetxattr_14702 SyS_fsetxattr 4 14702 NULL
104551 +persistent_ram_ecc_string_14704 persistent_ram_ecc_string 0 14704 NULL
104552 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
104553 +get_bio_block_14714 get_bio_block 0 14714 NULL
104554 +vfd_write_14717 vfd_write 3 14717 NULL
104555 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
104556 +raid1_resize_14740 raid1_resize 2 14740 NULL
104557 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
104558 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
104559 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
104560 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
104561 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
104562 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
104563 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
104564 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
104565 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
104566 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
104567 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
104568 +mrp_attr_create_14853 mrp_attr_create 3 14853 NULL
104569 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
104570 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
104571 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
104572 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
104573 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
104574 +unifi_read_14899 unifi_read 3 14899 NULL
104575 +SYSC_readv_14901 SYSC_readv 3 14901 NULL
104576 +krealloc_14908 krealloc 2 14908 NULL
104577 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
104578 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL nohasharray
104579 +qp_memcpy_to_queue_iov_14923 qp_memcpy_to_queue_iov 2-5 14923 &__arch_hweight64_14923
104580 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
104581 +queue_cnt_14951 queue_cnt 0 14951 NULL
104582 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
104583 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
104584 +setkey_14987 setkey 3 14987 NULL nohasharray
104585 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
104586 +xfs_dinode_size_14996 xfs_dinode_size 0 14996 NULL
104587 +vmap_15025 vmap 2 15025 NULL
104588 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
104589 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
104590 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
104591 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
104592 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
104593 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
104594 +compat_SyS_preadv_15105 compat_SyS_preadv 3 15105 NULL
104595 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
104596 +start_port_15124 start_port 0 15124 NULL
104597 +memchr_15126 memchr 0 15126 NULL
104598 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
104599 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
104600 +SYSC_setdomainname_15180 SYSC_setdomainname 2 15180 NULL
104601 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
104602 +reserve_resources_15194 reserve_resources 3 15194 NULL
104603 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
104604 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
104605 +div64_u64_15263 div64_u64 0-1-2 15263 NULL
104606 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
104607 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
104608 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
104609 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
104610 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
104611 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
104612 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
104613 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
104614 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
104615 +ioread16_15342 ioread16 0 15342 NULL
104616 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
104617 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
104618 +graph_depth_read_15371 graph_depth_read 3 15371 NULL
104619 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
104620 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
104621 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
104622 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
104623 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
104624 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
104625 +get_modalias_15406 get_modalias 2 15406 NULL
104626 +dm_cache_resize_15422 dm_cache_resize 2 15422 NULL
104627 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
104628 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 2 15438 NULL
104629 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
104630 +memweight_15450 memweight 2 15450 NULL
104631 +vmalloc_15464 vmalloc 1 15464 NULL
104632 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
104633 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
104634 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
104635 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
104636 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
104637 +persistent_status_15574 persistent_status 4 15574 NULL
104638 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
104639 +vme_user_write_15587 vme_user_write 3 15587 NULL
104640 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
104641 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
104642 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
104643 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
104644 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
104645 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
104646 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
104647 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
104648 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
104649 +fs_path_add_15648 fs_path_add 3 15648 NULL
104650 +xsd_read_15653 xsd_read 3 15653 NULL
104651 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
104652 +unix_bind_15668 unix_bind 3 15668 NULL
104653 +dm_read_15674 dm_read 3 15674 NULL
104654 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
104655 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
104656 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
104657 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
104658 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
104659 +do_test_15766 do_test 1 15766 NULL
104660 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
104661 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
104662 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
104663 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
104664 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
104665 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
104666 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL nohasharray
104667 +firmware_upload_15822 firmware_upload 3 15822 &afs_proc_rootcell_write_15822
104668 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
104669 +table_size_15851 table_size 0-1-2 15851 NULL
104670 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
104671 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
104672 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
104673 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
104674 +native_read_msr_15905 native_read_msr 0 15905 NULL
104675 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
104676 +power_read_15939 power_read 3 15939 NULL
104677 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
104678 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
104679 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
104680 +tfrc_calc_x_15975 tfrc_calc_x 1-2 15975 NULL
104681 +frame_alloc_15981 frame_alloc 4 15981 NULL
104682 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
104683 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
104684 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
104685 +got_frame_16028 got_frame 2 16028 NULL
104686 +read_file_spectral_period_16057 read_file_spectral_period 3 16057 NULL
104687 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
104688 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
104689 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
104690 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
104691 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
104692 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
104693 +fsm_init_16134 fsm_init 2 16134 NULL
104694 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
104695 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
104696 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
104697 +mapping_level_16188 mapping_level 2 16188 NULL
104698 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
104699 +SyS_pselect6_16210 SyS_pselect6 1 16210 NULL
104700 +create_table_16213 create_table 2 16213 NULL
104701 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
104702 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
104703 +swiotlb_sync_single_for_device_16247 swiotlb_sync_single_for_device 2 16247 NULL nohasharray
104704 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 &swiotlb_sync_single_for_device_16247
104705 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
104706 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
104707 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
104708 +mq_force_mapping_16277 mq_force_mapping 2 16277 NULL
104709 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
104710 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
104711 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
104712 +account_16283 account 0-2-4 16283 NULL nohasharray
104713 +mirror_status_16283 mirror_status 5 16283 &account_16283
104714 +retry_instruction_16285 retry_instruction 2 16285 NULL
104715 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
104716 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
104717 +tfrc_invert_loss_event_rate_16295 tfrc_invert_loss_event_rate 1 16295 NULL
104718 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
104719 +wb_map_16301 wb_map 2 16301 NULL
104720 +ext4_blocks_count_16320 ext4_blocks_count 0 16320 NULL
104721 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
104722 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
104723 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
104724 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
104725 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
104726 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
104727 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
104728 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
104729 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
104730 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
104731 +raid10_resize_16537 raid10_resize 2 16537 NULL
104732 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
104733 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
104734 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
104735 +virt_to_scatterlist_16582 virt_to_scatterlist 2 16582 NULL
104736 +palmas_irq_get_virq_16613 palmas_irq_get_virq 2 16613 NULL
104737 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
104738 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
104739 +ax88179_write_cmd_async_16671 ax88179_write_cmd_async 5 16671 NULL
104740 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
104741 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
104742 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
104743 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
104744 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
104745 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
104746 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
104747 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
104748 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
104749 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
104750 +vfio_pci_rw_16861 vfio_pci_rw 3 16861 NULL
104751 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
104752 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
104753 +st_write_16874 st_write 3 16874 NULL
104754 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
104755 +idx_to_pfn_16919 idx_to_pfn 0 16919 NULL
104756 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
104757 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
104758 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
104759 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
104760 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
104761 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
104762 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
104763 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
104764 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
104765 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
104766 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
104767 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
104768 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
104769 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
104770 +mac_address_string_17091 mac_address_string 0 17091 NULL
104771 +entry_length_17093 entry_length 0 17093 NULL
104772 +sys_preadv_17100 sys_preadv 3 17100 NULL
104773 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
104774 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
104775 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
104776 +sep_read_17161 sep_read 3 17161 NULL
104777 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
104778 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
104779 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
104780 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
104781 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
104782 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
104783 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
104784 +to_oblock_17254 to_oblock 0-1 17254 NULL
104785 +unpack_value_17259 unpack_value 1 17259 NULL
104786 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
104787 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
104788 +alloc_ep_17269 alloc_ep 1 17269 NULL
104789 +pg_read_17276 pg_read 3 17276 NULL
104790 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
104791 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
104792 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
104793 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
104794 +install_breakpoint_17292 install_breakpoint 4 17292 NULL
104795 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
104796 +skb_pad_17302 skb_pad 2 17302 NULL
104797 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
104798 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
104799 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
104800 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
104801 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
104802 +_fd_dma_mem_free_17406 _fd_dma_mem_free 1 17406 NULL
104803 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
104804 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
104805 +SYSC_fcntl_17441 SYSC_fcntl 3 17441 NULL
104806 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
104807 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
104808 +compat_cmd_17465 compat_cmd 2 17465 NULL
104809 +probe_bios_17467 probe_bios 1 17467 NULL
104810 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
104811 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
104812 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
104813 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
104814 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
104815 +copy_from_user_17559 copy_from_user 3 17559 NULL
104816 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
104817 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
104818 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
104819 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
104820 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
104821 +osst_execute_17607 osst_execute 7-6 17607 NULL
104822 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
104823 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
104824 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
104825 +SYSC_migrate_pages_17657 SYSC_migrate_pages 2 17657 NULL
104826 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
104827 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
104828 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
104829 +gfn_to_pfn_memslot_17693 gfn_to_pfn_memslot 2 17693 NULL
104830 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
104831 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
104832 +isku_sysfs_write_keys_function_17726 isku_sysfs_write_keys_function 6 17726 NULL
104833 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
104834 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
104835 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
104836 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
104837 +dtf_read_run_17768 dtf_read_run 3 17768 NULL
104838 +brcmf_sdio_chip_verifynvram_17776 brcmf_sdio_chip_verifynvram 4 17776 NULL
104839 +hash_ipport6_expire_17784 hash_ipport6_expire 3 17784 NULL
104840 +perf_clock_17787 perf_clock 0 17787 NULL
104841 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
104842 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
104843 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
104844 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
104845 +count_leafs_17842 count_leafs 0 17842 NULL
104846 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
104847 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
104848 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
104849 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
104850 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
104851 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
104852 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
104853 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
104854 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
104855 +recover_head_17904 recover_head 3 17904 NULL
104856 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
104857 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
104858 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
104859 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
104860 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
104861 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
104862 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
104863 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
104864 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
104865 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
104866 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
104867 +fill_read_18019 fill_read 0 18019 NULL
104868 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
104869 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
104870 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
104871 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
104872 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
104873 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
104874 +packet_came_18072 packet_came 3 18072 NULL
104875 +kvm_read_guest_page_18074 kvm_read_guest_page 5-2 18074 NULL
104876 +SYSC_pselect6_18076 SYSC_pselect6 1 18076 NULL
104877 +get_vm_area_18080 get_vm_area 1 18080 NULL
104878 +SYSC_semtimedop_18091 SYSC_semtimedop 3 18091 NULL
104879 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
104880 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
104881 +svc_getnl_18120 svc_getnl 0 18120 NULL
104882 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
104883 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
104884 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
104885 +_has_tag_18169 _has_tag 2 18169 NULL
104886 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
104887 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
104888 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
104889 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
104890 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
104891 +alloc_trace_uprobe_18247 alloc_trace_uprobe 3 18247 NULL
104892 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
104893 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
104894 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
104895 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
104896 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
104897 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
104898 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
104899 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
104900 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
104901 +um_idi_write_18293 um_idi_write 3 18293 NULL
104902 +nouveau_disp_create__18305 nouveau_disp_create_ 4-7 18305 NULL
104903 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
104904 +vga_r_18310 vga_r 0 18310 NULL
104905 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
104906 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
104907 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
104908 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
104909 +SyS_process_vm_readv_18366 SyS_process_vm_readv 3-5 18366 NULL
104910 +ep_io_18367 ep_io 0 18367 NULL
104911 +qib_user_sdma_num_pages_18371 qib_user_sdma_num_pages 0 18371 NULL
104912 +ci_role_write_18388 ci_role_write 3 18388 NULL
104913 +__video_register_device_18399 __video_register_device 3 18399 NULL
104914 +hash_ip4_expire_18402 hash_ip4_expire 3 18402 NULL nohasharray
104915 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 &hash_ip4_expire_18402
104916 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
104917 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
104918 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL nohasharray
104919 +iscsi_create_flashnode_sess_18433 iscsi_create_flashnode_sess 4 18433 &batadv_orig_node_add_if_18433
104920 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
104921 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
104922 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
104923 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
104924 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
104925 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
104926 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
104927 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
104928 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
104929 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
104930 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
104931 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
104932 +debug_output_18575 debug_output 3 18575 NULL
104933 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
104934 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
104935 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
104936 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
104937 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
104938 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
104939 +from_buffer_18625 from_buffer 3 18625 NULL
104940 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
104941 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
104942 +unmap_page_18665 unmap_page 2-3 18665 NULL
104943 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 NULL
104944 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
104945 +unlocked_compat_ipmi_ioctl_18708 unlocked_compat_ipmi_ioctl 3 18708 NULL nohasharray
104946 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 &unlocked_compat_ipmi_ioctl_18708
104947 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
104948 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
104949 +compat_SyS_writev_18712 compat_SyS_writev 3 18712 NULL
104950 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
104951 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
104952 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
104953 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
104954 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
104955 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
104956 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
104957 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
104958 +SyS_lsetxattr_18776 SyS_lsetxattr 4 18776 NULL
104959 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
104960 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
104961 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
104962 +madvise_hwpoison_18812 madvise_hwpoison 2 18812 NULL
104963 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
104964 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
104965 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
104966 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
104967 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
104968 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
104969 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
104970 +___alloc_bootmem_node_18882 ___alloc_bootmem_node 2-3 18882 NULL
104971 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
104972 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
104973 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
104974 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
104975 +regcache_sync_block_18963 regcache_sync_block 3-4 18963 NULL
104976 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
104977 +gfn_to_pfn_atomic_18981 gfn_to_pfn_atomic 2 18981 NULL
104978 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
104979 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
104980 +huge_page_size_19008 huge_page_size 0 19008 NULL
104981 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
104982 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
104983 +revalidate_19043 revalidate 2 19043 NULL
104984 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
104985 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
104986 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
104987 +msix_map_region_19072 msix_map_region 2 19072 NULL
104988 +ceph_create_snap_context_19082 ceph_create_snap_context 1 19082 NULL
104989 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
104990 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
104991 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
104992 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
104993 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
104994 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
104995 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
104996 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
104997 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
104998 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
104999 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
105000 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
105001 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
105002 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
105003 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
105004 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
105005 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
105006 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
105007 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
105008 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
105009 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
105010 +qc_capture_19298 qc_capture 3 19298 NULL
105011 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
105012 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
105013 +gfn_to_gpa_19320 gfn_to_gpa 0-1 19320 NULL
105014 +debug_read_19322 debug_read 3 19322 NULL
105015 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
105016 +closure_sub_19359 closure_sub 2 19359 NULL
105017 +read_zero_19366 read_zero 3 19366 NULL
105018 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
105019 +sync_fill_pt_info_19397 sync_fill_pt_info 0 19397 NULL
105020 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
105021 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
105022 +__phys_addr_19434 __phys_addr 0 19434 NULL
105023 +SyS_sched_getaffinity_19444 SyS_sched_getaffinity 2 19444 NULL
105024 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
105025 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
105026 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
105027 +sky2_read16_19475 sky2_read16 0 19475 NULL
105028 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
105029 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
105030 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
105031 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
105032 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
105033 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
105034 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
105035 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
105036 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
105037 +nfsd_read_19568 nfsd_read 5 19568 NULL
105038 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
105039 +bm_status_read_19583 bm_status_read 3 19583 NULL
105040 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
105041 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
105042 +__mei_cl_recv_19636 __mei_cl_recv 3 19636 NULL
105043 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
105044 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
105045 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
105046 +bio_detain_19690 bio_detain 2 19690 NULL
105047 +mem_cgroup_swappiness_19718 mem_cgroup_swappiness 0 19718 NULL
105048 +read_reg_19723 read_reg 0 19723 NULL
105049 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
105050 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
105051 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
105052 +p9_client_read_19750 p9_client_read 5 19750 NULL
105053 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
105054 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
105055 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
105056 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
105057 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
105058 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
105059 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
105060 +vfs_getxattr_19832 vfs_getxattr 0 19832 NULL
105061 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
105062 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
105063 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
105064 +__nla_put_19857 __nla_put 3 19857 NULL
105065 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
105066 +mrp_request_join_19882 mrp_request_join 4 19882 NULL
105067 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
105068 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
105069 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
105070 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
105071 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
105072 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
105073 +SYSC_fgetxattr_20027 SYSC_fgetxattr 4 20027 NULL
105074 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
105075 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
105076 +btrfs_pin_extent_for_log_replay_20069 btrfs_pin_extent_for_log_replay 2 20069 NULL
105077 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
105078 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
105079 +team_options_register_20091 team_options_register 3 20091 NULL
105080 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
105081 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
105082 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
105083 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
105084 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
105085 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
105086 +crystalhd_map_dio_20181 crystalhd_map_dio 3 20181 NULL
105087 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
105088 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
105089 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
105090 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
105091 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
105092 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
105093 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
105094 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
105095 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
105096 +handle_arr_calc_size_20355 handle_arr_calc_size 0-1 20355 NULL
105097 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
105098 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
105099 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
105100 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
105101 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
105102 +xen_create_contiguous_region_20457 xen_create_contiguous_region 1 20457 NULL
105103 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
105104 +dec_zcache_pers_zpages_20465 dec_zcache_pers_zpages 1 20465 NULL
105105 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
105106 +read_buf_20469 read_buf 2 20469 NULL
105107 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
105108 +fast_user_write_20494 fast_user_write 5 20494 NULL
105109 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
105110 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
105111 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
105112 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
105113 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
105114 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
105115 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
105116 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
105117 +venus_create_20555 venus_create 4 20555 NULL
105118 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
105119 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
105120 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
105121 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
105122 +sync_timeline_create_20601 sync_timeline_create 2 20601 NULL
105123 +lirc_write_20604 lirc_write 3 20604 NULL
105124 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
105125 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
105126 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
105127 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
105128 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
105129 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
105130 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
105131 +get_user_page_nowait_20682 get_user_page_nowait 3 20682 NULL nohasharray
105132 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 &get_user_page_nowait_20682
105133 +cpumask_size_20683 cpumask_size 0 20683 NULL
105134 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
105135 +gru_vtop_20689 gru_vtop 2 20689 NULL
105136 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
105137 +__maestro_read_20700 __maestro_read 0 20700 NULL
105138 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
105139 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
105140 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
105141 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
105142 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
105143 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
105144 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
105145 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
105146 +brcmf_p2p_escan_20763 brcmf_p2p_escan 2 20763 NULL
105147 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
105148 +ext4_r_blocks_count_20768 ext4_r_blocks_count 0 20768 NULL
105149 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
105150 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
105151 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
105152 +sys_sendto_20809 sys_sendto 6 20809 NULL
105153 +cfv_alloc_and_copy_skb_20812 cfv_alloc_and_copy_skb 4 20812 NULL
105154 +strndup_user_20819 strndup_user 2 20819 NULL
105155 +calc_layout_20829 calc_layout 3 20829 NULL
105156 +dtf_read_channel_20831 dtf_read_channel 3 20831 NULL
105157 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
105158 +uvc_alloc_entity_20836 uvc_alloc_entity 3-4 20836 NULL
105159 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
105160 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
105161 +skb_tail_pointer_20878 skb_tail_pointer 0 20878 NULL
105162 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
105163 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
105164 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
105165 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
105166 +htable_bits_20933 htable_bits 0 20933 NULL
105167 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
105168 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
105169 +nfs_map_name_to_uid_20962 nfs_map_name_to_uid 3 20962 NULL
105170 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
105171 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
105172 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
105173 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
105174 +ceph_osdc_new_request_21017 ceph_osdc_new_request 14-4 21017 NULL
105175 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
105176 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
105177 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
105178 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
105179 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
105180 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
105181 +multipath_status_21094 multipath_status 5 21094 NULL
105182 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
105183 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
105184 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
105185 +bitset_size_in_bytes_21124 bitset_size_in_bytes 0-1 21124 NULL
105186 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
105187 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
105188 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
105189 +alloc_pg_vec_21159 alloc_pg_vec 3 21159 NULL
105190 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
105191 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
105192 +scsi_execute_req_flags_21215 scsi_execute_req_flags 5 21215 NULL
105193 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
105194 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
105195 +SyS_mlock_21238 SyS_mlock 1 21238 NULL
105196 +input_ff_create_21240 input_ff_create 2 21240 NULL
105197 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
105198 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
105199 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
105200 +make_alloc_exact_21279 make_alloc_exact 1-3 21279 NULL
105201 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
105202 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
105203 +add_res_range_21310 add_res_range 4 21310 NULL
105204 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
105205 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
105206 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
105207 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
105208 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
105209 +SYSC_rt_sigpending_21379 SYSC_rt_sigpending 2 21379 NULL
105210 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
105211 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
105212 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
105213 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
105214 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
105215 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
105216 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
105217 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
105218 +concat_writev_21451 concat_writev 3 21451 NULL
105219 +mei_nfc_send_21477 mei_nfc_send 3 21477 NULL
105220 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
105221 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
105222 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
105223 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
105224 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
105225 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
105226 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
105227 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
105228 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
105229 +compat_SyS_pwritev64_21606 compat_SyS_pwritev64 3 21606 NULL
105230 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
105231 +validate_nnode_21638 validate_nnode 0 21638 NULL
105232 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
105233 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
105234 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
105235 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
105236 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
105237 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
105238 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
105239 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
105240 +vm_brk_21739 vm_brk 1 21739 NULL
105241 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
105242 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
105243 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
105244 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
105245 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
105246 +min_odd_21802 min_odd 0 21802 NULL
105247 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
105248 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
105249 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
105250 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
105251 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
105252 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
105253 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
105254 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
105255 +xen_swiotlb_map_page_21886 xen_swiotlb_map_page 3 21886 NULL
105256 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
105257 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
105258 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
105259 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
105260 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
105261 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
105262 +SYSC_prctl_21980 SYSC_prctl 4 21980 NULL
105263 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
105264 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
105265 +regcache_sync_block_raw_flush_22021 regcache_sync_block_raw_flush 3-4 22021 NULL
105266 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
105267 +_sp2d_min_pg_22032 _sp2d_min_pg 0 22032 NULL
105268 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
105269 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
105270 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
105271 +write_opcode_22082 write_opcode 2 22082 NULL
105272 +mem_rw_22085 mem_rw 3 22085 NULL
105273 +is_swbp_at_addr_22089 is_swbp_at_addr 2 22089 NULL
105274 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
105275 +sched_clock_cpu_22098 sched_clock_cpu 0 22098 NULL
105276 +qlcnic_sriov_pf_enable_22103 qlcnic_sriov_pf_enable 2 22103 NULL
105277 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
105278 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
105279 +compat_insn_22142 compat_insn 2 22142 NULL
105280 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
105281 +__kfifo_alloc_22173 __kfifo_alloc 3 22173 NULL
105282 +fls_22210 fls 0 22210 NULL
105283 +mem_write_22232 mem_write 3 22232 NULL
105284 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
105285 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
105286 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
105287 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
105288 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
105289 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
105290 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
105291 +extend_brk_22301 extend_brk 0 22301 NULL
105292 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
105293 +C_SYSC_msgrcv_22320 C_SYSC_msgrcv 2-3 22320 NULL
105294 +get_segment_base_22324 get_segment_base 0 22324 NULL
105295 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
105296 +atomic_read_22342 atomic_read 0 22342 NULL
105297 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
105298 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL nohasharray
105299 +memcg_size_22360 memcg_size 0 22360 &irq_reserve_irq_22360
105300 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
105301 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 NULL
105302 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
105303 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
105304 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
105305 +crash_shrink_memory_22401 crash_shrink_memory 1 22401 NULL
105306 +zoran_write_22404 zoran_write 3 22404 NULL
105307 +queue_reply_22416 queue_reply 3 22416 NULL
105308 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
105309 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
105310 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
105311 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
105312 +batadv_check_unicast_packet_22468 batadv_check_unicast_packet 3 22468 NULL
105313 +dtf_write_device_22471 dtf_write_device 3 22471 NULL
105314 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
105315 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
105316 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
105317 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
105318 +swiotlb_tbl_unmap_single_22522 swiotlb_tbl_unmap_single 2 22522 NULL nohasharray
105319 +usb_dump_config_descriptor_22522 usb_dump_config_descriptor 0 22522 &swiotlb_tbl_unmap_single_22522
105320 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
105321 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
105322 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
105323 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
105324 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
105325 +snapshot_read_22601 snapshot_read 3 22601 NULL
105326 +remove_breakpoint_22628 remove_breakpoint 3 22628 NULL
105327 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
105328 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
105329 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
105330 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
105331 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
105332 +compat_SyS_msgrcv_22661 compat_SyS_msgrcv 2-3 22661 NULL
105333 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
105334 +qlcnic_83xx_sysfs_flash_write_handler_22680 qlcnic_83xx_sysfs_flash_write_handler 6 22680 NULL
105335 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
105336 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
105337 +map_22700 map 2 22700 NULL
105338 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
105339 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
105340 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
105341 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL nohasharray
105342 +__mei_cl_send_22738 __mei_cl_send 3 22738 &ceph_decode_32_22738
105343 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
105344 +qlcnic_sriov_init_22762 qlcnic_sriov_init 2 22762 NULL
105345 +print_frame_22769 print_frame 0 22769 NULL
105346 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
105347 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
105348 +clone_bio_integrity_22842 clone_bio_integrity 4 22842 NULL
105349 +read_file_rcstat_22854 read_file_rcstat 3 22854 NULL
105350 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
105351 +create_attr_set_22861 create_attr_set 1 22861 NULL
105352 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
105353 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
105354 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
105355 +policy_emit_config_values_22900 policy_emit_config_values 3 22900 NULL
105356 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
105357 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
105358 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
105359 +vme_get_size_22964 vme_get_size 0 22964 NULL
105360 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
105361 +page_table_range_init_count_22977 page_table_range_init_count 0 22977 NULL
105362 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
105363 +set_msr_hyperv_22985 set_msr_hyperv 3 22985 NULL
105364 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
105365 +brcmf_sdio_chip_exit_download_23001 brcmf_sdio_chip_exit_download 4 23001 NULL
105366 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
105367 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
105368 +st_status_23032 st_status 5 23032 NULL
105369 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
105370 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
105371 +mei_cl_send_23068 mei_cl_send 3 23068 NULL
105372 +kvm_mmu_gva_to_gpa_write_23075 kvm_mmu_gva_to_gpa_write 0 23075 NULL
105373 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
105374 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
105375 +get_user_hdr_len_23079 get_user_hdr_len 0 23079 NULL
105376 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
105377 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
105378 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
105379 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
105380 +fls_long_23096 fls_long 0 23096 NULL
105381 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
105382 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
105383 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
105384 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
105385 +__clear_user_23118 __clear_user 0 23118 NULL
105386 +dm_write_async_23120 dm_write_async 3 23120 NULL
105387 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
105388 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
105389 +read_file_ani_23161 read_file_ani 3 23161 NULL
105390 +ioremap_23172 ioremap 1-2 23172 NULL
105391 +tg_get_cfs_quota_23176 tg_get_cfs_quota 0 23176 NULL
105392 +usblp_write_23178 usblp_write 3 23178 NULL
105393 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
105394 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
105395 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
105396 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
105397 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
105398 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
105399 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
105400 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
105401 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
105402 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
105403 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
105404 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
105405 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
105406 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
105407 +doc_probe_23285 doc_probe 1 23285 NULL
105408 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
105409 +perf_mmap_free_page_23302 perf_mmap_free_page 1 23302 NULL
105410 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
105411 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
105412 +page_readlink_23346 page_readlink 3 23346 NULL
105413 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
105414 +fd_setup_write_same_buf_23369 fd_setup_write_same_buf 3 23369 NULL
105415 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
105416 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
105417 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
105418 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 NULL
105419 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
105420 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
105421 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
105422 +event_filter_read_23494 event_filter_read 3 23494 NULL
105423 +__gfn_to_hva_many_23508 __gfn_to_hva_many 0-2 23508 NULL
105424 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
105425 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
105426 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
105427 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
105428 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
105429 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
105430 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
105431 +do_mmap_pgoff_23600 do_mmap_pgoff 0 23600 NULL
105432 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
105433 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
105434 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
105435 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
105436 +sInW_23663 sInW 0 23663 NULL
105437 +SyS_connect_23669 SyS_connect 3 23669 NULL
105438 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
105439 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
105440 +cx18_read_23699 cx18_read 3 23699 NULL
105441 +isku_sysfs_write_control_23718 isku_sysfs_write_control 6 23718 NULL
105442 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
105443 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
105444 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
105445 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
105446 +__build_packet_message_23778 __build_packet_message 10-4 23778 NULL
105447 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
105448 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
105449 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
105450 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2-3 23824 NULL
105451 +ceph_copy_page_vector_to_user_23829 ceph_copy_page_vector_to_user 3-4 23829 NULL
105452 +tfrc_binsearch_23833 tfrc_binsearch 0 23833 NULL
105453 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
105454 +pgdat_end_pfn_23842 pgdat_end_pfn 0 23842 NULL
105455 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
105456 +p54_init_common_23850 p54_init_common 1 23850 NULL
105457 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
105458 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
105459 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
105460 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
105461 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
105462 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
105463 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
105464 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
105465 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
105466 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
105467 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
105468 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
105469 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
105470 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
105471 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
105472 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
105473 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
105474 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
105475 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
105476 +adis16400_show_serial_number_24037 adis16400_show_serial_number 3 24037 NULL
105477 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
105478 +brcmf_sdio_ramrw_24074 brcmf_sdio_ramrw 5 24074 NULL
105479 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
105480 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
105481 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
105482 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
105483 +mpu401_read_24126 mpu401_read 3 24126 NULL
105484 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
105485 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
105486 +set_discard_24162 set_discard 2 24162 NULL
105487 +adu_read_24177 adu_read 3 24177 NULL
105488 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
105489 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
105490 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
105491 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
105492 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
105493 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
105494 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
105495 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
105496 +dm_cache_save_hint_24257 dm_cache_save_hint 2 24257 NULL
105497 +em28xx_alloc_urbs_24260 em28xx_alloc_urbs 4-6 24260 NULL
105498 +thin_status_24278 thin_status 5 24278 NULL
105499 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
105500 +msg_size_24288 msg_size 0 24288 NULL
105501 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
105502 +map_page_24298 map_page 3-4 24298 NULL
105503 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
105504 +reserve_metadata_bytes_24313 reserve_metadata_bytes 3 24313 NULL
105505 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
105506 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
105507 +si476x_radio_read_acf_blob_24336 si476x_radio_read_acf_blob 3 24336 NULL
105508 +C_SYSC_pwritev_24345 C_SYSC_pwritev 3 24345 NULL
105509 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
105510 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
105511 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
105512 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
105513 +igetword_24373 igetword 0 24373 NULL
105514 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
105515 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
105516 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
105517 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
105518 +iwl_nvm_read_section_24438 iwl_nvm_read_section 0 24438 NULL
105519 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
105520 +smk_user_access_24440 smk_user_access 3 24440 NULL
105521 +page_address_24444 page_address 0 24444 NULL
105522 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
105523 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
105524 +read_file_spec_scan_ctl_24491 read_file_spec_scan_ctl 3 24491 NULL
105525 +pd_video_read_24510 pd_video_read 3 24510 NULL
105526 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
105527 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
105528 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
105529 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
105530 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
105531 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
105532 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
105533 +count_preds_24600 count_preds 0 24600 NULL
105534 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
105535 +kvm_pv_enable_async_pf_24637 kvm_pv_enable_async_pf 2 24637 NULL
105536 +context_alloc_24645 context_alloc 3 24645 NULL
105537 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
105538 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
105539 +read_fs_24717 read_fs 0 24717 NULL
105540 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
105541 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
105542 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
105543 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
105544 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
105545 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
105546 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
105547 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
105548 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
105549 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
105550 +cache_read_24790 cache_read 3 24790 NULL
105551 +unpack_str_24798 unpack_str 0 24798 NULL
105552 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
105553 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
105554 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
105555 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
105556 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
105557 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
105558 +setup_buffering_24872 setup_buffering 3 24872 NULL
105559 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
105560 +queues_read_24877 queues_read 3 24877 NULL nohasharray
105561 +symbol_string_24877 symbol_string 0 24877 &queues_read_24877
105562 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
105563 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
105564 +next_token_24929 next_token 0 24929 NULL
105565 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
105566 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
105567 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
105568 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
105569 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
105570 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
105571 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
105572 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
105573 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
105574 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
105575 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
105576 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
105577 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
105578 +SYSC_listxattr_25072 SYSC_listxattr 3 25072 NULL
105579 +ceph_osdc_writepages_25085 ceph_osdc_writepages 5 25085 NULL
105580 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
105581 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
105582 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
105583 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
105584 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
105585 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
105586 +free_memcg_kmem_pages_25228 free_memcg_kmem_pages 1 25228 NULL
105587 +dtf_write_string_25232 dtf_write_string 5 25232 NULL
105588 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
105589 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
105590 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
105591 +stripe_status_25259 stripe_status 5 25259 NULL
105592 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
105593 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
105594 +vfs_writev_25278 vfs_writev 3 25278 NULL
105595 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
105596 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
105597 +help_25316 help 5 25316 NULL nohasharray
105598 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
105599 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
105600 +SYSC_kexec_load_25361 SYSC_kexec_load 2 25361 NULL
105601 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
105602 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
105603 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
105604 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
105605 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
105606 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
105607 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
105608 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
105609 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
105610 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
105611 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
105612 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
105613 +sb_permission_25523 sb_permission 0 25523 NULL
105614 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
105615 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
105616 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
105617 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
105618 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
105619 +find_extend_vma_25597 find_extend_vma 2 25597 NULL
105620 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
105621 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
105622 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
105623 +__get_user_pages_25628 __get_user_pages 0-3-4 25628 NULL nohasharray
105624 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
105625 +__direct_map_25647 __direct_map 5-6 25647 NULL
105626 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
105627 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
105628 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
105629 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
105630 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
105631 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
105632 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
105633 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2-3 25726 &sel_write_context_25726
105634 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
105635 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
105636 +__set_clear_dirty_25744 __set_clear_dirty 2 25744 NULL
105637 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
105638 +dtf_write_channel_25748 dtf_write_channel 3 25748 NULL
105639 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
105640 +sg_read_25799 sg_read 3 25799 NULL
105641 +system_enable_read_25815 system_enable_read 3 25815 NULL
105642 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
105643 +mthca_map_user_db_25823 mthca_map_user_db 5 25823 NULL
105644 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
105645 +parport_read_25855 parport_read 0 25855 NULL
105646 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
105647 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
105648 +key_attr_size_25865 key_attr_size 0 25865 NULL
105649 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
105650 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
105651 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
105652 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
105653 +nvme_trans_mode_page_create_25908 nvme_trans_mode_page_create 7 25908 NULL
105654 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
105655 +rcname_read_25919 rcname_read 3 25919 NULL
105656 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
105657 +key_flags_read_25931 key_flags_read 3 25931 NULL
105658 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
105659 +flush_25957 flush 2 25957 NULL
105660 +video_register_device_25971 video_register_device 3 25971 NULL
105661 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
105662 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
105663 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
105664 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
105665 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
105666 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
105667 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
105668 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
105669 +tun_do_read_26047 tun_do_read 5 26047 NULL
105670 +__alloc_memory_core_early_26053 __alloc_memory_core_early 2-3 26053 NULL
105671 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
105672 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
105673 +skb_cow_26138 skb_cow 2 26138 NULL
105674 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
105675 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
105676 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
105677 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
105678 +perf_adjust_period_26168 perf_adjust_period 2-3 26168 NULL
105679 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
105680 +disk_devt_26180 disk_devt 0 26180 NULL
105681 +get_registers_26187 get_registers 3 26187 NULL
105682 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
105683 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
105684 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
105685 +mce_write_26201 mce_write 3 26201 NULL
105686 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
105687 +bio_split_26235 bio_split 2 26235 NULL
105688 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
105689 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
105690 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
105691 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
105692 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
105693 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
105694 +efx_rx_mk_skb_26342 efx_rx_mk_skb 5 26342 NULL
105695 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
105696 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
105697 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
105698 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
105699 +dma_declare_contiguous_26455 dma_declare_contiguous 2 26455 NULL
105700 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
105701 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
105702 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
105703 +read_vmcore_26501 read_vmcore 3 26501 NULL
105704 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
105705 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
105706 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
105707 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
105708 +kvm_iommu_put_pages_26571 kvm_iommu_put_pages 2 26571 NULL
105709 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
105710 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
105711 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
105712 +regcache_set_reg_present_26598 regcache_set_reg_present 2 26598 NULL
105713 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
105714 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
105715 +pack_value_26625 pack_value 1 26625 NULL
105716 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
105717 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
105718 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
105719 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
105720 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
105721 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
105722 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
105723 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
105724 +SyS_fcntl_26737 SyS_fcntl 3 26737 NULL
105725 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
105726 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
105727 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
105728 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
105729 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
105730 +iwl_trans_read_mem32_26825 iwl_trans_read_mem32 0 26825 NULL
105731 +smk_write_load_26829 smk_write_load 3 26829 NULL
105732 +sizeof_pwm_leds_priv_26830 sizeof_pwm_leds_priv 0-1 26830 NULL
105733 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
105734 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
105735 +scnprint_id_26842 scnprint_id 3 26842 NULL
105736 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
105737 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
105738 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
105739 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
105740 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
105741 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
105742 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
105743 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
105744 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
105745 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
105746 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
105747 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
105748 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
105749 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
105750 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
105751 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
105752 +swiotlb_bounce_27046 swiotlb_bounce 2-1 27046 NULL
105753 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
105754 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
105755 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
105756 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
105757 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
105758 +compat_SyS_rt_sigpending_27084 compat_SyS_rt_sigpending 2 27084 NULL
105759 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
105760 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
105761 +nes_reg_user_mr_27106 nes_reg_user_mr 2-3 27106 NULL
105762 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
105763 +SYSC_ipc_27123 SYSC_ipc 3 27123 NULL
105764 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
105765 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
105766 +pms_capture_27142 pms_capture 4 27142 NULL
105767 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
105768 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
105769 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
105770 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
105771 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
105772 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
105773 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
105774 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
105775 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
105776 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
105777 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
105778 +virtqueue_add_inbuf_27312 virtqueue_add_inbuf 3 27312 NULL nohasharray
105779 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 &virtqueue_add_inbuf_27312
105780 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
105781 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
105782 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
105783 +compat_SyS_semctl_27349 compat_SyS_semctl 4 27349 NULL
105784 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
105785 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
105786 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
105787 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
105788 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
105789 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
105790 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
105791 +ktime_to_us_27455 ktime_to_us 0 27455 NULL
105792 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
105793 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
105794 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
105795 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
105796 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
105797 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
105798 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
105799 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
105800 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
105801 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
105802 +SyS_fgetxattr_27571 SyS_fgetxattr 4 27571 NULL
105803 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
105804 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
105805 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
105806 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
105807 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
105808 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
105809 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
105810 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
105811 +qword_get_27670 qword_get 0 27670 NULL
105812 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
105813 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
105814 +inc_zcache_eph_zbytes_27704 inc_zcache_eph_zbytes 1 27704 NULL
105815 +evm_write_key_27715 evm_write_key 3 27715 NULL
105816 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
105817 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
105818 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
105819 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
105820 +SyS_setsockopt_27759 SyS_setsockopt 5 27759 NULL
105821 +kcalloc_27770 kcalloc 1-2 27770 NULL
105822 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
105823 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
105824 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
105825 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
105826 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
105827 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
105828 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
105829 +read_profile_27859 read_profile 3 27859 NULL
105830 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
105831 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
105832 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
105833 +gluebi_write_27905 gluebi_write 3 27905 NULL
105834 +SyS_ptrace_27924 SyS_ptrace 3-4 27924 NULL
105835 +bm_find_next_27929 bm_find_next 2 27929 NULL
105836 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
105837 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
105838 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
105839 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
105840 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
105841 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
105842 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
105843 +alloc_one_pg_vec_page_28031 alloc_one_pg_vec_page 1 28031 NULL
105844 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
105845 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
105846 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
105847 +pool_status_28055 pool_status 5 28055 NULL
105848 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
105849 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
105850 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
105851 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
105852 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
105853 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
105854 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
105855 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
105856 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
105857 +video_read_28148 video_read 3 28148 NULL
105858 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
105859 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
105860 +vread_28173 vread 0 28173 NULL
105861 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
105862 +d_path_28198 d_path 0 28198 NULL
105863 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
105864 +__qp_memcpy_from_queue_28220 __qp_memcpy_from_queue 3-4 28220 NULL
105865 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
105866 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
105867 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
105868 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
105869 +usemap_size_28281 usemap_size 0 28281 NULL
105870 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
105871 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
105872 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
105873 +__mlock_vma_pages_range_28315 __mlock_vma_pages_range 2-3 28315 NULL
105874 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
105875 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
105876 +snapshot_write_28351 snapshot_write 3 28351 NULL
105877 +sys_writev_28384 sys_writev 3 28384 NULL
105878 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
105879 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
105880 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
105881 +bypass_pwup_write_28416 bypass_pwup_write 3 28416 NULL
105882 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
105883 +__split_large_page_28429 __split_large_page 2 28429 NULL
105884 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
105885 +set_memory_uc_28439 set_memory_uc 1 28439 NULL
105886 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
105887 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
105888 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
105889 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
105890 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
105891 +max_response_pages_28492 max_response_pages 0 28492 NULL
105892 +clear_discard_28494 clear_discard 2 28494 NULL
105893 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
105894 +__next_node_28521 __next_node 1 28521 NULL
105895 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
105896 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
105897 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
105898 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
105899 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
105900 +asymmetric_verify_28567 asymmetric_verify 3 28567 NULL
105901 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
105902 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
105903 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
105904 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
105905 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
105906 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
105907 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
105908 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
105909 +_set_range_28627 _set_range 3 28627 NULL
105910 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
105911 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
105912 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
105913 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
105914 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
105915 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
105916 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
105917 +spi_execute_28736 spi_execute 5 28736 NULL
105918 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
105919 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
105920 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
105921 +max_hw_blocks_28748 max_hw_blocks 0 28748 NULL
105922 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
105923 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
105924 +btrfs_block_rsv_refill_28800 btrfs_block_rsv_refill 3 28800 NULL nohasharray
105925 +sel_write_member_28800 sel_write_member 3 28800 &btrfs_block_rsv_refill_28800
105926 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
105927 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0 28809 NULL
105928 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
105929 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
105930 +C_SYSC_shmat_28843 C_SYSC_shmat 2 28843 NULL
105931 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
105932 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
105933 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
105934 +to_cblock_28899 to_cblock 0-1 28899 NULL
105935 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
105936 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
105937 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
105938 +push_rx_28939 push_rx 3 28939 NULL
105939 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
105940 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
105941 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
105942 +bin_uuid_28999 bin_uuid 3 28999 NULL
105943 +offset_to_bitmap_29004 offset_to_bitmap 2 29004 NULL
105944 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
105945 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
105946 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
105947 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
105948 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
105949 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
105950 +memblock_alloc_base_nid_29072 memblock_alloc_base_nid 1-2 29072 NULL
105951 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
105952 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
105953 +i915_error_object_create_sized_29091 i915_error_object_create_sized 3 29091 NULL
105954 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
105955 +snprintf_29125 snprintf 0 29125 NULL
105956 +iov_shorten_29130 iov_shorten 0 29130 NULL
105957 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
105958 +reshape_ring_29147 reshape_ring 2 29147 NULL
105959 +alloc_irqs_from_29152 alloc_irqs_from 1-2 29152 NULL
105960 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
105961 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
105962 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
105963 +__mm_populate_29204 __mm_populate 1 29204 NULL
105964 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
105965 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
105966 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
105967 +nvme_trans_copy_from_user_29227 nvme_trans_copy_from_user 3 29227 NULL
105968 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
105969 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
105970 +recover_peb_29238 recover_peb 6-7 29238 NULL
105971 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
105972 +block_div_29268 block_div 0-1-2 29268 NULL
105973 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
105974 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
105975 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
105976 +__fuse_get_req_29315 __fuse_get_req 2 29315 NULL
105977 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
105978 +tun_put_user_29337 tun_put_user 5 29337 NULL
105979 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
105980 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
105981 +ktime_us_delta_29375 ktime_us_delta 0 29375 NULL
105982 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
105983 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
105984 +mempool_create_29437 mempool_create 1 29437 NULL
105985 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
105986 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
105987 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
105988 +SyS_flistxattr_29474 SyS_flistxattr 3 29474 NULL
105989 +do_register_entry_29478 do_register_entry 4 29478 NULL
105990 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
105991 +sched_clock_local_29498 sched_clock_local 0 29498 NULL
105992 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
105993 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
105994 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
105995 +_regmap_raw_write_29541 _regmap_raw_write 4-2 29541 NULL
105996 +set_brk_29551 set_brk 1 29551 NULL nohasharray
105997 +ftrace_write_29551 ftrace_write 3 29551 &set_brk_29551
105998 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
105999 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
106000 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
106001 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
106002 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
106003 +slots_per_page_29601 slots_per_page 0 29601 NULL
106004 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
106005 +alloc_low_pages_29623 alloc_low_pages 1 29623 NULL
106006 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
106007 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
106008 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
106009 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
106010 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
106011 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
106012 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
106013 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
106014 +probes_write_29711 probes_write 3 29711 NULL
106015 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
106016 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
106017 +std_nic_write_29752 std_nic_write 3 29752 NULL
106018 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 NULL
106019 +tcf_csum_ipv6_icmp_29777 tcf_csum_ipv6_icmp 3 29777 NULL
106020 +dbAlloc_29794 dbAlloc 0 29794 NULL
106021 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
106022 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
106023 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
106024 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
106025 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
106026 +solo_enc_alloc_29860 solo_enc_alloc 3 29860 NULL
106027 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
106028 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
106029 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
106030 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
106031 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
106032 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
106033 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
106034 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
106035 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
106036 +vmci_host_setup_notify_30002 vmci_host_setup_notify 2 30002 NULL
106037 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
106038 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
106039 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
106040 +drp_wmove_30043 drp_wmove 4 30043 NULL
106041 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
106042 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
106043 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
106044 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL nohasharray
106045 +dma_to_phys_30098 dma_to_phys 0-2 30098 &rx_filter_data_filter_read_30098
106046 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
106047 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
106048 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
106049 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
106050 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
106051 +btrfs_start_transaction_lflush_30178 btrfs_start_transaction_lflush 2 30178 NULL
106052 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
106053 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
106054 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
106055 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
106056 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
106057 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
106058 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
106059 +f2fs_compat_ioctl_30261 f2fs_compat_ioctl 3 30261 NULL
106060 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
106061 +compat_readv_30273 compat_readv 3 30273 NULL
106062 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
106063 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
106064 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
106065 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
106066 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
106067 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
106068 +resource_from_user_30341 resource_from_user 3 30341 NULL
106069 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
106070 +C_SYSC_readv_30369 C_SYSC_readv 3 30369 NULL
106071 +sys_get_mempolicy_30379 sys_get_mempolicy 3-4 30379 NULL
106072 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
106073 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
106074 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
106075 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
106076 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
106077 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
106078 +mq_create_30425 mq_create 1 30425 NULL
106079 +enable_write_30456 enable_write 3 30456 NULL
106080 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
106081 +urandom_read_30462 urandom_read 3 30462 NULL
106082 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
106083 +ocrdma_reg_user_mr_30474 ocrdma_reg_user_mr 2-3 30474 NULL
106084 +write_head_30481 write_head 4 30481 NULL
106085 +adu_write_30487 adu_write 3 30487 NULL
106086 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
106087 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
106088 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
106089 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
106090 +set_le_30581 set_le 4 30581 NULL
106091 +from_cblock_30582 from_cblock 0-1 30582 NULL
106092 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
106093 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
106094 +sgl_map_user_pages_30610 sgl_map_user_pages 2-3-4 30610 NULL
106095 +SyS_msgrcv_30611 SyS_msgrcv 3 30611 NULL
106096 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
106097 +ieee80211_if_read_dot11MeshAwakeWindowDuration_30631 ieee80211_if_read_dot11MeshAwakeWindowDuration 3 30631 NULL
106098 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
106099 +agp_remap_30665 agp_remap 2 30665 NULL
106100 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
106101 +il_free_pages_30692 il_free_pages 2 30692 NULL
106102 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
106103 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
106104 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
106105 +snapshot_status_30744 snapshot_status 5 30744 NULL
106106 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
106107 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
106108 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
106109 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
106110 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL
106111 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
106112 +trace_probe_nr_files_30882 trace_probe_nr_files 0 30882 NULL
106113 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
106114 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
106115 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
106116 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
106117 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
106118 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
106119 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
106120 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
106121 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
106122 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
106123 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
106124 +sys_mincore_31079 sys_mincore 1 31079 NULL
106125 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
106126 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
106127 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3-4 31109 NULL
106128 +depth_read_31112 depth_read 3 31112 NULL
106129 +ssb_read16_31139 ssb_read16 0 31139 NULL
106130 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
106131 +size_inside_page_31141 size_inside_page 0 31141 NULL
106132 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
106133 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
106134 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
106135 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
106136 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
106137 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
106138 +kvm_mmu_page_fault_31213 kvm_mmu_page_fault 2 31213 NULL
106139 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
106140 +__read_reg_31216 __read_reg 0 31216 NULL
106141 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
106142 +cyy_readb_31240 cyy_readb 0 31240 NULL
106143 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
106144 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
106145 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
106146 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
106147 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
106148 +command_file_write_31318 command_file_write 3 31318 NULL
106149 +em28xx_init_usb_xfer_31337 em28xx_init_usb_xfer 4-6 31337 NULL
106150 +__cpu_to_node_31345 __cpu_to_node 0 31345 NULL
106151 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
106152 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3-2 31374 NULL
106153 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
106154 +inb_31388 inb 0 31388 NULL
106155 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
106156 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
106157 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
106158 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
106159 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
106160 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
106161 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
106162 +do_fcntl_31468 do_fcntl 3 31468 NULL
106163 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
106164 +alg_setkey_31485 alg_setkey 3 31485 NULL
106165 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
106166 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
106167 +__alloc_bootmem_31498 __alloc_bootmem 1-2 31498 NULL
106168 +rmode_tss_base_31510 rmode_tss_base 0 31510 NULL
106169 +hidraw_write_31536 hidraw_write 3 31536 NULL
106170 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
106171 +usbvision_read_31555 usbvision_read 3 31555 NULL
106172 +normalize_31566 normalize 0-1-2 31566 NULL
106173 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
106174 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
106175 +osst_write_31581 osst_write 3 31581 NULL
106176 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
106177 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
106178 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
106179 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
106180 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
106181 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
106182 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
106183 +emulator_set_cr_31665 emulator_set_cr 3 31665 NULL
106184 +__lgread_31668 __lgread 4 31668 NULL
106185 +symbol_string_31670 symbol_string 0 31670 NULL
106186 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
106187 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
106188 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
106189 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
106190 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL nohasharray
106191 +gfn_to_hva_read_31728 gfn_to_hva_read 2 31728 &ath6kl_wmi_send_probe_response_cmd_31728
106192 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
106193 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
106194 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
106195 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
106196 +muldiv64_31743 muldiv64 2-3 31743 NULL
106197 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
106198 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
106199 +set_memory_wb_31761 set_memory_wb 1 31761 NULL
106200 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
106201 +get_count_order_31800 get_count_order 0 31800 NULL
106202 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
106203 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
106204 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
106205 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
106206 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
106207 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
106208 +xattr_permission_31907 xattr_permission 0 31907 NULL
106209 +new_dir_31919 new_dir 3 31919 NULL
106210 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
106211 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
106212 +SYSC_sethostname_31940 SYSC_sethostname 2 31940 NULL
106213 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
106214 +vb2_write_31948 vb2_write 3 31948 NULL
106215 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
106216 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
106217 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
106218 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
106219 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
106220 +default_setup_hpet_msi_31991 default_setup_hpet_msi 1 31991 NULL
106221 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
106222 +calc_hmac_32010 calc_hmac 3 32010 NULL
106223 +vmcs_read64_32012 vmcs_read64 0 32012 NULL
106224 +aead_len_32021 aead_len 0 32021 NULL
106225 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
106226 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
106227 +stk_read_32038 stk_read 3 32038 NULL
106228 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
106229 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
106230 +SYSC_llistxattr_32061 SYSC_llistxattr 3 32061 NULL
106231 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
106232 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
106233 +bio_alloc_32095 bio_alloc 2 32095 NULL
106234 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
106235 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
106236 +disk_status_32120 disk_status 4 32120 NULL
106237 +venus_link_32165 venus_link 5 32165 NULL
106238 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
106239 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
106240 +load_header_32183 load_header 0 32183 NULL
106241 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
106242 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
106243 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
106244 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
106245 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
106246 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
106247 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
106248 +hex_string_32310 hex_string 0 32310 NULL
106249 +SyS_select_32319 SyS_select 1 32319 NULL
106250 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
106251 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
106252 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
106253 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
106254 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
106255 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
106256 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
106257 +local_clock_32385 local_clock 0 32385 NULL
106258 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
106259 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
106260 +vmci_qp_alloc_32405 vmci_qp_alloc 3-5 32405 NULL
106261 +log_text_32428 log_text 0 32428 NULL
106262 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
106263 +hid_input_report_32458 hid_input_report 4 32458 NULL
106264 +cache_status_32462 cache_status 5 32462 NULL
106265 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
106266 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
106267 +bypass_pwoff_write_32499 bypass_pwoff_write 3 32499 NULL
106268 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
106269 +disconnect_32521 disconnect 4 32521 NULL
106270 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
106271 +ilo_read_32531 ilo_read 3 32531 NULL
106272 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL
106273 +gnttab_set_unmap_op_32534 gnttab_set_unmap_op 2 32534 NULL
106274 +ieee80211_send_auth_32543 ieee80211_send_auth 6 32543 NULL
106275 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
106276 +__first_node_32558 __first_node 0 32558 NULL
106277 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
106278 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
106279 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
106280 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
106281 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
106282 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
106283 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
106284 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
106285 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
106286 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
106287 +kvmalloc_32646 kvmalloc 1 32646 NULL
106288 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
106289 +generic_readlink_32654 generic_readlink 3 32654 NULL
106290 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
106291 +compat_SyS_pwritev_32680 compat_SyS_pwritev 3 32680 NULL
106292 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
106293 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
106294 +get_arg_page_32746 get_arg_page 2 32746 NULL
106295 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
106296 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
106297 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
106298 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
106299 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
106300 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
106301 +vga_rseq_32848 vga_rseq 0 32848 NULL
106302 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
106303 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
106304 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
106305 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
106306 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
106307 +ext4_get_group_number_32899 ext4_get_group_number 0 32899 NULL
106308 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
106309 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
106310 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
106311 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
106312 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
106313 +arch_ptrace_32981 arch_ptrace 3-4 32981 NULL
106314 +compat_filldir_32999 compat_filldir 3 32999 NULL
106315 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL nohasharray
106316 +SyS_syslog_33007 SyS_syslog 3 33007 &ext3_alloc_blocks_33007
106317 +SYSC_lgetxattr_33049 SYSC_lgetxattr 4 33049 NULL
106318 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
106319 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
106320 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
106321 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
106322 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
106323 +alloc_tio_33077 alloc_tio 3 33077 NULL
106324 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
106325 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
106326 +write_node_33121 write_node 4 33121 NULL
106327 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
106328 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
106329 +__len_within_target_33132 __len_within_target 0 33132 NULL
106330 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
106331 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
106332 +pp_read_33210 pp_read 3 33210 NULL
106333 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
106334 +build_completion_wait_33242 build_completion_wait 2 33242 NULL
106335 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
106336 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
106337 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
106338 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
106339 +sync_pt_create_33282 sync_pt_create 2 33282 NULL
106340 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
106341 +isku_sysfs_read_keys_easyzone_33318 isku_sysfs_read_keys_easyzone 6 33318 NULL
106342 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
106343 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
106344 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
106345 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
106346 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
106347 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
106348 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
106349 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
106350 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
106351 +tg_get_cfs_period_33390 tg_get_cfs_period 0 33390 NULL
106352 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
106353 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
106354 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
106355 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
106356 +dis_tap_write_33426 dis_tap_write 3 33426 NULL
106357 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
106358 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
106359 +create_entry_33479 create_entry 2 33479 NULL
106360 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
106361 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
106362 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
106363 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
106364 +res_counter_read_33499 res_counter_read 4 33499 NULL
106365 +fb_read_33506 fb_read 3 33506 NULL
106366 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
106367 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
106368 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
106369 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
106370 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
106371 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
106372 +dup_array_33551 dup_array 3 33551 NULL
106373 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
106374 +count_subheaders_33591 count_subheaders 0 33591 NULL
106375 +scsi_execute_33596 scsi_execute 5 33596 NULL
106376 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
106377 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
106378 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
106379 +usb_gstrings_attach_33615 usb_gstrings_attach 3 33615 NULL nohasharray
106380 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 &usb_gstrings_attach_33615
106381 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
106382 +inw_p_33668 inw_p 0 33668 NULL
106383 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
106384 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
106385 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
106386 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
106387 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
106388 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
106389 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
106390 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
106391 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
106392 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
106393 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
106394 +Read_hfc_33755 Read_hfc 0 33755 NULL
106395 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
106396 +hashtab_create_33769 hashtab_create 3 33769 NULL
106397 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
106398 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
106399 +find_next_offset_33804 find_next_offset 3 33804 NULL
106400 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
106401 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
106402 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
106403 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
106404 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
106405 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
106406 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
106407 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
106408 +get_user_pages_33908 get_user_pages 0-3-4 33908 NULL
106409 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
106410 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
106411 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
106412 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
106413 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
106414 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
106415 +ppp_write_34034 ppp_write 3 34034 NULL
106416 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
106417 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
106418 +is_trap_at_addr_34047 is_trap_at_addr 2 34047 NULL
106419 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
106420 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
106421 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
106422 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
106423 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
106424 +proc_scsi_host_write_34107 proc_scsi_host_write 3 34107 NULL
106425 +is_discarded_oblock_34120 is_discarded_oblock 2 34120 NULL
106426 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
106427 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
106428 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
106429 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
106430 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
106431 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
106432 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
106433 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
106434 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
106435 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
106436 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
106437 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
106438 +__insert_34349 __insert 2-3 34349 NULL
106439 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
106440 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
106441 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
106442 +i2c_hid_get_raw_report_34376 i2c_hid_get_raw_report 0 34376 NULL
106443 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
106444 +ea_read_34378 ea_read 0 34378 NULL
106445 +fuse_send_read_34379 fuse_send_read 4 34379 NULL
106446 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
106447 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
106448 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
106449 +iwl_calib_set_34400 iwl_calib_set 3 34400 NULL nohasharray
106450 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 &iwl_calib_set_34400
106451 +wd_exp_mode_write_34407 wd_exp_mode_write 3 34407 NULL
106452 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
106453 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
106454 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
106455 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
106456 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
106457 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
106458 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
106459 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
106460 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
106461 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
106462 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
106463 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
106464 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
106465 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
106466 +brcmf_cfg80211_mgmt_tx_34608 brcmf_cfg80211_mgmt_tx 7 34608 NULL
106467 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
106468 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
106469 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
106470 +tomoyo_dump_page_34649 tomoyo_dump_page 2 34649 NULL
106471 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
106472 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
106473 +port_print_34704 port_print 3 34704 NULL
106474 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
106475 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
106476 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
106477 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
106478 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
106479 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
106480 +SYSC_keyctl_34800 SYSC_keyctl 4 34800 NULL
106481 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
106482 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
106483 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
106484 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
106485 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
106486 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
106487 +msg_print_text_34889 msg_print_text 0 34889 NULL
106488 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
106489 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
106490 +si476x_radio_read_rsq_primary_blob_34916 si476x_radio_read_rsq_primary_blob 3 34916 NULL
106491 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
106492 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
106493 +ceph_aio_write_34930 ceph_aio_write 4 34930 NULL
106494 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL nohasharray
106495 +i2c_transfer_34958 i2c_transfer 0 34958 &skb_gro_header_slow_34958
106496 +Realloc_34961 Realloc 2 34961 NULL
106497 +mq_lookup_34990 mq_lookup 2 34990 NULL
106498 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
106499 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
106500 +dm_cache_insert_mapping_35005 dm_cache_insert_mapping 2-3 35005 NULL
106501 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
106502 +alloc_p2m_page_35025 alloc_p2m_page 0 35025 NULL
106503 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
106504 +brcmf_sdio_chip_writenvram_35042 brcmf_sdio_chip_writenvram 4 35042 NULL
106505 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
106506 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
106507 +store_ifalias_35088 store_ifalias 4 35088 NULL
106508 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
106509 +capi_write_35104 capi_write 3 35104 NULL nohasharray
106510 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
106511 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
106512 +pointer_35138 pointer 0 35138 NULL
106513 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
106514 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
106515 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
106516 +solo_v4l2_init_35179 solo_v4l2_init 2 35179 NULL
106517 +mlx4_ib_get_cq_umem_35184 mlx4_ib_get_cq_umem 5-6 35184 NULL
106518 +iwl_nvm_read_chunk_35198 iwl_nvm_read_chunk 0 35198 NULL
106519 +uprobe_get_swbp_addr_35201 uprobe_get_swbp_addr 0 35201 NULL
106520 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
106521 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
106522 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
106523 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
106524 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 NULL nohasharray
106525 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 &rx_rx_cmplt_task_read_35226
106526 +gfn_to_page_many_atomic_35234 gfn_to_page_many_atomic 2 35234 NULL
106527 +SYSC_madvise_35241 SYSC_madvise 1 35241 NULL
106528 +set_fd_set_35249 set_fd_set 1 35249 NULL
106529 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
106530 +dis_disc_write_35265 dis_disc_write 3 35265 NULL
106531 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
106532 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
106533 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
106534 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
106535 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
106536 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
106537 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
106538 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
106539 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
106540 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
106541 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
106542 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
106543 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
106544 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
106545 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
106546 +SyS_getxattr_35408 SyS_getxattr 4 35408 NULL
106547 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
106548 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
106549 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
106550 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
106551 +ecryptfs_get_zeroed_pages_35483 ecryptfs_get_zeroed_pages 0 35483 NULL
106552 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
106553 +async_setkey_35521 async_setkey 3 35521 NULL
106554 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
106555 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
106556 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
106557 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
106558 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
106559 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
106560 +spk_msg_set_35586 spk_msg_set 3 35586 NULL
106561 +ReadZReg_35604 ReadZReg 0 35604 NULL
106562 +kernel_readv_35617 kernel_readv 3 35617 NULL
106563 +ixgbe_pci_sriov_configure_35624 ixgbe_pci_sriov_configure 2 35624 NULL
106564 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
106565 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
106566 +store_debug_level_35652 store_debug_level 3 35652 NULL
106567 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
106568 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
106569 +dm_table_create_35687 dm_table_create 3 35687 NULL
106570 +SYSC_pwritev_35690 SYSC_pwritev 3 35690 NULL
106571 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
106572 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
106573 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
106574 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
106575 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
106576 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
106577 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
106578 +fls64_35862 fls64 0 35862 NULL
106579 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
106580 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
106581 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
106582 +SyS_set_mempolicy_35909 SyS_set_mempolicy 3 35909 NULL
106583 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
106584 +rbio_nr_pages_35916 rbio_nr_pages 0-1-2 35916 NULL
106585 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
106586 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
106587 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
106588 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
106589 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
106590 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
106591 +acl_alloc_35979 acl_alloc 1 35979 NULL
106592 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
106593 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
106594 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
106595 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
106596 +__videobuf_alloc_36031 __videobuf_alloc 1 36031 NULL
106597 +account_shadowed_36048 account_shadowed 2 36048 NULL
106598 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
106599 +write_emulate_36065 write_emulate 2-4 36065 NULL
106600 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
106601 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
106602 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
106603 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
106604 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
106605 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
106606 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
106607 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
106608 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
106609 +max8925_irq_domain_map_36133 max8925_irq_domain_map 2 36133 NULL
106610 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
106611 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
106612 +twl_set_36154 twl_set 2 36154 NULL
106613 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
106614 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
106615 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
106616 +SyS_kexec_load_36176 SyS_kexec_load 2 36176 NULL
106617 +SYSC_sched_getaffinity_36208 SYSC_sched_getaffinity 2 36208 NULL
106618 +SYSC_process_vm_readv_36216 SYSC_process_vm_readv 3-5 36216 NULL
106619 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
106620 +is_dirty_36223 is_dirty 2 36223 NULL
106621 +dma_alloc_attrs_36225 dma_alloc_attrs 0 36225 NULL
106622 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
106623 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
106624 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
106625 +SYSC_getxattr_36242 SYSC_getxattr 4 36242 NULL
106626 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
106627 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
106628 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
106629 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
106630 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
106631 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
106632 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
106633 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
106634 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
106635 +fuse_get_user_addr_36312 fuse_get_user_addr 0 36312 NULL
106636 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
106637 +lc_create_36332 lc_create 4 36332 NULL
106638 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
106639 +isku_sysfs_read_key_mask_36343 isku_sysfs_read_key_mask 6 36343 NULL
106640 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
106641 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
106642 +to_sector_36361 to_sector 0-1 36361 NULL
106643 +tunables_read_36385 tunables_read 3 36385 NULL
106644 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
106645 +SyS_sethostname_36417 SyS_sethostname 2 36417 NULL
106646 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
106647 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
106648 +tcf_csum_ipv6_udp_36457 tcf_csum_ipv6_udp 3 36457 NULL
106649 +SyS_process_vm_writev_36476 SyS_process_vm_writev 3-5 36476 NULL
106650 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
106651 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
106652 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
106653 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
106654 +get_param_l_36518 get_param_l 0 36518 NULL
106655 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
106656 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
106657 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
106658 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
106659 +get_entry_len_36549 get_entry_len 0 36549 NULL
106660 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
106661 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
106662 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
106663 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
106664 +__erst_read_36579 __erst_read 0 36579 NULL
106665 +put_cmsg_36589 put_cmsg 4 36589 NULL
106666 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
106667 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
106668 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
106669 +format_decode_36638 format_decode 0 36638 NULL
106670 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
106671 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
106672 +perf_calculate_period_36662 perf_calculate_period 3-2 36662 NULL
106673 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
106674 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
106675 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
106676 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
106677 +sched_clock_36717 sched_clock 0 36717 NULL
106678 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
106679 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
106680 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
106681 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
106682 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
106683 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
106684 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
106685 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
106686 +tcf_csum_ipv6_tcp_36822 tcf_csum_ipv6_tcp 3 36822 NULL
106687 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
106688 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 NULL
106689 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
106690 +cm_write_36858 cm_write 3 36858 NULL
106691 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
106692 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
106693 +raid56_parity_write_36877 raid56_parity_write 5 36877 NULL
106694 +__btrfs_map_block_36883 __btrfs_map_block 3 36883 NULL
106695 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
106696 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
106697 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
106698 +build_key_36931 build_key 1 36931 NULL
106699 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
106700 +write_leb_36957 write_leb 5 36957 NULL
106701 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
106702 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
106703 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
106704 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
106705 +setxattr_37006 setxattr 4 37006 NULL
106706 +qp_broker_create_37053 qp_broker_create 6-5 37053 NULL nohasharray
106707 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 &qp_broker_create_37053
106708 +SYSC_setxattr_37078 SYSC_setxattr 4 37078 NULL
106709 +parse_command_37079 parse_command 2 37079 NULL
106710 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
106711 +tun_get_user_37094 tun_get_user 5 37094 NULL
106712 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
106713 +snd_hda_get_conn_list_37132 snd_hda_get_conn_list 0 37132 NULL
106714 +msg_word_37164 msg_word 0 37164 NULL
106715 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
106716 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
106717 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
106718 +__do_replace_37227 __do_replace 5 37227 NULL
106719 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
106720 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
106721 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
106722 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
106723 +nested_svm_map_37268 nested_svm_map 2 37268 NULL
106724 +c101_run_37279 c101_run 2 37279 NULL
106725 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
106726 +isku_sysfs_write_talkfx_37298 isku_sysfs_write_talkfx 6 37298 NULL
106727 +ieee80211_if_read_power_mode_37305 ieee80211_if_read_power_mode 3 37305 NULL
106728 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
106729 +send_msg_37323 send_msg 4 37323 NULL
106730 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
106731 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
106732 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
106733 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
106734 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
106735 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
106736 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
106737 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
106738 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
106739 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
106740 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
106741 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
106742 +tty_audit_log_37440 tty_audit_log 5 37440 NULL
106743 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
106744 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
106745 +__remove_37457 __remove 2 37457 NULL
106746 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
106747 +get_est_timing_37484 get_est_timing 0 37484 NULL
106748 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
106749 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
106750 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
106751 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
106752 +hdr_size_37536 hdr_size 0 37536 NULL
106753 +a2p_37544 a2p 0-1 37544 NULL
106754 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
106755 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
106756 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
106757 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
106758 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6-3 37611 NULL
106759 +SYSC_mbind_37622 SYSC_mbind 5 37622 NULL
106760 +btrfs_calc_trans_metadata_size_37629 btrfs_calc_trans_metadata_size 0-2 37629 NULL nohasharray
106761 +policy_residency_37629 policy_residency 0 37629 &btrfs_calc_trans_metadata_size_37629
106762 +check_pt_base_37635 check_pt_base 3 37635 NULL
106763 +alloc_fd_37637 alloc_fd 1 37637 NULL
106764 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
106765 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
106766 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
106767 +SYSC_get_mempolicy_37664 SYSC_get_mempolicy 4-3 37664 NULL
106768 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
106769 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
106770 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
106771 +nametbl_header_37698 nametbl_header 2 37698 NULL
106772 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
106773 +dm_thin_remove_block_37724 dm_thin_remove_block 2 37724 NULL
106774 +find_active_uprobe_37733 find_active_uprobe 1 37733 NULL
106775 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
106776 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
106777 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
106778 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
106779 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
106780 +dma_pte_addr_37784 dma_pte_addr 0 37784 NULL
106781 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
106782 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
106783 +deny_write_access_37813 deny_write_access 0 37813 NULL
106784 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
106785 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
106786 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
106787 +isku_sysfs_write_last_set_37868 isku_sysfs_write_last_set 6 37868 NULL nohasharray
106788 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 &isku_sysfs_write_last_set_37868
106789 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
106790 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
106791 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
106792 +compat_sys_rt_sigpending_37899 compat_sys_rt_sigpending 2 37899 NULL
106793 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
106794 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
106795 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
106796 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
106797 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
106798 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
106799 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
106800 +vfs_readv_38011 vfs_readv 3 38011 NULL
106801 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
106802 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
106803 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
106804 +SyS_llistxattr_38048 SyS_llistxattr 3 38048 NULL
106805 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL nohasharray
106806 +is_discarded_38058 is_discarded 2 38058 &_xfs_buf_alloc_38058
106807 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
106808 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
106809 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
106810 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
106811 +tcf_csum_ipv4_udp_38089 tcf_csum_ipv4_udp 3 38089 NULL
106812 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
106813 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
106814 +ep0_read_38095 ep0_read 3 38095 NULL
106815 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
106816 +rbd_obj_read_sync_38098 rbd_obj_read_sync 3-4 38098 NULL
106817 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
106818 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
106819 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
106820 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
106821 +cdev_add_38176 cdev_add 2-3 38176 NULL
106822 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
106823 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
106824 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
106825 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
106826 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
106827 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
106828 +palmas_gpio_to_irq_38235 palmas_gpio_to_irq 2 38235 NULL
106829 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
106830 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
106831 +from_dblock_38256 from_dblock 0-1 38256 NULL
106832 +vmci_qp_broker_set_page_store_38260 vmci_qp_broker_set_page_store 2-3 38260 NULL
106833 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
106834 +SYSC_msgrcv_38268 SYSC_msgrcv 3 38268 &ieee80211_if_read_auto_open_plinks_38268 nohasharray
106835 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &SYSC_msgrcv_38268
106836 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
106837 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
106838 +ftdi_process_packet_38281 ftdi_process_packet 4 38281 NULL nohasharray
106839 +swiotlb_sync_single_for_cpu_38281 swiotlb_sync_single_for_cpu 2 38281 &ftdi_process_packet_38281
106840 +gpa_to_gfn_38291 gpa_to_gfn 0-1 38291 NULL
106841 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
106842 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
106843 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
106844 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
106845 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
106846 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
106847 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
106848 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
106849 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
106850 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
106851 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
106852 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
106853 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
106854 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
106855 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
106856 +kvm_arch_setup_async_pf_38481 kvm_arch_setup_async_pf 3 38481 NULL
106857 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
106858 +cpu_to_mem_38501 cpu_to_mem 0 38501 NULL
106859 +dev_names_read_38509 dev_names_read 3 38509 NULL
106860 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
106861 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
106862 +set_queue_count_38519 set_queue_count 0 38519 NULL
106863 +mlx4_ib_db_map_user_38529 mlx4_ib_db_map_user 2 38529 NULL
106864 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
106865 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
106866 +cpu_to_node_38561 cpu_to_node 0 38561 NULL
106867 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
106868 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
106869 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
106870 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
106871 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
106872 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
106873 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
106874 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
106875 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
106876 +cma_create_area_38642 cma_create_area 2 38642 NULL
106877 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
106878 +qp_broker_alloc_38646 qp_broker_alloc 5-6 38646 NULL
106879 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
106880 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
106881 +skb_tnl_header_len_38669 skb_tnl_header_len 0 38669 NULL
106882 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
106883 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
106884 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
106885 +rbio_add_io_page_38700 rbio_add_io_page 6 38700 NULL
106886 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
106887 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
106888 +phys_to_virt_38757 phys_to_virt 0-1 38757 NULL
106889 +udf_readpages_38761 udf_readpages 4 38761 NULL
106890 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
106891 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
106892 +err_decode_38804 err_decode 2 38804 NULL
106893 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
106894 +sys_select_38827 sys_select 1 38827 NULL
106895 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
106896 +direct_entry_38836 direct_entry 3 38836 NULL
106897 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
106898 +interfaces_38859 interfaces 2 38859 NULL
106899 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
106900 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
106901 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
106902 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
106903 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
106904 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
106905 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
106906 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
106907 +C_SYSC_preadv64_38977 C_SYSC_preadv64 3 38977 NULL nohasharray
106908 +usb_maxpacket_38977 usb_maxpacket 0 38977 &C_SYSC_preadv64_38977
106909 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
106910 +udf_new_block_38999 udf_new_block 4 38999 NULL
106911 +get_nodes_39012 get_nodes 3 39012 NULL
106912 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
106913 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
106914 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
106915 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
106916 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
106917 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
106918 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
106919 +ea_foreach_39133 ea_foreach 0 39133 NULL
106920 +generic_permission_39150 generic_permission 0 39150 NULL
106921 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
106922 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
106923 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
106924 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
106925 +init_list_set_39188 init_list_set 2-3 39188 NULL
106926 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
106927 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
106928 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
106929 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
106930 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
106931 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
106932 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
106933 +drm_order_39244 drm_order 0 39244 NULL
106934 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
106935 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
106936 +__skb_cow_39254 __skb_cow 2 39254 NULL
106937 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
106938 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
106939 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
106940 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
106941 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
106942 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
106943 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
106944 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
106945 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
106946 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
106947 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
106948 +fnic_trace_debugfs_read_39380 fnic_trace_debugfs_read 3 39380 NULL
106949 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
106950 +__send_to_port_39386 __send_to_port 3 39386 NULL
106951 +user_power_read_39414 user_power_read 3 39414 NULL
106952 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
106953 +sys_semop_39457 sys_semop 3 39457 NULL
106954 +ptrace_peek_siginfo_39458 ptrace_peek_siginfo 3 39458 NULL
106955 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
106956 +do_get_mempolicy_39485 do_get_mempolicy 3 39485 NULL
106957 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
106958 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
106959 +int_proc_write_39542 int_proc_write 3 39542 NULL
106960 +pp_write_39554 pp_write 3 39554 NULL
106961 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
106962 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
106963 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
106964 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
106965 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
106966 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
106967 +ext_depth_39607 ext_depth 0 39607 NULL
106968 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
106969 +sdio_readb_39618 sdio_readb 0 39618 NULL
106970 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
106971 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
106972 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
106973 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
106974 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
106975 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
106976 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
106977 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
106978 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
106979 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
106980 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
106981 +remap_to_origin_clear_discard_39767 remap_to_origin_clear_discard 3 39767 NULL
106982 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
106983 +crypto_ablkcipher_blocksize_39811 crypto_ablkcipher_blocksize 0 39811 NULL
106984 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
106985 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
106986 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
106987 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
106988 +pkt_add_39897 pkt_add 3 39897 NULL
106989 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
106990 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
106991 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
106992 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
106993 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
106994 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
106995 +__spi_async_39932 __spi_async 0 39932 NULL
106996 +__get_order_39935 __get_order 0 39935 NULL
106997 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
106998 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
106999 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
107000 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
107001 +vfio_pci_read_39975 vfio_pci_read 3 39975 NULL
107002 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
107003 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
107004 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
107005 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
107006 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
107007 +disc_pwup_write_40027 disc_pwup_write 3 40027 NULL
107008 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
107009 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
107010 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
107011 +add_tty_40055 add_tty 1 40055 NULL nohasharray
107012 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
107013 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
107014 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
107015 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
107016 +dwc2_max_desc_num_40132 dwc2_max_desc_num 0 40132 NULL
107017 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
107018 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
107019 +pt_write_40159 pt_write 3 40159 NULL
107020 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
107021 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
107022 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
107023 +allocate_probes_40204 allocate_probes 1 40204 NULL
107024 +compat_put_long_40214 compat_put_long 1 40214 NULL
107025 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
107026 +osst_read_40237 osst_read 3 40237 NULL
107027 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
107028 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
107029 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
107030 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
107031 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
107032 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
107033 +_calc_trunk_info_40291 _calc_trunk_info 2 40291 NULL
107034 +crash_free_reserved_phys_range_40292 crash_free_reserved_phys_range 1 40292 NULL
107035 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
107036 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
107037 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
107038 +mmio_read_40348 mmio_read 4 40348 NULL
107039 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
107040 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
107041 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
107042 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
107043 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
107044 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
107045 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
107046 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
107047 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
107048 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
107049 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
107050 +tty_write_room_40495 tty_write_room 0 40495 NULL
107051 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
107052 +sg_phys_40507 sg_phys 0 40507 NULL
107053 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
107054 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
107055 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
107056 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
107057 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
107058 +bdev_sectors_40564 bdev_sectors 0 40564 NULL
107059 +lba_to_map_index_40580 lba_to_map_index 0-1 40580 NULL
107060 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
107061 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
107062 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
107063 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
107064 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
107065 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
107066 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
107067 +fops_read_40672 fops_read 3 40672 NULL
107068 +alloc_rbio_40676 alloc_rbio 4 40676 NULL
107069 +videobuf_dma_init_user_locked_40678 videobuf_dma_init_user_locked 3 40678 NULL
107070 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
107071 +vfio_pci_config_rw_40698 vfio_pci_config_rw 3 40698 NULL
107072 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
107073 +fuse_readpages_40737 fuse_readpages 4 40737 NULL
107074 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
107075 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
107076 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
107077 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
107078 +card_send_command_40757 card_send_command 3 40757 NULL
107079 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
107080 +pg_write_40766 pg_write 3 40766 NULL
107081 +show_list_40775 show_list 3 40775 NULL
107082 +calcu_metadata_size_40782 calcu_metadata_size 0 40782 NULL
107083 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
107084 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
107085 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
107086 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
107087 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
107088 +SyS_mbind_40828 SyS_mbind 5 40828 NULL
107089 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
107090 +isku_sysfs_write_keys_thumbster_40851 isku_sysfs_write_keys_thumbster 6 40851 NULL
107091 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
107092 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
107093 +read_file_queue_40895 read_file_queue 3 40895 NULL
107094 +waiters_read_40902 waiters_read 3 40902 NULL
107095 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
107096 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
107097 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
107098 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
107099 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
107100 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
107101 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
107102 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
107103 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
107104 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
107105 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
107106 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
107107 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
107108 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
107109 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
107110 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
107111 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
107112 +dma_attach_41094 dma_attach 5-6 41094 NULL
107113 +provide_user_output_41105 provide_user_output 3 41105 NULL
107114 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
107115 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
107116 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
107117 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
107118 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
107119 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
107120 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
107121 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
107122 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
107123 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
107124 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
107125 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
107126 +erst_read_41260 erst_read 0 41260 NULL
107127 +__fprog_create_41263 __fprog_create 2 41263 NULL
107128 +setup_cluster_bitmap_41270 setup_cluster_bitmap 4 41270 NULL
107129 +alloc_context_41283 alloc_context 1 41283 NULL
107130 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
107131 +objio_alloc_io_state_41316 objio_alloc_io_state 6 41316 NULL
107132 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
107133 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
107134 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
107135 +kmp_init_41373 kmp_init 2 41373 NULL
107136 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
107137 +is_writethrough_io_41406 is_writethrough_io 3 41406 NULL
107138 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
107139 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
107140 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
107141 +vsock_dev_compat_ioctl_41427 vsock_dev_compat_ioctl 3 41427 NULL
107142 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
107143 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
107144 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
107145 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
107146 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
107147 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
107148 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
107149 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
107150 +SyS_get_mempolicy_41495 SyS_get_mempolicy 3-4 41495 NULL
107151 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
107152 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
107153 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
107154 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
107155 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
107156 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
107157 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
107158 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
107159 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
107160 +vga_io_r_41609 vga_io_r 0 41609 NULL
107161 +tcp_hdrlen_41610 tcp_hdrlen 0 41610 NULL
107162 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
107163 +a2mp_send_41615 a2mp_send 4 41615 NULL
107164 +btrfs_calc_trunc_metadata_size_41626 btrfs_calc_trunc_metadata_size 0-2 41626 NULL
107165 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
107166 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
107167 +get_std_timing_41654 get_std_timing 0 41654 NULL
107168 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
107169 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
107170 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
107171 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
107172 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
107173 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
107174 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
107175 +fillonedir_41746 fillonedir 3 41746 NULL
107176 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
107177 +iwl_dbgfs_bt_notif_read_41794 iwl_dbgfs_bt_notif_read 3 41794 NULL
107178 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
107179 +regcache_sync_block_raw_41803 regcache_sync_block_raw 3-4 41803 NULL
107180 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
107181 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
107182 +lp_gpio_to_irq_41822 lp_gpio_to_irq 2 41822 NULL
107183 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
107184 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
107185 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
107186 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
107187 +get_packet_41914 get_packet 3 41914 NULL
107188 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
107189 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
107190 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
107191 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
107192 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
107193 +read_gssp_41947 read_gssp 3 41947 NULL
107194 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
107195 +portnames_read_41958 portnames_read 3 41958 NULL
107196 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
107197 +dst_mtu_41969 dst_mtu 0 41969 NULL
107198 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
107199 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
107200 +lguest_map_42008 lguest_map 1-2 42008 NULL
107201 +pool_allocate_42012 pool_allocate 3 42012 NULL
107202 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
107203 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
107204 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
107205 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
107206 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
107207 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
107208 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
107209 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
107210 +alloc_bitset_42085 alloc_bitset 1 42085 NULL
107211 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
107212 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
107213 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
107214 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL nohasharray
107215 +dw_dma_cyclic_prep_42113 dw_dma_cyclic_prep 3-4 42113 &sysfs_read_file_42113
107216 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
107217 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
107218 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
107219 +iwl_mvm_send_cmd_42173 iwl_mvm_send_cmd 0 42173 NULL
107220 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
107221 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
107222 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
107223 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
107224 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
107225 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
107226 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
107227 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
107228 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
107229 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
107230 +gfn_to_hva_42305 gfn_to_hva 0-2 42305 NULL
107231 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
107232 +free_cblock_42318 free_cblock 2 42318 NULL
107233 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
107234 +tcp_sync_mss_42330 tcp_sync_mss 0-2 42330 NULL
107235 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
107236 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
107237 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
107238 +hash_ipportnet4_expire_42391 hash_ipportnet4_expire 3 42391 NULL
107239 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
107240 +krng_get_random_42420 krng_get_random 3 42420 NULL
107241 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
107242 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
107243 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
107244 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
107245 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
107246 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
107247 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
107248 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
107249 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
107250 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
107251 +bypass_write_42498 bypass_write 3 42498 NULL
107252 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
107253 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
107254 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
107255 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
107256 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
107257 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
107258 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
107259 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
107260 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
107261 +map_state_42602 map_state 1 42602 NULL nohasharray
107262 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
107263 +nd_get_link_42603 nd_get_link 0 42603 NULL
107264 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
107265 +resp_write_42628 resp_write 2 42628 NULL
107266 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
107267 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
107268 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
107269 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
107270 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
107271 +acpi_dev_get_irqresource_42694 acpi_dev_get_irqresource 2 42694 NULL
107272 +vb2_read_42703 vb2_read 3 42703 NULL
107273 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
107274 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
107275 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
107276 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
107277 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
107278 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
107279 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
107280 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL nohasharray
107281 +isku_sysfs_read_info_42781 isku_sysfs_read_info 6 42781 &cryptd_hash_setkey_42781
107282 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
107283 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
107284 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
107285 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
107286 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
107287 +set_arg_42824 set_arg 3 42824 NULL
107288 +si476x_radio_read_rsq_blob_42827 si476x_radio_read_rsq_blob 3 42827 NULL
107289 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
107290 +prandom_u32_42853 prandom_u32 0 42853 NULL
107291 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
107292 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
107293 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
107294 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
107295 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
107296 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
107297 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
107298 +hd_end_request_42904 hd_end_request 2 42904 NULL
107299 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
107300 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
107301 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
107302 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
107303 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
107304 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
107305 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
107306 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
107307 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
107308 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
107309 +add_bytes_to_bitmap_43026 add_bytes_to_bitmap 0 43026 NULL
107310 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
107311 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
107312 +nfs_map_group_to_gid_43082 nfs_map_group_to_gid 3 43082 NULL
107313 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
107314 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
107315 +read_file_dfs_43145 read_file_dfs 3 43145 NULL nohasharray
107316 +i2c_hid_get_report_43145 i2c_hid_get_report 0 43145 &read_file_dfs_43145
107317 +uuid_string_43154 uuid_string 0 43154 NULL
107318 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
107319 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
107320 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
107321 +process_measurement_43190 process_measurement 0 43190 NULL
107322 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
107323 +uio_write_43202 uio_write 3 43202 NULL
107324 +iso_callback_43208 iso_callback 3 43208 NULL
107325 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
107326 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
107327 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
107328 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
107329 +fixup_leb_43256 fixup_leb 3 43256 NULL
107330 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
107331 +evtchn_write_43278 evtchn_write 3 43278 NULL
107332 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
107333 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
107334 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
107335 +mmu_set_spte_43327 mmu_set_spte 6-7 43327 NULL
107336 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
107337 +kvm_host_page_size_43348 kvm_host_page_size 2 43348 NULL
107338 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
107339 +hash_net4_expire_43378 hash_net4_expire 3 43378 NULL
107340 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1-2 43423 NULL nohasharray
107341 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 &__alloc_bootmem_low_43423
107342 +isku_sysfs_write_keys_capslock_43432 isku_sysfs_write_keys_capslock 6 43432 NULL
107343 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
107344 +ucs2_strsize_43438 ucs2_strsize 0 43438 NULL
107345 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
107346 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
107347 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
107348 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
107349 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
107350 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
107351 +do_readlink_43518 do_readlink 2 43518 NULL
107352 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
107353 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
107354 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
107355 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
107356 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
107357 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
107358 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
107359 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
107360 +proc_read_43614 proc_read 3 43614 NULL
107361 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
107362 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 NULL
107363 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
107364 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
107365 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
107366 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
107367 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
107368 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
107369 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
107370 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
107371 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
107372 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
107373 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
107374 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
107375 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
107376 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
107377 +div64_u64_safe_43815 div64_u64_safe 1-2 43815 NULL
107378 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
107379 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
107380 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
107381 +read_flush_43851 read_flush 3 43851 NULL
107382 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
107383 +pm860x_bulk_write_43875 pm860x_bulk_write 2-3 43875 NULL
107384 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
107385 +SendString_43928 SendString 3 43928 NULL
107386 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
107387 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
107388 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
107389 +nla_reserve_43984 nla_reserve 3 43984 NULL
107390 +__clkdev_alloc_43990 __clkdev_alloc 1 43990 NULL
107391 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
107392 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
107393 +emit_flags_44006 emit_flags 4-3 44006 NULL
107394 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
107395 +swiotlb_unmap_page_44063 swiotlb_unmap_page 2 44063 NULL
107396 +SYSC_add_key_44079 SYSC_add_key 4 44079 NULL
107397 +load_discard_44083 load_discard 3 44083 NULL
107398 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
107399 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
107400 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
107401 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
107402 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
107403 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
107404 +SYSC_set_mempolicy_44176 SYSC_set_mempolicy 3 44176 NULL
107405 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
107406 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
107407 +__set_free_44211 __set_free 2 44211 NULL
107408 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
107409 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
107410 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
107411 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
107412 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
107413 +enlarge_skb_44248 enlarge_skb 2 44248 NULL
107414 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
107415 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
107416 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
107417 +bitmap_scnprintf_44318 bitmap_scnprintf 2 44318 NULL
107418 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
107419 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
107420 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
107421 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
107422 +__is_discarded_44359 __is_discarded 2 44359 NULL
107423 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
107424 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
107425 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
107426 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
107427 +check_user_page_hwpoison_44412 check_user_page_hwpoison 1 44412 NULL
107428 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
107429 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
107430 +___alloc_bootmem_node_nopanic_44461 ___alloc_bootmem_node_nopanic 2-3 44461 NULL
107431 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
107432 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
107433 +bio_advance_44496 bio_advance 2 44496 NULL
107434 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
107435 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
107436 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
107437 +spidev_write_44510 spidev_write 3 44510 NULL
107438 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
107439 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
107440 +hash_ipport4_expire_44564 hash_ipport4_expire 3 44564 NULL
107441 +dgrp_config_proc_write_44571 dgrp_config_proc_write 3 44571 NULL
107442 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
107443 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
107444 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
107445 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
107446 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
107447 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
107448 +mpi_resize_44674 mpi_resize 2 44674 NULL
107449 +ts_read_44687 ts_read 3 44687 NULL
107450 +qib_get_user_pages_44689 qib_get_user_pages 1-2 44689 NULL
107451 +xfer_to_user_44713 xfer_to_user 3 44713 NULL
107452 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
107453 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
107454 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
107455 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
107456 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
107457 +set_brk_44749 set_brk 1 44749 NULL
107458 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
107459 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
107460 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
107461 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
107462 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
107463 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
107464 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
107465 +mei_cl_read_start_44824 mei_cl_read_start 2 44824 NULL
107466 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
107467 +sisusb_write_44834 sisusb_write 3 44834 NULL
107468 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
107469 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
107470 +cubic_root_44848 cubic_root 1 44848 NULL
107471 +copydesc_user_44855 copydesc_user 3 44855 NULL
107472 +skb_availroom_44883 skb_availroom 0 44883 NULL
107473 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
107474 +do_tty_write_44896 do_tty_write 5 44896 NULL
107475 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
107476 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
107477 +map_index_to_lba_44993 map_index_to_lba 0-1 44993 NULL
107478 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
107479 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
107480 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
107481 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
107482 +sel_write_user_45060 sel_write_user 3 45060 NULL
107483 +vmscan_swappiness_45062 vmscan_swappiness 0 45062 NULL
107484 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL nohasharray
107485 +do_video_ioctl_45069 do_video_ioctl 3 45069 &snd_mixart_BA0_read_45069
107486 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
107487 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
107488 +usbdev_read_45114 usbdev_read 3 45114 NULL
107489 +isku_sysfs_write_reset_45133 isku_sysfs_write_reset 6 45133 NULL
107490 +send_to_tty_45141 send_to_tty 3 45141 NULL
107491 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
107492 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
107493 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
107494 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
107495 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
107496 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
107497 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
107498 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
107499 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
107500 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
107501 +add_child_45201 add_child 4 45201 NULL
107502 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
107503 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
107504 +__dirty_45228 __dirty 2 45228 NULL
107505 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
107506 +prism2_pda_proc_read_45246 prism2_pda_proc_read 3 45246 NULL
107507 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
107508 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
107509 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
107510 +pte_val_45313 pte_val 0 45313 NULL
107511 +__i2c_hid_command_45321 __i2c_hid_command 0 45321 NULL
107512 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
107513 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
107514 +keymap_store_45406 keymap_store 4 45406 NULL
107515 +paging64_gva_to_gpa_45421 paging64_gva_to_gpa 2 45421 NULL nohasharray
107516 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 &paging64_gva_to_gpa_45421
107517 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
107518 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL nohasharray
107519 +SYSC_mremap_45446 SYSC_mremap 5-1-2 45446 &intel_render_ring_init_dri_45446
107520 +__node_remap_45458 __node_remap 4 45458 NULL
107521 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
107522 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
107523 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
107524 +arizona_init_fll_45503 arizona_init_fll 5 45503 NULL
107525 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
107526 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
107527 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
107528 +copy_macs_45534 copy_macs 4 45534 NULL
107529 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
107530 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
107531 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
107532 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
107533 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
107534 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
107535 +_regmap_bus_raw_write_45559 _regmap_bus_raw_write 2 45559 NULL
107536 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
107537 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
107538 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
107539 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
107540 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
107541 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
107542 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
107543 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
107544 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
107545 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
107546 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
107547 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
107548 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
107549 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
107550 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
107551 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
107552 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
107553 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
107554 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
107555 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
107556 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
107557 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
107558 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
107559 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
107560 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
107561 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
107562 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
107563 +isdn_write_45863 isdn_write 3 45863 NULL
107564 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
107565 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
107566 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
107567 +wm_adsp_region_to_reg_45915 wm_adsp_region_to_reg 0-2 45915 NULL
107568 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
107569 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
107570 +smp_scan_config_45934 smp_scan_config 1 45934 NULL
107571 +alloc_mr_45935 alloc_mr 1 45935 NULL
107572 +split_large_page_45941 split_large_page 2 45941 NULL
107573 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
107574 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
107575 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
107576 +ore_calc_stripe_info_46023 ore_calc_stripe_info 2 46023 NULL
107577 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
107578 +get_free_entries_46030 get_free_entries 1 46030 NULL
107579 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
107580 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
107581 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
107582 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
107583 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
107584 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
107585 +slhc_toss_46066 slhc_toss 0 46066 NULL
107586 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
107587 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
107588 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
107589 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
107590 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
107591 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
107592 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
107593 +C_SYSC_writev_46113 C_SYSC_writev 3 46113 NULL
107594 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
107595 +paging32_walk_addr_nested_46121 paging32_walk_addr_nested 3 46121 NULL
107596 +vb2_dma_sg_get_userptr_46146 vb2_dma_sg_get_userptr 2 46146 NULL
107597 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
107598 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
107599 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
107600 +add_conn_list_46197 add_conn_list 3 46197 NULL
107601 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
107602 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
107603 +dsp_write_46218 dsp_write 2 46218 NULL
107604 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
107605 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
107606 +ReadReg_46277 ReadReg 0 46277 NULL
107607 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
107608 +qlcnic_83xx_sysfs_flash_bulk_write_46320 qlcnic_83xx_sysfs_flash_bulk_write 4 46320 NULL
107609 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
107610 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
107611 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
107612 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
107613 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
107614 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
107615 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
107616 +hash_ipportip6_expire_46443 hash_ipportip6_expire 3 46443 NULL
107617 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
107618 +filldir64_46469 filldir64 3 46469 NULL
107619 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
107620 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
107621 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
107622 +kmsg_read_46514 kmsg_read 3 46514 NULL
107623 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
107624 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
107625 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
107626 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
107627 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
107628 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
107629 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
107630 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
107631 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
107632 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
107633 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
107634 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
107635 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
107636 +vfs_getxattr_alloc_46649 vfs_getxattr_alloc 0 46649 NULL
107637 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
107638 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
107639 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
107640 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
107641 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
107642 +prepare_copy_46725 prepare_copy 2 46725 NULL
107643 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
107644 +set_memory_wc_46747 set_memory_wc 1 46747 NULL
107645 +ext4_count_free_46754 ext4_count_free 2 46754 NULL nohasharray
107646 +pte_pfn_46754 pte_pfn 0 46754 &ext4_count_free_46754
107647 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
107648 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
107649 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
107650 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
107651 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
107652 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
107653 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
107654 +spi_async_46857 spi_async 0 46857 NULL
107655 +vsnprintf_46863 vsnprintf 0 46863 NULL nohasharray
107656 +SyS_move_pages_46863 SyS_move_pages 2 46863 &vsnprintf_46863
107657 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
107658 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
107659 +rvmalloc_46873 rvmalloc 1 46873 NULL
107660 +qp_memcpy_from_queue_iov_46874 qp_memcpy_from_queue_iov 4-5 46874 NULL
107661 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
107662 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
107663 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
107664 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
107665 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
107666 +ieee80211_if_fmt_power_mode_46906 ieee80211_if_fmt_power_mode 3 46906 NULL
107667 +wlcore_alloc_hw_46917 wlcore_alloc_hw 1 46917 NULL
107668 +fb_write_46924 fb_write 3 46924 NULL
107669 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
107670 +kvm_register_read_46948 kvm_register_read 0 46948 NULL
107671 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
107672 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
107673 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
107674 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
107675 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
107676 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
107677 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
107678 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
107679 +add_free_space_entry_47005 add_free_space_entry 2 47005 NULL
107680 +__map_single_47020 __map_single 3-4-7 47020 NULL
107681 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
107682 +swiotlb_sync_single_47031 swiotlb_sync_single 2 47031 NULL
107683 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
107684 +fs_path_len_47060 fs_path_len 0 47060 NULL
107685 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
107686 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
107687 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
107688 +iwl_dump_nic_event_log_47089 iwl_dump_nic_event_log 0 47089 NULL
107689 +mousedev_read_47123 mousedev_read 3 47123 NULL
107690 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
107691 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
107692 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
107693 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
107694 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
107695 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
107696 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
107697 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
107698 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
107699 +gnttab_set_map_op_47206 gnttab_set_map_op 2 47206 NULL
107700 +l2headersize_47238 l2headersize 0 47238 NULL
107701 +options_write_47243 options_write 3 47243 NULL
107702 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
107703 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
107704 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
107705 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
107706 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
107707 +vsnprintf_47291 vsnprintf 0 47291 NULL
107708 +SYSC_semop_47292 SYSC_semop 3 47292 NULL
107709 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
107710 +SyS_madvise_47354 SyS_madvise 1 47354 NULL
107711 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
107712 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
107713 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
107714 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
107715 +nv_rd32_47390 nv_rd32 0 47390 NULL nohasharray
107716 +trace_options_core_read_47390 trace_options_core_read 3 47390 &nv_rd32_47390
107717 +nametbl_list_47391 nametbl_list 2 47391 NULL
107718 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
107719 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
107720 +gfn_to_pfn_prot_47398 gfn_to_pfn_prot 2 47398 NULL
107721 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
107722 +sta_vht_capa_read_47409 sta_vht_capa_read 3 47409 NULL
107723 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
107724 +vzalloc_47421 vzalloc 1 47421 NULL
107725 +hash_ipportip4_expire_47426 hash_ipportip4_expire 3 47426 NULL
107726 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
107727 +__load_mapping_47460 __load_mapping 2 47460 NULL
107728 +nvme_trans_send_fw_cmd_47479 nvme_trans_send_fw_cmd 4 47479 NULL
107729 +wb_force_mapping_47485 wb_force_mapping 2 47485 NULL nohasharray
107730 +newpart_47485 newpart 6 47485 &wb_force_mapping_47485
107731 +core_sys_select_47494 core_sys_select 1 47494 NULL
107732 +alloc_arraycache_47505 alloc_arraycache 2 47505 NULL
107733 +unlink_simple_47506 unlink_simple 3 47506 NULL
107734 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
107735 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
107736 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
107737 +oz_events_read_47535 oz_events_read 3 47535 NULL
107738 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
107739 +read_ldt_47570 read_ldt 2 47570 NULL
107740 +_rtl_rx_get_padding_47572 _rtl_rx_get_padding 0 47572 NULL nohasharray
107741 +isku_sysfs_read_last_set_47572 isku_sysfs_read_last_set 6 47572 &_rtl_rx_get_padding_47572
107742 +pci_iomap_47575 pci_iomap 3 47575 NULL
107743 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
107744 +SYSC_fcntl64_47581 SYSC_fcntl64 3 47581 NULL
107745 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
107746 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
107747 +uea_request_47613 uea_request 4 47613 NULL
107748 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
107749 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
107750 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
107751 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
107752 +global_rt_runtime_47712 global_rt_runtime 0 47712 NULL
107753 +save_microcode_47717 save_microcode 3 47717 NULL
107754 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
107755 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
107756 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
107757 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
107758 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
107759 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
107760 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
107761 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
107762 +SyS_setgroups16_47780 SyS_setgroups16 1 47780 NULL
107763 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
107764 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
107765 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
107766 +KEY_SIZE_47855 KEY_SIZE 0 47855 NULL
107767 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
107768 +vhci_read_47878 vhci_read 3 47878 NULL
107769 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
107770 +load_mapping_47904 load_mapping 3 47904 NULL
107771 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
107772 +comedi_write_47926 comedi_write 3 47926 NULL
107773 +nvme_trans_get_blk_desc_len_47946 nvme_trans_get_blk_desc_len 0-2 47946 NULL
107774 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
107775 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
107776 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
107777 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
107778 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
107779 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
107780 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
107781 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
107782 +SYSC_writev_48040 SYSC_writev 3 48040 NULL
107783 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
107784 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
107785 +palmas_bulk_write_48068 palmas_bulk_write 2-3-5 48068 NULL
107786 +disc_write_48070 disc_write 3 48070 NULL
107787 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
107788 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
107789 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
107790 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
107791 +set_discoverable_48141 set_discoverable 4 48141 NULL
107792 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
107793 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
107794 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
107795 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
107796 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL nohasharray
107797 +rbd_obj_method_sync_48170 rbd_obj_method_sync 8 48170 &ocfs2_find_next_zero_bit_unaligned_48170
107798 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
107799 +init_ipath_48187 init_ipath 1 48187 NULL
107800 +brcmf_sdio_chip_cm3_exitdl_48192 brcmf_sdio_chip_cm3_exitdl 4 48192 NULL
107801 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
107802 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
107803 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
107804 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
107805 +read_file_recv_48232 read_file_recv 3 48232 NULL
107806 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL
107807 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
107808 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
107809 +send_set_info_48288 send_set_info 7 48288 NULL
107810 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
107811 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
107812 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
107813 +hash_setkey_48310 hash_setkey 3 48310 NULL
107814 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
107815 +skb_add_data_48363 skb_add_data 3 48363 NULL
107816 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
107817 +ixgbe_pci_sriov_enable_48410 ixgbe_pci_sriov_enable 2 48410 NULL
107818 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
107819 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
107820 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
107821 +print_filtered_48442 print_filtered 2-0 48442 NULL
107822 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
107823 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
107824 +send_control_msg_48498 send_control_msg 6 48498 NULL
107825 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
107826 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
107827 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
107828 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
107829 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
107830 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
107831 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
107832 +named_distribute_48544 named_distribute 4 48544 NULL
107833 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
107834 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
107835 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
107836 +mtd_read_48655 mtd_read 0 48655 NULL
107837 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
107838 +ore_get_rw_state_48667 ore_get_rw_state 4 48667 NULL
107839 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
107840 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
107841 +altera_drscan_48698 altera_drscan 2 48698 NULL
107842 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
107843 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
107844 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
107845 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
107846 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
107847 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
107848 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
107849 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
107850 +efi_memory_uc_48828 efi_memory_uc 1 48828 NULL
107851 +azx_get_position_48841 azx_get_position 0 48841 NULL
107852 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
107853 +C_SYSC_pwritev64_48864 C_SYSC_pwritev64 3 48864 NULL nohasharray
107854 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 &C_SYSC_pwritev64_48864
107855 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
107856 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
107857 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
107858 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
107859 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
107860 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
107861 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL
107862 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
107863 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
107864 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
107865 +vmci_handle_arr_create_48971 vmci_handle_arr_create 1 48971 NULL
107866 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
107867 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
107868 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
107869 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
107870 +filemap_check_errors_49022 filemap_check_errors 0 49022 NULL
107871 +transient_status_49027 transient_status 4 49027 NULL
107872 +ipath_reg_user_mr_49038 ipath_reg_user_mr 2-3 49038 NULL
107873 +setup_msi_irq_49052 setup_msi_irq 3-4 49052 NULL
107874 +ubi_read_49061 ubi_read 0 49061 NULL
107875 +scsi_register_49094 scsi_register 2 49094 NULL
107876 +paging64_walk_addr_nested_49100 paging64_walk_addr_nested 3 49100 NULL
107877 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
107878 +check_exists_49119 check_exists 2 49119 NULL nohasharray
107879 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 &check_exists_49119
107880 +pt_read_49136 pt_read 3 49136 NULL
107881 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
107882 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
107883 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
107884 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
107885 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
107886 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
107887 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
107888 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
107889 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
107890 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
107891 +resp_write_same_49217 resp_write_same 2 49217 NULL
107892 +nouveau_therm_create__49228 nouveau_therm_create_ 4 49228 NULL
107893 +nouveau_i2c_port_create__49237 nouveau_i2c_port_create_ 6 49237 NULL
107894 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
107895 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
107896 +isku_sysfs_read_keys_media_49268 isku_sysfs_read_keys_media 6 49268 NULL
107897 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
107898 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
107899 +uio_read_49300 uio_read 3 49300 NULL
107900 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
107901 +isku_sysfs_read_keys_macro_49312 isku_sysfs_read_keys_macro 6 49312 NULL
107902 +SYSC_mincore_49319 SYSC_mincore 1 49319 NULL
107903 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
107904 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
107905 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
107906 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
107907 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
107908 +px_raw_event_49371 px_raw_event 4 49371 NULL
107909 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
107910 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
107911 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
107912 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
107913 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
107914 +md_domain_init_49432 md_domain_init 2 49432 NULL
107915 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
107916 +get_lru_size_49441 get_lru_size 0 49441 NULL
107917 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
107918 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
107919 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
107920 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
107921 +SyS_listxattr_49519 SyS_listxattr 3 49519 NULL
107922 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
107923 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
107924 +smk_write_access_49561 smk_write_access 3 49561 NULL
107925 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
107926 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
107927 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
107928 +tap_write_49595 tap_write 3 49595 NULL
107929 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
107930 +btrfs_mksubvol_49616 btrfs_mksubvol 3 49616 NULL
107931 +heap_init_49617 heap_init 2 49617 NULL
107932 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
107933 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
107934 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
107935 +SyS_pwritev_49688 SyS_pwritev 3 49688 NULL
107936 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
107937 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
107938 +dm_thin_insert_block_49720 dm_thin_insert_block 2-3 49720 NULL
107939 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
107940 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
107941 +check_frame_49741 check_frame 0 49741 NULL
107942 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
107943 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
107944 +fuse_wr_pages_49753 fuse_wr_pages 0-1-2 49753 NULL
107945 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
107946 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
107947 +isku_sysfs_write_49767 isku_sysfs_write 6-5 49767 NULL
107948 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
107949 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
107950 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
107951 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
107952 +add_uuid_49831 add_uuid 4 49831 NULL
107953 +tcf_csum_ipv4_tcp_49834 tcf_csum_ipv4_tcp 3 49834 NULL
107954 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
107955 +twl4030_write_49846 twl4030_write 2 49846 NULL
107956 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
107957 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
107958 +btrfs_subvolume_reserve_metadata_49859 btrfs_subvolume_reserve_metadata 3 49859 NULL
107959 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
107960 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
107961 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
107962 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
107963 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
107964 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
107965 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
107966 +sta2x11_swiotlb_alloc_coherent_49994 sta2x11_swiotlb_alloc_coherent 2 49994 NULL
107967 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
107968 +__module_alloc_50004 __module_alloc 1 50004 NULL
107969 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
107970 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
107971 +isdn_read_50021 isdn_read 3 50021 NULL
107972 +qp_alloc_queue_50028 qp_alloc_queue 1 50028 NULL
107973 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
107974 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
107975 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
107976 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
107977 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
107978 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
107979 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
107980 +read_file_slot_50111 read_file_slot 3 50111 NULL
107981 +SYSC_preadv_50134 SYSC_preadv 3 50134 NULL
107982 +copy_items_50140 copy_items 6 50140 NULL
107983 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
107984 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
107985 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
107986 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
107987 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
107988 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
107989 +odev_update_50169 odev_update 2 50169 NULL
107990 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
107991 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
107992 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
107993 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
107994 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
107995 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
107996 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
107997 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
107998 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
107999 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
108000 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
108001 +SYSC_flistxattr_50307 SYSC_flistxattr 3 50307 NULL
108002 +SYSC_sched_setaffinity_50310 SYSC_sched_setaffinity 2 50310 NULL
108003 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
108004 +do_launder_page_50329 do_launder_page 0 50329 NULL
108005 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
108006 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
108007 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
108008 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
108009 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
108010 +tpm_read_50344 tpm_read 3 50344 NULL
108011 +sched_clock_remote_50347 sched_clock_remote 0 50347 NULL
108012 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
108013 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
108014 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
108015 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
108016 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
108017 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
108018 +hash_ip6_expire_50390 hash_ip6_expire 3 50390 NULL
108019 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
108020 +ceph_writepages_osd_request_50423 ceph_writepages_osd_request 5 50423 NULL
108021 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
108022 +validate_acl_mac_addrs_50429 validate_acl_mac_addrs 0 50429 NULL
108023 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
108024 +calc_csum_metadata_size_50448 calc_csum_metadata_size 0 50448 NULL
108025 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
108026 +force_mapping_50464 force_mapping 2 50464 NULL
108027 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
108028 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
108029 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
108030 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
108031 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
108032 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
108033 +fat_readpages_50582 fat_readpages 4 50582 NULL
108034 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
108035 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
108036 +sge_rx_50594 sge_rx 3 50594 NULL
108037 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
108038 +__ffs_50625 __ffs 0 50625 NULL
108039 +regcache_rbtree_write_50629 regcache_rbtree_write 2 50629 NULL
108040 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
108041 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
108042 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
108043 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
108044 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
108045 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
108046 +swiotlb_free_coherent_50690 swiotlb_free_coherent 4 50690 NULL
108047 +paging32_gva_to_gpa_50696 paging32_gva_to_gpa 2 50696 NULL
108048 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
108049 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
108050 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
108051 +skb_padto_50759 skb_padto 2 50759 NULL
108052 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
108053 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
108054 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
108055 +tpm_write_50798 tpm_write 3 50798 NULL
108056 +write_flush_50803 write_flush 3 50803 NULL
108057 +dvb_play_50814 dvb_play 3 50814 NULL
108058 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
108059 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
108060 +SetArea_50835 SetArea 4 50835 NULL nohasharray
108061 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
108062 +videobuf_dma_init_user_50839 videobuf_dma_init_user 3 50839 NULL
108063 +self_check_write_50856 self_check_write 5 50856 NULL
108064 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
108065 +SyS_lgetxattr_50889 SyS_lgetxattr 4 50889 NULL
108066 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
108067 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
108068 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
108069 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
108070 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
108071 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
108072 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
108073 +SyS_setxattr_50957 SyS_setxattr 4 50957 NULL
108074 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
108075 +timeout_write_50991 timeout_write 3 50991 NULL
108076 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL
108077 +proc_write_51003 proc_write 3 51003 NULL
108078 +snd_pcm_default_page_ops_51021 snd_pcm_default_page_ops 2 51021 NULL
108079 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
108080 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
108081 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
108082 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
108083 +dump_midi_51040 dump_midi 3 51040 NULL
108084 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
108085 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
108086 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
108087 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
108088 +solo_enc_v4l2_init_51094 solo_enc_v4l2_init 2 51094 NULL
108089 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
108090 +ti_recv_51110 ti_recv 3 51110 NULL
108091 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
108092 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
108093 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
108094 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
108095 +set_dirty_51144 set_dirty 3 51144 NULL
108096 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
108097 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
108098 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
108099 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
108100 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
108101 +tipc_send_51238 tipc_send 4 51238 NULL
108102 +drm_property_create_51239 drm_property_create 4 51239 NULL
108103 +st_read_51251 st_read 3 51251 NULL
108104 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
108105 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
108106 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
108107 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
108108 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
108109 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
108110 +get_cell_51316 get_cell 2 51316 NULL
108111 +init_map_ipmac_51317 init_map_ipmac 4-3-5 51317 NULL
108112 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
108113 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
108114 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
108115 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
108116 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
108117 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
108118 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
108119 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
108120 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
108121 +x86_swiotlb_free_coherent_51421 x86_swiotlb_free_coherent 4 51421 NULL
108122 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
108123 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
108124 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
108125 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
108126 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
108127 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
108128 +vaddr_51480 vaddr 0 51480 NULL
108129 +skb_inner_mac_header_51482 skb_inner_mac_header 0 51482 NULL nohasharray
108130 +btrfs_find_space_cluster_51482 btrfs_find_space_cluster 5 51482 &skb_inner_mac_header_51482
108131 +__cpa_process_fault_51502 __cpa_process_fault 2 51502 NULL
108132 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
108133 +load_pdptrs_51541 load_pdptrs 3 51541 NULL
108134 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
108135 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
108136 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
108137 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
108138 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
108139 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
108140 +gnttab_end_foreign_access_51617 gnttab_end_foreign_access 3 51617 NULL
108141 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
108142 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
108143 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
108144 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
108145 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
108146 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
108147 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
108148 +host_mapping_level_51696 host_mapping_level 2 51696 NULL
108149 +sel_write_access_51704 sel_write_access 3 51704 NULL
108150 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
108151 +v9fs_alloc_rdir_buf_51716 v9fs_alloc_rdir_buf 2 51716 NULL
108152 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
108153 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
108154 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
108155 +get_user_pages_fast_51751 get_user_pages_fast 0-1-2 51751 NULL
108156 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
108157 +if_write_51756 if_write 3 51756 NULL
108158 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
108159 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
108160 +to_ratio_51809 to_ratio 2-1 51809 NULL
108161 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
108162 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
108163 +ioread32_51847 ioread32 0 51847 NULL nohasharray
108164 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
108165 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
108166 +SYSC_sendto_51852 SYSC_sendto 6 51852 NULL
108167 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
108168 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
108169 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
108170 +user_read_51881 user_read 3 51881 NULL
108171 +memblock_alloc_51884 memblock_alloc 1-2 51884 NULL
108172 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
108173 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
108174 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
108175 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
108176 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
108177 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
108178 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
108179 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
108180 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
108181 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
108182 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
108183 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
108184 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
108185 +rdmalt_52022 rdmalt 0 52022 NULL
108186 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
108187 +override_release_52032 override_release 2 52032 NULL
108188 +end_port_52042 end_port 0 52042 NULL
108189 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
108190 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
108191 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
108192 +__fuse_request_alloc_52060 __fuse_request_alloc 1 52060 NULL
108193 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
108194 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
108195 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
108196 +smsdvb_stats_read_52114 smsdvb_stats_read 3 52114 NULL
108197 +retry_count_read_52129 retry_count_read 3 52129 NULL
108198 +zram_meta_alloc_52140 zram_meta_alloc 1 52140 NULL
108199 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
108200 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
108201 +htable_size_52148 htable_size 0-1 52148 NULL
108202 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
108203 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
108204 +alix_present_52165 alix_present 1 52165 NULL
108205 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
108206 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
108207 +print_prefix_52176 print_prefix 0 52176 NULL
108208 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
108209 +vmci_qp_broker_alloc_52216 vmci_qp_broker_alloc 5-6 52216 NULL
108210 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
108211 +fuse_request_alloc_52243 fuse_request_alloc 1 52243 NULL
108212 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
108213 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
108214 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
108215 +hva_to_pfn_slow_52262 hva_to_pfn_slow 1 52262 NULL
108216 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
108217 +atomic64_read_52300 atomic64_read 0 52300 NULL
108218 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
108219 +read_file_reset_52310 read_file_reset 3 52310 NULL
108220 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
108221 +hwflags_read_52318 hwflags_read 3 52318 NULL
108222 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
108223 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
108224 +compat_SyS_preadv64_52351 compat_SyS_preadv64 3 52351 NULL
108225 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
108226 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
108227 +mq_emit_config_values_52378 mq_emit_config_values 3 52378 NULL
108228 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
108229 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
108230 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
108231 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
108232 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
108233 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
108234 +delay_status_52431 delay_status 5 52431 NULL
108235 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
108236 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
108237 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
108238 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
108239 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
108240 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
108241 +qib_user_sdma_pin_pages_52498 qib_user_sdma_pin_pages 3-5 52498 NULL
108242 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
108243 +qlcnic_83xx_sysfs_flash_write_52507 qlcnic_83xx_sysfs_flash_write 4 52507 NULL
108244 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
108245 +dup_variable_bug_52525 dup_variable_bug 3 52525 NULL
108246 +from_oblock_52546 from_oblock 0-1 52546 NULL
108247 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
108248 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
108249 +emit_code_52583 emit_code 0-3 52583 NULL
108250 +isku_sysfs_read_macro_52587 isku_sysfs_read_macro 6 52587 NULL
108251 +tps80031_writes_52638 tps80031_writes 3-4 52638 NULL
108252 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
108253 +SYSC_gethostname_52677 SYSC_gethostname 2 52677 NULL
108254 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
108255 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
108256 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
108257 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
108258 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
108259 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
108260 +ieee80211_if_read_beacon_timeout_52756 ieee80211_if_read_beacon_timeout 3 52756 NULL
108261 +copy_ctr_args_52761 copy_ctr_args 2 52761 NULL
108262 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
108263 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
108264 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
108265 +twlreg_write_52880 twlreg_write 3 52880 NULL
108266 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
108267 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
108268 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
108269 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
108270 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
108271 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
108272 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
108273 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
108274 +send_packet_52960 send_packet 4 52960 NULL
108275 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
108276 +hx8357_spi_write_then_read_52964 hx8357_spi_write_then_read 3 52964 NULL nohasharray
108277 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 &hx8357_spi_write_then_read_52964
108278 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
108279 +num_node_state_52989 num_node_state 0 52989 NULL
108280 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
108281 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
108282 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
108283 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
108284 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
108285 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
108286 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
108287 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
108288 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
108289 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
108290 +verity_status_53120 verity_status 5 53120 NULL
108291 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
108292 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
108293 +ieee80211_bss_info_update_53170 ieee80211_bss_info_update 4 53170 NULL
108294 +btrfs_io_bio_alloc_53179 btrfs_io_bio_alloc 2 53179 NULL
108295 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
108296 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
108297 +fixup_user_fault_53210 fixup_user_fault 3 53210 NULL
108298 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
108299 +rbd_obj_method_sync_53252 rbd_obj_method_sync 8 53252 NULL
108300 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
108301 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
108302 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
108303 +isku_sysfs_write_key_mask_53305 isku_sysfs_write_key_mask 6 53305 NULL
108304 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
108305 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
108306 +vm_mmap_53339 vm_mmap 0 53339 NULL
108307 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
108308 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
108309 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
108310 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
108311 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
108312 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
108313 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
108314 +n2_run_53459 n2_run 3 53459 NULL
108315 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
108316 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
108317 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
108318 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
108319 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
108320 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
108321 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
108322 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
108323 +check_acl_53512 check_acl 0 53512 NULL
108324 +alloc_pages_exact_nid_53515 alloc_pages_exact_nid 2 53515 NULL
108325 +SYSC_bind_53582 SYSC_bind 3 53582 NULL nohasharray
108326 +set_registers_53582 set_registers 3 53582 &SYSC_bind_53582
108327 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
108328 +gfn_to_pfn_async_53597 gfn_to_pfn_async 2 53597 NULL
108329 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1-2 53626 NULL
108330 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
108331 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
108332 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
108333 +_preload_range_53676 _preload_range 2-3 53676 NULL
108334 +lowpan_fragment_xmit_53680 lowpan_fragment_xmit 3-4 53680 NULL
108335 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
108336 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
108337 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 NULL nohasharray
108338 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 &bdev_logical_block_size_53690
108339 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
108340 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
108341 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
108342 +wdm_write_53735 wdm_write 3 53735 NULL
108343 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
108344 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
108345 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
108346 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
108347 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
108348 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
108349 +qp_alloc_host_work_53798 qp_alloc_host_work 3-5 53798 NULL
108350 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
108351 +regmap_raw_write_53803 regmap_raw_write 2-4 53803 NULL
108352 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
108353 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
108354 +pms_read_53873 pms_read 3 53873 NULL
108355 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
108356 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL nohasharray
108357 +SyS_setgroups_53900 SyS_setgroups 1 53900 &ocfs2_rm_xattr_cluster_53900
108358 +proc_file_read_53905 proc_file_read 3 53905 NULL
108359 +early_reserve_e820_53915 early_reserve_e820 1-2 53915 NULL
108360 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
108361 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
108362 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
108363 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
108364 +mthca_reg_user_mr_53980 mthca_reg_user_mr 2-3 53980 NULL
108365 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
108366 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
108367 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
108368 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
108369 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
108370 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
108371 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
108372 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
108373 +btrfs_start_transaction_54066 btrfs_start_transaction 2 54066 NULL
108374 +_malloc_54077 _malloc 1 54077 NULL
108375 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
108376 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
108377 +create_xattr_54106 create_xattr 5 54106 NULL
108378 +inc_zcache_pers_zbytes_54107 inc_zcache_pers_zbytes 1 54107 NULL
108379 +strn_len_54122 strn_len 0 54122 NULL
108380 +isku_receive_54130 isku_receive 4 54130 NULL
108381 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
108382 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
108383 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
108384 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
108385 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
108386 +SyS_ipc_54206 SyS_ipc 3 54206 NULL
108387 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
108388 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
108389 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
108390 +reada_add_block_54247 reada_add_block 2 54247 NULL
108391 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
108392 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
108393 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
108394 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
108395 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
108396 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
108397 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
108398 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
108399 +get_iovec_page_array_54298 get_iovec_page_array 6 54298 NULL
108400 +sprintf_54306 sprintf 0 54306 NULL
108401 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
108402 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
108403 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
108404 +__get_free_pages_54352 __get_free_pages 0 54352 NULL nohasharray
108405 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 &__get_free_pages_54352
108406 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
108407 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
108408 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
108409 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
108410 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
108411 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
108412 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
108413 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
108414 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
108415 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
108416 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
108417 +copy_gadget_strings_54417 copy_gadget_strings 2-3 54417 NULL
108418 +swiotlb_tbl_sync_single_54486 swiotlb_tbl_sync_single 2 54486 NULL
108419 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
108420 +swiotlb_tbl_map_single_54495 swiotlb_tbl_map_single 3-0 54495 NULL
108421 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
108422 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL nohasharray
108423 +xen_bus_to_phys_54514 xen_bus_to_phys 0 54514 &cgroup_write_X64_54514
108424 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
108425 +vmci_transport_dgram_enqueue_54525 vmci_transport_dgram_enqueue 4 54525 NULL
108426 +viacam_read_54526 viacam_read 3 54526 NULL
108427 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
108428 +setsockopt_54539 setsockopt 5 54539 NULL
108429 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
108430 +SYSC_setsockopt_54561 SYSC_setsockopt 5 54561 NULL
108431 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
108432 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
108433 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
108434 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
108435 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
108436 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
108437 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
108438 +kvm_read_cr3_54662 kvm_read_cr3 0 54662 NULL
108439 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
108440 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
108441 +evm_read_key_54674 evm_read_key 3 54674 NULL
108442 +resource_string_54699 resource_string 0 54699 NULL
108443 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
108444 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL nohasharray
108445 +compat_SyS_readv_54711 compat_SyS_readv 3 54711 &rfkill_fop_read_54711
108446 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
108447 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
108448 +kzalloc_54740 kzalloc 1 54740 NULL
108449 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
108450 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
108451 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
108452 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
108453 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
108454 +domain_init_54797 domain_init 2 54797 NULL
108455 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
108456 +get_dev_size_54807 get_dev_size 0 54807 NULL
108457 +nfsd_write_54809 nfsd_write 6 54809 NULL
108458 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
108459 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
108460 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
108461 +write_rio_54837 write_rio 3 54837 NULL
108462 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
108463 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
108464 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
108465 +printer_read_54851 printer_read 3 54851 NULL
108466 +qib_reg_user_mr_54858 qib_reg_user_mr 2-3 54858 NULL
108467 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
108468 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
108469 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
108470 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
108471 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
108472 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
108473 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
108474 +add_port_54941 add_port 2 54941 NULL
108475 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
108476 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
108477 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
108478 +c4_add_card_54968 c4_add_card 3 54968 NULL
108479 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
108480 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
108481 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
108482 +Bus_to_Virtual_54991 Bus_to_Virtual 1 54991 NULL
108483 +mem_cgroup_get_lru_size_55008 mem_cgroup_get_lru_size 0 55008 NULL
108484 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
108485 +paging32_get_level1_sp_gpa_55022 paging32_get_level1_sp_gpa 0 55022 NULL
108486 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
108487 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
108488 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
108489 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
108490 +hx8357_spi_write_array_55095 hx8357_spi_write_array 3 55095 NULL
108491 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
108492 +corrupt_data_55120 corrupt_data 0 55120 NULL
108493 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
108494 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
108495 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
108496 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
108497 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
108498 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
108499 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
108500 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
108501 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL
108502 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 NULL
108503 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
108504 +qxl_alloc_client_monitors_config_55216 qxl_alloc_client_monitors_config 2 55216 NULL
108505 +nouveau_mc_create__55217 nouveau_mc_create_ 4 55217 NULL
108506 +dump_command_55220 dump_command 1 55220 NULL
108507 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
108508 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
108509 +hash_netport6_expire_55232 hash_netport6_expire 3 55232 NULL
108510 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
108511 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
108512 +persistent_ram_new_55286 persistent_ram_new 1-2 55286 NULL
108513 +ptrace_request_55288 ptrace_request 3-4 55288 NULL
108514 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
108515 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
108516 +qp_alloc_guest_work_55305 qp_alloc_guest_work 3-5 55305 NULL nohasharray
108517 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 &qp_alloc_guest_work_55305
108518 +do_shmat_55336 do_shmat 5 55336 NULL
108519 +vme_user_read_55338 vme_user_read 3 55338 NULL
108520 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
108521 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
108522 +__memblock_alloc_base_55359 __memblock_alloc_base 1-2 55359 NULL
108523 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
108524 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
108525 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
108526 +si476x_radio_read_rds_blckcnt_blob_55427 si476x_radio_read_rds_blckcnt_blob 3 55427 NULL
108527 +alloc_skb_55439 alloc_skb 1 55439 NULL
108528 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
108529 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
108530 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
108531 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
108532 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
108533 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
108534 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
108535 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
108536 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
108537 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
108538 +ea_get_55522 ea_get 0 55522 NULL
108539 +buffer_size_55534 buffer_size 0 55534 NULL
108540 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
108541 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
108542 +hash_netport4_expire_55584 hash_netport4_expire 3 55584 NULL
108543 +add_partition_55588 add_partition 2 55588 NULL
108544 +SyS_keyctl_55602 SyS_keyctl 4 55602 NULL
108545 +free_pages_55603 free_pages 1 55603 NULL
108546 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
108547 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
108548 +edge_tty_recv_55622 edge_tty_recv 3 55622 NULL
108549 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
108550 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
108551 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
108552 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
108553 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
108554 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
108555 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
108556 +read_oldmem_55658 read_oldmem 3 55658 NULL
108557 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
108558 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
108559 +get_info_55681 get_info 3 55681 NULL
108560 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
108561 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
108562 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
108563 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
108564 +tap_pwup_write_55723 tap_pwup_write 3 55723 NULL
108565 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 2 55738 NULL
108566 +set_local_name_55757 set_local_name 4 55757 NULL
108567 +strlen_55778 strlen 0 55778 NULL
108568 +set_spte_55783 set_spte 5-4 55783 NULL
108569 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
108570 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
108571 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
108572 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
108573 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
108574 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
108575 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
108576 +hsc_write_55875 hsc_write 3 55875 NULL
108577 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
108578 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
108579 +paging64_page_fault_55942 paging64_page_fault 2 55942 NULL
108580 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
108581 +ceph_get_direct_page_vector_55956 ceph_get_direct_page_vector 2 55956 NULL
108582 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
108583 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
108584 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
108585 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
108586 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
108587 +__set_discard_56081 __set_discard 2 56081 NULL
108588 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
108589 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
108590 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
108591 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
108592 +map_addr_56144 map_addr 7 56144 NULL
108593 +__i2c_transfer_56162 __i2c_transfer 0 56162 NULL
108594 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
108595 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
108596 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
108597 +skb_headroom_56200 skb_headroom 0 56200 NULL
108598 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
108599 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
108600 +vring_add_indirect_56222 vring_add_indirect 4 56222 NULL
108601 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
108602 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
108603 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
108604 +fd_copyin_56247 fd_copyin 3 56247 NULL
108605 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
108606 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
108607 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
108608 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
108609 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
108610 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
108611 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
108612 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
108613 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
108614 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
108615 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
108616 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
108617 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
108618 +dev_read_56369 dev_read 3 56369 NULL
108619 +write_gssp_56404 write_gssp 3 56404 NULL
108620 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
108621 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
108622 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
108623 +store_msg_56417 store_msg 3 56417 NULL
108624 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
108625 +fl_create_56435 fl_create 5 56435 NULL
108626 +gnttab_map_56439 gnttab_map 2 56439 NULL
108627 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
108628 +set_connectable_56458 set_connectable 4 56458 NULL
108629 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
108630 +putused_user_56467 putused_user 3 56467 NULL
108631 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
108632 +global_rt_period_56476 global_rt_period 0 56476 NULL
108633 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
108634 +ieee80211_rx_mgmt_probe_beacon_56491 ieee80211_rx_mgmt_probe_beacon 3 56491 NULL
108635 +init_map_ip_56508 init_map_ip 5 56508 NULL
108636 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
108637 +ip_options_get_56538 ip_options_get 4 56538 NULL
108638 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
108639 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
108640 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
108641 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
108642 +event_filter_write_56609 event_filter_write 3 56609 NULL
108643 +gather_array_56641 gather_array 3 56641 NULL
108644 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
108645 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
108646 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
108647 +build_map_info_56696 build_map_info 2 56696 NULL
108648 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
108649 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
108650 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
108651 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
108652 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
108653 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
108654 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
108655 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
108656 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
108657 +hash_lookup_56792 hash_lookup 2 56792 NULL
108658 +do_syslog_56807 do_syslog 3 56807 NULL
108659 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
108660 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
108661 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
108662 +si476x_radio_read_agc_blob_56849 si476x_radio_read_agc_blob 3 56849 NULL
108663 +wb_lookup_56858 wb_lookup 2 56858 NULL
108664 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
108665 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
108666 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
108667 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
108668 +strcspn_56913 strcspn 0 56913 NULL
108669 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
108670 +check_header_56930 check_header 2 56930 NULL
108671 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
108672 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
108673 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
108674 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
108675 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
108676 +aircable_process_packet_57027 aircable_process_packet 4 57027 NULL
108677 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
108678 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
108679 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
108680 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
108681 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
108682 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
108683 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
108684 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
108685 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
108686 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
108687 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
108688 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
108689 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
108690 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
108691 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
108692 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
108693 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
108694 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
108695 +__ipath_get_user_pages_57166 __ipath_get_user_pages 1-2 57166 NULL
108696 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
108697 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
108698 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
108699 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
108700 +flush_space_57241 flush_space 3 57241 NULL
108701 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
108702 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
108703 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
108704 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
108705 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
108706 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
108707 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
108708 +fw_file_size_57307 fw_file_size 0 57307 NULL
108709 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
108710 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
108711 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
108712 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
108713 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
108714 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
108715 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
108716 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
108717 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
108718 +read_file_blob_57406 read_file_blob 3 57406 NULL
108719 +enclosure_register_57412 enclosure_register 3 57412 NULL
108720 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
108721 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
108722 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
108723 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
108724 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
108725 +ReadReg_57453 ReadReg 0 57453 NULL
108726 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
108727 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
108728 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
108729 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
108730 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
108731 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
108732 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
108733 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
108734 +skb_headlen_57501 skb_headlen 0 57501 NULL
108735 +copy_in_user_57502 copy_in_user 3 57502 NULL
108736 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
108737 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
108738 +init_tag_map_57515 init_tag_map 3 57515 NULL
108739 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
108740 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
108741 +inode_permission_57531 inode_permission 0 57531 NULL
108742 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
108743 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
108744 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
108745 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
108746 +uio_find_mem_index_57584 uio_find_mem_index 0 57584 NULL
108747 +read_file_spectral_fft_period_57593 read_file_spectral_fft_period 3 57593 NULL
108748 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
108749 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
108750 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 NULL
108751 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
108752 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
108753 +mem_read_57631 mem_read 3 57631 NULL
108754 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
108755 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
108756 +r3964_write_57662 r3964_write 4 57662 NULL
108757 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
108758 +__lgwrite_57669 __lgwrite 4 57669 NULL
108759 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
108760 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
108761 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
108762 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
108763 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
108764 +nouveau_gpio_create__57735 nouveau_gpio_create_ 4-5 57735 NULL
108765 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
108766 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
108767 +SYSC_process_vm_writev_57776 SYSC_process_vm_writev 3-5 57776 NULL
108768 +ld2_57794 ld2 0 57794 NULL
108769 +ivtv_read_57796 ivtv_read 3 57796 NULL
108770 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
108771 +ipath_user_sdma_num_pages_57813 ipath_user_sdma_num_pages 0 57813 NULL
108772 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
108773 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
108774 +copy_to_user_57835 copy_to_user 3 57835 NULL
108775 +flash_read_57843 flash_read 3 57843 NULL
108776 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
108777 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
108778 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
108779 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
108780 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
108781 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
108782 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
108783 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
108784 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
108785 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
108786 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
108787 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
108788 +c2_reg_user_mr_57982 c2_reg_user_mr 2-3 57982 NULL
108789 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
108790 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
108791 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
108792 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
108793 +mce_async_out_58056 mce_async_out 3 58056 NULL
108794 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
108795 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
108796 +cm4040_write_58079 cm4040_write 3 58079 NULL
108797 +udi_log_event_58105 udi_log_event 3 58105 NULL
108798 +savemem_58129 savemem 3 58129 NULL
108799 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
108800 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
108801 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
108802 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
108803 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
108804 +hva_to_pfn_58241 hva_to_pfn 1 58241 NULL
108805 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
108806 +read_file_debug_58256 read_file_debug 3 58256 NULL
108807 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
108808 +profile_load_58267 profile_load 3 58267 NULL
108809 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
108810 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
108811 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
108812 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
108813 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
108814 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
108815 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
108816 +next_pidmap_58347 next_pidmap 2 58347 NULL
108817 +SyS_migrate_pages_58348 SyS_migrate_pages 2 58348 NULL
108818 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
108819 +save_hint_58359 save_hint 2 58359 NULL
108820 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
108821 +hash_ipportnet6_expire_58379 hash_ipportnet6_expire 3 58379 NULL
108822 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
108823 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
108824 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
108825 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
108826 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
108827 +capabilities_read_58457 capabilities_read 3 58457 NULL
108828 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
108829 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
108830 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
108831 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
108832 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
108833 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
108834 +memblock_alloc_try_nid_58493 memblock_alloc_try_nid 1-2 58493 NULL
108835 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
108836 +__clear_discard_58546 __clear_discard 2 58546 NULL
108837 +wrap_max_58548 wrap_max 0-1-2 58548 NULL
108838 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
108839 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
108840 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
108841 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
108842 +isku_sysfs_read_keys_thumbster_58590 isku_sysfs_read_keys_thumbster 6 58590 NULL
108843 +xip_file_read_58592 xip_file_read 3 58592 NULL
108844 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
108845 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
108846 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
108847 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
108848 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
108849 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
108850 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
108851 +__gfn_to_pfn_58671 __gfn_to_pfn 2 58671 NULL
108852 +iwl_trans_send_cmd_58681 iwl_trans_send_cmd 0 58681 NULL
108853 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
108854 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
108855 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
108856 +pci_alloc_consistent_58688 pci_alloc_consistent 0 58688 NULL
108857 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
108858 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
108859 +acpi_map_58725 acpi_map 1-2 58725 NULL
108860 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
108861 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
108862 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
108863 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
108864 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
108865 +oblock_to_dblock_58762 oblock_to_dblock 0-2 58762 NULL
108866 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
108867 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
108868 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
108869 +isku_sysfs_read_58806 isku_sysfs_read 6-5 58806 NULL
108870 +ep_read_58813 ep_read 3 58813 NULL
108871 +command_write_58841 command_write 3 58841 NULL
108872 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
108873 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
108874 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
108875 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
108876 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
108877 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
108878 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
108879 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
108880 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
108881 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
108882 +idx_to_kaddr_58968 idx_to_kaddr 0 58968 NULL
108883 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
108884 +remap_to_cache_dirty_58991 remap_to_cache_dirty 4-3 58991 NULL
108885 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
108886 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
108887 +ep_write_59008 ep_write 3 59008 NULL
108888 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
108889 +SyS_preadv_59029 SyS_preadv 3 59029 NULL
108890 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
108891 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
108892 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
108893 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
108894 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
108895 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
108896 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
108897 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
108898 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
108899 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
108900 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
108901 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
108902 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
108903 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
108904 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
108905 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
108906 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
108907 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
108908 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
108909 +dt3155_read_59226 dt3155_read 3 59226 NULL
108910 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
108911 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
108912 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
108913 +nla_len_59258 nla_len 0 59258 NULL
108914 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
108915 +fd_copyout_59323 fd_copyout 3 59323 NULL
108916 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
108917 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
108918 +paging64_get_level1_sp_gpa_59346 paging64_get_level1_sp_gpa 0 59346 NULL nohasharray
108919 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 &paging64_get_level1_sp_gpa_59346
108920 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
108921 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
108922 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
108923 +isku_sysfs_read_keys_function_59412 isku_sysfs_read_keys_function 6 59412 NULL
108924 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
108925 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
108926 +SyS_sched_setaffinity_59442 SyS_sched_setaffinity 2 59442 NULL
108927 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
108928 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
108929 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
108930 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
108931 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
108932 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
108933 +rds_pin_pages_59507 rds_pin_pages 0-1-2 59507 NULL
108934 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
108935 +tunables_write_59563 tunables_write 3 59563 NULL
108936 +memdup_user_59590 memdup_user 2 59590 NULL
108937 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
108938 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
108939 +mtrr_write_59622 mtrr_write 3 59622 NULL
108940 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
108941 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
108942 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
108943 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
108944 +paravirt_sched_clock_59660 paravirt_sched_clock 0 59660 NULL
108945 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
108946 +iwl_dbgfs_mac_params_read_59666 iwl_dbgfs_mac_params_read 3 59666 NULL
108947 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
108948 +can_nocow_odirect_59681 can_nocow_odirect 3 59681 NULL
108949 +sriov_enable_59689 sriov_enable 2 59689 NULL
108950 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
108951 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
108952 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
108953 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
108954 +strnlen_59746 strnlen 0 59746 NULL
108955 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
108956 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
108957 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
108958 +venus_remove_59781 venus_remove 4 59781 NULL
108959 +mei_nfc_recv_59784 mei_nfc_recv 3 59784 NULL
108960 +C_SYSC_preadv_59801 C_SYSC_preadv 3 59801 NULL
108961 +ipw_write_59807 ipw_write 3 59807 NULL
108962 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
108963 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
108964 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
108965 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
108966 +regmap_raw_write_async_59849 regmap_raw_write_async 2-4 59849 NULL
108967 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
108968 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL nohasharray
108969 +start_transaction_59885 start_transaction 2 59885 &shmem_zero_setup_59885
108970 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
108971 +swiotlb_map_page_59909 swiotlb_map_page 3 59909 NULL
108972 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
108973 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
108974 +lookup_node_59953 lookup_node 2 59953 NULL
108975 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 NULL nohasharray
108976 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 &il_dbgfs_missed_beacon_read_59956
108977 +kvm_set_cr3_59965 kvm_set_cr3 2 59965 NULL
108978 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
108979 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
108980 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
108981 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
108982 +ieee80211_if_fmt_dot11MeshAwakeWindowDuration_60006 ieee80211_if_fmt_dot11MeshAwakeWindowDuration 3 60006 NULL
108983 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
108984 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
108985 +register_device_60015 register_device 2-3 60015 NULL
108986 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
108987 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
108988 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
108989 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
108990 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
108991 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
108992 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
108993 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 NULL
108994 +compat_writev_60063 compat_writev 3 60063 NULL
108995 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 6-8 60064 NULL
108996 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
108997 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
108998 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
108999 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
109000 +SYSC_msgsnd_60113 SYSC_msgsnd 3 60113 NULL
109001 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
109002 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
109003 +init_state_60165 init_state 2 60165 NULL
109004 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
109005 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
109006 +fuse_async_req_send_60183 fuse_async_req_send 0-3 60183 NULL
109007 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
109008 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
109009 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
109010 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
109011 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
109012 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
109013 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
109014 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL nohasharray
109015 +__phys_addr_nodebug_60230 __phys_addr_nodebug 0-1 60230 &arizona_map_irq_60230
109016 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
109017 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
109018 +printer_write_60276 printer_write 3 60276 NULL
109019 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
109020 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
109021 +getDataLength_60301 getDataLength 0 60301 NULL
109022 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
109023 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
109024 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
109025 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
109026 +instruction_pointer_60384 instruction_pointer 0 60384 NULL
109027 +drop_outstanding_extent_60390 drop_outstanding_extent 0 60390 NULL
109028 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
109029 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
109030 +driver_names_read_60399 driver_names_read 3 60399 NULL
109031 +paging32_walk_addr_generic_60415 paging32_walk_addr_generic 4 60415 NULL
109032 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
109033 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
109034 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
109035 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
109036 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
109037 +rx_data_60442 rx_data 4 60442 NULL nohasharray
109038 +scaled_div32_60442 scaled_div32 1-2 60442 &rx_data_60442
109039 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
109040 +snd_hda_get_num_raw_conns_60462 snd_hda_get_num_raw_conns 0 60462 NULL
109041 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
109042 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
109043 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
109044 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
109045 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
109046 +nfsd_hashsize_60562 nfsd_hashsize 0 60562 NULL
109047 +hash_net6_expire_60598 hash_net6_expire 3 60598 NULL
109048 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
109049 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
109050 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
109051 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
109052 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
109053 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
109054 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
109055 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
109056 +init_data_container_60709 init_data_container 1 60709 NULL
109057 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
109058 +raid_status_60755 raid_status 5 60755 NULL
109059 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
109060 +opticon_write_60775 opticon_write 4 60775 NULL
109061 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
109062 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
109063 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
109064 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
109065 +generic_writepages_60871 generic_writepages 0 60871 NULL
109066 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
109067 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
109068 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
109069 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
109070 +sys_mlock_60932 sys_mlock 1 60932 NULL
109071 +pti_char_write_60960 pti_char_write 3 60960 NULL
109072 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
109073 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
109074 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
109075 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
109076 +symtab_init_61050 symtab_init 2 61050 NULL
109077 +fuse_send_write_61053 fuse_send_write 0-4 61053 NULL
109078 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
109079 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
109080 +get_derived_key_61100 get_derived_key 4 61100 NULL
109081 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
109082 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
109083 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
109084 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
109085 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
109086 +brcmf_sdio_chip_cr4_exitdl_61143 brcmf_sdio_chip_cr4_exitdl 4 61143 NULL
109087 +__vmalloc_61168 __vmalloc 1 61168 NULL
109088 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
109089 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
109090 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
109091 +SyS_prctl_61202 SyS_prctl 4 61202 NULL
109092 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
109093 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
109094 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
109095 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
109096 +sys_add_key_61288 sys_add_key 4 61288 NULL nohasharray
109097 +nvme_trans_copy_to_user_61288 nvme_trans_copy_to_user 3 61288 &sys_add_key_61288
109098 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
109099 +xfer_from_user_61307 xfer_from_user 3 61307 NULL
109100 +timespec_to_ns_61317 timespec_to_ns 0 61317 NULL
109101 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
109102 +C_SYSC_msgsnd_61330 C_SYSC_msgsnd 2-3 61330 NULL
109103 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
109104 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
109105 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
109106 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
109107 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
109108 +change_xattr_61390 change_xattr 5 61390 NULL
109109 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
109110 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
109111 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
109112 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
109113 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
109114 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
109115 +erst_errno_61526 erst_errno 0 61526 NULL
109116 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
109117 +get_ohm_of_thermistor_61545 get_ohm_of_thermistor 2 61545 NULL
109118 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
109119 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
109120 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
109121 +seq_open_private_61589 seq_open_private 3 61589 NULL
109122 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
109123 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
109124 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
109125 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
109126 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
109127 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
109128 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
109129 +resize_stripes_61650 resize_stripes 2 61650 NULL
109130 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
109131 +insert_one_name_61668 insert_one_name 7 61668 NULL
109132 +lock_loop_61681 lock_loop 1 61681 NULL
109133 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
109134 +filter_read_61692 filter_read 3 61692 NULL
109135 +iov_length_61716 iov_length 0 61716 NULL
109136 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
109137 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
109138 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
109139 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
109140 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
109141 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
109142 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
109143 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
109144 +SYSC_lsetxattr_61869 SYSC_lsetxattr 4 61869 NULL
109145 +get_fw_name_61874 get_fw_name 3 61874 NULL
109146 +free_init_pages_61875 free_init_pages 2 61875 NULL
109147 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
109148 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
109149 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
109150 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
109151 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
109152 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
109153 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
109154 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
109155 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
109156 +gfn_to_pfn_memslot_atomic_61947 gfn_to_pfn_memslot_atomic 2 61947 NULL
109157 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
109158 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
109159 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
109160 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
109161 +cow_file_range_61979 cow_file_range 3 61979 NULL
109162 +module_alloc_exec_61991 module_alloc_exec 1 61991 NULL
109163 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
109164 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
109165 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
109166 +SYSC_select_62024 SYSC_select 1 62024 NULL
109167 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
109168 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
109169 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
109170 +do_pselect_62061 do_pselect 1 62061 NULL
109171 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2-3 62074 NULL
109172 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
109173 +ipath_user_sdma_pin_pages_62100 ipath_user_sdma_pin_pages 3-5 62100 NULL
109174 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
109175 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
109176 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
109177 +ql_status_62135 ql_status 5 62135 NULL
109178 +video_usercopy_62151 video_usercopy 2 62151 NULL
109179 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
109180 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
109181 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
109182 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
109183 +SYSC_setgroups16_62232 SYSC_setgroups16 1 62232 NULL
109184 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
109185 +allocate_partition_62245 allocate_partition 4 62245 NULL
109186 +__qib_get_user_pages_62287 __qib_get_user_pages 1-2 62287 NULL
109187 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
109188 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
109189 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
109190 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
109191 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
109192 +subseq_list_62332 subseq_list 3-0 62332 NULL
109193 +flash_write_62354 flash_write 3 62354 NULL
109194 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
109195 +twl_get_num_slaves_62386 twl_get_num_slaves 0 62386 NULL
109196 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
109197 +altera_irscan_62396 altera_irscan 2 62396 NULL
109198 +set_ssp_62411 set_ssp 4 62411 NULL
109199 +unmap_single_62423 unmap_single 2 62423 NULL
109200 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
109201 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
109202 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
109203 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
109204 +remove_mapping_62491 remove_mapping 2 62491 NULL
109205 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
109206 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
109207 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL nohasharray
109208 +i915_next_seqno_read_62524 i915_next_seqno_read 3 62524 &pep_sendmsg_62524
109209 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
109210 +debugfs_read_62535 debugfs_read 3 62535 NULL
109211 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
109212 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
109213 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
109214 +get_subdir_62581 get_subdir 3 62581 NULL
109215 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
109216 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
109217 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
109218 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
109219 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
109220 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
109221 +memblock_alloc_nid_62652 memblock_alloc_nid 1-2 62652 NULL
109222 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
109223 +write_62671 write 3 62671 NULL
109224 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
109225 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
109226 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
109227 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
109228 +rdm_62719 rdm 0 62719 NULL
109229 +key_replays_read_62746 key_replays_read 3 62746 NULL
109230 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
109231 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
109232 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
109233 +C_SYSC_ipc_62776 C_SYSC_ipc 5-3-6-4 62776 NULL
109234 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
109235 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
109236 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
109237 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
109238 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
109239 +set_swbp_62853 set_swbp 3 62853 NULL
109240 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
109241 +aoechr_write_62883 aoechr_write 3 62883 NULL
109242 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
109243 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
109244 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
109245 +getdqbuf_62908 getdqbuf 1 62908 NULL
109246 +try_async_pf_62914 try_async_pf 3 62914 NULL nohasharray
109247 +SyS_remap_file_pages_62914 SyS_remap_file_pages 1 62914 &try_async_pf_62914
109248 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
109249 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 NULL
109250 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
109251 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
109252 +gso_pskb_expand_head_63052 gso_pskb_expand_head 2 63052 NULL
109253 +unlink1_63059 unlink1 3 63059 NULL
109254 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
109255 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
109256 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
109257 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
109258 +alloc_cblock_63133 alloc_cblock 2 63133 NULL
109259 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
109260 +xen_zap_pfn_range_63149 xen_zap_pfn_range 1 63149 NULL
109261 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
109262 +vme_master_read_63221 vme_master_read 0 63221 NULL
109263 +SyS_gethostname_63227 SyS_gethostname 2 63227 NULL
109264 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
109265 +ptp_read_63251 ptp_read 4 63251 NULL
109266 +raid5_resize_63306 raid5_resize 2 63306 NULL
109267 +proc_info_read_63344 proc_info_read 3 63344 NULL
109268 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
109269 +idmouse_read_63374 idmouse_read 3 63374 NULL
109270 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
109271 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
109272 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
109273 +nouveau_event_create_63411 nouveau_event_create 1 63411 NULL
109274 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
109275 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
109276 +kone_send_63435 kone_send 4 63435 NULL
109277 +gfn_to_hva_many_63437 gfn_to_hva_many 0-2 63437 NULL
109278 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
109279 +ipv6_is_mld_63461 ipv6_is_mld 3 63461 NULL
109280 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
109281 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
109282 +read_kcore_63488 read_kcore 3 63488 NULL
109283 +save_hint_63497 save_hint 2 63497 NULL
109284 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
109285 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
109286 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
109287 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
109288 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
109289 +kvm_write_guest_page_63555 kvm_write_guest_page 5-2 63555 &dbg_leb_write_63555
109290 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
109291 +iwch_reg_user_mr_63575 iwch_reg_user_mr 2-3 63575 NULL
109292 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
109293 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
109294 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
109295 +module_alloc_63630 module_alloc 1 63630 NULL
109296 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
109297 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
109298 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
109299 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
109300 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
109301 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
109302 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
109303 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
109304 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
109305 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
109306 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
109307 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
109308 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
109309 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
109310 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
109311 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
109312 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
109313 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
109314 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
109315 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
109316 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
109317 +dec_zcache_eph_zbytes_63817 dec_zcache_eph_zbytes 1 63817 NULL
109318 +prepare_copy_63826 prepare_copy 2 63826 NULL
109319 +sel_write_load_63830 sel_write_load 3 63830 NULL
109320 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
109321 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
109322 +divas_write_63901 divas_write 3 63901 NULL
109323 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
109324 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
109325 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
109326 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
109327 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
109328 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
109329 +__team_options_register_63941 __team_options_register 3 63941 NULL
109330 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
109331 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
109332 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
109333 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
109334 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
109335 +kmemdup_64015 kmemdup 2 64015 NULL
109336 +SyS_rt_sigpending_64018 SyS_rt_sigpending 2 64018 NULL
109337 +offset_to_vaddr_64025 offset_to_vaddr 0-2 64025 NULL nohasharray
109338 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 &offset_to_vaddr_64025
109339 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
109340 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
109341 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
109342 +tfrc_calc_x_reverse_lookup_64057 tfrc_calc_x_reverse_lookup 0 64057 NULL
109343 +get_u8_64076 get_u8 0 64076 NULL
109344 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
109345 +vmci_handle_arr_get_size_64088 vmci_handle_arr_get_size 0 64088 NULL
109346 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
109347 +SyS_mq_timedsend_64107 SyS_mq_timedsend 3 64107 NULL
109348 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
109349 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
109350 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
109351 +init_bch_64130 init_bch 1-2 64130 NULL
109352 +SYSC_ptrace_64136 SYSC_ptrace 3-4 64136 NULL
109353 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
109354 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
109355 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
109356 +__comedi_buf_alloc_64155 __comedi_buf_alloc 3 64155 NULL
109357 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
109358 +read_pulse_64227 read_pulse 0-3 64227 NULL
109359 +header_len_64232 header_len 0 64232 NULL
109360 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
109361 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
109362 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
109363 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
109364 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
109365 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
109366 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
109367 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
109368 +ffz_64324 ffz 0 64324 NULL
109369 +map_region_64328 map_region 1 64328 NULL
109370 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
109371 +ts_write_64336 ts_write 3 64336 NULL
109372 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
109373 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
109374 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
109375 +bnx2x_vfop_mcast_cmd_64354 bnx2x_vfop_mcast_cmd 5 64354 NULL
109376 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
109377 +ilo_write_64378 ilo_write 3 64378 NULL
109378 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
109379 +vmcs_readl_64381 vmcs_readl 0 64381 NULL
109380 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
109381 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
109382 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
109383 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
109384 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
109385 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
109386 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
109387 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
109388 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL nohasharray
109389 +read_file_spectral_short_repeat_64431 read_file_spectral_short_repeat 3 64431 &ext4_trim_extent_64431
109390 +cap_capable_64462 cap_capable 0 64462 NULL
109391 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
109392 +single_open_size_64483 single_open_size 4 64483 NULL
109393 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
109394 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
109395 +remove_uuid_64505 remove_uuid 4 64505 NULL nohasharray
109396 +handle_abnormal_pfn_64505 handle_abnormal_pfn 3 64505 &remove_uuid_64505
109397 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
109398 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
109399 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
109400 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
109401 +SyS_bind_64544 SyS_bind 3 64544 NULL
109402 +rbd_obj_read_sync_64554 rbd_obj_read_sync 3-4 64554 NULL
109403 +__spi_sync_64561 __spi_sync 0 64561 NULL
109404 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
109405 +fanotify_write_64623 fanotify_write 3 64623 NULL
109406 +to_dblock_64655 to_dblock 0-1 64655 NULL
109407 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
109408 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
109409 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
109410 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
109411 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
109412 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
109413 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
109414 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
109415 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
109416 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
109417 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
109418 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
109419 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
109420 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
109421 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
109422 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
109423 +regmap_reg_ranges_read_file_64798 regmap_reg_ranges_read_file 3 64798 NULL
109424 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
109425 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
109426 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
109427 +vaddr_get_pfn_64818 vaddr_get_pfn 1 64818 NULL
109428 +gfn_to_page_64826 gfn_to_page 2 64826 NULL
109429 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
109430 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
109431 +gfn_to_pfn_64870 gfn_to_pfn 2 64870 NULL
109432 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
109433 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
109434 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
109435 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
109436 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
109437 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
109438 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
109439 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
109440 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
109441 +pskb_pull_65005 pskb_pull 2 65005 NULL
109442 +unifi_write_65012 unifi_write 3 65012 NULL
109443 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
109444 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
109445 +insert_dent_65034 insert_dent 7 65034 NULL
109446 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
109447 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
109448 +tty_audit_log_65043 tty_audit_log 8 65043 NULL
109449 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
109450 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
109451 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
109452 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2-3 65076 NULL
109453 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
109454 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
109455 +C_SYSC_semctl_65091 C_SYSC_semctl 4 65091 NULL
109456 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
109457 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
109458 +print_endpoint_stat_65232 print_endpoint_stat 3-4-0 65232 NULL
109459 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
109460 +atomic_long_read_65263 atomic_long_read 0 65263 NULL
109461 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
109462 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
109463 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
109464 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
109465 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
109466 +get_var_len_65304 get_var_len 0 65304 NULL
109467 +unpack_array_65318 unpack_array 0 65318 NULL
109468 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
109469 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
109470 +init_list_set_65351 init_list_set 2-3 65351 NULL
109471 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
109472 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
109473 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
109474 +__ext4_new_inode_65370 __ext4_new_inode 5 65370 NULL
109475 +strchr_65372 strchr 0 65372 NULL nohasharray
109476 +SyS_writev_65372 SyS_writev 3 65372 &strchr_65372
109477 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1-2 65397 NULL
109478 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
109479 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
109480 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
109481 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
109482 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
109483 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
109484 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
109485 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
109486 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
109487 +alloc_dr_65495 alloc_dr 2 65495 NULL
109488 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
109489 new file mode 100644
109490 index 0000000..03d0c84
109491 --- /dev/null
109492 +++ b/tools/gcc/size_overflow_plugin.c
109493 @@ -0,0 +1,2113 @@
109494 +/*
109495 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
109496 + * Licensed under the GPL v2, or (at your option) v3
109497 + *
109498 + * Homepage:
109499 + * http://www.grsecurity.net/~ephox/overflow_plugin/
109500 + *
109501 + * Documentation:
109502 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
109503 + *
109504 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
109505 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
109506 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
109507 + *
109508 + * Usage:
109509 + * $ 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
109510 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
109511 + */
109512 +
109513 +#include "gcc-plugin.h"
109514 +#include "config.h"
109515 +#include "system.h"
109516 +#include "coretypes.h"
109517 +#include "tree.h"
109518 +#include "tree-pass.h"
109519 +#include "intl.h"
109520 +#include "plugin-version.h"
109521 +#include "tm.h"
109522 +#include "toplev.h"
109523 +#include "function.h"
109524 +#include "tree-flow.h"
109525 +#include "plugin.h"
109526 +#include "gimple.h"
109527 +#include "diagnostic.h"
109528 +#include "cfgloop.h"
109529 +
109530 +#if BUILDING_GCC_VERSION >= 4008
109531 +#define TODO_dump_func 0
109532 +#endif
109533 +
109534 +struct size_overflow_hash {
109535 + const struct size_overflow_hash * const next;
109536 + const char * const name;
109537 + const unsigned int param;
109538 +};
109539 +
109540 +#include "size_overflow_hash.h"
109541 +
109542 +enum mark {
109543 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
109544 +};
109545 +
109546 +enum err_code_conditions {
109547 + CAST_ONLY, FROM_CONST
109548 +};
109549 +
109550 +static unsigned int call_count = 0;
109551 +
109552 +#define __unused __attribute__((__unused__))
109553 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
109554 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
109555 +#define BEFORE_STMT true
109556 +#define AFTER_STMT false
109557 +#define CREATE_NEW_VAR NULL_TREE
109558 +#define CODES_LIMIT 32
109559 +#define MAX_PARAM 31
109560 +#define MY_STMT GF_PLF_1
109561 +#define NO_CAST_CHECK GF_PLF_2
109562 +#define FROM_ARG true
109563 +#define FROM_RET false
109564 +
109565 +#if BUILDING_GCC_VERSION == 4005
109566 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
109567 +#endif
109568 +
109569 +int plugin_is_GPL_compatible;
109570 +void debug_gimple_stmt(gimple gs);
109571 +
109572 +static tree expand(struct pointer_set_t *visited, tree lhs);
109573 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
109574 +static tree report_size_overflow_decl;
109575 +static const_tree const_char_ptr_type_node;
109576 +static unsigned int handle_function(void);
109577 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
109578 +static tree get_size_overflow_type(gimple stmt, const_tree node);
109579 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
109580 +static void print_missing_msg(tree func, unsigned int argnum);
109581 +
109582 +static struct plugin_info size_overflow_plugin_info = {
109583 + .version = "20130822beta",
109584 + .help = "no-size-overflow\tturn off size overflow checking\n",
109585 +};
109586 +
109587 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
109588 +{
109589 + unsigned int arg_count;
109590 + enum tree_code code = TREE_CODE(*node);
109591 +
109592 + switch (code) {
109593 + case FUNCTION_DECL:
109594 + arg_count = type_num_arguments(TREE_TYPE(*node));
109595 + break;
109596 + case FUNCTION_TYPE:
109597 + case METHOD_TYPE:
109598 + arg_count = type_num_arguments(*node);
109599 + break;
109600 + default:
109601 + *no_add_attrs = true;
109602 + error("%s: %qE attribute only applies to functions", __func__, name);
109603 + return NULL_TREE;
109604 + }
109605 +
109606 + for (; args; args = TREE_CHAIN(args)) {
109607 + tree position = TREE_VALUE(args);
109608 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
109609 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
109610 + *no_add_attrs = true;
109611 + }
109612 + }
109613 + return NULL_TREE;
109614 +}
109615 +
109616 +static const char* get_asm_name(tree node)
109617 +{
109618 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
109619 +}
109620 +
109621 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
109622 +{
109623 + unsigned int arg_count, arg_num;
109624 + enum tree_code code = TREE_CODE(*node);
109625 +
109626 + switch (code) {
109627 + case FUNCTION_DECL:
109628 + arg_count = type_num_arguments(TREE_TYPE(*node));
109629 + break;
109630 + case FUNCTION_TYPE:
109631 + case METHOD_TYPE:
109632 + arg_count = type_num_arguments(*node);
109633 + break;
109634 + case FIELD_DECL:
109635 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
109636 + if (arg_num != 0) {
109637 + *no_add_attrs = true;
109638 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
109639 + }
109640 + return NULL_TREE;
109641 + default:
109642 + *no_add_attrs = true;
109643 + error("%qE attribute only applies to functions", name);
109644 + return NULL_TREE;
109645 + }
109646 +
109647 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
109648 + return NULL_TREE;
109649 +
109650 + for (; args; args = TREE_CHAIN(args)) {
109651 + tree position = TREE_VALUE(args);
109652 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
109653 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
109654 + *no_add_attrs = true;
109655 + }
109656 + }
109657 + return NULL_TREE;
109658 +}
109659 +
109660 +static struct attribute_spec size_overflow_attr = {
109661 + .name = "size_overflow",
109662 + .min_length = 1,
109663 + .max_length = -1,
109664 + .decl_required = true,
109665 + .type_required = false,
109666 + .function_type_required = false,
109667 + .handler = handle_size_overflow_attribute,
109668 +#if BUILDING_GCC_VERSION >= 4007
109669 + .affects_type_identity = false
109670 +#endif
109671 +};
109672 +
109673 +static struct attribute_spec intentional_overflow_attr = {
109674 + .name = "intentional_overflow",
109675 + .min_length = 1,
109676 + .max_length = -1,
109677 + .decl_required = true,
109678 + .type_required = false,
109679 + .function_type_required = false,
109680 + .handler = handle_intentional_overflow_attribute,
109681 +#if BUILDING_GCC_VERSION >= 4007
109682 + .affects_type_identity = false
109683 +#endif
109684 +};
109685 +
109686 +static void register_attributes(void __unused *event_data, void __unused *data)
109687 +{
109688 + register_attribute(&size_overflow_attr);
109689 + register_attribute(&intentional_overflow_attr);
109690 +}
109691 +
109692 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
109693 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
109694 +{
109695 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
109696 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
109697 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
109698 +
109699 + unsigned int m = 0x57559429;
109700 + unsigned int n = 0x5052acdb;
109701 + const unsigned int *key4 = (const unsigned int *)key;
109702 + unsigned int h = len;
109703 + unsigned int k = len + seed + n;
109704 + unsigned long long p;
109705 +
109706 + while (len >= 8) {
109707 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
109708 + len -= 8;
109709 + }
109710 + if (len >= 4) {
109711 + cwmixb(key4[0]) key4 += 1;
109712 + len -= 4;
109713 + }
109714 + if (len)
109715 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
109716 + cwmixb(h ^ (k + n));
109717 + return k ^ h;
109718 +
109719 +#undef cwfold
109720 +#undef cwmixa
109721 +#undef cwmixb
109722 +}
109723 +
109724 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
109725 +{
109726 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
109727 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
109728 + return fn ^ codes;
109729 +}
109730 +
109731 +static inline tree get_original_function_decl(tree fndecl)
109732 +{
109733 + if (DECL_ABSTRACT_ORIGIN(fndecl))
109734 + return DECL_ABSTRACT_ORIGIN(fndecl);
109735 + return fndecl;
109736 +}
109737 +
109738 +static inline gimple get_def_stmt(const_tree node)
109739 +{
109740 + gcc_assert(node != NULL_TREE);
109741 + if (TREE_CODE(node) != SSA_NAME)
109742 + return NULL;
109743 + return SSA_NAME_DEF_STMT(node);
109744 +}
109745 +
109746 +static unsigned char get_tree_code(const_tree type)
109747 +{
109748 + switch (TREE_CODE(type)) {
109749 + case ARRAY_TYPE:
109750 + return 0;
109751 + case BOOLEAN_TYPE:
109752 + return 1;
109753 + case ENUMERAL_TYPE:
109754 + return 2;
109755 + case FUNCTION_TYPE:
109756 + return 3;
109757 + case INTEGER_TYPE:
109758 + return 4;
109759 + case POINTER_TYPE:
109760 + return 5;
109761 + case RECORD_TYPE:
109762 + return 6;
109763 + case UNION_TYPE:
109764 + return 7;
109765 + case VOID_TYPE:
109766 + return 8;
109767 + case REAL_TYPE:
109768 + return 9;
109769 + case VECTOR_TYPE:
109770 + return 10;
109771 + case REFERENCE_TYPE:
109772 + return 11;
109773 + case OFFSET_TYPE:
109774 + return 12;
109775 + case COMPLEX_TYPE:
109776 + return 13;
109777 + default:
109778 + debug_tree((tree)type);
109779 + gcc_unreachable();
109780 + }
109781 +}
109782 +
109783 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
109784 +{
109785 + gcc_assert(type != NULL_TREE);
109786 +
109787 + while (type && len < CODES_LIMIT) {
109788 + tree_codes[len] = get_tree_code(type);
109789 + len++;
109790 + type = TREE_TYPE(type);
109791 + }
109792 + return len;
109793 +}
109794 +
109795 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
109796 +{
109797 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
109798 + enum tree_code code = TREE_CODE(type);
109799 + size_t len = 0;
109800 +
109801 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
109802 +
109803 + arg = TYPE_ARG_TYPES(type);
109804 + // skip builtins __builtin_constant_p
109805 + if (!arg && DECL_BUILT_IN(fndecl))
109806 + return 0;
109807 +
109808 + if (TREE_CODE_CLASS(code) == tcc_type)
109809 + result = type;
109810 + else
109811 + result = DECL_RESULT(fndecl);
109812 +
109813 + gcc_assert(result != NULL_TREE);
109814 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
109815 +
109816 + if (arg == NULL_TREE) {
109817 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
109818 + arg_field = DECL_ARGUMENT_FLD(fndecl);
109819 + if (arg_field == NULL_TREE)
109820 + return 0;
109821 + arg = TREE_TYPE(arg_field);
109822 + len = add_type_codes(arg, tree_codes, len);
109823 + gcc_assert(len != 0);
109824 + return len;
109825 + }
109826 +
109827 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
109828 + while (arg && len < CODES_LIMIT) {
109829 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
109830 + arg = TREE_CHAIN(arg);
109831 + }
109832 +
109833 + gcc_assert(len != 0);
109834 + return len;
109835 +}
109836 +
109837 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
109838 +{
109839 + unsigned int hash;
109840 + const struct size_overflow_hash *entry;
109841 + unsigned char tree_codes[CODES_LIMIT];
109842 + size_t len;
109843 + const char *func_name;
109844 +
109845 + fndecl = get_original_function_decl(fndecl);
109846 + len = get_function_decl(fndecl, tree_codes);
109847 + if (len == 0)
109848 + return NULL;
109849 +
109850 + func_name = get_asm_name(fndecl);
109851 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
109852 +
109853 + entry = size_overflow_hash[hash];
109854 + while (entry) {
109855 + if (!strcmp(entry->name, func_name))
109856 + return entry;
109857 + entry = entry->next;
109858 + }
109859 +
109860 + return NULL;
109861 +}
109862 +
109863 +static bool is_bool(const_tree node)
109864 +{
109865 + const_tree type;
109866 +
109867 + if (node == NULL_TREE)
109868 + return false;
109869 +
109870 + type = TREE_TYPE(node);
109871 + if (!INTEGRAL_TYPE_P(type))
109872 + return false;
109873 + if (TREE_CODE(type) == BOOLEAN_TYPE)
109874 + return true;
109875 + if (TYPE_PRECISION(type) == 1)
109876 + return true;
109877 + return false;
109878 +}
109879 +
109880 +static bool skip_types(const_tree var)
109881 +{
109882 + tree type;
109883 +
109884 + if (is_gimple_constant(var))
109885 + return true;
109886 +
109887 + switch (TREE_CODE(var)) {
109888 + case ADDR_EXPR:
109889 +#if BUILDING_GCC_VERSION >= 4006
109890 + case MEM_REF:
109891 +#endif
109892 + case ARRAY_REF:
109893 + case BIT_FIELD_REF:
109894 + case INDIRECT_REF:
109895 + case TARGET_MEM_REF:
109896 + return true;
109897 + case PARM_DECL:
109898 + case VAR_DECL:
109899 + case COMPONENT_REF:
109900 + return false;
109901 + default:
109902 + break;
109903 + }
109904 +
109905 + gcc_assert(TREE_CODE(var) == SSA_NAME);
109906 +
109907 + type = TREE_TYPE(var);
109908 + switch (TREE_CODE(type)) {
109909 + case INTEGER_TYPE:
109910 + case ENUMERAL_TYPE:
109911 + return false;
109912 + case BOOLEAN_TYPE:
109913 + return is_bool(var);
109914 + default:
109915 + break;
109916 + }
109917 +
109918 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
109919 +
109920 + type = TREE_TYPE(type);
109921 + gcc_assert(type != NULL_TREE);
109922 + switch (TREE_CODE(type)) {
109923 + case RECORD_TYPE:
109924 + case POINTER_TYPE:
109925 + case ARRAY_TYPE:
109926 + return true;
109927 + case VOID_TYPE:
109928 + case INTEGER_TYPE:
109929 + case UNION_TYPE:
109930 + return false;
109931 + default:
109932 + break;
109933 + }
109934 +
109935 + debug_tree((tree)var);
109936 + gcc_unreachable();
109937 +}
109938 +
109939 +static unsigned int find_arg_number(const_tree arg, tree func)
109940 +{
109941 + tree var;
109942 + unsigned int argnum = 1;
109943 +
109944 + if (TREE_CODE(arg) == SSA_NAME)
109945 + arg = SSA_NAME_VAR(arg);
109946 +
109947 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
109948 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
109949 + continue;
109950 + if (!skip_types(var))
109951 + return argnum;
109952 + }
109953 +
109954 + return 0;
109955 +}
109956 +
109957 +static tree create_new_var(tree type)
109958 +{
109959 + tree new_var = create_tmp_var(type, "cicus");
109960 +
109961 +#if BUILDING_GCC_VERSION <= 4007
109962 + add_referenced_var(new_var);
109963 +#endif
109964 + return new_var;
109965 +}
109966 +
109967 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
109968 +{
109969 + gimple assign;
109970 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
109971 + tree type = TREE_TYPE(rhs1);
109972 + tree lhs = create_new_var(type);
109973 +
109974 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
109975 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
109976 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
109977 +
109978 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
109979 + update_stmt(assign);
109980 + gimple_set_plf(assign, MY_STMT, true);
109981 + return assign;
109982 +}
109983 +
109984 +static tree cast_a_tree(tree type, tree var)
109985 +{
109986 + gcc_assert(type != NULL_TREE);
109987 + gcc_assert(var != NULL_TREE);
109988 + gcc_assert(fold_convertible_p(type, var));
109989 +
109990 + return fold_convert(type, var);
109991 +}
109992 +
109993 +static tree get_lhs(const_gimple stmt)
109994 +{
109995 + switch (gimple_code(stmt)) {
109996 + case GIMPLE_ASSIGN:
109997 + return gimple_get_lhs(stmt);
109998 + case GIMPLE_PHI:
109999 + return gimple_phi_result(stmt);
110000 + case GIMPLE_CALL:
110001 + return gimple_call_lhs(stmt);
110002 + default:
110003 + return NULL_TREE;
110004 + }
110005 +}
110006 +
110007 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
110008 +{
110009 + const_gimple def_stmt = get_def_stmt(rhs);
110010 +
110011 + if (force)
110012 + return false;
110013 +
110014 + if (is_gimple_constant(rhs))
110015 + return false;
110016 +
110017 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
110018 + return false;
110019 +
110020 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
110021 + return false;
110022 +
110023 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
110024 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
110025 + return false;
110026 +
110027 + return true;
110028 +}
110029 +
110030 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
110031 +{
110032 + gimple assign, def_stmt;
110033 +
110034 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
110035 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
110036 + gcc_unreachable();
110037 +
110038 + def_stmt = get_def_stmt(rhs);
110039 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
110040 + return def_stmt;
110041 +
110042 + if (lhs == CREATE_NEW_VAR)
110043 + lhs = create_new_var(dst_type);
110044 +
110045 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
110046 +
110047 + if (!gsi_end_p(*gsi)) {
110048 + location_t loc = gimple_location(gsi_stmt(*gsi));
110049 + gimple_set_location(assign, loc);
110050 + }
110051 +
110052 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
110053 +
110054 + if (before)
110055 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
110056 + else
110057 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
110058 + update_stmt(assign);
110059 + gimple_set_plf(assign, MY_STMT, true);
110060 +
110061 + return assign;
110062 +}
110063 +
110064 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
110065 +{
110066 + gimple_stmt_iterator gsi;
110067 + tree lhs;
110068 + const_gimple new_stmt;
110069 +
110070 + if (rhs == NULL_TREE)
110071 + return NULL_TREE;
110072 +
110073 + gsi = gsi_for_stmt(stmt);
110074 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
110075 +
110076 + lhs = get_lhs(new_stmt);
110077 + gcc_assert(lhs != NULL_TREE);
110078 + return lhs;
110079 +}
110080 +
110081 +static tree cast_to_TI_type(gimple stmt, tree node)
110082 +{
110083 + gimple_stmt_iterator gsi;
110084 + gimple cast_stmt;
110085 + tree type = TREE_TYPE(node);
110086 +
110087 + if (types_compatible_p(type, intTI_type_node))
110088 + return node;
110089 +
110090 + gsi = gsi_for_stmt(stmt);
110091 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
110092 + return gimple_get_lhs(cast_stmt);
110093 +}
110094 +
110095 +static void check_function_hash(const_gimple stmt)
110096 +{
110097 + tree func;
110098 + const struct size_overflow_hash *hash;
110099 +
110100 + if (gimple_code(stmt) != GIMPLE_CALL)
110101 + return;
110102 +
110103 + func = gimple_call_fndecl(stmt);
110104 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
110105 + if (func == NULL_TREE)
110106 + return;
110107 +
110108 + hash = get_function_hash(func);
110109 + if (!hash)
110110 + print_missing_msg(func, 0);
110111 +}
110112 +
110113 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
110114 +{
110115 + tree lhs, new_lhs;
110116 + gimple_stmt_iterator gsi;
110117 +
110118 + if (rhs1 == NULL_TREE) {
110119 + debug_gimple_stmt(oldstmt);
110120 + error("%s: rhs1 is NULL_TREE", __func__);
110121 + gcc_unreachable();
110122 + }
110123 +
110124 + switch (gimple_code(oldstmt)) {
110125 + case GIMPLE_ASM:
110126 + lhs = rhs1;
110127 + break;
110128 + case GIMPLE_CALL:
110129 + lhs = gimple_call_lhs(oldstmt);
110130 + break;
110131 + case GIMPLE_ASSIGN:
110132 + lhs = gimple_get_lhs(oldstmt);
110133 + break;
110134 + default:
110135 + debug_gimple_stmt(oldstmt);
110136 + gcc_unreachable();
110137 + }
110138 +
110139 + gsi = gsi_for_stmt(oldstmt);
110140 + pointer_set_insert(visited, oldstmt);
110141 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
110142 + basic_block next_bb, cur_bb;
110143 + const_edge e;
110144 +
110145 + gcc_assert(before == false);
110146 + gcc_assert(stmt_can_throw_internal(oldstmt));
110147 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
110148 + gcc_assert(!gsi_end_p(gsi));
110149 +
110150 + cur_bb = gimple_bb(oldstmt);
110151 + next_bb = cur_bb->next_bb;
110152 + e = find_edge(cur_bb, next_bb);
110153 + gcc_assert(e != NULL);
110154 + gcc_assert(e->flags & EDGE_FALLTHRU);
110155 +
110156 + gsi = gsi_after_labels(next_bb);
110157 + gcc_assert(!gsi_end_p(gsi));
110158 +
110159 + before = true;
110160 + oldstmt = gsi_stmt(gsi);
110161 + }
110162 +
110163 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
110164 + return new_lhs;
110165 +}
110166 +
110167 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
110168 +{
110169 + gimple stmt;
110170 + gimple_stmt_iterator gsi;
110171 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
110172 +
110173 + if (gimple_plf(oldstmt, MY_STMT))
110174 + return lhs;
110175 +
110176 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
110177 + rhs1 = gimple_assign_rhs1(oldstmt);
110178 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
110179 + }
110180 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
110181 + rhs2 = gimple_assign_rhs2(oldstmt);
110182 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
110183 + }
110184 +
110185 + stmt = gimple_copy(oldstmt);
110186 + gimple_set_location(stmt, gimple_location(oldstmt));
110187 + gimple_set_plf(stmt, MY_STMT, true);
110188 +
110189 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
110190 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
110191 +
110192 + size_overflow_type = get_size_overflow_type(oldstmt, node);
110193 +
110194 + new_var = create_new_var(size_overflow_type);
110195 + new_var = make_ssa_name(new_var, stmt);
110196 + gimple_set_lhs(stmt, new_var);
110197 +
110198 + if (rhs1 != NULL_TREE)
110199 + gimple_assign_set_rhs1(stmt, rhs1);
110200 +
110201 + if (rhs2 != NULL_TREE)
110202 + gimple_assign_set_rhs2(stmt, rhs2);
110203 +#if BUILDING_GCC_VERSION >= 4007
110204 + if (rhs3 != NULL_TREE)
110205 + gimple_assign_set_rhs3(stmt, rhs3);
110206 +#endif
110207 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
110208 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
110209 +
110210 + gsi = gsi_for_stmt(oldstmt);
110211 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
110212 + update_stmt(stmt);
110213 + pointer_set_insert(visited, oldstmt);
110214 + return gimple_get_lhs(stmt);
110215 +}
110216 +
110217 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
110218 +{
110219 + basic_block first_bb;
110220 + gimple assign;
110221 + gimple_stmt_iterator gsi;
110222 +
110223 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
110224 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
110225 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
110226 +
110227 + gsi = gsi_start_bb(first_bb);
110228 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
110229 + return gimple_get_lhs(assign);
110230 +}
110231 +
110232 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
110233 +{
110234 + gimple_stmt_iterator gsi;
110235 + const_gimple assign;
110236 + gimple def_stmt = get_def_stmt(new_arg);
110237 +
110238 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
110239 + gsi = gsi_after_labels(gimple_bb(def_stmt));
110240 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
110241 + } else {
110242 + gsi = gsi_for_stmt(def_stmt);
110243 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
110244 + }
110245 +
110246 + return gimple_get_lhs(assign);
110247 +}
110248 +
110249 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
110250 +{
110251 + basic_block bb;
110252 + gimple_stmt_iterator gsi;
110253 + const_gimple assign, def_stmt;
110254 +
110255 + def_stmt = get_def_stmt(arg);
110256 + bb = gimple_bb(def_stmt);
110257 + gcc_assert(bb->index != 0);
110258 + gsi = gsi_after_labels(bb);
110259 +
110260 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
110261 + return gimple_get_lhs(assign);
110262 +}
110263 +
110264 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
110265 +{
110266 + tree size_overflow_type;
110267 + const_gimple def_stmt = get_def_stmt(arg);
110268 +
110269 + if (phi_ssa_name != NULL_TREE)
110270 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
110271 +
110272 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
110273 +
110274 + if (new_arg != NULL_TREE) {
110275 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
110276 + return use_phi_ssa_name(phi_ssa_name, new_arg);
110277 + }
110278 +
110279 + switch(gimple_code(def_stmt)) {
110280 + case GIMPLE_PHI:
110281 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
110282 + case GIMPLE_NOP:
110283 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
110284 + default:
110285 + debug_gimple_stmt((gimple)def_stmt);
110286 + gcc_unreachable();
110287 + }
110288 +}
110289 +
110290 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
110291 +{
110292 + basic_block bb;
110293 + gimple phi;
110294 + gimple_seq seq;
110295 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
110296 +
110297 + bb = gsi_bb(gsi);
110298 +
110299 + phi = create_phi_node(result, bb);
110300 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
110301 + seq = phi_nodes(bb);
110302 + gsi = gsi_last(seq);
110303 + gsi_remove(&gsi, false);
110304 +
110305 + gsi = gsi_for_stmt(oldstmt);
110306 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
110307 + gimple_set_bb(phi, bb);
110308 + gimple_set_plf(phi, MY_STMT, true);
110309 + return phi;
110310 +}
110311 +
110312 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
110313 +{
110314 + gimple new_phi = NULL;
110315 + gimple oldstmt = get_def_stmt(orig_result);
110316 + tree phi_ssa_name = NULL_TREE;
110317 + unsigned int i;
110318 +
110319 + pointer_set_insert(visited, oldstmt);
110320 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
110321 + tree arg, new_arg;
110322 +
110323 + arg = gimple_phi_arg_def(oldstmt, i);
110324 +
110325 + new_arg = expand(visited, arg);
110326 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
110327 + if (i == 0) {
110328 + phi_ssa_name = new_arg;
110329 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
110330 + }
110331 +
110332 + gcc_assert(new_phi != NULL);
110333 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
110334 + }
110335 +
110336 + gcc_assert(new_phi != NULL);
110337 + update_stmt(new_phi);
110338 + return gimple_phi_result(new_phi);
110339 +}
110340 +
110341 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
110342 +{
110343 + const_gimple assign;
110344 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
110345 + tree origtype = TREE_TYPE(orig_rhs);
110346 +
110347 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
110348 +
110349 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
110350 + return gimple_get_lhs(assign);
110351 +}
110352 +
110353 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
110354 +{
110355 + const_tree rhs1, lhs, rhs1_type, lhs_type;
110356 + enum machine_mode lhs_mode, rhs_mode;
110357 + gimple def_stmt = get_def_stmt(no_const_rhs);
110358 +
110359 + if (!gimple_assign_cast_p(def_stmt))
110360 + return false;
110361 +
110362 + rhs1 = gimple_assign_rhs1(def_stmt);
110363 + lhs = gimple_get_lhs(def_stmt);
110364 + rhs1_type = TREE_TYPE(rhs1);
110365 + lhs_type = TREE_TYPE(lhs);
110366 + rhs_mode = TYPE_MODE(rhs1_type);
110367 + lhs_mode = TYPE_MODE(lhs_type);
110368 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
110369 + return false;
110370 +
110371 + return true;
110372 +}
110373 +
110374 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
110375 +{
110376 + tree rhs1 = gimple_assign_rhs1(stmt);
110377 + tree lhs = gimple_get_lhs(stmt);
110378 + const_tree rhs1_type = TREE_TYPE(rhs1);
110379 + const_tree lhs_type = TREE_TYPE(lhs);
110380 +
110381 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
110382 + return create_assign(visited, stmt, lhs, AFTER_STMT);
110383 +
110384 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
110385 +}
110386 +
110387 +static bool no_uses(tree node)
110388 +{
110389 + imm_use_iterator imm_iter;
110390 + use_operand_p use_p;
110391 +
110392 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
110393 + const_gimple use_stmt = USE_STMT(use_p);
110394 + if (use_stmt == NULL)
110395 + return true;
110396 + if (is_gimple_debug(use_stmt))
110397 + continue;
110398 + if (!(gimple_bb(use_stmt)->flags & BB_REACHABLE))
110399 + continue;
110400 + return false;
110401 + }
110402 + return true;
110403 +}
110404 +
110405 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
110406 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
110407 +{
110408 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
110409 + gimple def_stmt = get_def_stmt(lhs);
110410 +
110411 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
110412 + return false;
110413 +
110414 + rhs1 = gimple_assign_rhs1(def_stmt);
110415 + rhs_type = TREE_TYPE(rhs1);
110416 + lhs_type = TREE_TYPE(lhs);
110417 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
110418 + return false;
110419 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
110420 + return false;
110421 +
110422 + def_stmt = get_def_stmt(rhs1);
110423 + if (!def_stmt || gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_num_ops(def_stmt) != 3)
110424 + return false;
110425 +
110426 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
110427 + return false;
110428 +
110429 + rhs1 = gimple_assign_rhs1(def_stmt);
110430 + rhs2 = gimple_assign_rhs2(def_stmt);
110431 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
110432 + return false;
110433 +
110434 + if (is_gimple_constant(rhs2))
110435 + not_const_rhs = rhs1;
110436 + else
110437 + not_const_rhs = rhs2;
110438 +
110439 + return no_uses(not_const_rhs);
110440 +}
110441 +
110442 +static bool skip_lhs_cast_check(const_gimple stmt)
110443 +{
110444 + const_tree rhs = gimple_assign_rhs1(stmt);
110445 + const_gimple def_stmt = get_def_stmt(rhs);
110446 +
110447 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
110448 + if (gimple_code(def_stmt) == GIMPLE_ASM)
110449 + return true;
110450 +
110451 + if (is_const_plus_unsigned_signed_truncation(rhs))
110452 + return true;
110453 +
110454 + return false;
110455 +}
110456 +
110457 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
110458 +{
110459 + bool cast_lhs, cast_rhs;
110460 + tree lhs = gimple_get_lhs(stmt);
110461 + tree rhs = gimple_assign_rhs1(stmt);
110462 + const_tree lhs_type = TREE_TYPE(lhs);
110463 + const_tree rhs_type = TREE_TYPE(rhs);
110464 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
110465 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
110466 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
110467 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
110468 +
110469 + static bool check_lhs[3][4] = {
110470 + // ss su us uu
110471 + { false, true, true, false }, // lhs > rhs
110472 + { false, false, false, false }, // lhs = rhs
110473 + { true, true, true, true }, // lhs < rhs
110474 + };
110475 +
110476 + static bool check_rhs[3][4] = {
110477 + // ss su us uu
110478 + { true, false, true, true }, // lhs > rhs
110479 + { true, false, true, true }, // lhs = rhs
110480 + { true, false, true, true }, // lhs < rhs
110481 + };
110482 +
110483 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
110484 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
110485 + return create_assign(visited, stmt, lhs, AFTER_STMT);
110486 +
110487 + if (lhs_size > rhs_size) {
110488 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
110489 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
110490 + } else if (lhs_size == rhs_size) {
110491 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
110492 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
110493 + } else {
110494 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
110495 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
110496 + }
110497 +
110498 + if (!cast_lhs && !cast_rhs)
110499 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
110500 +
110501 + if (cast_lhs && !skip_lhs_cast_check(stmt))
110502 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
110503 +
110504 + if (cast_rhs)
110505 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
110506 +
110507 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
110508 +}
110509 +
110510 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
110511 +{
110512 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
110513 +
110514 + if (gimple_plf(stmt, MY_STMT))
110515 + return lhs;
110516 +
110517 + rhs1 = gimple_assign_rhs1(stmt);
110518 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
110519 + return create_assign(visited, stmt, lhs, AFTER_STMT);
110520 +
110521 + new_rhs1 = expand(visited, rhs1);
110522 +
110523 + if (new_rhs1 == NULL_TREE)
110524 + return create_cast_assign(visited, stmt);
110525 +
110526 + if (gimple_plf(stmt, NO_CAST_CHECK))
110527 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
110528 +
110529 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
110530 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
110531 +
110532 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
110533 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
110534 + return create_assign(visited, stmt, lhs, AFTER_STMT);
110535 + }
110536 +
110537 + if (!gimple_assign_cast_p(stmt))
110538 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
110539 +
110540 + return create_cast_overflow_check(visited, new_rhs1, stmt);
110541 +}
110542 +
110543 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
110544 +{
110545 + tree rhs1, lhs = gimple_get_lhs(stmt);
110546 + gimple def_stmt = get_def_stmt(lhs);
110547 +
110548 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
110549 + rhs1 = gimple_assign_rhs1(def_stmt);
110550 +
110551 + if (is_gimple_constant(rhs1))
110552 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
110553 +
110554 + switch (TREE_CODE(rhs1)) {
110555 + case SSA_NAME:
110556 + return handle_unary_rhs(visited, def_stmt);
110557 + case ARRAY_REF:
110558 + case BIT_FIELD_REF:
110559 + case ADDR_EXPR:
110560 + case COMPONENT_REF:
110561 + case INDIRECT_REF:
110562 +#if BUILDING_GCC_VERSION >= 4006
110563 + case MEM_REF:
110564 +#endif
110565 + case TARGET_MEM_REF:
110566 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
110567 + case PARM_DECL:
110568 + case VAR_DECL:
110569 + return create_assign(visited, stmt, lhs, AFTER_STMT);
110570 +
110571 + default:
110572 + debug_gimple_stmt(def_stmt);
110573 + debug_tree(rhs1);
110574 + gcc_unreachable();
110575 + }
110576 +}
110577 +
110578 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
110579 +{
110580 + gimple cond_stmt;
110581 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
110582 +
110583 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
110584 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
110585 + update_stmt(cond_stmt);
110586 +}
110587 +
110588 +static tree create_string_param(tree string)
110589 +{
110590 + tree i_type, a_type;
110591 + const int length = TREE_STRING_LENGTH(string);
110592 +
110593 + gcc_assert(length > 0);
110594 +
110595 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
110596 + a_type = build_array_type(char_type_node, i_type);
110597 +
110598 + TREE_TYPE(string) = a_type;
110599 + TREE_CONSTANT(string) = 1;
110600 + TREE_READONLY(string) = 1;
110601 +
110602 + return build1(ADDR_EXPR, ptr_type_node, string);
110603 +}
110604 +
110605 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
110606 +{
110607 + gimple func_stmt;
110608 + const_gimple def_stmt;
110609 + const_tree loc_line;
110610 + tree loc_file, ssa_name, current_func;
110611 + expanded_location xloc;
110612 + char *ssa_name_buf;
110613 + int len;
110614 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
110615 +
110616 + def_stmt = get_def_stmt(arg);
110617 + xloc = expand_location(gimple_location(def_stmt));
110618 +
110619 + if (!gimple_has_location(def_stmt)) {
110620 + xloc = expand_location(gimple_location(stmt));
110621 + if (!gimple_has_location(stmt))
110622 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
110623 + }
110624 +
110625 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
110626 +
110627 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
110628 + loc_file = create_string_param(loc_file);
110629 +
110630 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
110631 + current_func = create_string_param(current_func);
110632 +
110633 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
110634 + call_count++;
110635 + 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);
110636 + gcc_assert(len > 0);
110637 + ssa_name = build_string(len + 1, ssa_name_buf);
110638 + free(ssa_name_buf);
110639 + ssa_name = create_string_param(ssa_name);
110640 +
110641 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
110642 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
110643 +
110644 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
110645 +}
110646 +
110647 +static void __unused print_the_code_insertions(const_gimple stmt)
110648 +{
110649 + location_t loc = gimple_location(stmt);
110650 +
110651 + inform(loc, "Integer size_overflow check applied here.");
110652 +}
110653 +
110654 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
110655 +{
110656 + basic_block cond_bb, join_bb, bb_true;
110657 + edge e;
110658 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
110659 +
110660 + cond_bb = gimple_bb(stmt);
110661 + if (before)
110662 + gsi_prev(&gsi);
110663 + if (gsi_end_p(gsi))
110664 + e = split_block_after_labels(cond_bb);
110665 + else
110666 + e = split_block(cond_bb, gsi_stmt(gsi));
110667 + cond_bb = e->src;
110668 + join_bb = e->dest;
110669 + e->flags = EDGE_FALSE_VALUE;
110670 + e->probability = REG_BR_PROB_BASE;
110671 +
110672 + bb_true = create_empty_bb(cond_bb);
110673 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
110674 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
110675 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
110676 +
110677 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
110678 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
110679 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
110680 +
110681 + if (current_loops != NULL) {
110682 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
110683 + add_bb_to_loop(bb_true, cond_bb->loop_father);
110684 + }
110685 +
110686 + insert_cond(cond_bb, arg, cond_code, type_value);
110687 + insert_cond_result(bb_true, stmt, arg, min);
110688 +
110689 +// print_the_code_insertions(stmt);
110690 +}
110691 +
110692 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
110693 +{
110694 + const_tree rhs_type = TREE_TYPE(rhs);
110695 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
110696 +
110697 + gcc_assert(rhs_type != NULL_TREE);
110698 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
110699 + return;
110700 +
110701 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
110702 +
110703 + if (is_const_plus_unsigned_signed_truncation(rhs))
110704 + return;
110705 +
110706 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
110707 + // typemax (-1) < typemin (0)
110708 + if (TREE_OVERFLOW(type_max))
110709 + return;
110710 +
110711 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
110712 +
110713 + cast_rhs_type = TREE_TYPE(cast_rhs);
110714 + type_max_type = TREE_TYPE(type_max);
110715 + type_min_type = TREE_TYPE(type_min);
110716 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
110717 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
110718 +
110719 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
110720 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
110721 +}
110722 +
110723 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
110724 +{
110725 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
110726 + return false;
110727 + if (!is_gimple_constant(rhs))
110728 + return false;
110729 + return true;
110730 +}
110731 +
110732 +static tree get_def_stmt_rhs(const_tree var)
110733 +{
110734 + tree rhs1, def_stmt_rhs1;
110735 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
110736 +
110737 + def_stmt = get_def_stmt(var);
110738 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
110739 +
110740 + rhs1 = gimple_assign_rhs1(def_stmt);
110741 + rhs1_def_stmt = get_def_stmt(rhs1);
110742 + if (!gimple_assign_cast_p(rhs1_def_stmt))
110743 + return rhs1;
110744 +
110745 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
110746 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
110747 +
110748 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
110749 + case GIMPLE_CALL:
110750 + case GIMPLE_NOP:
110751 + case GIMPLE_ASM:
110752 + case GIMPLE_PHI:
110753 + return def_stmt_rhs1;
110754 + case GIMPLE_ASSIGN:
110755 + return rhs1;
110756 + default:
110757 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
110758 + gcc_unreachable();
110759 + }
110760 +}
110761 +
110762 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
110763 +{
110764 + tree new_rhs, orig_rhs;
110765 + void (*gimple_assign_set_rhs)(gimple, tree);
110766 + tree rhs1 = gimple_assign_rhs1(stmt);
110767 + tree rhs2 = gimple_assign_rhs2(stmt);
110768 + tree lhs = gimple_get_lhs(stmt);
110769 +
110770 + if (!check_overflow)
110771 + return create_assign(visited, stmt, lhs, AFTER_STMT);
110772 +
110773 + if (change_rhs == NULL_TREE)
110774 + return create_assign(visited, stmt, lhs, AFTER_STMT);
110775 +
110776 + if (new_rhs2 == NULL_TREE) {
110777 + orig_rhs = rhs1;
110778 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
110779 + } else {
110780 + orig_rhs = rhs2;
110781 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
110782 + }
110783 +
110784 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
110785 +
110786 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
110787 + gimple_assign_set_rhs(stmt, new_rhs);
110788 + update_stmt(stmt);
110789 +
110790 + return create_assign(visited, stmt, lhs, AFTER_STMT);
110791 +}
110792 +
110793 +static bool is_subtraction_special(const_gimple stmt)
110794 +{
110795 + gimple rhs1_def_stmt, rhs2_def_stmt;
110796 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
110797 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
110798 + const_tree rhs1 = gimple_assign_rhs1(stmt);
110799 + const_tree rhs2 = gimple_assign_rhs2(stmt);
110800 +
110801 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
110802 + return false;
110803 +
110804 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
110805 +
110806 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
110807 + return false;
110808 +
110809 + rhs1_def_stmt = get_def_stmt(rhs1);
110810 + rhs2_def_stmt = get_def_stmt(rhs2);
110811 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
110812 + return false;
110813 +
110814 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
110815 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
110816 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
110817 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
110818 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
110819 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
110820 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
110821 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
110822 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
110823 + return false;
110824 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
110825 + return false;
110826 +
110827 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
110828 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
110829 + return true;
110830 +}
110831 +
110832 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
110833 +{
110834 + tree new_rhs1, new_rhs2;
110835 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
110836 + gimple assign, stmt = get_def_stmt(lhs);
110837 + tree rhs1 = gimple_assign_rhs1(stmt);
110838 + tree rhs2 = gimple_assign_rhs2(stmt);
110839 +
110840 + if (!is_subtraction_special(stmt))
110841 + return NULL_TREE;
110842 +
110843 + new_rhs1 = expand(visited, rhs1);
110844 + new_rhs2 = expand(visited, rhs2);
110845 +
110846 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
110847 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
110848 +
110849 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
110850 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
110851 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
110852 + }
110853 +
110854 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
110855 + new_lhs = gimple_get_lhs(assign);
110856 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
110857 +
110858 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
110859 +}
110860 +
110861 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
110862 +{
110863 + const_gimple def_stmt;
110864 +
110865 + if (TREE_CODE(rhs) != SSA_NAME)
110866 + return false;
110867 +
110868 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
110869 + return false;
110870 +
110871 + def_stmt = get_def_stmt(rhs);
110872 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
110873 + return false;
110874 +
110875 + return true;
110876 +}
110877 +
110878 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
110879 +{
110880 + tree rhs1, rhs2, new_lhs;
110881 + gimple def_stmt = get_def_stmt(lhs);
110882 + tree new_rhs1 = NULL_TREE;
110883 + tree new_rhs2 = NULL_TREE;
110884 +
110885 + rhs1 = gimple_assign_rhs1(def_stmt);
110886 + rhs2 = gimple_assign_rhs2(def_stmt);
110887 +
110888 + /* no DImode/TImode division in the 32/64 bit kernel */
110889 + switch (gimple_assign_rhs_code(def_stmt)) {
110890 + case RDIV_EXPR:
110891 + case TRUNC_DIV_EXPR:
110892 + case CEIL_DIV_EXPR:
110893 + case FLOOR_DIV_EXPR:
110894 + case ROUND_DIV_EXPR:
110895 + case TRUNC_MOD_EXPR:
110896 + case CEIL_MOD_EXPR:
110897 + case FLOOR_MOD_EXPR:
110898 + case ROUND_MOD_EXPR:
110899 + case EXACT_DIV_EXPR:
110900 + case POINTER_PLUS_EXPR:
110901 + case BIT_AND_EXPR:
110902 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
110903 + default:
110904 + break;
110905 + }
110906 +
110907 + new_lhs = handle_integer_truncation(visited, lhs);
110908 + if (new_lhs != NULL_TREE)
110909 + return new_lhs;
110910 +
110911 + if (TREE_CODE(rhs1) == SSA_NAME)
110912 + new_rhs1 = expand(visited, rhs1);
110913 + if (TREE_CODE(rhs2) == SSA_NAME)
110914 + new_rhs2 = expand(visited, rhs2);
110915 +
110916 + if (is_a_neg_overflow(def_stmt, rhs2))
110917 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
110918 + if (is_a_neg_overflow(def_stmt, rhs1))
110919 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
110920 +
110921 +
110922 + if (is_a_constant_overflow(def_stmt, rhs2))
110923 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
110924 + if (is_a_constant_overflow(def_stmt, rhs1))
110925 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
110926 +
110927 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
110928 +}
110929 +
110930 +#if BUILDING_GCC_VERSION >= 4007
110931 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
110932 +{
110933 + if (is_gimple_constant(rhs))
110934 + return cast_a_tree(size_overflow_type, rhs);
110935 + if (TREE_CODE(rhs) != SSA_NAME)
110936 + return NULL_TREE;
110937 + return expand(visited, rhs);
110938 +}
110939 +
110940 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
110941 +{
110942 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
110943 + gimple def_stmt = get_def_stmt(lhs);
110944 +
110945 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
110946 +
110947 + rhs1 = gimple_assign_rhs1(def_stmt);
110948 + rhs2 = gimple_assign_rhs2(def_stmt);
110949 + rhs3 = gimple_assign_rhs3(def_stmt);
110950 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
110951 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
110952 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
110953 +
110954 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
110955 +}
110956 +#endif
110957 +
110958 +static tree get_size_overflow_type(gimple stmt, const_tree node)
110959 +{
110960 + const_tree type;
110961 + tree new_type;
110962 +
110963 + gcc_assert(node != NULL_TREE);
110964 +
110965 + type = TREE_TYPE(node);
110966 +
110967 + if (gimple_plf(stmt, MY_STMT))
110968 + return TREE_TYPE(node);
110969 +
110970 + switch (TYPE_MODE(type)) {
110971 + case QImode:
110972 + new_type = intHI_type_node;
110973 + break;
110974 + case HImode:
110975 + new_type = intSI_type_node;
110976 + break;
110977 + case SImode:
110978 + new_type = intDI_type_node;
110979 + break;
110980 + case DImode:
110981 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
110982 + new_type = intDI_type_node;
110983 + else
110984 + new_type = intTI_type_node;
110985 + break;
110986 + default:
110987 + debug_tree((tree)node);
110988 + error("%s: unsupported gcc configuration.", __func__);
110989 + gcc_unreachable();
110990 + }
110991 +
110992 + if (TYPE_QUALS(type) != 0)
110993 + return build_qualified_type(new_type, TYPE_QUALS(type));
110994 + return new_type;
110995 +}
110996 +
110997 +static tree expand_visited(gimple def_stmt)
110998 +{
110999 + const_gimple next_stmt;
111000 + gimple_stmt_iterator gsi;
111001 + enum gimple_code code = gimple_code(def_stmt);
111002 +
111003 + if (code == GIMPLE_ASM)
111004 + return NULL_TREE;
111005 +
111006 + gsi = gsi_for_stmt(def_stmt);
111007 + gsi_next(&gsi);
111008 +
111009 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
111010 + return NULL_TREE;
111011 + gcc_assert(!gsi_end_p(gsi));
111012 + next_stmt = gsi_stmt(gsi);
111013 +
111014 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
111015 + return NULL_TREE;
111016 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
111017 +
111018 + return get_lhs(next_stmt);
111019 +}
111020 +
111021 +static tree expand(struct pointer_set_t *visited, tree lhs)
111022 +{
111023 + gimple def_stmt;
111024 +
111025 + if (skip_types(lhs))
111026 + return NULL_TREE;
111027 +
111028 + def_stmt = get_def_stmt(lhs);
111029 +
111030 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
111031 + return NULL_TREE;
111032 +
111033 + if (gimple_plf(def_stmt, MY_STMT))
111034 + return lhs;
111035 +
111036 + if (pointer_set_contains(visited, def_stmt))
111037 + return expand_visited(def_stmt);
111038 +
111039 + switch (gimple_code(def_stmt)) {
111040 + case GIMPLE_PHI:
111041 + return handle_phi(visited, lhs);
111042 + case GIMPLE_CALL:
111043 + case GIMPLE_ASM:
111044 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
111045 + case GIMPLE_ASSIGN:
111046 + switch (gimple_num_ops(def_stmt)) {
111047 + case 2:
111048 + return handle_unary_ops(visited, def_stmt);
111049 + case 3:
111050 + return handle_binary_ops(visited, lhs);
111051 +#if BUILDING_GCC_VERSION >= 4007
111052 + case 4:
111053 + return handle_ternary_ops(visited, lhs);
111054 +#endif
111055 + }
111056 + default:
111057 + debug_gimple_stmt(def_stmt);
111058 + error("%s: unknown gimple code", __func__);
111059 + gcc_unreachable();
111060 + }
111061 +}
111062 +
111063 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
111064 +{
111065 + const_gimple assign;
111066 + tree orig_type = TREE_TYPE(orig_node);
111067 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
111068 +
111069 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
111070 + return gimple_get_lhs(assign);
111071 +}
111072 +
111073 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
111074 +{
111075 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
111076 + update_stmt(stmt);
111077 +}
111078 +
111079 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
111080 +{
111081 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
111082 + update_stmt(stmt);
111083 +}
111084 +
111085 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
111086 +{
111087 + tree arg;
111088 + const_tree origarg;
111089 +
111090 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
111091 + return true;
111092 +
111093 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
111094 + while (origarg && *argnum) {
111095 + (*argnum)--;
111096 + origarg = TREE_CHAIN(origarg);
111097 + }
111098 +
111099 + gcc_assert(*argnum == 0);
111100 +
111101 + gcc_assert(origarg != NULL_TREE);
111102 + *argnum = 0;
111103 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
111104 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
111105 + return true;
111106 + return false;
111107 +}
111108 +
111109 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
111110 +{
111111 + gimple phi = get_def_stmt(result);
111112 + unsigned int i, n = gimple_phi_num_args(phi);
111113 +
111114 + if (!phi)
111115 + return MARK_NO;
111116 +
111117 + pointer_set_insert(visited, phi);
111118 + for (i = 0; i < n; i++) {
111119 + enum mark marked;
111120 + const_tree arg = gimple_phi_arg_def(phi, i);
111121 + marked = pre_expand(visited, search_err_code, arg);
111122 + if (marked != MARK_NO)
111123 + return marked;
111124 + }
111125 + return MARK_NO;
111126 +}
111127 +
111128 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
111129 +{
111130 + gimple def_stmt = get_def_stmt(lhs);
111131 + const_tree rhs;
111132 +
111133 + if (!def_stmt)
111134 + return MARK_NO;
111135 +
111136 + rhs = gimple_assign_rhs1(def_stmt);
111137 +
111138 + def_stmt = get_def_stmt(rhs);
111139 + if (is_gimple_constant(rhs))
111140 + search_err_code[FROM_CONST] = true;
111141 +
111142 + return pre_expand(visited, search_err_code, rhs);
111143 +}
111144 +
111145 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
111146 +{
111147 + gimple def_stmt = get_def_stmt(lhs);
111148 + const_tree rhs1, rhs2;
111149 + enum mark marked;
111150 +
111151 + if (!def_stmt)
111152 + return MARK_NO;
111153 +
111154 + search_err_code[CAST_ONLY] = false;
111155 +
111156 + rhs1 = gimple_assign_rhs1(def_stmt);
111157 + rhs2 = gimple_assign_rhs2(def_stmt);
111158 + marked = pre_expand(visited, search_err_code, rhs1);
111159 + if (marked != MARK_NO)
111160 + return marked;
111161 + return pre_expand(visited, search_err_code, rhs2);
111162 +}
111163 +
111164 +static const_tree search_field_decl(const_tree comp_ref)
111165 +{
111166 + const_tree field = NULL_TREE;
111167 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
111168 +
111169 + for (i = 0; i < len; i++) {
111170 + field = TREE_OPERAND(comp_ref, i);
111171 + if (TREE_CODE(field) == FIELD_DECL)
111172 + break;
111173 + }
111174 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
111175 + return field;
111176 +}
111177 +
111178 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
111179 +{
111180 + const_tree attr, p;
111181 +
111182 + // 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);
111183 + if (fndecl == NULL_TREE)
111184 + return MARK_NO;
111185 +
111186 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
111187 + if (!attr || !TREE_VALUE(attr))
111188 + return MARK_NO;
111189 +
111190 + p = TREE_VALUE(attr);
111191 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
111192 + return MARK_TURN_OFF;
111193 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
111194 + return MARK_NOT_INTENTIONAL;
111195 + if (argnum == 0) {
111196 + gcc_assert(current_function_decl == fndecl);
111197 + return MARK_NO;
111198 + }
111199 +
111200 + do {
111201 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
111202 + return MARK_YES;
111203 + p = TREE_CHAIN(p);
111204 + } while (p);
111205 +
111206 + return MARK_NO;
111207 +}
111208 +
111209 +static void print_missing_msg(tree func, unsigned int argnum)
111210 +{
111211 + unsigned int new_hash;
111212 + size_t len;
111213 + unsigned char tree_codes[CODES_LIMIT];
111214 + location_t loc;
111215 + const char *curfunc;
111216 +
111217 + func = get_original_function_decl(func);
111218 + loc = DECL_SOURCE_LOCATION(func);
111219 + curfunc = get_asm_name(func);
111220 +
111221 + len = get_function_decl(func, tree_codes);
111222 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
111223 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
111224 +}
111225 +
111226 +static unsigned int search_missing_attribute(const_tree arg)
111227 +{
111228 + unsigned int argnum;
111229 + const struct size_overflow_hash *hash;
111230 + const_tree type = TREE_TYPE(arg);
111231 + tree func = get_original_function_decl(current_function_decl);
111232 +
111233 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
111234 +
111235 + if (TREE_CODE(type) == POINTER_TYPE)
111236 + return 0;
111237 +
111238 + argnum = find_arg_number(arg, func);
111239 + if (argnum == 0)
111240 + return 0;
111241 +
111242 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
111243 + return argnum;
111244 +
111245 + hash = get_function_hash(func);
111246 + if (!hash || !(hash->param & (1U << argnum))) {
111247 + print_missing_msg(func, argnum);
111248 + return 0;
111249 + }
111250 + return argnum;
111251 +}
111252 +
111253 +static enum mark is_already_marked(const_tree lhs)
111254 +{
111255 + unsigned int argnum;
111256 + const_tree fndecl;
111257 +
111258 + argnum = search_missing_attribute(lhs);
111259 + fndecl = get_original_function_decl(current_function_decl);
111260 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
111261 + return MARK_YES;
111262 + return MARK_NO;
111263 +}
111264 +
111265 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
111266 +{
111267 + const_gimple def_stmt;
111268 +
111269 + if (skip_types(lhs))
111270 + return MARK_NO;
111271 +
111272 + if (TREE_CODE(lhs) == PARM_DECL)
111273 + return is_already_marked(lhs);
111274 +
111275 + if (TREE_CODE(lhs) == COMPONENT_REF) {
111276 + const_tree field, attr;
111277 +
111278 + field = search_field_decl(lhs);
111279 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
111280 + if (!attr || !TREE_VALUE(attr))
111281 + return MARK_NO;
111282 + return MARK_YES;
111283 + }
111284 +
111285 + def_stmt = get_def_stmt(lhs);
111286 +
111287 + if (!def_stmt)
111288 + return MARK_NO;
111289 +
111290 + if (pointer_set_contains(visited, def_stmt))
111291 + return MARK_NO;
111292 +
111293 + switch (gimple_code(def_stmt)) {
111294 + case GIMPLE_NOP:
111295 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
111296 + return is_already_marked(lhs);
111297 + return MARK_NO;
111298 + case GIMPLE_PHI:
111299 + return walk_phi(visited, search_err_code, lhs);
111300 + case GIMPLE_CALL:
111301 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
111302 + return MARK_TURN_OFF;
111303 + check_function_hash(def_stmt);
111304 + return MARK_NO;
111305 + case GIMPLE_ASM:
111306 + search_err_code[CAST_ONLY] = false;
111307 + return MARK_NO;
111308 + case GIMPLE_ASSIGN:
111309 + switch (gimple_num_ops(def_stmt)) {
111310 + case 2:
111311 + return walk_unary_ops(visited, search_err_code, lhs);
111312 + case 3:
111313 + return walk_binary_ops(visited, search_err_code, lhs);
111314 + }
111315 + default:
111316 + debug_gimple_stmt((gimple)def_stmt);
111317 + error("%s: unknown gimple code", __func__);
111318 + gcc_unreachable();
111319 + }
111320 +}
111321 +
111322 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
111323 +static bool skip_asm(const_tree arg)
111324 +{
111325 + gimple def_stmt = get_def_stmt(arg);
111326 +
111327 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
111328 + return false;
111329 +
111330 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
111331 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
111332 +}
111333 +
111334 +/*
111335 +0</MARK_YES: no dup, search attributes (so, int)
111336 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
111337 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
111338 +*/
111339 +
111340 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
111341 +{
111342 + struct pointer_set_t *visited;
111343 + enum mark is_marked, is_found;
111344 + location_t loc;
111345 + bool search_err_code[2] = {true, false};
111346 +
111347 + is_marked = mark_status(current_function_decl, 0);
111348 + if (is_marked == MARK_TURN_OFF)
111349 + return true;
111350 +
111351 + is_marked = mark_status(fndecl, argnum + 1);
111352 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
111353 + return true;
111354 +
111355 + visited = pointer_set_create();
111356 + is_found = pre_expand(visited, search_err_code, arg);
111357 + pointer_set_destroy(visited);
111358 +
111359 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
111360 + return true;
111361 +
111362 + if (where == FROM_ARG && skip_asm(arg))
111363 + return true;
111364 +
111365 + if (is_found == MARK_TURN_OFF)
111366 + return true;
111367 +
111368 + if ((is_found == MARK_YES && is_marked == MARK_YES))
111369 + return true;
111370 +
111371 + if (is_found == MARK_YES) {
111372 + loc = DECL_SOURCE_LOCATION(fndecl);
111373 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
111374 + return true;
111375 + }
111376 + return false;
111377 +}
111378 +
111379 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
111380 +{
111381 + struct pointer_set_t *visited;
111382 + tree arg, new_arg;
111383 + bool match;
111384 +
111385 + if (argnum == 0)
111386 + return;
111387 +
111388 + argnum--;
111389 +
111390 + match = get_function_arg(&argnum, fndecl);
111391 + if (!match)
111392 + return;
111393 + gcc_assert(gimple_call_num_args(stmt) > argnum);
111394 + arg = gimple_call_arg(stmt, argnum);
111395 + if (arg == NULL_TREE)
111396 + return;
111397 +
111398 + if (skip_types(arg))
111399 + return;
111400 +
111401 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
111402 + return;
111403 +
111404 + visited = pointer_set_create();
111405 + new_arg = expand(visited, arg);
111406 + pointer_set_destroy(visited);
111407 +
111408 + if (new_arg == NULL_TREE)
111409 + return;
111410 +
111411 + change_function_arg(stmt, arg, argnum, new_arg);
111412 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
111413 +}
111414 +
111415 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
111416 +{
111417 + tree p = TREE_VALUE(attr);
111418 + do {
111419 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
111420 + p = TREE_CHAIN(p);
111421 + } while (p);
111422 +}
111423 +
111424 +static void handle_function_by_hash(gimple stmt, tree fndecl)
111425 +{
111426 + unsigned int num;
111427 + const struct size_overflow_hash *hash;
111428 +
111429 + hash = get_function_hash(fndecl);
111430 + if (!hash)
111431 + return;
111432 +
111433 + for (num = 0; num <= MAX_PARAM; num++)
111434 + if (hash->param & (1U << num))
111435 + handle_function_arg(stmt, fndecl, num);
111436 +}
111437 +
111438 +static bool check_return_value(void)
111439 +{
111440 + const struct size_overflow_hash *hash;
111441 +
111442 + hash = get_function_hash(current_function_decl);
111443 + if (!hash || !(hash->param & 1U << 0))
111444 + return false;
111445 +
111446 + return true;
111447 +}
111448 +
111449 +static void handle_return_value(gimple ret_stmt)
111450 +{
111451 + struct pointer_set_t *visited;
111452 + tree ret, new_ret;
111453 +
111454 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
111455 + return;
111456 +
111457 + ret = gimple_return_retval(ret_stmt);
111458 +
111459 + if (skip_types(ret))
111460 + return;
111461 +
111462 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
111463 + return;
111464 +
111465 + visited = pointer_set_create();
111466 + new_ret = expand(visited, ret);
111467 + pointer_set_destroy(visited);
111468 +
111469 + change_function_return(ret_stmt, ret, new_ret);
111470 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
111471 +}
111472 +
111473 +static void set_plf_false(void)
111474 +{
111475 + basic_block bb;
111476 +
111477 + FOR_ALL_BB(bb) {
111478 + gimple_stmt_iterator si;
111479 +
111480 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
111481 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
111482 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
111483 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
111484 + }
111485 +}
111486 +
111487 +static unsigned int handle_function(void)
111488 +{
111489 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
111490 + bool check_ret;
111491 +
111492 + set_plf_false();
111493 +
111494 + check_ret = check_return_value();
111495 +
111496 + do {
111497 + gimple_stmt_iterator gsi;
111498 + next = bb->next_bb;
111499 +
111500 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
111501 + tree fndecl, attr;
111502 + gimple stmt = gsi_stmt(gsi);
111503 +
111504 + if (check_ret)
111505 + handle_return_value(stmt);
111506 +
111507 + if (!(is_gimple_call(stmt)))
111508 + continue;
111509 + fndecl = gimple_call_fndecl(stmt);
111510 + if (fndecl == NULL_TREE)
111511 + continue;
111512 + if (gimple_call_num_args(stmt) == 0)
111513 + continue;
111514 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
111515 + if (!attr || !TREE_VALUE(attr))
111516 + handle_function_by_hash(stmt, fndecl);
111517 + else
111518 + handle_function_by_attribute(stmt, attr, fndecl);
111519 + gsi = gsi_for_stmt(stmt);
111520 + next = gimple_bb(stmt)->next_bb;
111521 + }
111522 + bb = next;
111523 + } while (bb);
111524 + return 0;
111525 +}
111526 +
111527 +static struct gimple_opt_pass size_overflow_pass = {
111528 + .pass = {
111529 + .type = GIMPLE_PASS,
111530 + .name = "size_overflow",
111531 +#if BUILDING_GCC_VERSION >= 4008
111532 + .optinfo_flags = OPTGROUP_NONE,
111533 +#endif
111534 + .gate = NULL,
111535 + .execute = handle_function,
111536 + .sub = NULL,
111537 + .next = NULL,
111538 + .static_pass_number = 0,
111539 + .tv_id = TV_NONE,
111540 + .properties_required = PROP_cfg,
111541 + .properties_provided = 0,
111542 + .properties_destroyed = 0,
111543 + .todo_flags_start = 0,
111544 + .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
111545 + }
111546 +};
111547 +
111548 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
111549 +{
111550 + tree fntype;
111551 +
111552 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
111553 +
111554 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
111555 + fntype = build_function_type_list(void_type_node,
111556 + const_char_ptr_type_node,
111557 + unsigned_type_node,
111558 + const_char_ptr_type_node,
111559 + const_char_ptr_type_node,
111560 + NULL_TREE);
111561 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
111562 +
111563 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
111564 + TREE_PUBLIC(report_size_overflow_decl) = 1;
111565 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
111566 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
111567 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
111568 +}
111569 +
111570 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
111571 +{
111572 + int i;
111573 + const char * const plugin_name = plugin_info->base_name;
111574 + const int argc = plugin_info->argc;
111575 + const struct plugin_argument * const argv = plugin_info->argv;
111576 + bool enable = true;
111577 +
111578 + struct register_pass_info size_overflow_pass_info = {
111579 + .pass = &size_overflow_pass.pass,
111580 + .reference_pass_name = "ssa",
111581 + .ref_pass_instance_number = 1,
111582 + .pos_op = PASS_POS_INSERT_AFTER
111583 + };
111584 +
111585 + if (!plugin_default_version_check(version, &gcc_version)) {
111586 + error(G_("incompatible gcc/plugin versions"));
111587 + return 1;
111588 + }
111589 +
111590 + for (i = 0; i < argc; ++i) {
111591 + if (!strcmp(argv[i].key, "no-size-overflow")) {
111592 + enable = false;
111593 + continue;
111594 + }
111595 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
111596 + }
111597 +
111598 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
111599 + if (enable) {
111600 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
111601 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
111602 + }
111603 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
111604 +
111605 + return 0;
111606 +}
111607 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
111608 new file mode 100644
111609 index 0000000..ac2901e
111610 --- /dev/null
111611 +++ b/tools/gcc/stackleak_plugin.c
111612 @@ -0,0 +1,327 @@
111613 +/*
111614 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
111615 + * Licensed under the GPL v2
111616 + *
111617 + * Note: the choice of the license means that the compilation process is
111618 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
111619 + * but for the kernel it doesn't matter since it doesn't link against
111620 + * any of the gcc libraries
111621 + *
111622 + * gcc plugin to help implement various PaX features
111623 + *
111624 + * - track lowest stack pointer
111625 + *
111626 + * TODO:
111627 + * - initialize all local variables
111628 + *
111629 + * BUGS:
111630 + * - none known
111631 + */
111632 +#include "gcc-plugin.h"
111633 +#include "config.h"
111634 +#include "system.h"
111635 +#include "coretypes.h"
111636 +#include "tree.h"
111637 +#include "tree-pass.h"
111638 +#include "flags.h"
111639 +#include "intl.h"
111640 +#include "toplev.h"
111641 +#include "plugin.h"
111642 +//#include "expr.h" where are you...
111643 +#include "diagnostic.h"
111644 +#include "plugin-version.h"
111645 +#include "tm.h"
111646 +#include "function.h"
111647 +#include "basic-block.h"
111648 +#include "gimple.h"
111649 +#include "rtl.h"
111650 +#include "emit-rtl.h"
111651 +
111652 +#if BUILDING_GCC_VERSION >= 4008
111653 +#define TODO_dump_func 0
111654 +#endif
111655 +
111656 +extern void print_gimple_stmt(FILE *, gimple, int, int);
111657 +
111658 +int plugin_is_GPL_compatible;
111659 +
111660 +static int track_frame_size = -1;
111661 +static const char track_function[] = "pax_track_stack";
111662 +static const char check_function[] = "pax_check_alloca";
111663 +static bool init_locals;
111664 +
111665 +static struct plugin_info stackleak_plugin_info = {
111666 + .version = "201302112000",
111667 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
111668 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
111669 +};
111670 +
111671 +static bool gate_stackleak_track_stack(void);
111672 +static unsigned int execute_stackleak_tree_instrument(void);
111673 +static unsigned int execute_stackleak_final(void);
111674 +
111675 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
111676 + .pass = {
111677 + .type = GIMPLE_PASS,
111678 + .name = "stackleak_tree_instrument",
111679 +#if BUILDING_GCC_VERSION >= 4008
111680 + .optinfo_flags = OPTGROUP_NONE,
111681 +#endif
111682 + .gate = gate_stackleak_track_stack,
111683 + .execute = execute_stackleak_tree_instrument,
111684 + .sub = NULL,
111685 + .next = NULL,
111686 + .static_pass_number = 0,
111687 + .tv_id = TV_NONE,
111688 + .properties_required = PROP_gimple_leh | PROP_cfg,
111689 + .properties_provided = 0,
111690 + .properties_destroyed = 0,
111691 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
111692 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
111693 + }
111694 +};
111695 +
111696 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
111697 + .pass = {
111698 + .type = RTL_PASS,
111699 + .name = "stackleak_final",
111700 +#if BUILDING_GCC_VERSION >= 4008
111701 + .optinfo_flags = OPTGROUP_NONE,
111702 +#endif
111703 + .gate = gate_stackleak_track_stack,
111704 + .execute = execute_stackleak_final,
111705 + .sub = NULL,
111706 + .next = NULL,
111707 + .static_pass_number = 0,
111708 + .tv_id = TV_NONE,
111709 + .properties_required = 0,
111710 + .properties_provided = 0,
111711 + .properties_destroyed = 0,
111712 + .todo_flags_start = 0,
111713 + .todo_flags_finish = TODO_dump_func
111714 + }
111715 +};
111716 +
111717 +static bool gate_stackleak_track_stack(void)
111718 +{
111719 + return track_frame_size >= 0;
111720 +}
111721 +
111722 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
111723 +{
111724 + gimple check_alloca;
111725 + tree fntype, fndecl, alloca_size;
111726 +
111727 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
111728 + fndecl = build_fn_decl(check_function, fntype);
111729 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
111730 +
111731 + // insert call to void pax_check_alloca(unsigned long size)
111732 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
111733 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
111734 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
111735 +}
111736 +
111737 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
111738 +{
111739 + gimple track_stack;
111740 + tree fntype, fndecl;
111741 +
111742 + fntype = build_function_type_list(void_type_node, NULL_TREE);
111743 + fndecl = build_fn_decl(track_function, fntype);
111744 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
111745 +
111746 + // insert call to void pax_track_stack(void)
111747 + track_stack = gimple_build_call(fndecl, 0);
111748 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
111749 +}
111750 +
111751 +#if BUILDING_GCC_VERSION == 4005
111752 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
111753 +{
111754 + tree fndecl;
111755 +
111756 + if (!is_gimple_call(stmt))
111757 + return false;
111758 + fndecl = gimple_call_fndecl(stmt);
111759 + if (!fndecl)
111760 + return false;
111761 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
111762 + return false;
111763 +// print_node(stderr, "pax", fndecl, 4);
111764 + return DECL_FUNCTION_CODE(fndecl) == code;
111765 +}
111766 +#endif
111767 +
111768 +static bool is_alloca(gimple stmt)
111769 +{
111770 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
111771 + return true;
111772 +
111773 +#if BUILDING_GCC_VERSION >= 4007
111774 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
111775 + return true;
111776 +#endif
111777 +
111778 + return false;
111779 +}
111780 +
111781 +static unsigned int execute_stackleak_tree_instrument(void)
111782 +{
111783 + basic_block bb, entry_bb;
111784 + bool prologue_instrumented = false, is_leaf = true;
111785 +
111786 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
111787 +
111788 + // 1. loop through BBs and GIMPLE statements
111789 + FOR_EACH_BB(bb) {
111790 + gimple_stmt_iterator gsi;
111791 +
111792 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
111793 + gimple stmt;
111794 +
111795 + stmt = gsi_stmt(gsi);
111796 +
111797 + if (is_gimple_call(stmt))
111798 + is_leaf = false;
111799 +
111800 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
111801 + if (!is_alloca(stmt))
111802 + continue;
111803 +
111804 + // 2. insert stack overflow check before each __builtin_alloca call
111805 + stackleak_check_alloca(&gsi);
111806 +
111807 + // 3. insert track call after each __builtin_alloca call
111808 + stackleak_add_instrumentation(&gsi);
111809 + if (bb == entry_bb)
111810 + prologue_instrumented = true;
111811 + }
111812 + }
111813 +
111814 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
111815 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
111816 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
111817 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
111818 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
111819 + return 0;
111820 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
111821 + return 0;
111822 +
111823 + // 4. insert track call at the beginning
111824 + if (!prologue_instrumented) {
111825 + gimple_stmt_iterator gsi;
111826 +
111827 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
111828 + if (dom_info_available_p(CDI_DOMINATORS))
111829 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
111830 + gsi = gsi_start_bb(bb);
111831 + stackleak_add_instrumentation(&gsi);
111832 + }
111833 +
111834 + return 0;
111835 +}
111836 +
111837 +static unsigned int execute_stackleak_final(void)
111838 +{
111839 + rtx insn, next;
111840 +
111841 + if (cfun->calls_alloca)
111842 + return 0;
111843 +
111844 + // keep calls only if function frame is big enough
111845 + if (get_frame_size() >= track_frame_size)
111846 + return 0;
111847 +
111848 + // 1. find pax_track_stack calls
111849 + for (insn = get_insns(); insn; insn = next) {
111850 + // 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))
111851 + rtx body;
111852 +
111853 + next = NEXT_INSN(insn);
111854 + if (!CALL_P(insn))
111855 + continue;
111856 + body = PATTERN(insn);
111857 + if (GET_CODE(body) != CALL)
111858 + continue;
111859 + body = XEXP(body, 0);
111860 + if (GET_CODE(body) != MEM)
111861 + continue;
111862 + body = XEXP(body, 0);
111863 + if (GET_CODE(body) != SYMBOL_REF)
111864 + continue;
111865 + if (strcmp(XSTR(body, 0), track_function))
111866 + continue;
111867 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
111868 + // 2. delete call
111869 + delete_insn_and_edges(insn);
111870 +#if BUILDING_GCC_VERSION >= 4007
111871 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
111872 + insn = next;
111873 + next = NEXT_INSN(insn);
111874 + delete_insn_and_edges(insn);
111875 + }
111876 +#endif
111877 + }
111878 +
111879 +// print_simple_rtl(stderr, get_insns());
111880 +// print_rtl(stderr, get_insns());
111881 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
111882 +
111883 + return 0;
111884 +}
111885 +
111886 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
111887 +{
111888 + const char * const plugin_name = plugin_info->base_name;
111889 + const int argc = plugin_info->argc;
111890 + const struct plugin_argument * const argv = plugin_info->argv;
111891 + int i;
111892 + struct register_pass_info stackleak_tree_instrument_pass_info = {
111893 + .pass = &stackleak_tree_instrument_pass.pass,
111894 +// .reference_pass_name = "tree_profile",
111895 + .reference_pass_name = "optimized",
111896 + .ref_pass_instance_number = 1,
111897 + .pos_op = PASS_POS_INSERT_BEFORE
111898 + };
111899 + struct register_pass_info stackleak_final_pass_info = {
111900 + .pass = &stackleak_final_rtl_opt_pass.pass,
111901 + .reference_pass_name = "final",
111902 + .ref_pass_instance_number = 1,
111903 + .pos_op = PASS_POS_INSERT_BEFORE
111904 + };
111905 +
111906 + if (!plugin_default_version_check(version, &gcc_version)) {
111907 + error(G_("incompatible gcc/plugin versions"));
111908 + return 1;
111909 + }
111910 +
111911 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
111912 +
111913 + for (i = 0; i < argc; ++i) {
111914 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
111915 + if (!argv[i].value) {
111916 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
111917 + continue;
111918 + }
111919 + track_frame_size = atoi(argv[i].value);
111920 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
111921 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
111922 + continue;
111923 + }
111924 + if (!strcmp(argv[i].key, "initialize-locals")) {
111925 + if (argv[i].value) {
111926 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
111927 + continue;
111928 + }
111929 + init_locals = true;
111930 + continue;
111931 + }
111932 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
111933 + }
111934 +
111935 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
111936 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
111937 +
111938 + return 0;
111939 +}
111940 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
111941 new file mode 100644
111942 index 0000000..4fae911
111943 --- /dev/null
111944 +++ b/tools/gcc/structleak_plugin.c
111945 @@ -0,0 +1,277 @@
111946 +/*
111947 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
111948 + * Licensed under the GPL v2
111949 + *
111950 + * Note: the choice of the license means that the compilation process is
111951 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
111952 + * but for the kernel it doesn't matter since it doesn't link against
111953 + * any of the gcc libraries
111954 + *
111955 + * gcc plugin to forcibly initialize certain local variables that could
111956 + * otherwise leak kernel stack to userland if they aren't properly initialized
111957 + * by later code
111958 + *
111959 + * Homepage: http://pax.grsecurity.net/
111960 + *
111961 + * Usage:
111962 + * $ # for 4.5/4.6/C based 4.7
111963 + * $ 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
111964 + * $ # for C++ based 4.7/4.8+
111965 + * $ 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
111966 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
111967 + *
111968 + * TODO: eliminate redundant initializers
111969 + * increase type coverage
111970 + */
111971 +
111972 +#include "gcc-plugin.h"
111973 +#include "config.h"
111974 +#include "system.h"
111975 +#include "coretypes.h"
111976 +#include "tree.h"
111977 +#include "tree-pass.h"
111978 +#include "intl.h"
111979 +#include "plugin-version.h"
111980 +#include "tm.h"
111981 +#include "toplev.h"
111982 +#include "function.h"
111983 +#include "tree-flow.h"
111984 +#include "plugin.h"
111985 +#include "gimple.h"
111986 +#include "diagnostic.h"
111987 +#include "cfgloop.h"
111988 +#include "langhooks.h"
111989 +
111990 +#if BUILDING_GCC_VERSION >= 4008
111991 +#define TODO_dump_func 0
111992 +#endif
111993 +
111994 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
111995 +
111996 +// unused type flag in all versions 4.5-4.8
111997 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
111998 +
111999 +int plugin_is_GPL_compatible;
112000 +void debug_gimple_stmt(gimple gs);
112001 +
112002 +static struct plugin_info structleak_plugin_info = {
112003 + .version = "201304082245",
112004 + .help = "disable\tdo not activate plugin\n",
112005 +};
112006 +
112007 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
112008 +{
112009 + *no_add_attrs = true;
112010 +
112011 + // check for types? for now accept everything linux has to offer
112012 + if (TREE_CODE(*node) != FIELD_DECL)
112013 + return NULL_TREE;
112014 +
112015 + *no_add_attrs = false;
112016 + return NULL_TREE;
112017 +}
112018 +
112019 +static struct attribute_spec user_attr = {
112020 + .name = "user",
112021 + .min_length = 0,
112022 + .max_length = 0,
112023 + .decl_required = false,
112024 + .type_required = false,
112025 + .function_type_required = false,
112026 + .handler = handle_user_attribute,
112027 +#if BUILDING_GCC_VERSION >= 4007
112028 + .affects_type_identity = true
112029 +#endif
112030 +};
112031 +
112032 +static void register_attributes(void *event_data, void *data)
112033 +{
112034 + register_attribute(&user_attr);
112035 +// register_attribute(&force_attr);
112036 +}
112037 +
112038 +static tree get_field_type(tree field)
112039 +{
112040 + return strip_array_types(TREE_TYPE(field));
112041 +}
112042 +
112043 +static bool is_userspace_type(tree type)
112044 +{
112045 + tree field;
112046 +
112047 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
112048 + tree fieldtype = get_field_type(field);
112049 + enum tree_code code = TREE_CODE(fieldtype);
112050 +
112051 + if (code == RECORD_TYPE || code == UNION_TYPE)
112052 + if (is_userspace_type(fieldtype))
112053 + return true;
112054 +
112055 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
112056 + return true;
112057 + }
112058 + return false;
112059 +}
112060 +
112061 +static void finish_type(void *event_data, void *data)
112062 +{
112063 + tree type = (tree)event_data;
112064 +
112065 + if (TYPE_USERSPACE(type))
112066 + return;
112067 +
112068 + if (is_userspace_type(type))
112069 + TYPE_USERSPACE(type) = 1;
112070 +}
112071 +
112072 +static void initialize(tree var)
112073 +{
112074 + basic_block bb;
112075 + gimple_stmt_iterator gsi;
112076 + tree initializer;
112077 + gimple init_stmt;
112078 +
112079 + // this is the original entry bb before the forced split
112080 + // TODO: check further BBs in case more splits occured before us
112081 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
112082 +
112083 + // first check if the variable is already initialized, warn otherwise
112084 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
112085 + gimple stmt = gsi_stmt(gsi);
112086 + tree rhs1;
112087 +
112088 + // we're looking for an assignment of a single rhs...
112089 + if (!gimple_assign_single_p(stmt))
112090 + continue;
112091 + rhs1 = gimple_assign_rhs1(stmt);
112092 +#if BUILDING_GCC_VERSION >= 4007
112093 + // ... of a non-clobbering expression...
112094 + if (TREE_CLOBBER_P(rhs1))
112095 + continue;
112096 +#endif
112097 + // ... to our variable...
112098 + if (gimple_get_lhs(stmt) != var)
112099 + continue;
112100 + // if it's an initializer then we're good
112101 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
112102 + return;
112103 + }
112104 +
112105 + // these aren't the 0days you're looking for
112106 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
112107 +
112108 + // build the initializer expression
112109 + initializer = build_constructor(TREE_TYPE(var), NULL);
112110 +
112111 + // build the initializer stmt
112112 + init_stmt = gimple_build_assign(var, initializer);
112113 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
112114 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
112115 + update_stmt(init_stmt);
112116 +}
112117 +
112118 +static unsigned int handle_function(void)
112119 +{
112120 + basic_block bb;
112121 + unsigned int ret = 0;
112122 + tree var;
112123 +
112124 +#if BUILDING_GCC_VERSION == 4005
112125 + tree vars;
112126 +#else
112127 + unsigned int i;
112128 +#endif
112129 +
112130 + // split the first bb where we can put the forced initializers
112131 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
112132 + if (dom_info_available_p(CDI_DOMINATORS))
112133 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
112134 +
112135 + // enumarate all local variables and forcibly initialize our targets
112136 +#if BUILDING_GCC_VERSION == 4005
112137 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
112138 + var = TREE_VALUE(vars);
112139 +#else
112140 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
112141 +#endif
112142 + tree type = TREE_TYPE(var);
112143 +
112144 + gcc_assert(DECL_P(var));
112145 + if (!auto_var_in_fn_p(var, current_function_decl))
112146 + continue;
112147 +
112148 + // only care about structure types
112149 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
112150 + continue;
112151 +
112152 + // if the type is of interest, examine the variable
112153 + if (TYPE_USERSPACE(type))
112154 + initialize(var);
112155 + }
112156 +
112157 + return ret;
112158 +}
112159 +
112160 +static struct gimple_opt_pass structleak_pass = {
112161 + .pass = {
112162 + .type = GIMPLE_PASS,
112163 + .name = "structleak",
112164 +#if BUILDING_GCC_VERSION >= 4008
112165 + .optinfo_flags = OPTGROUP_NONE,
112166 +#endif
112167 + .gate = NULL,
112168 + .execute = handle_function,
112169 + .sub = NULL,
112170 + .next = NULL,
112171 + .static_pass_number = 0,
112172 + .tv_id = TV_NONE,
112173 + .properties_required = PROP_cfg,
112174 + .properties_provided = 0,
112175 + .properties_destroyed = 0,
112176 + .todo_flags_start = 0,
112177 + .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
112178 + }
112179 +};
112180 +
112181 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
112182 +{
112183 + int i;
112184 + const char * const plugin_name = plugin_info->base_name;
112185 + const int argc = plugin_info->argc;
112186 + const struct plugin_argument * const argv = plugin_info->argv;
112187 + bool enable = true;
112188 +
112189 + struct register_pass_info structleak_pass_info = {
112190 + .pass = &structleak_pass.pass,
112191 + .reference_pass_name = "ssa",
112192 + .ref_pass_instance_number = 1,
112193 + .pos_op = PASS_POS_INSERT_AFTER
112194 + };
112195 +
112196 + if (!plugin_default_version_check(version, &gcc_version)) {
112197 + error(G_("incompatible gcc/plugin versions"));
112198 + return 1;
112199 + }
112200 +
112201 + if (strcmp(lang_hooks.name, "GNU C")) {
112202 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
112203 + enable = false;
112204 + }
112205 +
112206 + for (i = 0; i < argc; ++i) {
112207 + if (!strcmp(argv[i].key, "disable")) {
112208 + enable = false;
112209 + continue;
112210 + }
112211 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
112212 + }
112213 +
112214 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
112215 + if (enable) {
112216 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
112217 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
112218 + }
112219 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
112220 +
112221 + return 0;
112222 +}
112223 diff --git a/tools/lib/lk/Makefile b/tools/lib/lk/Makefile
112224 index 926cbf3..b8403e0 100644
112225 --- a/tools/lib/lk/Makefile
112226 +++ b/tools/lib/lk/Makefile
112227 @@ -10,7 +10,7 @@ LIB_OBJS += $(OUTPUT)debugfs.o
112228
112229 LIBFILE = liblk.a
112230
112231 -CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
112232 +CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
112233 EXTLIBS = -lpthread -lrt -lelf -lm
112234 ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
112235 ALL_LDFLAGS = $(LDFLAGS)
112236 diff --git a/tools/perf/Makefile b/tools/perf/Makefile
112237 index b0f164b..63c9f7d 100644
112238 --- a/tools/perf/Makefile
112239 +++ b/tools/perf/Makefile
112240 @@ -188,7 +188,7 @@ endif
112241
112242 ifndef PERF_DEBUG
112243 ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -D_FORTIFY_SOURCE=2,-D_FORTIFY_SOURCE=2),y)
112244 - CFLAGS := $(CFLAGS) -D_FORTIFY_SOURCE=2
112245 + CFLAGS := $(CFLAGS) -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
112246 endif
112247 endif
112248
112249 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
112250 index 6789d78..4afd019e 100644
112251 --- a/tools/perf/util/include/asm/alternative-asm.h
112252 +++ b/tools/perf/util/include/asm/alternative-asm.h
112253 @@ -5,4 +5,7 @@
112254
112255 #define altinstruction_entry #
112256
112257 + .macro pax_force_retaddr rip=0, reload=0
112258 + .endm
112259 +
112260 #endif
112261 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
112262 index 96b919d..c49bb74 100644
112263 --- a/tools/perf/util/include/linux/compiler.h
112264 +++ b/tools/perf/util/include/linux/compiler.h
112265 @@ -18,4 +18,12 @@
112266 #define __force
112267 #endif
112268
112269 +#ifndef __size_overflow
112270 +# define __size_overflow(...)
112271 +#endif
112272 +
112273 +#ifndef __intentional_overflow
112274 +# define __intentional_overflow(...)
112275 +#endif
112276 +
112277 #endif
112278 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
112279 index 302681c..3bde377 100644
112280 --- a/virt/kvm/kvm_main.c
112281 +++ b/virt/kvm/kvm_main.c
112282 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
112283
112284 static cpumask_var_t cpus_hardware_enabled;
112285 static int kvm_usage_count = 0;
112286 -static atomic_t hardware_enable_failed;
112287 +static atomic_unchecked_t hardware_enable_failed;
112288
112289 struct kmem_cache *kvm_vcpu_cache;
112290 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
112291
112292 -static __read_mostly struct preempt_ops kvm_preempt_ops;
112293 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
112294 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
112295 +static struct preempt_ops kvm_preempt_ops = {
112296 + .sched_in = kvm_sched_in,
112297 + .sched_out = kvm_sched_out,
112298 +};
112299
112300 struct dentry *kvm_debugfs_dir;
112301
112302 @@ -766,7 +771,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
112303 /* We can read the guest memory with __xxx_user() later on. */
112304 if ((mem->slot < KVM_USER_MEM_SLOTS) &&
112305 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
112306 - !access_ok(VERIFY_WRITE,
112307 + !__access_ok(VERIFY_WRITE,
112308 (void __user *)(unsigned long)mem->userspace_addr,
112309 mem->memory_size)))
112310 goto out;
112311 @@ -1878,7 +1883,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
112312 return 0;
112313 }
112314
112315 -static struct file_operations kvm_vcpu_fops = {
112316 +static file_operations_no_const kvm_vcpu_fops __read_only = {
112317 .release = kvm_vcpu_release,
112318 .unlocked_ioctl = kvm_vcpu_ioctl,
112319 #ifdef CONFIG_COMPAT
112320 @@ -2561,7 +2566,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
112321 return 0;
112322 }
112323
112324 -static struct file_operations kvm_vm_fops = {
112325 +static file_operations_no_const kvm_vm_fops __read_only = {
112326 .release = kvm_vm_release,
112327 .unlocked_ioctl = kvm_vm_ioctl,
112328 #ifdef CONFIG_COMPAT
112329 @@ -2662,7 +2667,7 @@ out:
112330 return r;
112331 }
112332
112333 -static struct file_operations kvm_chardev_ops = {
112334 +static file_operations_no_const kvm_chardev_ops __read_only = {
112335 .unlocked_ioctl = kvm_dev_ioctl,
112336 .compat_ioctl = kvm_dev_ioctl,
112337 .llseek = noop_llseek,
112338 @@ -2688,7 +2693,7 @@ static void hardware_enable_nolock(void *junk)
112339
112340 if (r) {
112341 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
112342 - atomic_inc(&hardware_enable_failed);
112343 + atomic_inc_unchecked(&hardware_enable_failed);
112344 printk(KERN_INFO "kvm: enabling virtualization on "
112345 "CPU%d failed\n", cpu);
112346 }
112347 @@ -2742,10 +2747,10 @@ static int hardware_enable_all(void)
112348
112349 kvm_usage_count++;
112350 if (kvm_usage_count == 1) {
112351 - atomic_set(&hardware_enable_failed, 0);
112352 + atomic_set_unchecked(&hardware_enable_failed, 0);
112353 on_each_cpu(hardware_enable_nolock, NULL, 1);
112354
112355 - if (atomic_read(&hardware_enable_failed)) {
112356 + if (atomic_read_unchecked(&hardware_enable_failed)) {
112357 hardware_disable_all_nolock();
112358 r = -EBUSY;
112359 }
112360 @@ -3099,7 +3104,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
112361 kvm_arch_vcpu_put(vcpu);
112362 }
112363
112364 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
112365 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
112366 struct module *module)
112367 {
112368 int r;
112369 @@ -3146,7 +3151,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
112370 if (!vcpu_align)
112371 vcpu_align = __alignof__(struct kvm_vcpu);
112372 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
112373 - 0, NULL);
112374 + SLAB_USERCOPY, NULL);
112375 if (!kvm_vcpu_cache) {
112376 r = -ENOMEM;
112377 goto out_free_3;
112378 @@ -3156,9 +3161,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
112379 if (r)
112380 goto out_free;
112381
112382 + pax_open_kernel();
112383 kvm_chardev_ops.owner = module;
112384 kvm_vm_fops.owner = module;
112385 kvm_vcpu_fops.owner = module;
112386 + pax_close_kernel();
112387
112388 r = misc_register(&kvm_dev);
112389 if (r) {
112390 @@ -3168,9 +3175,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
112391
112392 register_syscore_ops(&kvm_syscore_ops);
112393
112394 - kvm_preempt_ops.sched_in = kvm_sched_in;
112395 - kvm_preempt_ops.sched_out = kvm_sched_out;
112396 -
112397 r = kvm_init_debug();
112398 if (r) {
112399 printk(KERN_ERR "kvm: create debugfs files failed\n");